aboutsummaryrefslogtreecommitdiff
path: root/src/unit/taf.cpp
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2007-06-15 18:54:59 +0000
committerDavid <david@xagasoft.com>2007-06-15 18:54:59 +0000
commit2b90449c30e4a420af4fff7e58588611d71f61fc (patch)
treed4d7ac5b12c236bf98d1f2275d6b9545e9ba8fd3 /src/unit/taf.cpp
parent9f98bc834ce2ac524c47ef633be4b4fb9eb8a079 (diff)
downloadlibbu++-2b90449c30e4a420af4fff7e58588611d71f61fc.tar.gz
libbu++-2b90449c30e4a420af4fff7e58588611d71f61fc.tar.bz2
libbu++-2b90449c30e4a420af4fff7e58588611d71f61fc.tar.xz
libbu++-2b90449c30e4a420af4fff7e58588611d71f61fc.zip
david - wrote two silly unit tests...
Diffstat (limited to '')
-rw-r--r--src/unit/taf.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/unit/taf.cpp b/src/unit/taf.cpp
new file mode 100644
index 0000000..ab485d0
--- /dev/null
+++ b/src/unit/taf.cpp
@@ -0,0 +1,48 @@
1#include "unitsuite.h"
2#include "file.h"
3#include "tafreader.h"
4
5#include <string.h>
6#include <unistd.h>
7
8class Unit : public Bu::UnitSuite
9{
10public:
11 Unit()
12 {
13 setName("taf");
14 addTest( Unit::read1 );
15 }
16
17 virtual ~Unit()
18 {
19 }
20
21 void read1()
22 {
23#define FN_TMP ("/tmp/tmpXXXXXXXX")
24 Bu::FString sFnTmp(FN_TMP);
25 Bu::File fOut = Bu::File::tempFile( sFnTmp, "wb" );
26 const char *data =
27"{test: name=\"Bob\"}"
28;
29 fOut.write(data,strlen(data));
30 fOut.close();
31
32 Bu::File fIn(sFnTmp.c_str(), "rb");
33 Bu::TafReader tr(fIn);
34
35 Bu::TafNode *tn = tr.getNode();
36 unitTest( !strcmp("Bob", tn->getProperty("name").c_str()) );
37 delete tn;
38
39 unlink(sFnTmp.c_str());
40#undef FN_TMP
41 }
42};
43
44int main( int argc, char *argv[] )
45{
46 return Unit().run( argc, argv );
47}
48