diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-05-26 14:36:57 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-05-26 14:36:57 +0000 |
commit | a820665eea71a64b40e74ed24afeaf07a7a99db4 (patch) | |
tree | 515af31ac2ed78aa92ce7e90e478bdb452e6e438 /src/unit/xml.cpp | |
parent | bd5bb1ca60a6a97b110cbf221b3625e6e6200141 (diff) | |
download | libbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.tar.gz libbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.tar.bz2 libbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.tar.xz libbu++-a820665eea71a64b40e74ed24afeaf07a7a99db4.zip |
Added the first of many unit tests. For now the unit tests are just built with
everything else in the all target of the makefile, which is fine, but relies on
CppTest, which can be found at http://cpptest.sf.net
Also fixed some things I've been meaning to get to for a while in the xml
system, including a few bugs that will make coping with malformed data not hang
other programs, and do the error reporting in a nice way.
Diffstat (limited to 'src/unit/xml.cpp')
-rw-r--r-- | src/unit/xml.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/unit/xml.cpp b/src/unit/xml.cpp new file mode 100644 index 0000000..559b2f4 --- /dev/null +++ b/src/unit/xml.cpp | |||
@@ -0,0 +1,43 @@ | |||
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 | |||
20 | private: | ||
21 | void badXml01() | ||
22 | { | ||
23 | TEST_THROWS( XmlStringReader r("<hello></bye>"), XmlException & ); | ||
24 | } | ||
25 | |||
26 | void badXml02() | ||
27 | { | ||
28 | TEST_THROWS( XmlStringReader r("<hello>"), XmlException & ); | ||
29 | } | ||
30 | |||
31 | void badXml03() | ||
32 | { | ||
33 | TEST_THROWS( XmlStringReader r("<hello param=\"stuff?"), XmlException & ); | ||
34 | } | ||
35 | }; | ||
36 | |||
37 | int main( int argc, char *argv[] ) | ||
38 | { | ||
39 | Test::TextOutput output( Test::TextOutput::Verbose ); | ||
40 | XmlCoreTestSuite ts; | ||
41 | return ts.run( output ) ? EXIT_SUCCESS : EXIT_FAILURE; | ||
42 | } | ||
43 | |||