00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <j2k/Fred/String/String.hpp>
00016 #include <j2k/Fred/String/String.cpp>
00017
00018 size_t sz = 20;
00019
00020 JString s1a;
00021 JString s1b( strNull );
00022
00023 JString s2( "Hello" );
00024 JString s3( "World", sz );
00025
00026 JString s4a( (char*)NULL );
00027
00028
00029 JString s4b( "", (size_t)NULL );
00030
00031 JString s4c( "", sz*2 );
00032 JString s4d( " ", 10 );
00033
00034 JString s5( s3 );
00035
00036
00037 JString s6a( "A" );
00038 JString s7a( "", sz );
00039
00040 JString s6b( (char)'A' );
00041 JString s7b( (char)'#', 5 );
00042 JString s8( new JStringData( "Fred" ) );
00043 JString s9("World", sz-10);
00044 JString strPI( "3.14159265358979" );
00045
00046 JString temp( "", (size_t)80 );
00047 JString temp2;
00048
00049 void init() {
00050
00051
00052
00053
00054 s7a.FillBuffer( '#' );
00055 assert( s7a == "####################" );
00056
00057 assert( s6b == "A" );
00058
00059 assert( s7b == "#####" );
00060
00061
00062
00063
00064
00065
00066 assert( s1a == (char*)NULL );
00067 assert( s1a == (char )NULL );
00068
00069 assert( s1b == (char*)NULL );
00070 assert( s1b == (char )NULL );
00071
00072 assert( s1a == (char*)0 );
00073 assert( s1a == (char )0 );
00074
00075 assert( s1b == (char*)0 );
00076 assert( s1b == (char )0 );
00077
00078 assert( s1a == (char*)((void*)0) );
00079 assert( s1a == (char )((void*)0) );
00080
00081 assert( s1b == (char*)((void*)0) );
00082 assert( s1b == (char )((void*)0) );
00083
00084 assert( s1a == (char*)'\0' );
00085 assert( s1b == (char*)'\0' );
00086
00087 assert( s1a == (char )'\0' );
00088 assert( s1b == (char )'\0' );
00089
00090 assert( s1a == '\0' );
00091 assert( s1b == '\0' );
00092
00093 assert( s1a == "" );
00094 assert( s1b == "" );
00095
00096 assert( s2 == "Hello" );
00097 assert( s3 == "World" );
00098 assert( s4a == s1a );
00099 assert( s4b == s1a );
00100 assert( s4c == s1a );
00101 assert( s4a == s1b );
00102 assert( s4b == s1b );
00103 assert( s4c == s1b );
00104 assert( s4d == " " );
00105 assert( s5 == s3 );
00106
00107 assert( s6a == 'A' );
00108 assert( s7a != '#' );
00109 assert( s6b == 'A' );
00110 assert( s7b != '#' );
00111
00112 assert( s8 == "Fred" );
00113 assert( s9 == "World" );
00114
00115 cout << "[s1a[" << s1a << "]\n";
00116 cout << "[s1b[" << s1b << "]\n";
00117 cout << "[s2[" << s2 << "]\n";
00118 cout << "[s3[" << s3 << "]\n";
00119 cout << "[s4a[" << s4a << "]\n";
00120 cout << "[s4b[" << s4b << "]\n";
00121 cout << "[s4c[" << s4c << "]\n";
00122 cout << "[s4d[" << s4d << "]\n";
00123 cout << "[s5[" << s5 << "]\n";
00124 cout << "[s6a[" << s6a << "]\n";
00125 cout << "[s6b[" << s6b << "]\n";
00126 cout << "[s7a[" << s7a << "]\n";
00127 cout << "[s7b[" << s7b << "]\n";
00128 cout << "[s8[" << s8 << "]\n";
00129 cout << "Is OK ?\n";
00130
00131 assert( s1a.OK() );
00132 assert( s1b.OK() );
00133 assert( s2.OK() );
00134 assert( s3.OK() );
00135 assert( s4a.OK() );
00136
00137 assert( s4b.OK() );
00138
00139 assert( s4c.OK() );
00140 assert( s5.OK() );
00141 assert( s6a.OK() );
00142 assert( s6b.OK() );
00143 assert( s7a.OK() );
00144 assert( s7b.OK() );
00145 assert( s8.OK() );
00146
00147 assert( s1a.isEmpty() );
00148 assert( s1b.isEmpty() );
00149
00150 assert( s4a.isEmpty() );
00151 assert( s4b.isEmpty() );
00152 assert( s4c.isEmpty() );
00153
00154 assert( !s2.isEmpty() );
00155 assert( !s3.isEmpty() );
00156
00157 assert( !s5.isEmpty() );
00158 assert( !s6a.isEmpty() );
00159 assert( !s6b.isEmpty() );
00160 assert( !s7a.isEmpty() );
00161 assert( !s7b.isEmpty() );
00162 assert( !s8.isEmpty() );
00163 }
00164
00165 void debug()
00166 {
00167 printf( "Debug {\n ");
00168 printf( "[s1a[%s]\n", (char*)s1a );
00169 printf( "[s1b[%s]\n", (char*)s1b );
00170 printf( "[s2[%s]\n", (char*)s2 );
00171 printf( "[s3[%s]\n", (char*)s3 );
00172 printf( "[s4a[%s]\n", (char*)s4a );
00173 printf( "[s4b[%s]\n", (char*)s4b );
00174 printf( "[s4c[%s]\n", (char*)s4c );
00175 printf( "[s4d[%s]\n", (char*)s4d );
00176 printf( "[s5[%s]\n", (char*)s5 );
00177 printf( "[s6a[%s]\n", (char*)s6a );
00178 printf( "[s6b[%s]\n", (char*)s6b );
00179 printf( "[s7a[%s]\n", (char*)s7a );
00180 printf( "[s7b[%s]\n", (char*)s7b );
00181 printf( "[s8[%s]\n", (char*)s8 );
00182 printf( "}\n ");
00183 fflush( stdout );
00184 }
00185
00186 void fill()
00187 {
00188 s4c = s8;
00189 s4c.Clear();
00190
00191 #ifndef __J2K__QUIET
00192 cout << "[s4c[Clear[" << s4c << "]\n";
00193 cout << "[s8[" << s8 << "]\n";
00194 #endif
00195
00196 s4c = s3;
00197
00198 assert( s3 == s4c );
00199
00200 s4c.Empty();
00201
00202 #ifndef __J2K__QUIET
00203 cout << "[s3[Empty(" << s3 << ") == [" << s4c << "]\n";
00204 #endif
00205
00206 assert( s4d.length() == 2 );
00207
00208 cout << s4d.length() << "-" << s4d.getBufferSize() << endl;
00209
00210 s4a.FillString( '1' );
00211 s4b.FillString( '1' );
00212 s4c.FillString( '1' );
00213 s4d.FillString( '1' );
00214
00215 #ifndef __J2K__QUIET
00216 cout << "[s4a[Fill(1)[" << s4a << "]\n";
00217 cout << "[s4b[Fill(1)[" << s4b << "]\n";
00218 cout << "[s4c[Fill(1)[" << s4c << "]\n";
00219 cout << "[s4d[Fill(1)[" << s4d << "]\n";
00220 #endif
00221
00222 cout << s4d.length() << "-" << s4d.getBufferSize() << endl;
00223
00224 assert( s4d.length() == 2 );
00225 assert( s4d.getBufferSize() == 10 );
00226
00227 s4a.FillBuffer( '2' );
00228 s4b.FillBuffer( '2' );
00229 s4c.FillBuffer( '2' );
00230 s4d.FillBuffer( '2' );
00231
00232 assert( s4d.length() == 10 );
00233 assert( s4d.getBufferSize() == 10 );
00234
00235 cout << s4d.length() << "-" << s4d.getBufferSize() << endl;
00236
00237 #ifndef __J2K__QUIET
00238 cout << "[s4a[FillBuf(2)[" << s4a << "]\n";
00239 cout << "[s4b[FillBuf(2)[" << s4b << "]\n";
00240 cout << "[s4c[FillBuf(2)[" << s4c << "]\n";
00241 cout << "[s4d[FillBuf(2)[" << s4d << "]\n";
00242 #endif
00243 }
00244
00245
00246 void display() {
00247 cout << "Display all\n";
00248 s1a.Display();
00249 cout << endl;
00250 s1b.Display();
00251 cout << endl;
00252 s2.Display();
00253 cout << endl;
00254 s3.Display();
00255 cout << endl;
00256 s4a.Display();
00257 cout << endl;
00258 s4b.Display();
00259 cout << endl;
00260 s4c.Display();
00261 cout << endl;
00262 s4d.Display();
00263 cout << endl;
00264 s5.Display();
00265 cout << endl;
00266 s6a.Display();
00267 cout << endl;
00268 s6b.Display();
00269 cout << endl;
00270 s7a.Display();
00271 cout << endl;
00272 s7b.Display();
00273 cout << endl;
00274 s8.Display();
00275 cout << endl;
00276 }
00277
00278 void displayTemp()
00279 {
00280 temp.Display();
00281 cout << endl;
00282
00283 temp2.Display();
00284 cout << endl;
00285 }
00286
00287 void length()
00288 {
00289 assert( s1a.getLength() == 0 );
00290 assert( s1b.getLength() == 0 );
00291 assert( s2.getLength() == 5 );
00292 assert( s3.getLength() == 5 );
00293 assert( s4a.getLength() == 0 );
00294 assert( s4b.getLength() == 0 );
00295 assert( s4c.getLength() == 0 );
00296 assert( s5.getLength() == 5 );
00297 assert( s6a.getLength() == 1 );
00298 assert( s6b.getLength() == 1 );
00299 assert( s7a.getLength() == 20 );
00300 assert( s7b.getLength() == 5 );
00301 assert( s8.getLength() == 4 );
00302
00303 assert( s1a.length() == 0 );
00304 assert( s1b.length() == 0 );
00305 assert( s2.length() == 5 );
00306 assert( s3.length() == 5 );
00307 assert( s4a.length() == 0 );
00308 assert( s4b.length() == 0 );
00309 assert( s4c.length() == 0 );
00310 assert( s5.length() == 5 );
00311 assert( s6a.length() == 1 );
00312 assert( s6b.length() == 1 );
00313 assert( s7a.length() == 20 );
00314 assert( s7b.length() == 5 );
00315 assert( s8.length() == 4 );
00316
00317 assert( s1a.getLength() == s1a.length() );
00318 assert( s1b.getLength() == s1b.length() );
00319 assert( s2.getLength() == s2.length() );
00320 assert( s3.getLength() == s3.length() );
00321 assert( s4a.getLength() == s4a.length() );
00322 assert( s4b.getLength() == s4b.length() );
00323 assert( s4c.getLength() == s4c.length() );
00324 assert( s5.getLength() == s5.length() );
00325 assert( s6a.getLength() == s6a.length() );
00326 assert( s6b.getLength() == s6b.length() );
00327 assert( s7a.getLength() == s7a.length() );
00328 assert( s7b.getLength() == s7b.length() );
00329 assert( s8.getLength() == s8.length() );
00330
00331 assert( s1a.getAllocLength() == 0 );
00332 assert( s1b.getAllocLength() == 0 );
00333 assert( s2.getAllocLength() == 5 );
00334 assert( s3.getAllocLength() == 20 );
00335 assert( s4a.getAllocLength() == 0 );
00336 assert( s4b.getAllocLength() == 0 );
00337 assert( s4c.getAllocLength() == 0 );
00338 assert( s5.getAllocLength() == 20 );
00339 assert( s6a.getAllocLength() == 1 );
00340 assert( s6b.getAllocLength() == 1 );
00341 assert( s7a.getAllocLength() == 20 );
00342 assert( s7b.getAllocLength() == 5 );
00343 assert( s8.getAllocLength() == 4 );
00344
00345 assert( s1a.getBufferSize() == 0 );
00346 assert( s1b.getBufferSize() == 0 );
00347 assert( s2.getBufferSize() == 5 );
00348 assert( s3.getBufferSize() == 20 );
00349 assert( s4a.getBufferSize() == 0 );
00350 assert( s4b.getBufferSize() == 0 );
00351 assert( s4c.getBufferSize() == 0 );
00352 assert( s5.getBufferSize() == 20 );
00353 assert( s6a.getBufferSize() == 1 );
00354 assert( s6b.getBufferSize() == 1 );
00355 assert( s7a.getBufferSize() == 20 );
00356 assert( s7b.getBufferSize() == 5 );
00357 assert( s8.getBufferSize() == 4 );
00358 }
00359
00360 void lock()
00361 {
00362
00363 assert( s1a.getLockNb() == 0 );
00364 assert( s1b.getLockNb() == 0 );
00365 assert( s2.getLockNb() == 0 );
00366 assert( s3.getLockNb() == 0 );
00367 assert( s4a.getLockNb() == 0 );
00368 assert( s4b.getLockNb() == 0 );
00369 assert( s4c.getLockNb() == 0 );
00370 assert( s5.getLockNb() == 0 );
00371 assert( s6a.getLockNb() == 0 );
00372 assert( s6b.getLockNb() == 0 );
00373 assert( s7a.getLockNb() == 0 );
00374 assert( s7b.getLockNb() == 0 );
00375 assert( s8.getLockNb() == 0 );
00376
00377 assert( !s1a.isLock() );
00378 assert( !s1b.isLock() );
00379 assert( !s2.isLock() );
00380 assert( !s3.isLock() );
00381 assert( !s4a.isLock() );
00382 assert( !s4b.isLock() );
00383 assert( !s4c.isLock() );
00384 assert( !s5.isLock() );
00385 assert( !s6a.isLock() );
00386 assert( !s6b.isLock() );
00387 assert( !s7a.isLock() );
00388 assert( !s7b.isLock() );
00389 assert( !s8.isLock() );
00390
00391 assert( s1a.isUnlock() );
00392 assert( s1b.isUnlock() );
00393 assert( s2.isUnlock() );
00394 assert( s3.isUnlock() );
00395 assert( s4a.isUnlock() );
00396 assert( s4b.isUnlock() );
00397 assert( s4c.isUnlock() );
00398 assert( s5.isUnlock() );
00399 assert( s6a.isUnlock() );
00400 assert( s6b.isUnlock() );
00401 assert( s7a.isUnlock() );
00402 assert( s7b.isUnlock() );
00403 assert( s8.isUnlock() );
00404 }
00405
00406 void comp() {
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416 #ifndef __J2K__QUIET
00417 cout << "Compare:\n";
00418 #endif
00419
00420 assert( s3.compare( s9 ) == 0 );
00421 assert( s3.compare( (char*)s9 ) == 0 );
00422 assert( s3.compare( "World" ) == 0 );
00423 assert( s9.compare( s3 ) == 0 );
00424
00425 assert( s2 < s3 );
00426 assert( s2 < "Z" );
00427 assert( s3 > s2 );
00428 assert( s3 > "A" );
00429
00430 assert( s2 <= s3 );
00431 assert( s2 <= "Z" );
00432 assert( s3 >= s2 );
00433 assert( s3 >= "A" );
00434
00435 assert( s3 == s9 );
00436 assert( s3 == "World" );
00437
00438 assert( s2 != s3 );
00439 assert( s3 != "Hello" );
00440 }
00441
00442 void parse() {
00443
00444
00445
00446
00447
00448
00449 assert( !strcmp( (char*)strPI, "3.14159265358979" ) );
00450
00451 assert( ((int)(strPI) ) == 3 );
00452 assert( ((long)(strPI) ) == 3 );
00453 assert( ((double)(strPI)) == 3.14159265358979 );
00454
00455 #ifndef __J2K__QUIET
00456 cout << "Compare PI:\n";
00457 #endif
00458
00459 assert( strPI.parseInt() == 3 );
00460 assert( strPI.parseLong() == 3 );
00461 assert( strPI.parseDouble() == 3.14159265358979 );
00462
00463 assert( !strcmp( strPI.parseString(), "3.14159265358979" ) );
00464
00465 assert( !strcmp( strPI.toString(), "3.14159265358979" ) );
00466 assert( !strcmp( strPI.getText(), "3.14159265358979" ) );
00467
00468
00469
00470
00471 #ifndef __J2K__QUIET
00472 cout << "[strPI[" << strPI << "]\n";
00473 #endif
00474
00475 }
00476
00477 void assign() {
00478
00479
00480
00481
00482 temp = strPI;
00483
00484 strPI = "9.81";
00485
00486 assert( strPI.parseDouble() == 9.81 );
00487
00488 strPI = temp;
00489
00490 assert( strPI == temp );
00491 assert( !( strPI != temp ) );
00492
00493 #ifndef __J2K__QUIET
00494 cout << "[temp[" << temp << "]\n";
00495 #endif
00496
00497 temp = 'a';
00498
00499 #ifndef __J2K__QUIET
00500 cout << "[temp[" << temp << "]\n";
00501 #endif
00502
00503
00504 assert( !strcmp( temp, "a" ) );
00505
00506 temp = "Fred";
00507
00508 assert( temp == "Fred" );
00509 assert( temp != "FRED" );
00510 assert( temp != "fred" );
00511 }
00512
00513 void concat() {
00514
00515
00516
00517
00518 #ifndef __J2K__QUIET
00519 cout << "Additions:\n";
00520 #endif
00521
00522 temp = s2;
00523
00524 s2.Append( " Fred...", 8 );
00525
00526 assert( s2 == "Hello Fred...");
00527
00528 s2 = temp;
00529
00530 s2 += s3;
00531
00532 assert( s2 == "HelloWorld" );
00533
00534 s2 = temp;
00535
00536 JString temp3 = s3;
00537
00538 temp2 = s3;
00539
00540 assert( temp2 == temp3 );
00541
00542 s3 += s2;
00543
00544 assert( s3 == "WorldHello" );
00545 assert( s2.OK() );
00546 assert( s3.OK() );
00547
00548 s3 += "!";
00549 assert( s3.OK() );
00550 assert( s3 == "WorldHello!" );
00551
00552 s2 += temp2;
00553 s2 += "$";
00554 assert( s2.OK() );
00555
00556 assert( temp == "Hello" );
00557 assert( temp2 == "World" );
00558 assert( s2 == "HelloWorld$" );
00559
00560 s2 += " Fred $ ";
00561
00562 assert( s2 == "HelloWorld$ Fred $ " );
00563
00564 s3 = temp2;
00565 s2 = temp;
00566
00567 assert( s3 == "World" );
00568 assert( s2 == "Hello" );
00569 }
00570
00571 void add() {
00572
00573
00574
00575
00576 temp = s2 + s3;
00577 temp += '!';
00578
00579 char* A = "Alpha";
00580 char* B = "Beta";
00581
00582 assert( temp == "HelloWorld!" );
00583
00584 temp += A;
00585 temp += B;
00586
00587 assert( temp == "HelloWorld!AlphaBeta" );
00588
00589 temp = temp + "=)";
00590
00591 assert( temp == "HelloWorld!AlphaBeta=)" );
00592
00593 temp = "=]" + temp + " =}";
00594
00595 assert( temp == "=]HelloWorld!AlphaBeta=) =}" );
00596
00597 temp = "{" + temp;
00598
00599 assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00600
00601 temp2 = temp;
00602 }
00603
00604 void tools() {
00605
00606
00607
00608
00609
00610 cout << "\nTesting tools()...\n" << endl;
00611
00612 assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00613
00614 displayTemp();
00615
00616 temp.MakeUpper();
00617
00618 displayTemp();
00619
00620 assert( temp == "{=]HELLOWORLD!ALPHABETA=) =}" );
00621
00622 temp.MakeLower();
00623 assert( temp == "{=]helloworld!alphabeta=) =}" );
00624
00625 temp.MakeReverse();
00626
00627 assert( temp == "}= )=atebahpla!dlrowolleh]={" );
00628
00629 temp.MakeReverse();
00630 assert( temp == "{=]helloworld!alphabeta=) =}" );
00631
00632 temp.UCase();
00633 assert( temp == "{=]HELLOWORLD!ALPHABETA=) =}" );
00634
00635 temp.LCase();
00636 assert( temp == "{=]helloworld!alphabeta=) =}" );
00637
00638 temp.Reverse();
00639
00640 #ifndef __J2K__QUIET
00641 cout << "T:" << "[temp[" << temp << "]\n";
00642 cout << "R:" << Reverse( temp ) << endl;
00643 #endif
00644
00645 assert( temp == "}= )=atebahpla!dlrowolleh]={" );
00646 assert( Reverse( temp ) == "{=]helloworld!alphabeta=) =}" );
00647
00648 temp = temp2;
00649
00650 #ifndef __J2K__QUIET
00651 cout << "T:" << "[temp[" << temp << "]\n";
00652 cout << "U:" << UCase( temp ) << endl;
00653 cout << "RR:" << LCase( temp ) << endl;
00654 cout << "RR:" << Reverse( Reverse( temp2 ) ) << endl;
00655 cout << "URR:" << UCase( Reverse( Reverse( temp2 ) ) ) << endl;
00656 cout << "LRR:" << LCase( Reverse( Reverse( temp2 ) ) ) << endl;
00657 #endif
00658
00659 assert( temp == temp2 );
00660 assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00661 assert( UCase( temp ) == "{=]HELLOWORLD!ALPHABETA=) =}" );
00662 assert( LCase( temp ) == "{=]helloworld!alphabeta=) =}" );
00663 assert( Reverse( Reverse( temp2 ) ) == temp2 );
00664 assert( UCase( Reverse( Reverse( temp2 ) ) ) == "{=]HELLOWORLD!ALPHABETA=) =}" );
00665 assert( LCase( Reverse( Reverse( temp2 ) ) ) == "{=]helloworld!alphabeta=) =}" );
00666
00667 assert( temp == temp2 );
00668 assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00669 assert( temp.setUpper() == "{=]HELLOWORLD!ALPHABETA=) =}" );
00670 assert( temp.setLower() == "{=]helloworld!alphabeta=) =}" );
00671
00672 temp = temp2;
00673 assert( temp == temp2 );
00674 assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00675 assert( temp.setReverse().setReverse() == temp2 );
00676 assert( temp.setUpper().setReverse().setReverse() == "{=]HELLOWORLD!ALPHABETA=) =}" );
00677 assert( temp.setLower().setReverse().setReverse() == "{=]helloworld!alphabeta=) =}" );
00678
00679 temp = temp2;
00680 assert( temp == temp2 );
00681 assert( !strcmp(temp.getUpper(), "{=]HELLOWORLD!ALPHABETA=) =}" ));
00682 assert( !strcmp(temp.getLower(), "{=]helloworld!alphabeta=) =}" ));
00683
00684 temp = temp2;
00685 assert( temp == temp2 );
00686 assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00687 assert( !strcmp(temp.setReverse().getReverse(), temp2.toString() ) );
00688 assert( !strcmp(temp.setReverse().getUpper(), "{=]HELLOWORLD!ALPHABETA=) =}"));
00689 assert( !strcmp(temp.setReverse().setReverse().getLower(), "{=]helloworld!alphabeta=) =}"));
00690 }
00691
00692 void qbtools() {
00693
00694
00695
00696
00697 cout << "QB Tools:\n";
00698
00699
00700
00701 temp = LCase( temp2 );
00702 assert( temp2 == "{=]HelloWorld!AlphaBeta=) =}" );
00703 assert( temp.Find( 'w' ) == 8 );
00704 assert( Reverse( temp ).Find( 'w' ) == 19 );
00705 assert( UCase( Reverse( temp ) ).Find( 'w' ) == -1 );
00706 assert( UCase( Reverse( temp ) ).Find( 'W' ) == 19 );
00707 assert( UCase( Reverse( temp ) ).ReverseFind( 'W' ) == 8 );
00708
00709 assert( temp.Find( "hello" ) == 3 );
00710 assert( temp.Find( "hello", 3 ) == 0 );
00711
00712 assert( temp.Find( 'w' ) == 8 );
00713 assert( temp.setReverse().Find( 'w' ) == 19 );
00714
00715 temp = temp2;
00716 assert( temp.setReverse().setUpper().Find( 'w' ) == -1 );
00717
00718 temp = temp2;
00719 assert( temp.setReverse().setUpper().Find( 'W' ) == 19 );
00720
00721 temp = temp2;
00722 assert( temp.setReverse().setUpper().ReverseFind( 'W' ) == 8 );
00723
00724 temp = temp2;
00725 assert( temp.setReverse().setReverse().Find( "Hello" ) == 3 );
00726 assert( temp.setReverse().setReverse().Find( "Hello", 3 ) == 0 );
00727 }
00728
00729 void atX() {
00730
00731
00732
00733
00734
00735 cout << "AtX()\n";
00736
00737 s4d = "World";
00738
00739 assert( s4d == "World" );
00740
00741
00742 s1a = temp.at( temp.setReverse().Find( s4d.getReverse() ) ).setReverse();
00743 assert( s1a == "{=]HelloWorld" );
00744
00745 s1b = s1a.at( s1a.Find( s4d ) );
00746 assert( s1b.at() == "World" );
00747
00748 temp.setReverse();
00749 assert( temp == temp2 );
00750
00751 long start = temp.Find( s4d );
00752 long len = s4d.length();
00753
00754 assert( start == 8 );
00755 assert( len == 5 );
00756
00757 JString atxy = temp.at( start, len );
00758
00759 assert( atxy == s4d );
00760 assert( temp.at( temp.Find( s4d ), s4d.length() ) == s4d );
00761
00762 atxy = temp.at( temp.Find( s4d ), s4d.length() ).setReverse();
00763
00764 cout << s4d.getReverse() << endl;
00765 displayTemp();
00766
00767 assert( atxy == s4d.getReverse() );
00768 assert( temp.at( temp.Find( s4d ), s4d.length() ).setReverse() == s4d.getReverse() );
00769
00770 temp = temp2;
00771
00772 s4d = "World";
00773
00774 assert( s4d == "World" );
00775
00776
00777
00778
00779
00780 s1a = temp( temp.setReverse().Find( s4d.getReverse() ) ).setReverse();
00781 assert( s1a == "{=]HelloWorld" );
00782
00783 s1b = s1a( s1a.Find( s4d ) );
00784 assert( s1b.at() == "World" );
00785
00786 temp.setReverse();
00787 assert( temp == temp2 );
00788
00789 assert( temp( temp.Find( s4d ), s4d.length() ) == s4d );
00790 assert( temp( temp.Find( s4d ), s4d.length() ).setReverse() == s4d.getReverse() );
00791
00792 assert( temp.at( s4d.getText(), 0 ).left(5) == s4d );
00793
00794 assert( temp.at( s4d, 0 ).left(5).right(2) == "ld" );
00795 assert( temp.mid( s4d, 0, 5 ).right( 2 ) == "ld" );
00796
00797 cout << temp.at( s4d.getText(), 0 ).left(5) << "]\n";
00798 cout << "\n[" << temp( s4d.getText(), 0 ) << "]\n";
00799
00800
00801
00802 s1a = temp.setAt( temp.Find( s4d ), 'w' );
00803 assert( s1a.at( s4d.setLower(), 0 ).left(5) == LCase( s4d ) );
00804
00805 }
00806
00807 void ansi() {
00808
00809
00810
00811
00812 cout << temp << endl;
00813 cout << temp.firstCharFound( 'l' ) << endl;
00814 cout << temp.lastCharFound( 'l' ) << endl;
00815
00816 assert( temp[ temp.firstCharFound( 'l' ) ] == 'l' );
00817 assert( temp[ temp.lastCharFound( 'l' ) ] == 'l' );
00818
00819 assert( temp.getAt( temp.firstCharFound( 'l' ) ) == 'l' );
00820 assert( temp.getAt( temp.lastCharFound( 'l' ) ) == 'l' );
00821
00822 assert( temp.firstCharFound( 'l' ) == 5 );
00823 assert( temp.lastCharFound( 'l' ) == 15 );
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911 JString SpanIncluding(const char* s) const;
00912 JString SpanExcluding(const char* s) const;
00913
00914
00915
00916
00917 // simple formatting
00918 void Format(const char* s Format, ...);
00919 void Format(size_t nFormatID, ...);
00920 void FormatV(const char* lpszFormat, va_list argList);
00921
00922 *************************************************************************
00923
00924 */
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944 }
00945
00946 int main()
00947 {
00948 debug();
00949 init();
00950 fill();
00951
00952 display();
00953 displayTemp();
00954
00955 length();
00956 lock();
00957 comp();
00958 parse();
00959 assign();
00960 concat();
00961 add();
00962 tools();
00963 qbtools();
00964 atX();
00965
00966 ansi();
00967
00968 cout << "Done! \n";
00969
00970 return 0;
00971 }