aboutsummaryrefslogtreecommitdiff
path: root/src/unit/archive.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-07 15:59:57 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-07 15:59:57 +0000
commit45e065bc4fc93731ea9a0543462bc7cf9e6084d7 (patch)
treea9e8279fe00b9b01dc2393f59dc7f41b5e416b2a /src/unit/archive.cpp
parentd96fe229e79f9b1947cbd24ff52d6bf7bb9bf80d (diff)
downloadlibbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.tar.gz
libbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.tar.bz2
libbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.tar.xz
libbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.zip
Only two real changes. First, Bu::FString and Bu::FBasicString are in different
files. This won't affect any programs at all anywhere. This will just make it easier to maintain and extend later. You still want to include "bu/fstring.h" and use Bu::FString in code. The other is kinda fun. I created a special format for unit tests, they use the extension .unit now and use the mkunit.sh script to convert them to c++ code. There are some nice features here too, maintaining unit tests is much, much easier, and we can have more features without making the code any harder to use. Also, it will be easier to have the unit tests generate reports and be run from a master program and the like.
Diffstat (limited to 'src/unit/archive.cpp')
-rw-r--r--src/unit/archive.cpp145
1 files changed, 0 insertions, 145 deletions
diff --git a/src/unit/archive.cpp b/src/unit/archive.cpp
deleted file mode 100644
index 8e71f4b..0000000
--- a/src/unit/archive.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
1/*
2 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/unitsuite.h"
9#include "bu/membuf.h"
10
11class Unit : public Bu::UnitSuite
12{
13public:
14 Unit()
15 {
16 setName("Archive");
17 addTest( Unit::testPrimitives );
18 addTest( Unit::testContainers );
19 }
20
21 virtual ~Unit()
22 {
23 }
24
25 void testPrimitives()
26 {
27 Bu::MemBuf mb;
28 {
29 Bu::Archive ar( mb, Bu::Archive::save );
30 ar << (int8_t)1;
31 ar << (uint8_t)2;
32 ar << (int16_t)3;
33 ar << (uint16_t)4;
34 ar << (int32_t)5;
35 ar << (uint32_t)6;
36 ar << (int64_t)7;
37 ar << (uint64_t)8;
38 ar << (char)9;
39 ar << (unsigned char)10;
40 ar << (short)11;
41 ar << (unsigned short)12;
42 ar << (int)13;
43 ar << (unsigned int)14;
44 ar << (long)15;
45 ar << (unsigned long)16;
46 ar << (long long)17;
47 ar << (unsigned long long)18;
48 ar.close();
49 }
50 mb.setPos( 0 );
51 {
52 Bu::Archive ar( mb, Bu::Archive::load );
53 int8_t p1;
54 uint8_t p2;
55 int16_t p3;
56 uint16_t p4;
57 int32_t p5;
58 uint32_t p6;
59 int64_t p7;
60 uint64_t p8;
61 char p9;
62 unsigned char p10;
63 short p11;
64 unsigned short p12;
65 int p13;
66 unsigned int p14;
67 long p15;
68 unsigned long p16;
69 long long p17;
70 unsigned long long p18;
71 ar >> p1;
72 ar >> p2;
73 ar >> p3;
74 ar >> p4;
75 ar >> p5;
76 ar >> p6;
77 ar >> p7;
78 ar >> p8;
79 ar >> p9;
80 ar >> p10;
81 ar >> p11;
82 ar >> p12;
83 ar >> p13;
84 ar >> p14;
85 ar >> p15;
86 ar >> p16;
87 ar >> p17;
88 ar >> p18;
89 unitTest( p1 == 1 );
90 unitTest( p2 == 2 );
91 unitTest( p3 == 3 );
92 unitTest( p4 == 4 );
93 unitTest( p5 == 5 );
94 unitTest( p6 == 6 );
95 unitTest( p7 == 7 );
96 unitTest( p8 == 8 );
97 unitTest( p9 == 9 );
98 unitTest( p10 == 10 );
99 unitTest( p11 == 11 );
100 unitTest( p12 == 12 );
101 unitTest( p13 == 13 );
102 unitTest( p14 == 14 );
103 unitTest( p15 == 15 );
104 unitTest( p16 == 16 );
105 unitTest( p17 == 17 );
106 unitTest( p18 == 18 );
107 ar.close();
108 }
109 }
110
111 void testContainers()
112 {
113 Bu::MemBuf mb;
114 {
115 Bu::Archive ar( mb, Bu::Archive::save );
116 Bu::FString sStr("This is a test string.");
117 Bu::List<int> lList;
118 lList.append( 10 );
119 lList.append( 20 );
120 lList.append( 30 );
121 lList.append( 40 );
122 ar << sStr;
123 ar << lList;
124 ar.close();
125 }
126 mb.setPos( 0 );
127 {
128 Bu::Archive ar( mb, Bu::Archive::load );
129 Bu::FString sStr;
130 Bu::List<int> lList;
131 ar >> sStr;
132 ar >> lList;
133 unitTest( sStr == "This is a test string." );
134 unitTest( lList.getSize() == 4 );
135 Bu::List<int>::iterator i = lList.begin();
136 unitTest( *i == 10 ); i++;
137 unitTest( *i == 20 ); i++;
138 unitTest( *i == 30 ); i++;
139 unitTest( *i == 40 );
140 ar.close();
141 }
142 }
143};
144
145int main( int argc, char *argv[] ){ return Unit().run( argc, argv ); }