public class PublicIdTest { Grammar g = XmlGrammar.createGrammarBuilder().build(); @Test public void ok() { assertThat(g.rule(XmlGrammar.PUBLIC_ID)).matches("PUBLIC \"foo\""); } }
public class CDStartTest { Grammar g = XmlGrammar.createGrammarBuilder().build(); @Test public void ok() { assertThat(g.rule(XmlGrammar.CD_START)).matches("<![CDATA[").notMatches("<![cdata["); } }
public class EqTest { Grammar g = XmlGrammar.createGrammarBuilder().build(); @Test public void ok() { assertThat(g.rule(XmlGrammar.EQ)) .matches("=") .matches(" =") .matches("= ") .matches(" = "); } }
public class CharRefTest { Grammar g = XmlGrammar.createGrammarBuilder().build(); @Test public void ok() { assertThat(g.rule(XmlGrammar.CHAR_REF)) .matches("�") .matches("{") .matches("") .notMatches("&#AB;"); } }
public class PITest { Grammar g = XmlGrammar.createGrammarBuilder().build(); @Test public void ok() { assertThat(g.rule(XmlGrammar.PI)) .matches("<?foo?>") .matches("<?foo bar?>") .matches("<?foo bar baz ?>") .notMatches("<??>") .notMatches("<?xml?>"); } }
public class NameTest { Grammar g = XmlGrammar.createGrammarBuilder().build(); @Test public void ok() { assertThat(g.rule(XmlGrammar.NAME)) .matches("foo") .matches("foo42") .matches(":") .matches("F") .matches("_") .matches("h") .matches("\u00D0") .matches("\u00D9") .notMatches("\u00D7") .notMatches("-") .notMatches("\u200E") .notMatches("foo?") .notMatches("foo "); } }
public class ElementDeclTest { Grammar g = XmlGrammar.createGrammarBuilder().build(); @Test public void ok() { assertThat(g.rule(XmlGrammar.ELEMENT_DECL)) .matches("<!ELEMENT br EMPTY>") .matches("<!ELEMENT p (#PCDATA|emph)* >") .matches("<!ELEMENT container ANY>") .matches("<!ELEMENT spec (front, body, back?)>") .matches("<!ELEMENT div1 (head, (p | list | note)*, div2*)>") .matches("<!ELEMENT p (#PCDATA|a|ul|b|i|em)*>") .matches("<!ELEMENT b (#PCDATA)>"); } // TEST - FIXME: "Name does not match %, looks like a PEReference, email sent to xml-editors" public void w3() { assertThat(g.rule(XmlGrammar.ELEMENT_DECL)) .matches("<!ELEMENT %name.para; %content.para; >") .matches("<!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*>") .matches("<!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >"); } }