/// Tests for rules shared between various speech styles: /// * modified var use crate::common::*; #[test] fn salt() { let expr = "NaCl"; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap n eigh, cap c l,"); } #[test] fn water() { let expr = "H2O"; test_prefs("en", "ClearSpeak", vec![("Verbosity", "Terse")], expr, "cap h, 2 cap o,"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium")], expr, "cap h, sub 2 cap o,"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose")], expr, "cap h, subscript 2, cap o,"); } #[test] fn carbon() { let expr = "C"; // not enough to trigger recognition test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap c"); } #[test] fn sulfate() { let expr = " [SO4] 2 "; test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium")], expr, "open bracket, cap s, cap o, sub 4; close bracket super 2 minus"); } #[test] fn aluminum_sulfate() { let expr = "Al2 (SO4)3"; test_prefs("en", "ClearSpeak", vec![("Verbosity", "Terse")], expr, "cap eigh l, 2, open cap s, cap o, 4, close 3"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium")], expr, "cap eigh l, sub 2; open paren, cap s, cap o, sub 4; close paren sub 3"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose")], expr, "cap eigh l, subscript 2; open paren, cap s, cap o, subscript 4; close paren subscript 3"); } #[test] fn ethanol_bonds() { let expr = " C H 3 C H 2 O H "; test_prefs("en", "ClearSpeak", vec![("Verbosity", "Terse")], expr, "cap c, cap h, 3 single bond cap c, cap h, 2 single bond cap o, cap h,"); } #[test] fn dichlorine_hexoxide() { let expr = " [ClO2] + [ClO4] - "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "open bracket, cap c l, cap o, 2, close bracket plus; \ open bracket, cap c l, cap o, 4, close bracket minus"); test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Medium")], expr, "open bracket, cap c l, cap o, sub 2; close bracket super plus; \ open bracket, cap c l, cap o, sub 4; close bracket super minus"); test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Verbose")], expr, "open bracket, cap c l, cap o, subscript 2; close bracket superscript plus; \ open bracket, cap c l, cap o, subscript 4; close bracket superscript minus"); } #[test] fn ethylene_with_bond() { let expr = " H2C = CH2 "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap h, 2 cap c, double bond cap c, cap h, 2"); } #[test] fn ferric_chloride_aq() { let expr = " Fe Cl3 (aq) "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap f e, cap c l, 3 aqueous,"); } #[test] fn ethylene_with_colon_bond() { let expr = " H2C :: CH2 "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap h, 2 cap c, double bond cap c, cap h, 2"); } #[test] fn beta_decay() { let expr = " C 6 14 N 7 14 + e 1 0 "; test_prefs("en", "ClearSpeak", vec![("Verbosity", "Terse")], expr, "14, 6, cap c; forms, 14, 7, cap n; plus 0, negative 1, e,"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium")], expr, "super 14, sub 6, cap c; reacts to form; super 14, sub 7, cap n; plus super 0, sub negative 1, e,"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose")], expr, "superscript 14, subscript 6, cap c; reacts to form; superscript 14, subscript 7, cap n; plus, superscript 0, subscript negative 1, e,"); } #[test] fn mhchem_beta_decay() { let expr = " A 6 14 A 2 6 2 14 C A 7 14 A 2 7 2 14 N + A 1 0 A 2 1 2 0 e "; test_prefs("en", "ClearSpeak", vec![("Verbosity", "Terse")], expr, "14, 6, cap c; forms, 14, 7, cap n; plus 0, negative 1, e,"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Medium")], expr, "super 14, sub 6, cap c; reacts to form; super 14, sub 7, cap n; plus super 0, sub negative 1, e,"); test_prefs("en", "ClearSpeak", vec![("Verbosity", "Verbose")], expr, "superscript 14, subscript 6, cap c; reacts to form; superscript 14, subscript 7, cap n; plus, superscript 0, subscript negative 1, e,"); } #[test] fn hcl_na_yields() { let expr = " 2HCl+2Na 2NaCl+ H 2 "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Verbose")], expr, "2, cap h, cap c l; plus 2 cap n eigh; reacts to form; 2, cap n eigh, cap c l; plus cap h, subscript 2"); } #[test] fn mhchem_so4_2plus() { let expr = " SO A 4 A 2 + "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap s; cap o, 4, 2 plus,"); test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Medium")], expr, "cap s; cap o, sub 4, super 2 plus,"); test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Verbose")], expr, "cap s; cap o, subscript 4, superscript 2 plus,"); } #[test] fn mhchem_hcl_aq_etc() { let expr = " 2 HCl ( aq ) + 2 Na ( s ) 2 NaCl ( aq ) + H A 2 ( g ) "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "2, cap h, cap c l, aqueous; plus, 2, cap n eigh, solid; forms; 2, cap n eigh, cap c l, aqueous; plus, cap h, 2, gas,"); } #[test] fn mhchem_barbed_equilibrium() { let expr = " H 2 ( g ) + I 2 ( g ) - - 2 H I ( g ) "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap h, 2, gas; plus; cap i, 2, gas; is in equilibrium with, 2, cap h, cap i, gas,"); } #[test] fn mhchem_roman_in_superscript() { let expr = " Fe II Fe III O 4 "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "cap f e, 2; cap f e, 3; cap o, 4,"); }