summaryrefslogtreecommitdiff
path: root/src/unit/archive.unit
diff options
context:
space:
mode:
Diffstat (limited to 'src/unit/archive.unit')
-rw-r--r--src/unit/archive.unit337
1 files changed, 169 insertions, 168 deletions
diff --git a/src/unit/archive.unit b/src/unit/archive.unit
index a0ae3ef..a7f2640 100644
--- a/src/unit/archive.unit
+++ b/src/unit/archive.unit
@@ -12,184 +12,185 @@
12 12
13using namespace Bu; 13using namespace Bu;
14 14
15{=Init} 15suite Archive
16
17{%testPrimitives}
18{ 16{
19 MemBuf mb; 17 test primitives
20 {
21 Archive ar( mb, Archive::save );
22 ar << (int8_t)1;
23 ar << (uint8_t)2;
24 ar << (int16_t)3;
25 ar << (uint16_t)4;
26 ar << (int32_t)5;
27 ar << (uint32_t)6;
28 ar << (int64_t)7;
29 ar << (uint64_t)8;
30 ar << (char)9;
31 ar << (unsigned char)10;
32 ar << (short)11;
33 ar << (unsigned short)12;
34 ar << (int)13;
35 ar << (unsigned int)14;
36 ar << (long)15;
37 ar << (unsigned long)16;
38 ar << (long long)17;
39 ar << (unsigned long long)18;
40 ar.close();
41 }
42 mb.setPos( 0 );
43 { 18 {
44 Archive ar( mb, Archive::load ); 19 MemBuf mb;
45 int8_t p1; 20 {
46 uint8_t p2; 21 Archive ar( mb, Archive::save );
47 int16_t p3; 22 ar << (int8_t)1;
48 uint16_t p4; 23 ar << (uint8_t)2;
49 int32_t p5; 24 ar << (int16_t)3;
50 uint32_t p6; 25 ar << (uint16_t)4;
51 int64_t p7; 26 ar << (int32_t)5;
52 uint64_t p8; 27 ar << (uint32_t)6;
53 char p9; 28 ar << (int64_t)7;
54 unsigned char p10; 29 ar << (uint64_t)8;
55 short p11; 30 ar << (char)9;
56 unsigned short p12; 31 ar << (unsigned char)10;
57 int p13; 32 ar << (short)11;
58 unsigned int p14; 33 ar << (unsigned short)12;
59 long p15; 34 ar << (int)13;
60 unsigned long p16; 35 ar << (unsigned int)14;
61 long long p17; 36 ar << (long)15;
62 unsigned long long p18; 37 ar << (unsigned long)16;
63 ar >> p1; 38 ar << (long long)17;
64 ar >> p2; 39 ar << (unsigned long long)18;
65 ar >> p3; 40 ar.close();
66 ar >> p4; 41 }
67 ar >> p5; 42 mb.setPos( 0 );
68 ar >> p6; 43 {
69 ar >> p7; 44 Archive ar( mb, Archive::load );
70 ar >> p8; 45 int8_t p1;
71 ar >> p9; 46 uint8_t p2;
72 ar >> p10; 47 int16_t p3;
73 ar >> p11; 48 uint16_t p4;
74 ar >> p12; 49 int32_t p5;
75 ar >> p13; 50 uint32_t p6;
76 ar >> p14; 51 int64_t p7;
77 ar >> p15; 52 uint64_t p8;
78 ar >> p16; 53 char p9;
79 ar >> p17; 54 unsigned char p10;
80 ar >> p18; 55 short p11;
81 unitTest( p1 == 1 ); 56 unsigned short p12;
82 unitTest( p2 == 2 ); 57 int p13;
83 unitTest( p3 == 3 ); 58 unsigned int p14;
84 unitTest( p4 == 4 ); 59 long p15;
85 unitTest( p5 == 5 ); 60 unsigned long p16;
86 unitTest( p6 == 6 ); 61 long long p17;
87 unitTest( p7 == 7 ); 62 unsigned long long p18;
88 unitTest( p8 == 8 ); 63 ar >> p1;
89 unitTest( p9 == 9 ); 64 ar >> p2;
90 unitTest( p10 == 10 ); 65 ar >> p3;
91 unitTest( p11 == 11 ); 66 ar >> p4;
92 unitTest( p12 == 12 ); 67 ar >> p5;
93 unitTest( p13 == 13 ); 68 ar >> p6;
94 unitTest( p14 == 14 ); 69 ar >> p7;
95 unitTest( p15 == 15 ); 70 ar >> p8;
96 unitTest( p16 == 16 ); 71 ar >> p9;
97 unitTest( p17 == 17 ); 72 ar >> p10;
98 unitTest( p18 == 18 ); 73 ar >> p11;
99 ar.close(); 74 ar >> p12;
75 ar >> p13;
76 ar >> p14;
77 ar >> p15;
78 ar >> p16;
79 ar >> p17;
80 ar >> p18;
81 unitTest( p1 == 1 );
82 unitTest( p2 == 2 );
83 unitTest( p3 == 3 );
84 unitTest( p4 == 4 );
85 unitTest( p5 == 5 );
86 unitTest( p6 == 6 );
87 unitTest( p7 == 7 );
88 unitTest( p8 == 8 );
89 unitTest( p9 == 9 );
90 unitTest( p10 == 10 );
91 unitTest( p11 == 11 );
92 unitTest( p12 == 12 );
93 unitTest( p13 == 13 );
94 unitTest( p14 == 14 );
95 unitTest( p15 == 15 );
96 unitTest( p16 == 16 );
97 unitTest( p17 == 17 );
98 unitTest( p18 == 18 );
99 ar.close();
100 }
100 } 101 }
101}
102 102
103{%testContainers1} 103 test containers1
104{
105 MemBuf mb;
106 {
107 Archive ar( mb, Archive::save );
108 FString sStr("This is a test string.");
109 List<int> lList;
110 lList.append( 10 );
111 lList.append( 20 );
112 lList.append( 30 );
113 lList.append( 40 );
114 ar << sStr;
115 ar << lList;
116 ar.close();
117 }
118 mb.setPos( 0 );
119 { 104 {
120 Archive ar( mb, Archive::load ); 105 MemBuf mb;
121 FString sStr; 106 {
122 List<int> lList; 107 Archive ar( mb, Archive::save );
123 ar >> sStr; 108 FString sStr("This is a test string.");
124 ar >> lList; 109 List<int> lList;
125 unitTest( sStr == "This is a test string." ); 110 lList.append( 10 );
126 unitTest( lList.getSize() == 4 ); 111 lList.append( 20 );
127 List<int>::iterator i = lList.begin(); 112 lList.append( 30 );
128 unitTest( *i == 10 ); i++; 113 lList.append( 40 );
129 unitTest( *i == 20 ); i++; 114 ar << sStr;
130 unitTest( *i == 30 ); i++; 115 ar << lList;
131 unitTest( *i == 40 ); 116 ar.close();
132 ar.close(); 117 }
118 mb.setPos( 0 );
119 {
120 Archive ar( mb, Archive::load );
121 FString sStr;
122 List<int> lList;
123 ar >> sStr;
124 ar >> lList;
125 unitTest( sStr == "This is a test string." );
126 unitTest( lList.getSize() == 4 );
127 List<int>::iterator i = lList.begin();
128 unitTest( *i == 10 ); i++;
129 unitTest( *i == 20 ); i++;
130 unitTest( *i == 30 ); i++;
131 unitTest( *i == 40 );
132 ar.close();
133 }
133 } 134 }
134}
135 135
136{%testContainers2} 136 test containers2
137{
138 MemBuf mb;
139 {
140 Archive ar( mb, Archive::save );
141 FString sStr("This is a test string.");
142 Array<int> lArray;
143 lArray.append( 10 );
144 lArray.append( 20 );
145 lArray.append( 30 );
146 lArray.append( 40 );
147 ar << sStr;
148 ar << lArray;
149 ar.close();
150 }
151 mb.setPos( 0 );
152 { 137 {
153 Archive ar( mb, Archive::load ); 138 MemBuf mb;
154 FString sStr; 139 {
155 Array<int> lArray; 140 Archive ar( mb, Archive::save );
156 ar >> sStr; 141 FString sStr("This is a test string.");
157 ar >> lArray; 142 Array<int> lArray;
158 unitTest( sStr == "This is a test string." ); 143 lArray.append( 10 );
159 unitTest( lArray.getSize() == 4 ); 144 lArray.append( 20 );
160 Array<int>::iterator i = lArray.begin(); 145 lArray.append( 30 );
161 unitTest( *i == 10 ); i++; 146 lArray.append( 40 );
162 unitTest( *i == 20 ); i++; 147 ar << sStr;
163 unitTest( *i == 30 ); i++; 148 ar << lArray;
164 unitTest( *i == 40 ); 149 ar.close();
165 ar.close(); 150 }
151 mb.setPos( 0 );
152 {
153 Archive ar( mb, Archive::load );
154 FString sStr;
155 Array<int> lArray;
156 ar >> sStr;
157 ar >> lArray;
158 unitTest( sStr == "This is a test string." );
159 unitTest( lArray.getSize() == 4 );
160 Array<int>::iterator i = lArray.begin();
161 unitTest( *i == 10 ); i++;
162 unitTest( *i == 20 ); i++;
163 unitTest( *i == 30 ); i++;
164 unitTest( *i == 40 );
165 ar.close();
166 }
166 } 167 }
167}
168 168
169{%testContainers3} 169 test containers3
170{
171 MemBuf mb;
172 {
173 Archive ar( mb, Archive::save );
174 Array<FString> lArray;
175 lArray.append( "10" );
176 lArray.append( "20" );
177 lArray.append( "30" );
178 lArray.append( "40" );
179 ar << lArray;
180 ar.close();
181 }
182 mb.setPos( 0 );
183 { 170 {
184 Archive ar( mb, Archive::load ); 171 MemBuf mb;
185 Array<FString> lArray; 172 {
186 ar >> lArray; 173 Archive ar( mb, Archive::save );
187 unitTest( lArray.getSize() == 4 ); 174 Array<FString> lArray;
188 Array<FString>::iterator i = lArray.begin(); 175 lArray.append( "10" );
189 unitTest( *i == "10" ); i++; 176 lArray.append( "20" );
190 unitTest( *i == "20" ); i++; 177 lArray.append( "30" );
191 unitTest( *i == "30" ); i++; 178 lArray.append( "40" );
192 unitTest( *i == "40" ); 179 ar << lArray;
193 ar.close(); 180 ar.close();
181 }
182 mb.setPos( 0 );
183 {
184 Archive ar( mb, Archive::load );
185 Array<FString> lArray;
186 ar >> lArray;
187 unitTest( lArray.getSize() == 4 );
188 Array<FString>::iterator i = lArray.begin();
189 unitTest( *i == "10" ); i++;
190 unitTest( *i == "20" ); i++;
191 unitTest( *i == "30" ); i++;
192 unitTest( *i == "40" );
193 ar.close();
194 }
194 } 195 }
195} 196}