summaryrefslogtreecommitdiff
path: root/src/unit/fstring.unit
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 02:14:08 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 02:14:08 +0000
commitf5aca1a1b402bd7ebc944dc6e6fe65828d863365 (patch)
tree4a0fdd8e166d5c4b03543279d332b9a858ef62df /src/unit/fstring.unit
parent10c557562e1d67c55314c212371ea9cb7f802863 (diff)
downloadlibbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.tar.gz
libbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.tar.bz2
libbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.tar.xz
libbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.zip
Bu::FString is now String, and there's a shell script to fix any other programs
that were using fstring, I hope.
Diffstat (limited to '')
-rw-r--r--src/unit/fstring.unit134
1 files changed, 67 insertions, 67 deletions
diff --git a/src/unit/fstring.unit b/src/unit/fstring.unit
index c6d7414..d282052 100644
--- a/src/unit/fstring.unit
+++ b/src/unit/fstring.unit
@@ -6,29 +6,29 @@
6 * terms of the license contained in the file LICENSE. 6 * terms of the license contained in the file LICENSE.
7 */ 7 */
8 8
9#include "bu/fstring.h" 9#include "bu/string.h"
10 10
11#include <dirent.h> 11#include <dirent.h>
12 12
13suite FString 13suite String
14{ 14{
15 test compare1 15 test compare1
16 { 16 {
17 Bu::FString b("Bob"); 17 Bu::String b("Bob");
18 unitTest( !(b == "Bobo") ); 18 unitTest( !(b == "Bobo") );
19 unitTest( b == "Bob" ); 19 unitTest( b == "Bob" );
20 } 20 }
21 21
22 test compare2 22 test compare2
23 { 23 {
24 Bu::FString b("Bobo"); 24 Bu::String b("Bobo");
25 unitTest( !(b == "Bob") ); 25 unitTest( !(b == "Bob") );
26 unitTest( b == "Bobo" ); 26 unitTest( b == "Bobo" );
27 } 27 }
28 28
29 test appendSingle 29 test appendSingle
30 { 30 {
31 Bu::FString b; 31 Bu::String b;
32 for( char l = 'a'; l < 'g'; l++ ) 32 for( char l = 'a'; l < 'g'; l++ )
33 b += l; 33 b += l;
34 unitTest( b == "abcdef" ); 34 unitTest( b == "abcdef" );
@@ -37,8 +37,8 @@ suite FString
37 37
38 test shared1 38 test shared1
39 { 39 {
40 Bu::FString a("Hey there"); 40 Bu::String a("Hey there");
41 Bu::FString b( a ); 41 Bu::String b( a );
42 unitTest( a.getConstStr() == b.getConstStr() ); 42 unitTest( a.getConstStr() == b.getConstStr() );
43 b += " guy"; 43 b += " guy";
44 unitTest( a.getConstStr() != b.getConstStr() ); 44 unitTest( a.getConstStr() != b.getConstStr() );
@@ -48,7 +48,7 @@ suite FString
48 48
49 test insert 49 test insert
50 { 50 {
51 Bu::FString a("abcd"); 51 Bu::String a("abcd");
52 a.insert( 2, "-!-", 3 ); 52 a.insert( 2, "-!-", 3 );
53 unitTest( a == "ab-!-cd" ); 53 unitTest( a == "ab-!-cd" );
54 54
@@ -67,7 +67,7 @@ suite FString
67 67
68 test remove 68 test remove
69 { 69 {
70 Bu::FString a("abHEYcd"); 70 Bu::String a("abHEYcd");
71 a.remove( 2, 3 ); 71 a.remove( 2, 3 );
72 unitTest( a == "abcd" ); 72 unitTest( a == "abcd" );
73 a.remove( 2, 5 ); 73 a.remove( 2, 5 );
@@ -79,42 +79,42 @@ suite FString
79 79
80 test add1 80 test add1
81 { 81 {
82 Bu::FString a("hi there"); 82 Bu::String a("hi there");
83 Bu::FString b(", yeah!"); 83 Bu::String b(", yeah!");
84 Bu::FString c = a + b; 84 Bu::String c = a + b;
85 85
86 unitTest( c == "hi there, yeah!" ); 86 unitTest( c == "hi there, yeah!" );
87 } 87 }
88 88
89 test add2 89 test add2
90 { 90 {
91 Bu::FString a("hi there"); 91 Bu::String a("hi there");
92 Bu::FString c = a + ", yeah!"; 92 Bu::String c = a + ", yeah!";
93 93
94 unitTest( c == "hi there, yeah!" ); 94 unitTest( c == "hi there, yeah!" );
95 } 95 }
96 96
97 test add3 97 test add3
98 { 98 {
99 Bu::FString a("hi there"); 99 Bu::String a("hi there");
100 Bu::FString b(", yeah!"); 100 Bu::String b(", yeah!");
101 Bu::FString c = a + ", Mr. Man" + b; 101 Bu::String c = a + ", Mr. Man" + b;
102 102
103 unitTest( c == "hi there, Mr. Man, yeah!" ); 103 unitTest( c == "hi there, Mr. Man, yeah!" );
104 } 104 }
105 105
106 test add4 106 test add4
107 { 107 {
108 Bu::FString b(", yeah!"); 108 Bu::String b(", yeah!");
109 Bu::FString c = "hi there" + b; 109 Bu::String c = "hi there" + b;
110 110
111 unitTest( c == "hi there, yeah!" ); 111 unitTest( c == "hi there, yeah!" );
112 } 112 }
113 113
114 test add5 114 test add5
115 { 115 {
116 Bu::FString b; 116 Bu::String b;
117 Bu::FString c = "sup?"; 117 Bu::String c = "sup?";
118 b += "hey, " + c; 118 b += "hey, " + c;
119 119
120 unitTest( b == "hey, sup?" ); 120 unitTest( b == "hey, sup?" );
@@ -122,17 +122,17 @@ suite FString
122 122
123 test add6 123 test add6
124 { 124 {
125 Bu::FString a("Hello"); 125 Bu::String a("Hello");
126 char b[256] = {"Dude"}; 126 char b[256] = {"Dude"};
127 Bu::FString c = a + "/" + b; 127 Bu::String c = a + "/" + b;
128 128
129 unitTest( c == "Hello/Dude" ); 129 unitTest( c == "Hello/Dude" );
130 } 130 }
131 131
132 test add7 132 test add7
133 { 133 {
134 const Bu::FString a("hello "); 134 const Bu::String a("hello ");
135 Bu::FString b(" how "); 135 Bu::String b(" how ");
136 unitTest( a == "hello " ); 136 unitTest( a == "hello " );
137 unitTest( a + "dude" == "hello dude" ); 137 unitTest( a + "dude" == "hello dude" );
138 unitTest( a + "dude" + b + "are you?" == "hello dude how are you?" ); 138 unitTest( a + "dude" + b + "are you?" == "hello dude how are you?" );
@@ -140,16 +140,16 @@ suite FString
140 140
141 test subStr1 141 test subStr1
142 { 142 {
143 Bu::FString a("abcdefghijklmnop"); 143 Bu::String a("abcdefghijklmnop");
144 Bu::FString::iterator i = a.find('f'); 144 Bu::String::iterator i = a.find('f');
145 unitTest( a.getSubStr( i, Bu::FString::iterator() ) == "fghijklmnop" ); 145 unitTest( a.getSubStr( i, Bu::String::iterator() ) == "fghijklmnop" );
146 Bu::FString::iterator j = i.find('l'); 146 Bu::String::iterator j = i.find('l');
147 unitTest( a.getSubStr( i, j ) == "fghijk" ); 147 unitTest( a.getSubStr( i, j ) == "fghijk" );
148 } 148 }
149 149
150 test compareSub1 150 test compareSub1
151 { 151 {
152 Bu::FString a("just a string."); 152 Bu::String a("just a string.");
153 unitTest( a.compareSub("a ", 5, 2) == true ); 153 unitTest( a.compareSub("a ", 5, 2) == true );
154 unitTest( a.compareSub("string.aoeu", 7, 11 ) == false ); 154 unitTest( a.compareSub("string.aoeu", 7, 11 ) == false );
155 unitTest( a.compareSub("string.aoeu", 7, 3 ) == true ); 155 unitTest( a.compareSub("string.aoeu", 7, 3 ) == true );
@@ -157,17 +157,17 @@ suite FString
157 157
158 test compareSub2 158 test compareSub2
159 { 159 {
160 Bu::FString a("just a string."); 160 Bu::String a("just a string.");
161 unitTest( a.compareSub(Bu::FString("a "), 5, 2) == true ); 161 unitTest( a.compareSub(Bu::String("a "), 5, 2) == true );
162 unitTest( a.compareSub(Bu::FString("string.aoeu"), 7, 11 ) == false ); 162 unitTest( a.compareSub(Bu::String("string.aoeu"), 7, 11 ) == false );
163 unitTest( a.compareSub(Bu::FString("string.aoeu"), 7, 3 ) == true ); 163 unitTest( a.compareSub(Bu::String("string.aoeu"), 7, 3 ) == true );
164 } 164 }
165 165
166 test iterator1 166 test iterator1
167 { 167 {
168 Bu::FString a("This is a test."); 168 Bu::String a("This is a test.");
169 Bu::FString b; 169 Bu::String b;
170 for( Bu::FString::iterator i = a.begin(); i; i++ ) 170 for( Bu::String::iterator i = a.begin(); i; i++ )
171 { 171 {
172 b += *i; 172 b += *i;
173 } 173 }
@@ -176,10 +176,10 @@ suite FString
176 176
177 test iterator2 177 test iterator2
178 { 178 {
179 Bu::FString a("This is a test."); 179 Bu::String a("This is a test.");
180 Bu::FString b("--This is a test."); 180 Bu::String b("--This is a test.");
181 Bu::FString::iterator ai = a.begin(); 181 Bu::String::iterator ai = a.begin();
182 Bu::FString::iterator bi = b.begin(); 182 Bu::String::iterator bi = b.begin();
183 unitTest( ai.compare( bi ) == false ); 183 unitTest( ai.compare( bi ) == false );
184 unitTest( bi.compare( ai ) == false ); 184 unitTest( bi.compare( ai ) == false );
185 bi++; bi++; 185 bi++; bi++;
@@ -189,10 +189,10 @@ suite FString
189 189
190 test iterator3 190 test iterator3
191 { 191 {
192 Bu::FString a("1234honour"); 192 Bu::String a("1234honour");
193 Bu::FString b("--1234ueje"); 193 Bu::String b("--1234ueje");
194 Bu::FString::iterator ai = a.begin(); 194 Bu::String::iterator ai = a.begin();
195 Bu::FString::iterator bi = b.begin(); 195 Bu::String::iterator bi = b.begin();
196 unitTest( ai.compare( bi, 4 ) == false ); 196 unitTest( ai.compare( bi, 4 ) == false );
197 unitTest( bi.compare( ai, 4 ) == false ); 197 unitTest( bi.compare( ai, 4 ) == false );
198 bi++; bi++; 198 bi++; bi++;
@@ -205,8 +205,8 @@ suite FString
205 205
206 test iterator4 206 test iterator4
207 { 207 {
208 Bu::FString a("1234aoeu"); 208 Bu::String a("1234aoeu");
209 Bu::FString::iterator ai = a.begin(); 209 Bu::String::iterator ai = a.begin();
210 unitTest( ai.compare("1234") == false ); 210 unitTest( ai.compare("1234") == false );
211 unitTest( ai.compare("1234aoeu") == true ); 211 unitTest( ai.compare("1234aoeu") == true );
212 unitTest( ai.compare("1234aoeuee") == false ); 212 unitTest( ai.compare("1234aoeuee") == false );
@@ -214,8 +214,8 @@ suite FString
214 214
215 test iterator5 215 test iterator5
216 { 216 {
217 Bu::FString a("1234aoeu"); 217 Bu::String a("1234aoeu");
218 Bu::FString::iterator ai = a.begin(); 218 Bu::String::iterator ai = a.begin();
219 unitTest( ai.compare("1234", 4) == true ); 219 unitTest( ai.compare("1234", 4) == true );
220 unitTest( ai.compare("1234aoeu", 8) == true ); 220 unitTest( ai.compare("1234aoeu", 8) == true );
221 unitTest( ai.compare("1234aoeuee", 10) == false ); 221 unitTest( ai.compare("1234aoeuee", 10) == false );
@@ -223,9 +223,9 @@ suite FString
223 223
224 test iterator6 224 test iterator6
225 { 225 {
226 Bu::FString a("just ->this part"); 226 Bu::String a("just ->this part");
227 Bu::FString b; 227 Bu::String b;
228 Bu::FString::iterator s = a.begin(); 228 Bu::String::iterator s = a.begin();
229 for(; s; s++ ) 229 for(; s; s++ )
230 { 230 {
231 if( *s == '>' ) 231 if( *s == '>' )
@@ -239,7 +239,7 @@ suite FString
239 239
240 b.append( s ); 240 b.append( s );
241 241
242 Bu::FString c; 242 Bu::String c;
243 c.set( b.begin() ); 243 c.set( b.begin() );
244 244
245 // This is here because the comparison operator used to cause flattening. 245 // This is here because the comparison operator used to cause flattening.
@@ -249,9 +249,9 @@ suite FString
249 249
250 test iterator7 250 test iterator7
251 { 251 {
252 Bu::FString a("just [this] part"); 252 Bu::String a("just [this] part");
253 Bu::FString b; 253 Bu::String b;
254 Bu::FString::iterator s = a.begin(); 254 Bu::String::iterator s = a.begin();
255 for(; s; s++ ) 255 for(; s; s++ )
256 { 256 {
257 if( *s == '[' ) 257 if( *s == '[' )
@@ -260,7 +260,7 @@ suite FString
260 break; 260 break;
261 } 261 }
262 } 262 }
263 Bu::FString::iterator e = s; 263 Bu::String::iterator e = s;
264 for(; e; e++ ) 264 for(; e; e++ )
265 { 265 {
266 if( *e == ']' ) 266 if( *e == ']' )
@@ -273,9 +273,9 @@ suite FString
273 273
274 b.append( s, e ); 274 b.append( s, e );
275 275
276 for( Bu::FString::iterator i = b.begin(); i;) 276 for( Bu::String::iterator i = b.begin(); i;)
277 { 277 {
278 Bu::FString::iterator k = i; 278 Bu::String::iterator k = i;
279 k++; 279 k++;
280 if( !k ) 280 if( !k )
281 { 281 {
@@ -284,12 +284,12 @@ suite FString
284 } 284 }
285 i = k; 285 i = k;
286 } 286 }
287 Bu::FString l; 287 Bu::String l;
288 l.set( b.begin() ); 288 l.set( b.begin() );
289 unitTest( l == "thisthisthisthi" ); 289 unitTest( l == "thisthisthisthi" );
290 for( Bu::FString::iterator i = b.begin(); i;) 290 for( Bu::String::iterator i = b.begin(); i;)
291 { 291 {
292 Bu::FString::iterator k = i; 292 Bu::String::iterator k = i;
293 k++; 293 k++;
294 if( !k ) 294 if( !k )
295 { 295 {
@@ -304,7 +304,7 @@ suite FString
304 304
305 test isSet1 305 test isSet1
306 { 306 {
307 Bu::FString bob; 307 Bu::String bob;
308 308
309 unitTest( bob.isSet() == false ); 309 unitTest( bob.isSet() == false );
310 bob = "something"; 310 bob = "something";
@@ -315,7 +315,7 @@ suite FString
315 315
316 test swap1 316 test swap1
317 { 317 {
318 Bu::FString a, b; 318 Bu::String a, b;
319 a = "Goodbye"; 319 a = "Goodbye";
320 b = "Hello"; 320 b = "Hello";
321 Bu::swap( a, b ); 321 Bu::swap( a, b );
@@ -325,7 +325,7 @@ suite FString
325 325
326 test swap2 326 test swap2
327 { 327 {
328 Bu::FString a, b; 328 Bu::String a, b;
329 a = "Goodbye"; 329 a = "Goodbye";
330 b = "Hello"; 330 b = "Hello";
331 std::swap( a, b ); 331 std::swap( a, b );
@@ -335,14 +335,14 @@ suite FString
335 335
336 test replace1 336 test replace1
337 { 337 {
338 Bu::FString a; 338 Bu::String a;
339 a = "This is a test."; 339 a = "This is a test.";
340 unitTest( a.replace("i", "ooo") == "Thooos ooos a test." ); 340 unitTest( a.replace("i", "ooo") == "Thooos ooos a test." );
341 } 341 }
342 342
343 test coreDerefBug1 343 test coreDerefBug1
344 { 344 {
345 Bu::FString a, b; 345 Bu::String a, b;
346 a = "bob"; 346 a = "bob";
347 a.setSize( 0 ); 347 a.setSize( 0 );
348 b = a; 348 b = a;