diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/old/unit/xml | |
parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/old/unit/xml')
-rw-r--r-- | src/old/unit/xml/xml.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/old/unit/xml/xml.cpp b/src/old/unit/xml/xml.cpp new file mode 100644 index 0000000..e4d779c --- /dev/null +++ b/src/old/unit/xml/xml.cpp | |||
@@ -0,0 +1,59 @@ | |||
1 | #include <cstdlib> | ||
2 | #include <cstring> | ||
3 | #include <iostream> | ||
4 | #include <cpptest.h> | ||
5 | #include <string.h> | ||
6 | |||
7 | #include "xmlstringreader.h" | ||
8 | #include "xmlexception.h" | ||
9 | |||
10 | class XmlCoreTestSuite : public Test::Suite | ||
11 | { | ||
12 | public: | ||
13 | XmlCoreTestSuite() | ||
14 | { | ||
15 | TEST_ADD( XmlCoreTestSuite::badXml01 ) | ||
16 | TEST_ADD( XmlCoreTestSuite::badXml02 ) | ||
17 | TEST_ADD( XmlCoreTestSuite::badXml03 ) | ||
18 | |||
19 | TEST_ADD( XmlCoreTestSuite::entityBuiltin01 ) | ||
20 | |||
21 | TEST_ADD( XmlCoreTestSuite::entityDoc01 ) | ||
22 | } | ||
23 | |||
24 | private: | ||
25 | void badXml01() | ||
26 | { | ||
27 | TEST_THROWS( XmlStringReader r("<hello></bye>"), XmlException & ); | ||
28 | } | ||
29 | |||
30 | void badXml02() | ||
31 | { | ||
32 | TEST_THROWS( XmlStringReader r("<hello>"), XmlException & ); | ||
33 | } | ||
34 | |||
35 | void badXml03() | ||
36 | { | ||
37 | TEST_THROWS( XmlStringReader r("<hello param=\"stuff?"), XmlException & ); | ||
38 | } | ||
39 | |||
40 | void entityBuiltin01() | ||
41 | { | ||
42 | XmlStringReader r("<hello>><&'"</hello>"); | ||
43 | TEST_ASSERT( strcmp( r.getRoot()->getContent(), "><&\'\"" ) == 0 ); | ||
44 | } | ||
45 | |||
46 | void entityDoc01() | ||
47 | { | ||
48 | XmlStringReader r("<!ENTITY name \"bob the man\"><hello>"&name;"</hello>"); | ||
49 | TEST_ASSERT( strcmp( r.getRoot()->getContent(), "\"bob the man\"" ) == 0 ); | ||
50 | } | ||
51 | }; | ||
52 | |||
53 | int main( int argc, char *argv[] ) | ||
54 | { | ||
55 | Test::TextOutput output( Test::TextOutput::Verbose ); | ||
56 | XmlCoreTestSuite ts; | ||
57 | return ts.run( output ) ? EXIT_SUCCESS : EXIT_FAILURE; | ||
58 | } | ||
59 | |||