new tests, cleanup, prepared for node-limits
This commit is contained in:
		| @@ -199,13 +199,16 @@ class ComplexTest: public CppUnit::TestFixture { | ||||
|            <<"<child/>" | ||||
|            <<"< otherchild ><  / otherchild  >< otherchild / >"<<std::endl | ||||
|            <<"</base>"; | ||||
|       CPPUNIT_ASSERT_THROW(factory.read(file2), xml::access_error); | ||||
|       CPPUNIT_ASSERT_THROW(factory.read(file2), xml::wrong_start_tag); | ||||
|       { | ||||
|         std::stringstream file("<base></xyz>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::wrong_end_tag); | ||||
|       } { | ||||
|         std::stringstream file("<xyz></xyz>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::wrong_start_tag); | ||||
|       } { | ||||
|         std::stringstream file("<xyz/>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::wrong_start_tag); | ||||
|       } { | ||||
|         std::stringstream file("base"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::tag_expected); | ||||
| @@ -234,7 +237,7 @@ class ComplexTest: public CppUnit::TestFixture { | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::missing_end_tag); | ||||
|       } { | ||||
|         std::stringstream file; | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::missing_end_tag); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::tag_expected); | ||||
|       } { | ||||
|         std::stringstream file("<base><child a=b></base>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), | ||||
| @@ -249,14 +252,50 @@ class ComplexTest: public CppUnit::TestFixture { | ||||
|     } | ||||
|     void attributes() { | ||||
|       xml::Factory factory(xml::Node("base") | ||||
|                            .attr("one", xml::mandatory) | ||||
|                            .attr("two", xml::optional) | ||||
|                            <<(xml::Node("child") | ||||
|                               <<xml::String("childofchild") | ||||
|                               <<xml::UnsignedInteger("number")) | ||||
|                            <<xml::Node("otherchild")); | ||||
|       { | ||||
|         std::stringstream file("<base></base>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), | ||||
|                              xml::mandatory_attribute_missing); | ||||
|       } { | ||||
|         std::stringstream file("<base one two three></base>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), xml::illegal_attribute); | ||||
|       }       | ||||
|     } | ||||
|     void ranges() { | ||||
|       xml::Factory factory(xml::Node("base", 2, 2) | ||||
|                            <<xml::Node("mandatory", 1) | ||||
|                            <<xml::Node("optional", 0, 1)); | ||||
|       { | ||||
|         std::stringstream file("<base><mandatory></mandatory></base>" | ||||
|                                "<base><mandatory/><optional/></base>"); | ||||
|         CPPUNIT_ASSERT_NO_THROW(factory.read(file)); | ||||
|       } /*{ | ||||
|         std::stringstream file("<base><mandatory></mandatory></base>" | ||||
|                                "<base><mandatory/><optional/></base>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), | ||||
|                              xml::wrong_node_number); | ||||
|       } { | ||||
|         std::stringstream file("<base><mandatory></mandatory></base>" | ||||
|                                "<base><mandatory/><optional/></base>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), | ||||
|                              xml::wrong_node_number); | ||||
|       } { | ||||
|         std::stringstream file("<base><mandatory></mandatory></base>" | ||||
|                                "<base><mandatory/><optional/></base>"); | ||||
|         CPPUNIT_ASSERT_THROW(factory.read(file), | ||||
|                              xml::wrong_node_number); | ||||
|       }*/ | ||||
|     } | ||||
|     CPPUNIT_TEST_SUITE(ComplexTest); | ||||
|     CPPUNIT_TEST(nodes); | ||||
|     CPPUNIT_TEST(attributes); | ||||
|     CPPUNIT_TEST(ranges); | ||||
|     CPPUNIT_TEST_SUITE_END(); | ||||
| }; | ||||
| CPPUNIT_TEST_SUITE_REGISTRATION(ComplexTest); | ||||
| @@ -293,7 +332,7 @@ class FunTest: public CppUnit::TestFixture { | ||||
|                            <<(xml::Node("head") | ||||
|                               <<xml::String("title")) | ||||
|                            <<(xml::Node("body") | ||||
|                               <<xml::String("h1") | ||||
|                               <<xml::String("h1").attr("class", xml::optional) | ||||
|                               <<xml::String("h2") | ||||
|                               <<xml::String("p"))); | ||||
|       std::auto_ptr<xml::Node> read(factory.read(ss)); // read back the example | ||||
|   | ||||
		Reference in New Issue
	
	Block a user