MCPcopy Create free account
hub / github.com/daisy/MathCAT / test_entities

Function test_entities

src/interface.rs:753–780  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

751
752 #[test]
753 fn test_entities() {
754 // this forces initialization
755 set_rules_dir(super::super::abs_rules_dir_path()).unwrap();
756
757 let entity_str = set_mathml("<math><mrow><mo>&minus;</mo><mi>&mopf;</mi></mrow></math>".to_string()).unwrap();
758 let converted_str = set_mathml("<math><mrow><mo>&#x02212;</mo><mi>&#x1D55E;</mi></mrow></math>".to_string()).unwrap();
759
760 // need to remove unique ids
761 lazy_static! {
762 static ref ID_MATCH: Regex = Regex::new(r#"id='.+?' "#).unwrap();
763 }
764 let entity_str = ID_MATCH.replace_all(&entity_str, "");
765 let converted_str = ID_MATCH.replace_all(&converted_str, "");
766 assert_eq!(entity_str, converted_str, "normal entity test failed");
767
768
769 let entity_str = set_mathml("<math data-quot=\"&quot;value&quot;\" data-apos='&apos;value&apos;'><mi>XXX</mi></math>".to_string()).unwrap();
770 let converted_str = set_mathml("<math data-quot='\"value\"' data-apos=\"'value'\"><mi>XXX</mi></math>".to_string()).unwrap();
771 let entity_str = ID_MATCH.replace_all(&entity_str, "");
772 let converted_str = ID_MATCH.replace_all(&converted_str, "");
773 assert_eq!(entity_str, converted_str, "special entities quote test failed");
774
775 let entity_str = set_mathml("<math><mo>&lt;</mo><mo>&gt;</mo><mtext>&amp;lt;</mtext></math>".to_string()).unwrap();
776 let converted_str = set_mathml("<math><mo>&#x003C;</mo><mo>&#x003E;</mo><mtext>&#x0026;lt;</mtext></math>".to_string()).unwrap();
777 let entity_str = ID_MATCH.replace_all(&entity_str, "");
778 let converted_str = ID_MATCH.replace_all(&converted_str, "");
779 assert_eq!(entity_str, converted_str, "special entities <,>,& test failed");
780 }
781
782
783 #[test]

Callers

nothing calls this directly

Calls 3

set_rules_dirFunction · 0.85
set_mathmlFunction · 0.85
abs_rules_dir_pathFunction · 0.70

Tested by

no test coverage detected