/// Tests for fractions
/// includes simple fractions and more complex fractions
/// also tests mixed fractions (implicit and explicit)
use crate::common::*;
#[test]
fn common_fraction_half() {
let expr = "";
test("en", "ClearSpeak", expr, "1 half");
}
#[test]
fn common_fraction_thirds() {
let expr = "";
test("en", "ClearSpeak", expr, "2 thirds");
}
#[test]
fn common_fraction_tenths() {
let expr = "";
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Auto")], expr, "17 tenths");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Ordinal")], expr, "17 tenths");
}
#[test]
#[allow(non_snake_case)]
fn not_ClearSpeak_common_fraction_tenths() {
let expr = "";
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Auto")], expr, "89 over 10");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Ordinal")], expr, "89 tenths");
}
#[test]
fn non_simple_fraction() {
let expr = "
";
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Auto")], expr, "the fraction with numerator; x plus y; and denominator x minus y;");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Ordinal")], expr, "the fraction with numerator; x plus y; and denominator x minus y;");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Over")], expr, "x plus y over x minus y");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "FracOver")], expr, "the fraction x plus y over x minus y");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "General")], expr, "the fraction with numerator; x plus y; and denominator x minus y;");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "EndFrac")], expr, "the fraction with numerator; x plus y; and denominator x minus y; end fraction,");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "GeneralEndFrac")], expr, "the fraction with numerator; x plus y; and denominator x minus y; end fraction,");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "OverEndFrac")], expr, "x plus y over x minus y, end fraction,");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Per")], expr, "x plus y per x minus y");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose"),("ClearSpeak_Fractions", "Auto")], expr, "the fraction with numerator; x plus y; and denominator x minus y; end fraction,");
}
#[test]
fn mixed_number() {
let expr = "";
test("en", "ClearSpeak", expr, "3 and 1 half");
}
#[test]
fn explicit_mixed_number() {
let expr = "";
test("en", "ClearSpeak", expr, "3 and 1 eighth");
}
#[test]
fn mixed_number_big() {
let expr = "";
test("en", "ClearSpeak", expr, "3 and 7 over 83");
}
#[test]
fn simple_text() {
let expr = "";
test("en", "ClearSpeak", expr, "rise over run");
}
#[test]
fn number_and_text() {
let expr = "";
test("en", "ClearSpeak", expr, "2 miles over 3 gallons");
}
#[test]
fn nested_simple_fractions() {
let expr = "";
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "Auto")], expr, "1 half over 2 thirds");
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "Ordinal")], expr, "1 half over 2 thirds");
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "Over")], expr, "1 over 2 over 2 over 3");
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "FracOver")], expr,
"the fraction the fraction 1 over 2 over the fraction 2 over 3");
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "General")], expr,
"the fraction with numerator the fraction with numerator 1; and denominator 2; and denominator the fraction with numerator 2; and denominator 3;");
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "EndFrac")], expr, "1 half over 2 thirds");
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "GeneralEndFrac")], expr,
"the fraction with numerator the fraction with numerator 1; and denominator 2; end fraction; and denominator the fraction with numerator 2; and denominator 3; end fraction; end fraction,");
test_prefs("en", "ClearSpeak", vec![("ClearSpeak_Fractions", "OverEndFrac")], expr,
"1 over 2, end fraction, over 2 over 3, end fraction; end fraction,");
}
#[test]
fn semi_nested_fraction() {
let expr = "";
test("en", "ClearSpeak", expr, "2 thirds x over 6");
}
#[test]
fn general_nested_fraction() {
let expr = "
";
test("en", "ClearSpeak", expr, "the fraction with numerator; 10 over n; and denominator 2 over n;");
}
#[test]
fn complex_nested_fraction() {
let expr = "
";
test("en", "ClearSpeak", expr, "the fraction with numerator; the fraction with numerator; n plus 10; and denominator n; and denominator 2 over n;");
}
#[test]
fn simple_function() {
let expr = "";
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Auto")], expr, "f of x over 2");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose"), ("ClearSpeak_Fractions", "Auto")], expr, "f of x over 2, end fraction,");
}
#[test]
fn function_over_function() {
let expr = "";
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Auto")], expr, "f of x over g of x");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose"), ("ClearSpeak_Fractions", "Auto")], expr, "f of x over g of x, end fraction,");
}
#[test]
fn non_simple_function_over_function() {
let expr = "";
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium"), ("ClearSpeak_Fractions", "Auto")], expr,
"the fraction with numerator; f of, open paren x plus 1, close paren; and denominator g of x;");
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose"), ("ClearSpeak_Fractions", "Auto")], expr,
"the fraction with numerator; f of, open paren x plus 1, close paren; and denominator g of x; end fraction,");
}
#[test]
fn binomial() {
let expr = "";
test("en", "ClearSpeak", expr, "2 times 7 choose 3");
}