libsheepyCSmallStringCuTest.c (421210B)
1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <string.h> 4 5 #include "CuTest/CuTest.h" 6 7 #define ck_assert_str_eq(a,b) CuAssertStrEquals(tc, b, a) 8 #define ck_assert_str_ne(a,b) CuAssertStrNotEquals(tc, b, a) 9 #define ck_assert_ptr_eq(a,b) CuAssertPtrEquals(tc, b, a) 10 #define ck_assert_ptr_ne(a,b) CuAssertPtrNotEquals(tc, b, a) 11 #define ck_assert_uint_eq(a,b) CuAssertUintEquals(tc, b, a) 12 #define ck_assert_uint_ne(a,b) CuAssertUintNotEquals(tc, b, a) 13 #define ck_assert_int_eq(a,b) CuAssertIntEquals(tc, b, a) 14 #define ck_assert_int_ne(a,b) CuAssertIntNotEquals(tc, b, a) 15 #define ck_assert(a) CuAssertTrue(tc, a) 16 17 18 #include "../libsheepy.h" 19 #include "../libsheepyObject.h" 20 21 #ifdef __GNUC__ 22 #define UNUSED __attribute__ ((unused)) 23 #else 24 #define UNUSED 25 #endif 26 27 // TODO redirect stderr 28 29 30 void initiateSmallStringT(CuTest *tc UNUSED) { 31 32 smallStringt self; 33 34 initiateSmallString(&self); 35 36 } 37 38 39 void initiateAllocateSmallStringT(CuTest *tc UNUSED) { 40 41 smallStringt *self = null; 42 43 initiateAllocateSmallString(&self); 44 terminateO(self); 45 46 } 47 48 49 void allocSmallStringT(CuTest *tc UNUSED) { 50 51 smallStringt* r; 52 53 r = allocSmallString("qwe"); 54 ck_assert_ptr_ne(r, null); 55 char *s = toStringO(r); 56 ck_assert_str_eq(s, "qwe"); 57 free(s); 58 terminateO(r); 59 60 } 61 62 63 void createSFT(CuTest *tc UNUSED) { 64 65 smallStringt* r; 66 67 r = createS("qwe", "123", "!@#"); 68 ck_assert_ptr_ne(r, null); 69 char *s = toStringO(r); 70 ck_assert_str_eq(s, "qwe123!@#"); 71 free(s); 72 terminateO(r); 73 74 75 } 76 77 78 void freeSmallStringT(CuTest *tc UNUSED) { 79 80 smallStringt *self = allocG("qwe"); 81 82 freeO(self); 83 ck_assert_ptr_eq(toStringO(self), null); 84 terminateO(self); 85 86 } 87 88 89 void terminateSmallStringT(CuTest *tc UNUSED) { 90 91 smallStringt *self = allocG(""); 92 93 terminateO(self); 94 ck_assert_ptr_eq(self, null); 95 96 } 97 98 99 void toStringSmallStringT(CuTest *tc UNUSED) { 100 101 char* r; 102 smallStringt *self = allocG("qwe"); 103 104 r = toStringO(self); 105 ck_assert_str_eq(r, "qwe"); 106 free(r); 107 freeO(self); 108 ck_assert_ptr_eq(toStringO(self), null); 109 terminateO(self); 110 111 } 112 113 114 void duplicateSmallStringT(CuTest *tc UNUSED) { 115 116 smallStringt* r; 117 smallStringt *self = allocG("qwe"); 118 119 r = duplicateO(self); 120 ck_assert_ptr_ne(r, null); 121 char *s = toStringO(r); 122 ck_assert_str_eq(s, "qwe"); 123 free(s); 124 terminateO(r); 125 // empty object 126 freeO(self); 127 r = duplicateO(self); 128 ck_assert_ptr_ne(r, null); 129 ck_assert_ptr_eq(toStringO(r), null); 130 terminateO(r); 131 terminateO(self); 132 133 } 134 135 136 void smashSmallStringT(CuTest *tc UNUSED) { 137 138 smallStringt *self = allocG(""); 139 140 freeO(self); 141 smashO(self); 142 143 } 144 145 146 void finishSmallStringT(CuTest *tc UNUSED) { 147 148 smallStringt *self = allocG(""); 149 150 freeO(self); 151 finishO(self); 152 153 } 154 155 156 void getSmallStringT(CuTest *tc UNUSED) { 157 158 char* r; 159 smallStringt *self = allocG(""); 160 161 r = getValO(self); 162 ck_assert_ptr_ne(r, null); 163 ck_assert_str_eq(r, ""); 164 // empty object 165 freeO(self); 166 r = getValO(self); 167 ck_assert_ptr_eq(r, null); 168 terminateO(self); 169 170 } 171 172 173 void setSmallStringT(CuTest *tc UNUSED) { 174 175 smallStringt* r; 176 smallStringt *self = allocG(""); 177 178 r = setValO(self, "qwe"); 179 ck_assert_ptr_ne(r, null); 180 char *s = toStringO(r); 181 ck_assert_str_eq(s, "qwe"); 182 free(s); 183 // null 184 r = setValO(self, null); 185 ck_assert_ptr_eq(r, null); 186 terminateO(self); 187 188 } 189 190 191 void setCharSmallStringT(CuTest *tc UNUSED) { 192 193 smallStringt* r; 194 smallStringt *self = allocG(""); 195 196 r = self->f->setChar(self, 'q'); 197 ck_assert_ptr_ne(r, null); 198 char *s = toStringO(r); 199 ck_assert_str_eq(s, "q"); 200 free(s); 201 terminateO(self); 202 203 } 204 205 206 void setBoolSmallStringT(CuTest *tc UNUSED) { 207 208 smallStringt* r; 209 smallStringt* self = allocG(""); 210 211 r = self->f->setBool(self, false); 212 ck_assert_ptr_ne(r, null); 213 char *s = toStringO(r); 214 ck_assert_str_eq(s, "false"); 215 free(s); 216 r = self->f->setBool(self, true); 217 ck_assert_ptr_ne(r, null); 218 s = toStringO(r); 219 ck_assert_str_eq(s, "true"); 220 free(s); 221 terminateO(self); 222 223 } 224 225 226 void setDoubleSmallStringT(CuTest *tc UNUSED) { 227 228 smallStringt* r; 229 smallStringt* self = allocG(""); 230 231 r = self->f->setDouble(self, 2.2); 232 ck_assert_ptr_ne(r, null); 233 char *s = toStringO(r); 234 ck_assert_str_eq(s, "2.200000e+00"); 235 free(s); 236 terminateO(self); 237 238 } 239 240 241 void setInt64SmallStringT(CuTest *tc UNUSED) { 242 243 smallStringt* r; 244 smallStringt* self = allocG(""); 245 246 r = self->f->setInt64(self, 2); 247 ck_assert_ptr_ne(r, null); 248 char *s = toStringO(r); 249 ck_assert_str_eq(s, "2"); 250 free(s); 251 terminateO(self); 252 253 } 254 255 256 void setInt32SmallStringT(CuTest *tc UNUSED) { 257 258 smallStringt* r; 259 smallStringt* self = allocG(""); 260 261 r = self->f->setInt32(self, 2); 262 ck_assert_ptr_ne(r, null); 263 char *s = toStringO(r); 264 ck_assert_str_eq(s, "2"); 265 free(s); 266 terminateO(self); 267 268 } 269 270 271 void setUint32SmallStringT(CuTest *tc UNUSED) { 272 273 smallStringt* r; 274 smallStringt* self = allocG(""); 275 276 r = self->f->setUint32(self, 2); 277 ck_assert_ptr_ne(r, null); 278 char *s = toStringO(r); 279 ck_assert_str_eq(s, "2"); 280 free(s); 281 terminateO(self); 282 283 } 284 285 286 void setUint64SmallStringT(CuTest *tc UNUSED) { 287 288 smallStringt* r; 289 smallStringt* self = allocG(""); 290 291 r = self->f->setUint64(self, 2); 292 ck_assert_ptr_ne(r, null); 293 char *s = toStringO(r); 294 ck_assert_str_eq(s, "2"); 295 free(s); 296 terminateO(self); 297 298 } 299 300 301 void setSmallArraySmallStringT(CuTest *tc UNUSED) { 302 303 smallStringt* r; 304 smallStringt* self = allocG(""); 305 smallArrayt* p2 = allocSmallArray(); 306 307 p2->f->pushS(p2, "asd"); 308 r = self->f->setSmallArray(self, p2); 309 ck_assert_ptr_ne(r, null); 310 char *s = toStringO(r); 311 ck_assert_str_eq(s, "[\"asd\"]"); 312 free(s); 313 terminateO(p2); 314 // not smallArray object 315 p2 = (smallArrayt*) allocSmallInt(1); 316 r = self->f->setSmallArray(self, p2); 317 ck_assert_ptr_eq(r, null); 318 terminateO(p2); 319 // null parameter 320 r = self->f->setSmallArray(self, null); 321 ck_assert_ptr_eq(r, null); 322 terminateO(self); 323 324 } 325 326 327 void setFromSmallDictSmallStringT(CuTest *tc UNUSED) { 328 329 smallStringt* r; 330 smallStringt* self = allocG(""); 331 smallDictt* p2 = allocSmallDict(); 332 333 p2->f->setS(p2, "1", "asd"); 334 r = self->f->setFromSmallDict(self, p2); 335 ck_assert_ptr_ne(r, null); 336 char *s = toStringO(r); 337 ck_assert_str_eq(s, "{\"1\":\"asd\"}"); 338 free(s); 339 terminateO(p2); 340 // not smallDict object 341 p2 = (smallDictt*) allocSmallInt(1); 342 r = self->f->setFromSmallDict(self, p2); 343 ck_assert_ptr_eq(r, null); 344 terminateO(p2); 345 // null parameter 346 r = self->f->setFromSmallDict(self, null); 347 ck_assert_ptr_eq(r, null); 348 terminateO(self); 349 350 } 351 352 353 void setFromSmallJsonSmallStringT(CuTest *tc UNUSED) { 354 355 smallStringt* r; 356 smallStringt* self = allocG(""); 357 smallJsont* p2 = allocSmallJson(); 358 359 p2->f->setS(p2, "1", "asd"); 360 r = self->f->setFromSmallJson(self, p2); 361 ck_assert_ptr_ne(r, null); 362 char *s = toStringO(r); 363 ck_assert_str_eq(s, "{\"1\":\"asd\"}"); 364 free(s); 365 terminateO(p2); 366 // not smallJson object 367 p2 = (smallJsont*) allocSmallInt(1); 368 r = self->f->setFromSmallJson(self, p2); 369 ck_assert_ptr_eq(r, null); 370 terminateO(p2); 371 // null parameter 372 r = self->f->setFromSmallJson(self, null); 373 ck_assert_ptr_eq(r, null); 374 terminateO(self); 375 376 } 377 378 379 void setSmallBoolSmallStringT(CuTest *tc UNUSED) { 380 381 smallStringt* r; 382 smallStringt* self = allocG(""); 383 smallBoolt* p2 = allocSmallBool(true); 384 385 r = self->f->setSmallBool(self, p2); 386 ck_assert_ptr_ne(r, null); 387 char *s = toStringO(r); 388 ck_assert_str_eq(s, "true"); 389 free(s); 390 terminateO(p2); 391 // not smallBool object 392 p2 = (smallBoolt*) allocSmallInt(1); 393 r = self->f->setSmallBool(self, p2); 394 ck_assert_ptr_eq(r, null); 395 terminateO(p2); 396 // null parameter 397 r = self->f->setSmallBool(self, null); 398 ck_assert_ptr_eq(r, null); 399 terminateO(self); 400 401 } 402 403 404 void setSmallDoubleSmallStringT(CuTest *tc UNUSED) { 405 406 smallStringt* r; 407 smallStringt* self = allocG(""); 408 smallDoublet* p2 = allocSmallDouble(2.2); 409 410 r = self->f->setSmallDouble(self, p2); 411 ck_assert_ptr_ne(r, null); 412 char *s = toStringO(r); 413 ck_assert_str_eq(s, "2.200000e+00"); 414 free(s); 415 terminateO(p2); 416 // not smallDouble object 417 p2 = (smallDoublet*) allocSmallInt(1); 418 r = self->f->setSmallDouble(self, p2); 419 ck_assert_ptr_eq(r, null); 420 terminateO(p2); 421 // null parameter 422 r = self->f->setSmallDouble(self, null); 423 ck_assert_ptr_eq(r, null); 424 terminateO(self); 425 426 } 427 428 429 void setSmallIntSmallStringT(CuTest *tc UNUSED) { 430 431 smallStringt* r; 432 smallStringt* self = allocG(""); 433 smallIntt* p2 = allocSmallInt(2); 434 435 r = self->f->setSmallInt(self, p2); 436 ck_assert_ptr_ne(r, null); 437 char *s = toStringO(r); 438 ck_assert_str_eq(s, "2"); 439 free(s); 440 terminateO(p2); 441 // not smallInt object 442 p2 = (smallIntt*) allocSmallJson(); 443 r = self->f->setSmallInt(self, p2); 444 ck_assert_ptr_eq(r, null); 445 terminateO(p2); 446 // null parameter 447 r = self->f->setSmallInt(self, null); 448 ck_assert_ptr_eq(r, null); 449 terminateO(self); 450 451 } 452 453 454 void setSmallJsonSmallStringT(CuTest *tc UNUSED) { 455 456 smallStringt* r; 457 smallStringt* self = allocG("qwe"); 458 smallJsont* p2 = allocSmallJson(); 459 460 // undefined 461 createUndefined(u); 462 setTopO(p2, (baset*)&u); 463 r = self->f->setSmallJson(self, p2); 464 ck_assert_ptr_ne(r, null); 465 char *s = toStringO(r); 466 ck_assert_str_eq(s, "qwe"); 467 free(s); 468 freeO(p2); 469 // bool 470 setTopBoolO(p2, true); 471 r = self->f->setSmallJson(self, p2); 472 ck_assert_ptr_ne(r, null); 473 s = toStringO(r); 474 ck_assert_str_eq(s, "true"); 475 free(s); 476 freeO(p2); 477 // double 478 setTopDoubleO(p2, 2.2); 479 r = self->f->setSmallJson(self, p2); 480 ck_assert_ptr_ne(r, null); 481 s = toStringO(r); 482 ck_assert_str_eq(s, "2.200000e+00"); 483 free(s); 484 freeO(p2); 485 // int 486 setTopIntO(p2, 2); 487 r = self->f->setSmallJson(self, p2); 488 ck_assert_ptr_ne(r, null); 489 s = toStringO(r); 490 ck_assert_str_eq(s, "2"); 491 free(s); 492 freeO(p2); 493 // string 494 setTopStringO(p2, "qwe"); 495 r = self->f->setSmallJson(self, p2); 496 ck_assert_ptr_ne(r, null); 497 s = toStringO(r); 498 ck_assert_str_eq(s, "qwe"); 499 free(s); 500 freeO(p2); 501 // dict 502 createSmallDict(d); 503 setTopDictO(p2, &d); 504 r = self->f->setSmallJson(self, p2); 505 ck_assert_ptr_ne(r, null); 506 s = toStringO(r); 507 ck_assert_str_eq(s, "{}"); 508 free(s); 509 freeO(p2); 510 // array 511 createSmallArray(a); 512 setTopArrayO(p2, &a); 513 r = self->f->setSmallJson(self, p2); 514 ck_assert_ptr_ne(r, null); 515 s = toStringO(r); 516 ck_assert_str_eq(s, "[]"); 517 free(s); 518 freeO(p2); 519 // empty p2 object 520 r = self->f->setSmallJson(self, p2); 521 ck_assert_ptr_ne(r, null); 522 s = toStringO(r); 523 ck_assert_str_eq(s, "[]"); 524 free(s); 525 finishO(p2); 526 // not smallJson object 527 p2 = (smallJsont*) allocSmallInt(1); 528 r = self->f->setSmallJson(self, p2); 529 ck_assert_ptr_eq(r, null); 530 terminateO(p2); 531 // null parameter 532 r = self->f->setSmallJson(self, null); 533 ck_assert_ptr_eq(r, null); 534 terminateO(self); 535 536 } 537 538 539 void setSmallStringSmallStringT(CuTest *tc UNUSED) { 540 541 smallStringt* r; 542 smallStringt* self = allocG(""); 543 smallStringt* p2 = allocSmallString("qwe"); 544 545 r = self->f->setSmallString(self, p2); 546 ck_assert_ptr_ne(r, null); 547 char *s = toStringO(r); 548 ck_assert_str_eq(s, "qwe"); 549 free(s); 550 terminateO(p2); 551 // not smallString object 552 p2 = (smallStringt*) allocSmallInt(1); 553 r = self->f->setSmallString(self, p2); 554 ck_assert_ptr_eq(r, null); 555 terminateO(p2); 556 // null parameter 557 r = self->f->setSmallString(self, null); 558 ck_assert_ptr_eq(r, null); 559 terminateO(self); 560 561 } 562 563 564 void setNFreeSmallStringT(CuTest *tc UNUSED) { 565 566 smallStringt* r; 567 smallStringt *self = allocG(""); 568 569 r = self->f->setNFree(self, strdup("qwe")); 570 ck_assert_ptr_ne(r, null); 571 char *s = toStringO(r); 572 ck_assert_str_eq(s, "qwe"); 573 free(s); 574 // null parameter 575 r = self->f->setNFree(self, null); 576 ck_assert_ptr_eq(r, null); 577 terminateO(self); 578 579 } 580 581 582 void appendSmallStringT(CuTest *tc UNUSED) { 583 584 smallStringt* r; 585 smallStringt *self = allocG("qwe"); 586 smallStringt *string = allocSmallString("!@#"); 587 588 r = appendO(self, string); 589 ck_assert_ptr_ne(r, null); 590 char *s = toStringO(r); 591 ck_assert_str_eq(s, "qwe!@#"); 592 free(s); 593 // empty string 594 setValO(string, ""); 595 r = appendO(self, string); 596 ck_assert_ptr_ne(r, null); 597 s = toStringO(r); 598 ck_assert_str_eq(s, "qwe!@#"); 599 free(s); 600 freeO(string); 601 r = appendO(self, string); 602 ck_assert_ptr_ne(r, null); 603 s = toStringO(r); 604 ck_assert_str_eq(s, "qwe!@#"); 605 free(s); 606 // empty self 607 freeO(self); 608 setValO(string, "asd"); 609 r = appendO(self, string); 610 ck_assert_ptr_ne(r, null); 611 s = toStringO(r); 612 ck_assert_str_eq(s, "asd"); 613 free(s); 614 terminateO(string); 615 // not smallString object 616 string = (smallStringt*) allocSmallInt(1); 617 r = appendO(self, string); 618 ck_assert_ptr_eq(r, null); 619 terminateO(string); 620 // null parameter 621 r = appendO(self, null); 622 ck_assert_ptr_eq(r, null); 623 terminateO(self); 624 625 } 626 627 628 void appendSmallJsonSmallStringT(CuTest *tc UNUSED) { 629 630 smallStringt* r; 631 smallStringt *self = allocG("qwe"); 632 smallJsont *string = allocSmallJson(); 633 634 setTopSO(string, "!@#"); 635 r = self->f->appendSmallJson(self, string); 636 ck_assert_ptr_ne(r, null); 637 char *s = toStringO(r); 638 ck_assert_str_eq(s, "qwe!@#"); 639 free(s); 640 // empty string 641 freeO(string); 642 setTopSO(string, ""); 643 r = self->f->appendSmallJson(self, string); 644 ck_assert_ptr_ne(r, null); 645 s = toStringO(r); 646 ck_assert_str_eq(s, "qwe!@#"); 647 free(s); 648 // not json string 649 freeO(string); 650 setTopBoolO(string, true); 651 r = self->f->appendSmallJson(self, string); 652 ck_assert_ptr_eq(r, null); 653 terminateO(string); 654 // not smallString object 655 string = (smallJsont*) allocSmallInt(1); 656 r = self->f->appendSmallJson(self, string); 657 ck_assert_ptr_eq(r, null); 658 terminateO(string); 659 // null parameter 660 r = self->f->appendSmallJson(self, null); 661 ck_assert_ptr_eq(r, null); 662 terminateO(self); 663 664 } 665 666 667 void appendNSmashSmallStringT(CuTest *tc UNUSED) { 668 669 smallStringt* r; 670 smallStringt *self = allocG("qwe"); 671 smallStringt *string = allocSmallString("!@#"); 672 673 r = appendNSmashO(self, string); 674 ck_assert_ptr_ne(r, null); 675 char *s = toStringO(r); 676 ck_assert_str_eq(s, "qwe!@#"); 677 free(s); 678 // empty string 679 string = allocSmallString(""); 680 r = appendNSmashO(self, string); 681 ck_assert_ptr_ne(r, null); 682 s = toStringO(r); 683 ck_assert_str_eq(s, "qwe!@#"); 684 free(s); 685 string = allocSmallString(""); 686 freeO(string); 687 r = appendNSmashO(self, string); 688 ck_assert_ptr_ne(r, null); 689 s = toStringO(r); 690 ck_assert_str_eq(s, "qwe!@#"); 691 free(s); 692 // empty self 693 freeO(self); 694 string = allocSmallString("asd"); 695 r = appendNSmashO(self, string); 696 ck_assert_ptr_ne(r, null); 697 s = toStringO(r); 698 ck_assert_str_eq(s, "asd"); 699 free(s); 700 // not smallString object 701 string = (smallStringt*) allocSmallInt(1); 702 r = appendNSmashO(self, string); 703 ck_assert_ptr_eq(r, null); 704 terminateO(string); 705 // null parameter 706 r = appendNSmashO(self, null); 707 ck_assert_ptr_eq(r, null); 708 terminateO(self); 709 710 } 711 712 713 void appendSSmallStringT(CuTest *tc UNUSED) { 714 715 smallStringt* r; 716 smallStringt *self = allocG("qwe"); 717 718 r = self->f->appendS(self, "!@#"); 719 ck_assert_ptr_ne(r, null); 720 char *s = toStringO(r); 721 ck_assert_str_eq(s, "qwe!@#"); 722 free(s); 723 // empty string 724 r = self->f->appendS(self, ""); 725 ck_assert_ptr_ne(r, null); 726 s = toStringO(r); 727 ck_assert_str_eq(s, "qwe!@#"); 728 free(s); 729 // empty self 730 freeO(self); 731 r = self->f->appendS(self, "asd"); 732 ck_assert_ptr_ne(r, null); 733 s = toStringO(r); 734 ck_assert_str_eq(s, "asd"); 735 free(s); 736 // null parameter 737 r = self->f->appendS(self, null); 738 ck_assert_ptr_eq(r, null); 739 terminateO(self); 740 741 } 742 743 744 void appendCharSmallStringT(CuTest *tc UNUSED) { 745 746 smallStringt* r; 747 smallStringt *self = allocG("qwe"); 748 749 r = appendCharO(self, '!'); 750 ck_assert_ptr_ne(r, null); 751 char *s = toStringO(r); 752 ck_assert_str_eq(s, "qwe!"); 753 free(s); 754 terminateO(self); 755 756 } 757 758 759 void appendNSmashSmallJsonSmallStringT(CuTest *tc UNUSED) { 760 761 smallStringt* r; 762 smallStringt *self = allocG("qwe"); 763 smallJsont *string = allocSmallJson(); 764 765 setTopSO(string, "!@#"); 766 r = self->f->appendNSmashSmallJson(self, string); 767 ck_assert_ptr_ne(r, null); 768 char *s = toStringO(r); 769 ck_assert_str_eq(s, "qwe!@#"); 770 free(s); 771 // empty string 772 string = allocSmallJson(); 773 setTopSO(string, ""); 774 r = self->f->appendNSmashSmallJson(self, string); 775 ck_assert_ptr_ne(r, null); 776 s = toStringO(r); 777 ck_assert_str_eq(s, "qwe!@#"); 778 free(s); 779 string = allocSmallJson(); 780 setTypeStringO(string); 781 r = self->f->appendNSmashSmallJson(self, string); 782 ck_assert_ptr_ne(r, null); 783 s = toStringO(r); 784 ck_assert_str_eq(s, "qwe!@#"); 785 free(s); 786 // not json string 787 string = allocSmallJson(); 788 setTopBoolO(string, true); 789 r = self->f->appendNSmashSmallJson(self, string); 790 ck_assert_ptr_eq(r, null); 791 terminateO(string); 792 // not smallString object 793 string = (smallJsont*) allocSmallInt(1); 794 r = self->f->appendNSmashSmallJson(self, string); 795 ck_assert_ptr_eq(r, null); 796 terminateO(string); 797 // null parameter 798 r = self->f->appendNSmashSmallJson(self, null); 799 ck_assert_ptr_eq(r, null); 800 terminateO(self); 801 802 } 803 804 805 void appendNSmashSSmallStringT(CuTest *tc UNUSED) { 806 807 smallStringt* r; 808 smallStringt *self = allocG("qwe"); 809 810 r = appendNSmashSO(self, strdup("!@#")); 811 ck_assert_ptr_ne(r, null); 812 char *s = toStringO(r); 813 ck_assert_str_eq(s, "qwe!@#"); 814 free(s); 815 // empty string 816 r = appendNSmashSO(self, strdup("")); 817 ck_assert_ptr_ne(r, null); 818 s = toStringO(r); 819 ck_assert_str_eq(s, "qwe!@#"); 820 free(s); 821 // empty self 822 freeO(self); 823 r = appendNSmashSO(self, strdup("asd")); 824 ck_assert_ptr_ne(r, null); 825 s = toStringO(r); 826 ck_assert_str_eq(s, "asd"); 827 free(s); 828 // null parameter 829 r = appendNSmashSO(self, null); 830 ck_assert_ptr_eq(r, null); 831 terminateO(self); 832 833 } 834 835 836 void prependSmallStringT(CuTest *tc UNUSED) { 837 838 smallStringt* r; 839 smallStringt *self = allocG("qwe"); 840 smallStringt *string = allocSmallString("!@#"); 841 842 r = prependO(self, string); 843 ck_assert_ptr_ne(r, null); 844 char *s = toStringO(r); 845 ck_assert_str_eq(s, "!@#qwe"); 846 free(s); 847 // empty string 848 setValO(string, ""); 849 r = prependO(self, string); 850 ck_assert_ptr_ne(r, null); 851 s = toStringO(r); 852 ck_assert_str_eq(s, "!@#qwe"); 853 free(s); 854 freeO(string); 855 r = prependO(self, string); 856 ck_assert_ptr_ne(r, null); 857 s = toStringO(r); 858 ck_assert_str_eq(s, "!@#qwe"); 859 free(s); 860 // empty self 861 freeO(self); 862 setValO(string, "asd"); 863 r = prependO(self, string); 864 ck_assert_ptr_ne(r, null); 865 s = toStringO(r); 866 ck_assert_str_eq(s, "asd"); 867 free(s); 868 terminateO(string); 869 // not smallString object 870 string = (smallStringt*) allocSmallInt(1); 871 r = prependO(self, string); 872 ck_assert_ptr_eq(r, null); 873 terminateO(string); 874 // null parameter 875 r = prependO(self, null); 876 ck_assert_ptr_eq(r, null); 877 terminateO(self); 878 879 } 880 881 882 void prependSmallJsonSmallStringT(CuTest *tc UNUSED) { 883 884 smallStringt* r; 885 smallStringt *self = allocG("qwe"); 886 smallJsont *string = allocSmallJson(); 887 888 setTopSO(string, "!@#"); 889 r = self->f->prependSmallJson(self, string); 890 ck_assert_ptr_ne(r, null); 891 char *s = toStringO(r); 892 ck_assert_str_eq(s, "!@#qwe"); 893 free(s); 894 // empty string 895 freeO(string); 896 setTopSO(string, ""); 897 r = self->f->prependSmallJson(self, string); 898 ck_assert_ptr_ne(r, null); 899 s = toStringO(r); 900 ck_assert_str_eq(s, "!@#qwe"); 901 free(s); 902 // not json string 903 freeO(string); 904 setTopBoolO(string, true); 905 r = self->f->prependSmallJson(self, string); 906 ck_assert_ptr_eq(r, null); 907 terminateO(string); 908 // not smallString object 909 string = (smallJsont*) allocSmallInt(1); 910 r = self->f->prependSmallJson(self, string); 911 ck_assert_ptr_eq(r, null); 912 terminateO(string); 913 // null parameter 914 r = self->f->prependSmallJson(self, null); 915 ck_assert_ptr_eq(r, null); 916 terminateO(self); 917 918 } 919 920 921 void prependNSmashSmallStringT(CuTest *tc UNUSED) { 922 923 smallStringt* r; 924 smallStringt *self = allocG("qwe"); 925 smallStringt *string = allocSmallString("!@#"); 926 927 r = prependNSmashO(self, string); 928 ck_assert_ptr_ne(r, null); 929 char *s = toStringO(r); 930 ck_assert_str_eq(s, "!@#qwe"); 931 free(s); 932 // empty string 933 string = allocSmallString(""); 934 r = prependNSmashO(self, string); 935 ck_assert_ptr_ne(r, null); 936 s = toStringO(r); 937 ck_assert_str_eq(s, "!@#qwe"); 938 free(s); 939 string = allocSmallString(""); 940 freeO(string); 941 r = prependNSmashO(self, string); 942 ck_assert_ptr_ne(r, null); 943 s = toStringO(r); 944 ck_assert_str_eq(s, "!@#qwe"); 945 free(s); 946 // empty self 947 freeO(self); 948 string = allocSmallString("asd"); 949 r = prependNSmashO(self, string); 950 ck_assert_ptr_ne(r, null); 951 s = toStringO(r); 952 ck_assert_str_eq(s, "asd"); 953 free(s); 954 // not smallString object 955 string = (smallStringt*) allocSmallInt(1); 956 r = prependNSmashO(self, string); 957 ck_assert_ptr_eq(r, null); 958 terminateO(string); 959 // null parameter 960 r = prependNSmashO(self, null); 961 ck_assert_ptr_eq(r, null); 962 terminateO(self); 963 964 } 965 966 967 void prependNSmashSmallJsonSmallStringT(CuTest *tc UNUSED) { 968 969 smallStringt* r; 970 smallStringt *self = allocG("qwe"); 971 smallJsont *string = allocSmallJson(); 972 973 setTopSO(string, "!@#"); 974 r = prependNSmashSmallJsonO(self, string); 975 ck_assert_ptr_ne(r, null); 976 char *s = toStringO(r); 977 ck_assert_str_eq(s, "!@#qwe"); 978 free(s); 979 // empty string 980 string = allocSmallJson(); 981 setTopSO(string, ""); 982 r = prependNSmashSmallJsonO(self, string); 983 ck_assert_ptr_ne(r, null); 984 s = toStringO(r); 985 ck_assert_str_eq(s, "!@#qwe"); 986 free(s); 987 string = allocSmallJson(); 988 setTypeStringO(string); 989 r = prependNSmashSmallJsonO(self, string); 990 ck_assert_ptr_ne(r, null); 991 s = toStringO(r); 992 ck_assert_str_eq(s, "!@#qwe"); 993 free(s); 994 // not json string 995 string = allocSmallJson(); 996 setTopBoolO(string, true); 997 r = prependNSmashSmallJsonO(self, string); 998 ck_assert_ptr_eq(r, null); 999 terminateO(string); 1000 // not smallString object 1001 string = (smallJsont*) allocSmallInt(1); 1002 r = prependNSmashSmallJsonO(self, string); 1003 ck_assert_ptr_eq(r, null); 1004 terminateO(string); 1005 // null parameter 1006 r = prependNSmashSmallJsonO(self, null); 1007 ck_assert_ptr_eq(r, null); 1008 terminateO(self); 1009 1010 } 1011 1012 1013 void prependSSmallStringT(CuTest *tc UNUSED) { 1014 1015 smallStringt* r; 1016 smallStringt *self = allocG("qwe"); 1017 1018 r = prependSO(self, "!@#"); 1019 ck_assert_ptr_ne(r, null); 1020 char *s = toStringO(r); 1021 ck_assert_str_eq(s, "!@#qwe"); 1022 free(s); 1023 // empty string 1024 r = prependSO(self, ""); 1025 ck_assert_ptr_ne(r, null); 1026 s = toStringO(r); 1027 ck_assert_str_eq(s, "!@#qwe"); 1028 free(s); 1029 // empty self 1030 freeO(self); 1031 r = prependSO(self, "asd"); 1032 ck_assert_ptr_ne(r, null); 1033 s = toStringO(r); 1034 ck_assert_str_eq(s, "asd"); 1035 free(s); 1036 // null parameter 1037 r = prependSO(self, null); 1038 ck_assert_ptr_eq(r, null); 1039 terminateO(self); 1040 1041 } 1042 1043 1044 void prependCharSmallStringT(CuTest *tc UNUSED) { 1045 1046 smallStringt* r; 1047 smallStringt *self = allocG("qwe"); 1048 1049 r = prependCharO(self, '!'); 1050 ck_assert_ptr_ne(r, null); 1051 char *s = toStringO(r); 1052 ck_assert_str_eq(s, "!qwe"); 1053 free(s); 1054 terminateO(self); 1055 1056 } 1057 1058 1059 void prependNSmashSSmallStringT(CuTest *tc UNUSED) { 1060 1061 smallStringt* r; 1062 smallStringt *self = allocG("qwe"); 1063 1064 r = prependNSmashSO(self, strdup("!@#")); 1065 ck_assert_ptr_ne(r, null); 1066 char *s = toStringO(r); 1067 ck_assert_str_eq(s, "!@#qwe"); 1068 free(s); 1069 // empty string 1070 r = prependNSmashSO(self, strdup("")); 1071 ck_assert_ptr_ne(r, null); 1072 s = toStringO(r); 1073 ck_assert_str_eq(s, "!@#qwe"); 1074 free(s); 1075 // empty self 1076 freeO(self); 1077 r = prependNSmashSO(self, strdup("asd")); 1078 ck_assert_ptr_ne(r, null); 1079 s = toStringO(r); 1080 ck_assert_str_eq(s, "asd"); 1081 free(s); 1082 // null parameter 1083 r = prependNSmashSO(self, null); 1084 ck_assert_ptr_eq(r, null); 1085 terminateO(self); 1086 1087 } 1088 1089 1090 void catSmallStringT(CuTest *tc UNUSED) { 1091 1092 smallStringt* r; 1093 smallStringt *self = allocG("qwe"); 1094 1095 smallStringt *s1 = allocSmallString("123"); 1096 smallStringt *s2 = allocSmallString("456"); 1097 r = catO(self, s1, s2); 1098 ck_assert_ptr_ne(r, null); 1099 char *s = toStringO(r); 1100 ck_assert_str_eq(s, "qwe123456"); 1101 free(s); 1102 // non smallString object 1103 terminateO(s2); 1104 s2 = (smallStringt*) allocSmallInt(1); 1105 r = catO(self, s1, s2); 1106 ck_assert_ptr_eq(r, null); 1107 s = toStringO(self); 1108 ck_assert_str_eq(s, "qwe123456"); 1109 free(s); 1110 terminateO(s1); 1111 terminateO(s2); 1112 terminateO(self); 1113 1114 } 1115 1116 1117 void catSSmallStringT(CuTest *tc UNUSED) { 1118 1119 smallStringt* r; 1120 smallStringt *self = allocG("qwe"); 1121 1122 r = catSO(self, "123", "456"); 1123 ck_assert_ptr_ne(r, null); 1124 char *s = toStringO(r); 1125 ck_assert_str_eq(s, "qwe123456"); 1126 free(s); 1127 terminateO(self); 1128 1129 } 1130 1131 1132 void pushNFreeManySmallStringT(CuTest *tc UNUSED) { 1133 1134 smallStringt* r; 1135 smallStringt *self = allocG("qwe"); 1136 1137 smallStringt *s1 = allocSmallString("123"); 1138 smallStringt *s2 = allocSmallString("456"); 1139 r = pushNFreeManyO(self, s1, s2); 1140 ck_assert_ptr_ne(r, null); 1141 char *s = toStringO(r); 1142 ck_assert_str_eq(s, "qwe123456"); 1143 free(s); 1144 // non smallString object 1145 s1 = allocSmallString("123"); 1146 s2 = (smallStringt*) allocSmallInt(1); 1147 r = pushNFreeManyO(self, s1, s2); 1148 ck_assert_ptr_eq(r, null); 1149 s = toStringO(self); 1150 ck_assert_str_eq(s, "qwe123456"); 1151 free(s); 1152 terminateO(s2); 1153 terminateO(self); 1154 1155 } 1156 1157 1158 void pushNFreeManySSmallStringT(CuTest *tc UNUSED) { 1159 1160 smallStringt* r; 1161 smallStringt *self = allocG("qwe"); 1162 1163 r = pushNFreeManySO(self, strdup("123"), strdup("456")); 1164 ck_assert_ptr_ne(r, null); 1165 char *s = toStringO(r); 1166 ck_assert_str_eq(s, "qwe123456"); 1167 free(s); 1168 terminateO(self); 1169 1170 } 1171 1172 1173 void replaceSmallStringT(CuTest *tc UNUSED) { 1174 1175 smallStringt* r; 1176 smallStringt *self = allocG("#ee#ee#ad"); 1177 1178 // replace string, multiple character new delimeter 1179 r = replaceO(self, "#","^^", 0); 1180 ck_assert_ptr_ne(r, null); 1181 char *s = toStringO(r); 1182 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1183 free(s); 1184 // replace string, multiple character old delimeter 1185 setValO(self, "AA##ee##ee#"); 1186 r = replaceO(self, "##","|", 0); 1187 ck_assert_ptr_ne(r, null); 1188 s = toStringO(r); 1189 ck_assert_str_eq(s, "AA|ee|ee#"); 1190 free(s); 1191 // replace one time at the start of string 1192 setValO(self, "#ee#ee#ad"); 1193 r = replaceO(self, "#","^^",1); 1194 ck_assert_ptr_ne(r, null); 1195 s = toStringO(r); 1196 ck_assert_str_eq(s, "^^ee#ee#ad"); 1197 free(s); 1198 // replace one time 1199 setValO(self, "AA##ee##ee#"); 1200 r = replaceO(self, "##","|",1); 1201 ck_assert_ptr_ne(r, null); 1202 s = toStringO(r); 1203 ck_assert_str_eq(s, "AA|ee##ee#"); 1204 free(s); 1205 // NULL new delimiter, one time: same as empty delimiter 1206 setValO(self, "AA##ee##ee#"); 1207 r = replaceO(self, "##",NULL,1); 1208 ck_assert_ptr_ne(r, null); 1209 s = toStringO(r); 1210 ck_assert_str_eq(s, "AAee##ee#"); 1211 free(s); 1212 // empty string 1213 setValO(self, ""); 1214 r = replaceO(self, "##",NULL,1); 1215 ck_assert_ptr_ne(r, null); 1216 s = toStringO(r); 1217 ck_assert_str_eq(s, ""); 1218 free(s); 1219 // empty old delimiter 1220 setValO(self, "qwe"); 1221 ck_assert_ptr_eq(replaceO(self, "","|",1), NULL); 1222 // NULL old delimiter 1223 ck_assert_ptr_eq(replaceO(self, NULL,"|",1), NULL); 1224 // empty old delimiter 1225 ck_assert_ptr_eq(replaceO(self, "","|",1), NULL); 1226 // NULL string 1227 freeO(self); 1228 ck_assert_ptr_eq(replaceO(self, "##","|",1), NULL); 1229 terminateO(self); 1230 1231 } 1232 1233 1234 void replaceCharSSmallStringT(CuTest *tc UNUSED) { 1235 1236 smallStringt* r; 1237 smallStringt *self = allocG(""); 1238 1239 // replace string, multiple character new delimeter 1240 setValO(self, "#ee#ee#ad"); 1241 r = replaceCharSO(self, '#',"^^", 0); 1242 ck_assert_ptr_ne(r, null); 1243 char *s = toStringO(r); 1244 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1245 free(s); 1246 // replace one time at the start of string 1247 setValO(self, "#ee#ee#ad"); 1248 r = replaceCharSO(self, '#',"^^",1); 1249 ck_assert_ptr_ne(r, null); 1250 s = toStringO(r); 1251 ck_assert_str_eq(s, "^^ee#ee#ad"); 1252 free(s); 1253 // replace one time 1254 setValO(self, "AA##ee##ee#"); 1255 r = replaceCharSO(self, '#',"|",1); 1256 ck_assert_ptr_ne(r, null); 1257 s = toStringO(r); 1258 ck_assert_str_eq(s, "AA|#ee##ee#"); 1259 free(s); 1260 // NULL new delimiter, one time: same as empty delimiter 1261 setValO(self, "AA#ee##ee#"); 1262 r = replaceCharSO(self, '#',NULL,1); 1263 ck_assert_ptr_ne(r, null); 1264 s = toStringO(r); 1265 ck_assert_str_eq(s, "AAee##ee#"); 1266 free(s); 1267 // empty string 1268 setValO(self, ""); 1269 r = replaceCharSO(self, '#',NULL,1); 1270 ck_assert_ptr_ne(r, null); 1271 s = toStringO(r); 1272 ck_assert_str_eq(s, ""); 1273 free(s); 1274 // empty old delimiter 1275 setValO(self, "qwe"); 1276 ck_assert_ptr_eq(replaceCharSO(self, 0,"|",1), NULL); 1277 // NULL string 1278 freeO(self); 1279 ck_assert_ptr_eq(replaceCharSO(self, '#',"|",1), NULL); 1280 terminateO(self); 1281 1282 } 1283 1284 1285 void replaceSCharSmallStringT(CuTest *tc UNUSED) { 1286 1287 smallStringt* r; 1288 smallStringt *self = allocG(""); 1289 1290 // replace string, multiple character new delimeter 1291 setValO(self, "#ee#ee#ad"); 1292 r = replaceSCharO(self, "#",'^',0); 1293 ck_assert_ptr_ne(r, null); 1294 char *s = toStringO(r); 1295 ck_assert_str_eq(s, "^ee^ee^ad"); 1296 free(s); 1297 // replace string, multiple character old delimeter 1298 setValO(self, "AA##ee##ee#"); 1299 r = replaceSCharO(self, "##",'|',0); 1300 ck_assert_ptr_ne(r, null); 1301 s = toStringO(r); 1302 ck_assert_str_eq(s, "AA|ee|ee#"); 1303 free(s); 1304 // replace string empty char, multiple character old delimeter 1305 setValO(self, "AA##ee##ee#"); 1306 r = replaceSCharO(self, "##", 0,0); 1307 ck_assert_ptr_ne(r, null); 1308 s = toStringO(r); 1309 ck_assert_str_eq(s, "AAeeee#"); 1310 free(s); 1311 // replace one time at the start of string 1312 setValO(self, "#ee#ee#ad"); 1313 r = replaceSCharO(self, "#",'^',1); 1314 ck_assert_ptr_ne(r, null); 1315 s = toStringO(r); 1316 ck_assert_str_eq(s, "^ee#ee#ad"); 1317 free(s); 1318 // replace one time 1319 setValO(self, "AA##ee##ee#"); 1320 r = replaceSCharO(self, "##",'|',1); 1321 ck_assert_ptr_ne(r, null); 1322 s = toStringO(r); 1323 ck_assert_str_eq(s, "AA|ee##ee#"); 1324 free(s); 1325 // empty string 1326 setValO(self, ""); 1327 r = replaceSCharO(self, "##",0,1); 1328 ck_assert_ptr_ne(r, null); 1329 s = toStringO(r); 1330 ck_assert_str_eq(s, ""); 1331 free(s); 1332 // empty old delimiter 1333 setValO(self, "qwe"); 1334 ck_assert_ptr_eq(replaceSCharO(self, "",'|',1), NULL); 1335 // NULL old delimiter 1336 ck_assert_ptr_eq(replaceSCharO(self, NULL,'|',1), NULL); 1337 // NULL string 1338 freeO(self); 1339 ck_assert_ptr_eq(replaceSCharO(self, "##",'|',1), NULL); 1340 terminateO(self); 1341 1342 } 1343 1344 1345 void replaceCharCharSmallStringT(CuTest *tc UNUSED) { 1346 1347 smallStringt* r; 1348 smallStringt *self = allocG(""); 1349 1350 // replace string, multiple character new delimeter 1351 setValO(self, "#ee#ee#ad"); 1352 r = replaceCharCharO(self, '#','^', 0); 1353 ck_assert_ptr_ne(r, null); 1354 char *s = toStringO(r); 1355 ck_assert_str_eq(s, "^ee^ee^ad"); 1356 free(s); 1357 // replace one time at the start of string 1358 setValO(self, "#ee#ee#ad"); 1359 r = replaceCharCharO(self, '#','^',1); 1360 ck_assert_ptr_ne(r, null); 1361 s = toStringO(r); 1362 ck_assert_str_eq(s, "^ee#ee#ad"); 1363 free(s); 1364 // replace one time 1365 setValO(self, "AA#ee##ee#"); 1366 r = replaceCharCharO(self, '#','|',1); 1367 ck_assert_ptr_ne(r, null); 1368 s = toStringO(r); 1369 ck_assert_str_eq(s, "AA|ee##ee#"); 1370 free(s); 1371 // empty string 1372 setValO(self, ""); 1373 r = replaceCharCharO(self, '#','^',1); 1374 ck_assert_ptr_ne(r, null); 1375 s = toStringO(r); 1376 ck_assert_str_eq(s, ""); 1377 free(s); 1378 // empty old delimiter 1379 setValO(self, "qwe"); 1380 ck_assert_ptr_eq(replaceCharCharO(self, 0,'|',1), NULL); 1381 // NULL string 1382 freeO(self); 1383 ck_assert_ptr_eq(replaceCharCharO(self, '#','|',1), NULL); 1384 terminateO(self); 1385 1386 } 1387 1388 1389 void replaceSmallJsonSmallJsonSmallStringT(CuTest *tc UNUSED) { 1390 1391 smallStringt* r; 1392 smallStringt *self = allocG("#ee#ee#ad"); 1393 smallJsont *olds = allocSmallJson(); 1394 smallJsont *news = allocSmallJson(); 1395 1396 // replace string, multiple character new delimeter 1397 freeO(olds); 1398 freeO(news); 1399 setTopSO(olds, "#"); 1400 setTopSO(news, "^^"); 1401 r = replaceSmallJsonSmallJsonO(self, olds, news, 0); 1402 ck_assert_ptr_ne(r, null); 1403 char *s = toStringO(r); 1404 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1405 free(s); 1406 // replace string, multiple character old delimeter 1407 setValO(self, "AA##ee##ee#"); 1408 freeO(olds); 1409 freeO(news); 1410 setTopSO(olds, "##"); 1411 setTopSO(news, "|"); 1412 r = replaceSmallJsonSmallJsonO(self, olds, news, 0); 1413 ck_assert_ptr_ne(r, null); 1414 s = toStringO(r); 1415 ck_assert_str_eq(s, "AA|ee|ee#"); 1416 free(s); 1417 // replace one time at the start of string 1418 setValO(self, "#ee#ee#ad"); 1419 freeO(olds); 1420 freeO(news); 1421 setTopSO(olds, "#"); 1422 setTopSO(news, "^^"); 1423 r = replaceSmallJsonSmallJsonO(self, olds, news,1); 1424 ck_assert_ptr_ne(r, null); 1425 s = toStringO(r); 1426 ck_assert_str_eq(s, "^^ee#ee#ad"); 1427 free(s); 1428 // replace one time 1429 setValO(self, "AA##ee##ee#"); 1430 freeO(olds); 1431 freeO(news); 1432 setTopSO(olds, "##"); 1433 setTopSO(news, "|"); 1434 r = replaceSmallJsonSmallJsonO(self, olds, news,1); 1435 ck_assert_ptr_ne(r, null); 1436 s = toStringO(r); 1437 ck_assert_str_eq(s, "AA|ee##ee#"); 1438 free(s); 1439 // NULL new delimiter, one time: same as empty delimiter 1440 setValO(self, "AA##ee##ee#"); 1441 freeO(olds); 1442 setTopSO(olds, "##"); 1443 r = replaceSmallJsonSmallJsonO(self, olds, NULL,1); 1444 ck_assert_ptr_ne(r, null); 1445 s = toStringO(r); 1446 ck_assert_str_eq(s, "AAee##ee#"); 1447 free(s); 1448 // non json string 1449 freeO(olds); 1450 setTopIntO(olds, 1); 1451 r = replaceSmallJsonSmallJsonO(self, olds, news,1); 1452 ck_assert_ptr_eq(r, null); 1453 freeO(olds); 1454 freeO(news); 1455 setTopSO(olds, "e"); 1456 setTopIntO(news, 1); 1457 r = replaceSmallJsonSmallJsonO(self, olds, news,1); 1458 ck_assert_ptr_eq(r, null); 1459 // non json object 1460 terminateO(olds); 1461 olds = (smallJsont*) allocSmallInt(1); 1462 r = replaceSmallJsonSmallJsonO(self, olds, news,1); 1463 ck_assert_ptr_eq(r, null); 1464 terminateO(olds); 1465 terminateO(news); 1466 olds = allocSmallJson(); 1467 news = (smallJsont*) allocSmallInt(1); 1468 r = replaceSmallJsonSmallJsonO(self, olds, news,1); 1469 ck_assert_ptr_eq(r, null); 1470 terminateO(news); 1471 news = allocSmallJson(); 1472 // empty string 1473 setValO(self, ""); 1474 freeO(olds); 1475 setTopSO(olds, "##"); 1476 r = replaceSmallJsonSmallJsonO(self, olds, NULL,1); 1477 ck_assert_ptr_ne(r, null); 1478 s = toStringO(r); 1479 ck_assert_str_eq(s, ""); 1480 free(s); 1481 // empty old delimiter 1482 setValO(self, "qwe"); 1483 freeO(olds); 1484 freeO(news); 1485 setTopSO(olds, ""); 1486 setTopSO(news, "|"); 1487 ck_assert_ptr_eq(replaceSmallJsonSmallJsonO(self, olds, news,1), NULL); 1488 // NULL old delimiter 1489 ck_assert_ptr_eq(replaceSmallJsonSmallJsonO(self, NULL, news,1), NULL); 1490 // NULL string 1491 freeO(self); 1492 ck_assert_ptr_eq(replaceSmallJsonSmallJsonO(self, olds, news,1), NULL); 1493 terminateO(olds); 1494 terminateO(news); 1495 terminateO(self); 1496 1497 } 1498 1499 1500 void replaceSmallJsonSmallStringSmallStringT(CuTest *tc UNUSED) { 1501 1502 smallStringt* r; 1503 smallStringt *self = allocG("#ee#ee#ad"); 1504 smallJsont *olds = allocSmallJson(); 1505 smallStringt *news = allocSmallString(""); 1506 1507 // replace string, multiple character new delimeter 1508 freeO(olds); 1509 setTopSO(olds, "#"); 1510 setValO(news, "^^"); 1511 r = replaceSmallJsonSmallStringO(self, olds, news, 0); 1512 ck_assert_ptr_ne(r, null); 1513 char *s = toStringO(r); 1514 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1515 free(s); 1516 // replace string, multiple character old delimeter 1517 setValO(self, "AA##ee##ee#"); 1518 freeO(olds); 1519 setTopSO(olds, "##"); 1520 setValO(news, "|"); 1521 r = replaceSmallJsonSmallStringO(self, olds, news, 0); 1522 ck_assert_ptr_ne(r, null); 1523 s = toStringO(r); 1524 ck_assert_str_eq(s, "AA|ee|ee#"); 1525 free(s); 1526 // replace one time at the start of string 1527 setValO(self, "#ee#ee#ad"); 1528 freeO(olds); 1529 setTopSO(olds, "#"); 1530 setValO(news, "^^"); 1531 r = replaceSmallJsonSmallStringO(self, olds, news,1); 1532 ck_assert_ptr_ne(r, null); 1533 s = toStringO(r); 1534 ck_assert_str_eq(s, "^^ee#ee#ad"); 1535 free(s); 1536 // replace one time 1537 setValO(self, "AA##ee##ee#"); 1538 freeO(olds); 1539 setTopSO(olds, "##"); 1540 setValO(news, "|"); 1541 r = replaceSmallJsonSmallStringO(self, olds, news,1); 1542 ck_assert_ptr_ne(r, null); 1543 s = toStringO(r); 1544 ck_assert_str_eq(s, "AA|ee##ee#"); 1545 free(s); 1546 // NULL new delimiter, one time: same as empty delimiter 1547 setValO(self, "AA##ee##ee#"); 1548 freeO(olds); 1549 setTopSO(olds, "##"); 1550 r = replaceSmallJsonSmallStringO(self, olds, NULL,1); 1551 ck_assert_ptr_ne(r, null); 1552 s = toStringO(r); 1553 ck_assert_str_eq(s, "AAee##ee#"); 1554 free(s); 1555 // non json string 1556 freeO(olds); 1557 setTopIntO(olds, 1); 1558 r = replaceSmallJsonSmallStringO(self, olds, news,1); 1559 ck_assert_ptr_eq(r, null); 1560 // non json object 1561 terminateO(olds); 1562 olds = (smallJsont*) allocSmallInt(1); 1563 r = replaceSmallJsonSmallStringO(self, olds, news,1); 1564 ck_assert_ptr_eq(r, null); 1565 terminateO(olds); 1566 terminateO(news); 1567 olds = allocSmallJson(); 1568 news = (smallStringt*) allocSmallInt(1); 1569 r = replaceSmallJsonSmallStringO(self, olds, news,1); 1570 ck_assert_ptr_eq(r, null); 1571 terminateO(news); 1572 news = allocSmallString(""); 1573 // empty string 1574 setValO(self, ""); 1575 freeO(olds); 1576 setTopSO(olds, "##"); 1577 r = replaceSmallJsonSmallStringO(self, olds, NULL,1); 1578 ck_assert_ptr_ne(r, null); 1579 s = toStringO(r); 1580 ck_assert_str_eq(s, ""); 1581 free(s); 1582 // empty old delimiter 1583 setValO(self, "qwe"); 1584 freeO(olds); 1585 setTopSO(olds, ""); 1586 setValO(news, "|"); 1587 ck_assert_ptr_eq(replaceSmallJsonSmallStringO(self, olds, news,1), NULL); 1588 // NULL old delimiter 1589 ck_assert_ptr_eq(replaceSmallJsonSmallStringO(self, NULL, news,1), NULL); 1590 // NULL string 1591 freeO(self); 1592 ck_assert_ptr_eq(replaceSmallJsonSmallStringO(self, olds, news,1), NULL); 1593 terminateO(olds); 1594 terminateO(news); 1595 terminateO(self); 1596 1597 } 1598 1599 1600 void replaceSmallJsonSSmallStringT(CuTest *tc UNUSED) { 1601 1602 smallStringt* r; 1603 smallStringt *self = allocG("#ee#ee#ad"); 1604 smallJsont *olds = allocSmallJson(); 1605 const char *news; 1606 1607 // replace string, multiple character new delimeter 1608 freeO(olds); 1609 setTopSO(olds, "#"); 1610 news = "^^"; 1611 r = replaceSmallJsonSO(self, olds, news, 0); 1612 ck_assert_ptr_ne(r, null); 1613 char *s = toStringO(r); 1614 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1615 free(s); 1616 // replace string, multiple character old delimeter 1617 setValO(self, "AA##ee##ee#"); 1618 freeO(olds); 1619 setTopSO(olds, "##"); 1620 news = "|"; 1621 r = replaceSmallJsonSO(self, olds, news, 0); 1622 ck_assert_ptr_ne(r, null); 1623 s = toStringO(r); 1624 ck_assert_str_eq(s, "AA|ee|ee#"); 1625 free(s); 1626 // replace one time at the start of string 1627 setValO(self, "#ee#ee#ad"); 1628 freeO(olds); 1629 setTopSO(olds, "#"); 1630 news = "^^"; 1631 r = replaceSmallJsonSO(self, olds, news,1); 1632 ck_assert_ptr_ne(r, null); 1633 s = toStringO(r); 1634 ck_assert_str_eq(s, "^^ee#ee#ad"); 1635 free(s); 1636 // replace one time 1637 setValO(self, "AA##ee##ee#"); 1638 freeO(olds); 1639 setTopSO(olds, "##"); 1640 news = "|"; 1641 r = replaceSmallJsonSO(self, olds, news,1); 1642 ck_assert_ptr_ne(r, null); 1643 s = toStringO(r); 1644 ck_assert_str_eq(s, "AA|ee##ee#"); 1645 free(s); 1646 // NULL new delimiter, one time: same as empty delimiter 1647 setValO(self, "AA##ee##ee#"); 1648 freeO(olds); 1649 setTopSO(olds, "##"); 1650 r = replaceSmallJsonSO(self, olds, NULL,1); 1651 ck_assert_ptr_ne(r, null); 1652 s = toStringO(r); 1653 ck_assert_str_eq(s, "AAee##ee#"); 1654 free(s); 1655 // non json string 1656 freeO(olds); 1657 setTopIntO(olds, 1); 1658 r = replaceSmallJsonSO(self, olds, news,1); 1659 ck_assert_ptr_eq(r, null); 1660 // non json object 1661 terminateO(olds); 1662 olds = (smallJsont*) allocSmallInt(1); 1663 r = replaceSmallJsonSO(self, olds, news,1); 1664 ck_assert_ptr_eq(r, null); 1665 terminateO(olds); 1666 // empty string 1667 olds = allocSmallJson(); 1668 setValO(self, ""); 1669 setTopSO(olds, "##"); 1670 r = replaceSmallJsonSO(self, olds, NULL,1); 1671 ck_assert_ptr_ne(r, null); 1672 s = toStringO(r); 1673 ck_assert_str_eq(s, ""); 1674 free(s); 1675 // empty old delimiter 1676 setValO(self, "qwe"); 1677 freeO(olds); 1678 setTopSO(olds, ""); 1679 news = "|"; 1680 ck_assert_ptr_eq(replaceSmallJsonSO(self, olds, news,1), NULL); 1681 // NULL old delimiter 1682 ck_assert_ptr_eq(replaceSmallJsonSO(self, NULL, news,1), NULL); 1683 // NULL string 1684 freeO(self); 1685 ck_assert_ptr_eq(replaceSmallJsonSO(self, olds, news,1), NULL); 1686 terminateO(olds); 1687 terminateO(self); 1688 1689 } 1690 1691 1692 void replaceSmallJsonCharSmallStringT(CuTest *tc UNUSED) { 1693 1694 smallStringt* r; 1695 smallStringt *self = allocG("#ee#ee#ad"); 1696 smallJsont *olds = allocSmallJson(); 1697 char news; 1698 1699 // replace string, multiple character new delimeter 1700 freeO(olds); 1701 setTopSO(olds, "#"); 1702 news = '^'; 1703 r = replaceSmallJsonCharO(self, olds, news, 0); 1704 ck_assert_ptr_ne(r, null); 1705 char *s = toStringO(r); 1706 ck_assert_str_eq(s, "^ee^ee^ad"); 1707 free(s); 1708 // replace string, multiple character old delimeter 1709 setValO(self, "AA##ee##ee#"); 1710 freeO(olds); 1711 setTopSO(olds, "##"); 1712 news = '|'; 1713 r = replaceSmallJsonCharO(self, olds, news, 0); 1714 ck_assert_ptr_ne(r, null); 1715 s = toStringO(r); 1716 ck_assert_str_eq(s, "AA|ee|ee#"); 1717 free(s); 1718 // replace one time at the start of string 1719 setValO(self, "#ee#ee#ad"); 1720 freeO(olds); 1721 setTopSO(olds, "#"); 1722 news = '^'; 1723 r = replaceSmallJsonCharO(self, olds, news,1); 1724 ck_assert_ptr_ne(r, null); 1725 s = toStringO(r); 1726 ck_assert_str_eq(s, "^ee#ee#ad"); 1727 free(s); 1728 // replace one time 1729 setValO(self, "AA##ee##ee#"); 1730 freeO(olds); 1731 setTopSO(olds, "##"); 1732 news = '|'; 1733 r = replaceSmallJsonCharO(self, olds, news,1); 1734 ck_assert_ptr_ne(r, null); 1735 s = toStringO(r); 1736 ck_assert_str_eq(s, "AA|ee##ee#"); 1737 free(s); 1738 // non json string 1739 setValO(self, "AA##ee##ee#"); 1740 freeO(olds); 1741 setTopIntO(olds, 1); 1742 r = replaceSmallJsonCharO(self, olds, news,1); 1743 ck_assert_ptr_eq(r, null); 1744 // non json object 1745 terminateO(olds); 1746 olds = (smallJsont*) allocSmallInt(1); 1747 r = replaceSmallJsonCharO(self, olds, news,1); 1748 ck_assert_ptr_eq(r, null); 1749 terminateO(olds); 1750 // empty string 1751 olds = allocSmallJson(); 1752 setValO(self, ""); 1753 setTopSO(olds, "##"); 1754 r = replaceSmallJsonCharO(self, olds, news,1); 1755 ck_assert_ptr_ne(r, null); 1756 s = toStringO(r); 1757 ck_assert_str_eq(s, ""); 1758 free(s); 1759 // empty old delimiter 1760 setValO(self, "qwe"); 1761 freeO(olds); 1762 setTopSO(olds, ""); 1763 news = '|'; 1764 ck_assert_ptr_eq(replaceSmallJsonCharO(self, olds, news,1), NULL); 1765 // NULL old delimiter 1766 ck_assert_ptr_eq(replaceSmallJsonCharO(self, NULL, news,1), NULL); 1767 // NULL string 1768 freeO(self); 1769 ck_assert_ptr_eq(replaceSmallJsonCharO(self, olds, news,1), NULL); 1770 terminateO(olds); 1771 terminateO(self); 1772 1773 } 1774 1775 1776 void replaceSmallStringSmallJsonSmallStringT(CuTest *tc UNUSED) { 1777 1778 smallStringt* r; 1779 smallStringt *self = allocG("#ee#ee#ad"); 1780 smallStringt *olds = allocSmallString(""); 1781 smallJsont *news = allocSmallJson(); 1782 1783 // replace string, multiple character new delimeter 1784 freeO(news); 1785 setValO(olds, "#"); 1786 setTopSO(news, "^^"); 1787 r = self->f->replaceSmallStringSmallJson(self, olds, news, 0); 1788 ck_assert_ptr_ne(r, null); 1789 char *s = toStringO(r); 1790 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1791 free(s); 1792 // replace string, multiple character old delimeter 1793 setValO(self, "AA##ee##ee#"); 1794 freeO(news); 1795 setValO(olds, "##"); 1796 setTopSO(news, "|"); 1797 r = self->f->replaceSmallStringSmallJson(self, olds, news, 0); 1798 ck_assert_ptr_ne(r, null); 1799 s = toStringO(r); 1800 ck_assert_str_eq(s, "AA|ee|ee#"); 1801 free(s); 1802 // replace one time at the start of string 1803 setValO(self, "#ee#ee#ad"); 1804 freeO(news); 1805 setValO(olds, "#"); 1806 setTopSO(news, "^^"); 1807 r = self->f->replaceSmallStringSmallJson(self, olds, news,1); 1808 ck_assert_ptr_ne(r, null); 1809 s = toStringO(r); 1810 ck_assert_str_eq(s, "^^ee#ee#ad"); 1811 free(s); 1812 // replace one time 1813 setValO(self, "AA##ee##ee#"); 1814 freeO(news); 1815 setValO(olds, "##"); 1816 setTopSO(news, "|"); 1817 r = self->f->replaceSmallStringSmallJson(self, olds, news,1); 1818 ck_assert_ptr_ne(r, null); 1819 s = toStringO(r); 1820 ck_assert_str_eq(s, "AA|ee##ee#"); 1821 free(s); 1822 // NULL new delimiter, one time: same as empty delimiter 1823 setValO(self, "AA##ee##ee#"); 1824 setValO(olds, "##"); 1825 r = self->f->replaceSmallStringSmallJson(self, olds, NULL,1); 1826 ck_assert_ptr_ne(r, null); 1827 s = toStringO(r); 1828 ck_assert_str_eq(s, "AAee##ee#"); 1829 free(s); 1830 // non json string 1831 freeO(news); 1832 setTopIntO(news, 1); 1833 r = self->f->replaceSmallStringSmallJson(self, olds, news,1); 1834 ck_assert_ptr_eq(r, null); 1835 // non json object 1836 terminateO(olds); 1837 olds = (smallStringt*) allocSmallInt(1); 1838 r = self->f->replaceSmallStringSmallJson(self, olds, news,1); 1839 ck_assert_ptr_eq(r, null); 1840 terminateO(olds); 1841 terminateO(news); 1842 olds = allocSmallString(""); 1843 news = (smallJsont*) allocSmallInt(1); 1844 r = self->f->replaceSmallStringSmallJson(self, olds, news,1); 1845 ck_assert_ptr_eq(r, null); 1846 terminateO(news); 1847 news = allocSmallJson(); 1848 // empty string 1849 setValO(self, ""); 1850 setValO(olds, "##"); 1851 r = self->f->replaceSmallStringSmallJson(self, olds, NULL,1); 1852 ck_assert_ptr_ne(r, null); 1853 s = toStringO(r); 1854 ck_assert_str_eq(s, ""); 1855 free(s); 1856 // empty old delimiter 1857 setValO(self, "qwe"); 1858 freeO(news); 1859 setValO(olds, ""); 1860 setTopSO(news, "|"); 1861 ck_assert_ptr_eq(self->f->replaceSmallStringSmallJson(self, olds, news,1), NULL); 1862 // NULL old delimiter 1863 ck_assert_ptr_eq(self->f->replaceSmallStringSmallJson(self, NULL, news,1), NULL); 1864 // NULL string 1865 freeO(self); 1866 ck_assert_ptr_eq(self->f->replaceSmallStringSmallJson(self, olds, news,1), NULL); 1867 terminateO(olds); 1868 terminateO(news); 1869 terminateO(self); 1870 1871 } 1872 1873 1874 void replaceSmallStringSmallStringSmallStringT(CuTest *tc UNUSED) { 1875 1876 smallStringt* r; 1877 smallStringt *self = allocG("#ee#ee#ad"); 1878 smallStringt *olds = allocSmallString(""); 1879 smallStringt *news = allocSmallString(""); 1880 1881 // replace string, multiple character new delimeter 1882 setValO(olds, "#"); 1883 setValO(news, "^^"); 1884 r = replaceSmallStringSmallStringO(self, olds, news, 0); 1885 ck_assert_ptr_ne(r, null); 1886 char *s = toStringO(r); 1887 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1888 free(s); 1889 // replace string, multiple character old delimeter 1890 setValO(self, "AA##ee##ee#"); 1891 setValO(olds, "##"); 1892 setValO(news, "|"); 1893 r = replaceSmallStringSmallStringO(self, olds, news, 0); 1894 ck_assert_ptr_ne(r, null); 1895 s = toStringO(r); 1896 ck_assert_str_eq(s, "AA|ee|ee#"); 1897 free(s); 1898 // replace one time at the start of string 1899 setValO(self, "#ee#ee#ad"); 1900 setValO(olds, "#"); 1901 setValO(news, "^^"); 1902 r = replaceSmallStringSmallStringO(self, olds, news,1); 1903 ck_assert_ptr_ne(r, null); 1904 s = toStringO(r); 1905 ck_assert_str_eq(s, "^^ee#ee#ad"); 1906 free(s); 1907 // replace one time 1908 setValO(self, "AA##ee##ee#"); 1909 setValO(olds, "##"); 1910 setValO(news, "|"); 1911 r = replaceSmallStringSmallStringO(self, olds, news,1); 1912 ck_assert_ptr_ne(r, null); 1913 s = toStringO(r); 1914 ck_assert_str_eq(s, "AA|ee##ee#"); 1915 free(s); 1916 // NULL new delimiter, one time: same as empty delimiter 1917 setValO(self, "AA##ee##ee#"); 1918 setValO(olds, "##"); 1919 r = replaceSmallStringSmallStringO(self, olds, NULL,1); 1920 ck_assert_ptr_ne(r, null); 1921 s = toStringO(r); 1922 ck_assert_str_eq(s, "AAee##ee#"); 1923 free(s); 1924 // non smallString object 1925 terminateO(olds); 1926 olds = (smallStringt*) allocSmallInt(1); 1927 r = replaceSmallStringSmallStringO(self, olds, news,1); 1928 ck_assert_ptr_eq(r, null); 1929 terminateO(olds); 1930 terminateO(news); 1931 olds = allocSmallString(""); 1932 news = (smallStringt*) allocSmallInt(1); 1933 r = replaceSmallStringSmallStringO(self, olds, news,1); 1934 ck_assert_ptr_eq(r, null); 1935 terminateO(news); 1936 news = allocSmallString(""); 1937 // empty string 1938 setValO(self, ""); 1939 setValO(olds, "##"); 1940 r = replaceSmallStringSmallStringO(self, olds, NULL,1); 1941 ck_assert_ptr_ne(r, null); 1942 s = toStringO(r); 1943 ck_assert_str_eq(s, ""); 1944 free(s); 1945 // empty old delimiter 1946 setValO(self, "qwe"); 1947 setValO(olds, ""); 1948 setValO(news, "|"); 1949 ck_assert_ptr_eq(replaceSmallStringSmallStringO(self, olds, news,1), NULL); 1950 // NULL old delimiter 1951 ck_assert_ptr_eq(replaceSmallStringSmallStringO(self, NULL, news,1), NULL); 1952 // NULL string 1953 freeO(self); 1954 ck_assert_ptr_eq(replaceSmallStringSmallStringO(self, olds, news,1), NULL); 1955 terminateO(olds); 1956 terminateO(news); 1957 terminateO(self); 1958 1959 } 1960 1961 1962 void replaceSmallStringSSmallStringT(CuTest *tc UNUSED) { 1963 1964 smallStringt* r; 1965 smallStringt *self = allocG("#ee#ee#ad"); 1966 smallStringt *olds = allocSmallString(""); 1967 const char *news; 1968 1969 // replace string, multiple character new delimeter 1970 setValO(olds, "#"); 1971 news = "^^"; 1972 r = replaceSmallStringSO(self, olds, news, 0); 1973 ck_assert_ptr_ne(r, null); 1974 char *s = toStringO(r); 1975 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 1976 free(s); 1977 // replace string, multiple character old delimeter 1978 setValO(self, "AA##ee##ee#"); 1979 setValO(olds, "##"); 1980 news = "|"; 1981 r = replaceSmallStringSO(self, olds, news, 0); 1982 ck_assert_ptr_ne(r, null); 1983 s = toStringO(r); 1984 ck_assert_str_eq(s, "AA|ee|ee#"); 1985 free(s); 1986 // replace one time at the start of string 1987 setValO(self, "#ee#ee#ad"); 1988 setValO(olds, "#"); 1989 news = "^^"; 1990 r = replaceSmallStringSO(self, olds, news,1); 1991 ck_assert_ptr_ne(r, null); 1992 s = toStringO(r); 1993 ck_assert_str_eq(s, "^^ee#ee#ad"); 1994 free(s); 1995 // replace one time 1996 setValO(self, "AA##ee##ee#"); 1997 setValO(olds, "##"); 1998 news = "|"; 1999 r = replaceSmallStringSO(self, olds, news,1); 2000 ck_assert_ptr_ne(r, null); 2001 s = toStringO(r); 2002 ck_assert_str_eq(s, "AA|ee##ee#"); 2003 free(s); 2004 // NULL new delimiter, one time: same as empty delimiter 2005 setValO(self, "AA##ee##ee#"); 2006 setValO(olds, "##"); 2007 r = replaceSmallStringSO(self, olds, NULL,1); 2008 ck_assert_ptr_ne(r, null); 2009 s = toStringO(r); 2010 ck_assert_str_eq(s, "AAee##ee#"); 2011 free(s); 2012 // non smallString object 2013 terminateO(olds); 2014 olds = (smallStringt*) allocSmallInt(1); 2015 r = replaceSmallStringSO(self, olds, news,1); 2016 ck_assert_ptr_eq(r, null); 2017 terminateO(olds); 2018 olds = allocSmallString(""); 2019 // empty string 2020 setValO(self, ""); 2021 setValO(olds, "##"); 2022 r = replaceSmallStringSO(self, olds, NULL,1); 2023 ck_assert_ptr_ne(r, null); 2024 s = toStringO(r); 2025 ck_assert_str_eq(s, ""); 2026 free(s); 2027 // empty old delimiter 2028 setValO(self, "qwe"); 2029 setValO(olds, ""); 2030 news = "|"; 2031 ck_assert_ptr_eq(replaceSmallStringSO(self, olds, news,1), NULL); 2032 // NULL old delimiter 2033 ck_assert_ptr_eq(replaceSmallStringSO(self, NULL, news,1), NULL); 2034 // NULL string 2035 freeO(self); 2036 ck_assert_ptr_eq(replaceSmallStringSO(self, olds, news,1), NULL); 2037 terminateO(olds); 2038 terminateO(self); 2039 2040 } 2041 2042 2043 void replaceSmallStringCharSmallStringT(CuTest *tc UNUSED) { 2044 2045 smallStringt* r; 2046 smallStringt *self = allocG("#ee#ee#ad"); 2047 smallStringt *olds = allocSmallString(""); 2048 char news; 2049 2050 // replace string, multiple character new delimeter 2051 setValO(olds, "#"); 2052 news = '^'; 2053 r = replaceSmallStringCharO(self, olds, news, 0); 2054 ck_assert_ptr_ne(r, null); 2055 char *s = toStringO(r); 2056 ck_assert_str_eq(s, "^ee^ee^ad"); 2057 free(s); 2058 // replace string, multiple character old delimeter 2059 setValO(self, "AA##ee##ee#"); 2060 setValO(olds, "##"); 2061 news = '|'; 2062 r = replaceSmallStringCharO(self, olds, news, 0); 2063 ck_assert_ptr_ne(r, null); 2064 s = toStringO(r); 2065 ck_assert_str_eq(s, "AA|ee|ee#"); 2066 free(s); 2067 // replace one time at the start of string 2068 setValO(self, "#ee#ee#ad"); 2069 setValO(olds, "#"); 2070 news = '^'; 2071 r = replaceSmallStringCharO(self, olds, news,1); 2072 ck_assert_ptr_ne(r, null); 2073 s = toStringO(r); 2074 ck_assert_str_eq(s, "^ee#ee#ad"); 2075 free(s); 2076 // replace one time 2077 setValO(self, "AA##ee##ee#"); 2078 setValO(olds, "##"); 2079 news = '|'; 2080 r = replaceSmallStringCharO(self, olds, news,1); 2081 ck_assert_ptr_ne(r, null); 2082 s = toStringO(r); 2083 ck_assert_str_eq(s, "AA|ee##ee#"); 2084 free(s); 2085 // non smallString object 2086 terminateO(olds); 2087 olds = (smallStringt*) allocSmallInt(1); 2088 r = replaceSmallStringCharO(self, olds, news,1); 2089 ck_assert_ptr_eq(r, null); 2090 terminateO(olds); 2091 olds = allocSmallString(""); 2092 // empty string 2093 setValO(self, ""); 2094 setValO(olds, "##"); 2095 r = replaceSmallStringCharO(self, olds, news,1); 2096 ck_assert_ptr_ne(r, null); 2097 s = toStringO(r); 2098 ck_assert_str_eq(s, ""); 2099 free(s); 2100 // empty old delimiter 2101 setValO(self, "qwe"); 2102 setValO(olds, ""); 2103 news = '|'; 2104 ck_assert_ptr_eq(replaceSmallStringCharO(self, olds, news,1), NULL); 2105 // NULL old delimiter 2106 ck_assert_ptr_eq(replaceSmallStringCharO(self, NULL, news,1), NULL); 2107 // NULL string 2108 freeO(self); 2109 ck_assert_ptr_eq(replaceSmallStringCharO(self, olds, news,1), NULL); 2110 terminateO(olds); 2111 terminateO(self); 2112 2113 } 2114 2115 2116 void replaceSSmallJsonSmallStringT(CuTest *tc UNUSED) { 2117 2118 smallStringt* r; 2119 smallStringt *self = allocG("#ee#ee#ad"); 2120 const char *olds; 2121 smallJsont *news = allocSmallJson(); 2122 2123 // replace string, multiple character new delimeter 2124 freeO(news); 2125 olds = "#"; 2126 setTopSO(news, "^^"); 2127 r = replaceSSmallJsonO(self, olds, news, 0); 2128 ck_assert_ptr_ne(r, null); 2129 char *s = toStringO(r); 2130 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2131 free(s); 2132 // replace string, multiple character old delimeter 2133 setValO(self, "AA##ee##ee#"); 2134 freeO(news); 2135 olds = "##"; 2136 setTopSO(news, "|"); 2137 r = replaceSSmallJsonO(self, olds, news, 0); 2138 ck_assert_ptr_ne(r, null); 2139 s = toStringO(r); 2140 ck_assert_str_eq(s, "AA|ee|ee#"); 2141 free(s); 2142 // replace one time at the start of string 2143 setValO(self, "#ee#ee#ad"); 2144 freeO(news); 2145 olds = "#"; 2146 setTopSO(news, "^^"); 2147 r = replaceSSmallJsonO(self, olds, news,1); 2148 ck_assert_ptr_ne(r, null); 2149 s = toStringO(r); 2150 ck_assert_str_eq(s, "^^ee#ee#ad"); 2151 free(s); 2152 // replace one time 2153 setValO(self, "AA##ee##ee#"); 2154 freeO(news); 2155 olds = "##"; 2156 setTopSO(news, "|"); 2157 r = replaceSSmallJsonO(self, olds, news,1); 2158 ck_assert_ptr_ne(r, null); 2159 s = toStringO(r); 2160 ck_assert_str_eq(s, "AA|ee##ee#"); 2161 free(s); 2162 // NULL new delimiter, one time: same as empty delimiter 2163 setValO(self, "AA##ee##ee#"); 2164 olds = "##"; 2165 r = replaceSSmallJsonO(self, olds, NULL,1); 2166 ck_assert_ptr_ne(r, null); 2167 s = toStringO(r); 2168 ck_assert_str_eq(s, "AAee##ee#"); 2169 free(s); 2170 // non json string 2171 freeO(news); 2172 olds = "e"; 2173 setTopIntO(news, 1); 2174 r = replaceSSmallJsonO(self, olds, news,1); 2175 ck_assert_ptr_eq(r, null); 2176 // non json object 2177 terminateO(news); 2178 news = (smallJsont*) allocSmallInt(1); 2179 r = replaceSSmallJsonO(self, olds, news,1); 2180 ck_assert_ptr_eq(r, null); 2181 terminateO(news); 2182 news = allocSmallJson(); 2183 // empty string 2184 setValO(self, ""); 2185 olds = "##"; 2186 r = replaceSSmallJsonO(self, olds, NULL,1); 2187 ck_assert_ptr_ne(r, null); 2188 s = toStringO(r); 2189 ck_assert_str_eq(s, ""); 2190 free(s); 2191 // empty old delimiter 2192 setValO(self, "qwe"); 2193 freeO(news); 2194 olds = ""; 2195 setTopSO(news, "|"); 2196 ck_assert_ptr_eq(replaceSSmallJsonO(self, olds, news,1), NULL); 2197 // NULL old delimiter 2198 ck_assert_ptr_eq(replaceSSmallJsonO(self, NULL, news,1), NULL); 2199 // NULL string 2200 freeO(self); 2201 ck_assert_ptr_eq(replaceSSmallJsonO(self, olds, news,1), NULL); 2202 terminateO(news); 2203 terminateO(self); 2204 2205 } 2206 2207 2208 void replaceSSmallStringSmallStringT(CuTest *tc UNUSED) { 2209 2210 smallStringt* r; 2211 smallStringt *self = allocG("#ee#ee#ad"); 2212 const char *olds; 2213 smallStringt *news = allocSmallString(""); 2214 2215 // replace string, multiple character new delimeter 2216 olds = "#"; 2217 setValO(news, "^^"); 2218 r = replaceSSmallStringO(self, olds, news, 0); 2219 ck_assert_ptr_ne(r, null); 2220 char *s = toStringO(r); 2221 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2222 free(s); 2223 // replace string, multiple character old delimeter 2224 setValO(self, "AA##ee##ee#"); 2225 olds = "##"; 2226 setValO(news, "|"); 2227 r = replaceSSmallStringO(self, olds, news, 0); 2228 ck_assert_ptr_ne(r, null); 2229 s = toStringO(r); 2230 ck_assert_str_eq(s, "AA|ee|ee#"); 2231 free(s); 2232 // replace one time at the start of string 2233 setValO(self, "#ee#ee#ad"); 2234 olds = "#"; 2235 setValO(news, "^^"); 2236 r = replaceSSmallStringO(self, olds, news,1); 2237 ck_assert_ptr_ne(r, null); 2238 s = toStringO(r); 2239 ck_assert_str_eq(s, "^^ee#ee#ad"); 2240 free(s); 2241 // replace one time 2242 setValO(self, "AA##ee##ee#"); 2243 olds = "##"; 2244 setValO(news, "|"); 2245 r = replaceSSmallStringO(self, olds, news,1); 2246 ck_assert_ptr_ne(r, null); 2247 s = toStringO(r); 2248 ck_assert_str_eq(s, "AA|ee##ee#"); 2249 free(s); 2250 // NULL new delimiter, one time: same as empty delimiter 2251 setValO(self, "AA##ee##ee#"); 2252 olds = "##"; 2253 r = replaceSSmallStringO(self, olds, NULL,1); 2254 ck_assert_ptr_ne(r, null); 2255 s = toStringO(r); 2256 ck_assert_str_eq(s, "AAee##ee#"); 2257 free(s); 2258 // non smallString object 2259 terminateO(news); 2260 news = (smallStringt*) allocSmallInt(1); 2261 r = replaceSSmallStringO(self, olds, news,1); 2262 ck_assert_ptr_eq(r, null); 2263 terminateO(news); 2264 news = allocSmallString(""); 2265 // empty string 2266 setValO(self, ""); 2267 olds = "##"; 2268 r = replaceSSmallStringO(self, olds, NULL,1); 2269 ck_assert_ptr_ne(r, null); 2270 s = toStringO(r); 2271 ck_assert_str_eq(s, ""); 2272 free(s); 2273 // empty old delimiter 2274 setValO(self, "qwe"); 2275 olds = ""; 2276 setValO(news, "|"); 2277 ck_assert_ptr_eq(replaceSSmallStringO(self, olds, news,1), NULL); 2278 // NULL old delimiter 2279 ck_assert_ptr_eq(replaceSSmallStringO(self, NULL, news,1), NULL); 2280 // NULL string 2281 freeO(self); 2282 ck_assert_ptr_eq(replaceSSmallStringO(self, olds, news,1), NULL); 2283 terminateO(news); 2284 terminateO(self); 2285 2286 } 2287 2288 2289 void replaceCharSmallJsonSmallStringT(CuTest *tc UNUSED) { 2290 2291 smallStringt* r; 2292 smallStringt *self = allocG("#ee#ee#ad"); 2293 char olds; 2294 smallJsont *news = allocSmallJson(); 2295 2296 // replace string, multiple character new delimeter 2297 freeO(news); 2298 olds = '#'; 2299 setTopSO(news, "^^"); 2300 r = replaceCharSmallJsonO(self, olds, news, 0); 2301 ck_assert_ptr_ne(r, null); 2302 char *s = toStringO(r); 2303 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2304 free(s); 2305 // replace string, multiple character old delimeter 2306 setValO(self, "AA#ee#ee"); 2307 freeO(news); 2308 olds = '#'; 2309 setTopSO(news, "|"); 2310 r = replaceCharSmallJsonO(self, olds, news, 0); 2311 ck_assert_ptr_ne(r, null); 2312 s = toStringO(r); 2313 ck_assert_str_eq(s, "AA|ee|ee"); 2314 free(s); 2315 // replace one time at the start of string 2316 setValO(self, "#ee#ee#ad"); 2317 freeO(news); 2318 olds = '#'; 2319 setTopSO(news, "^^"); 2320 r = replaceCharSmallJsonO(self, olds, news,1); 2321 ck_assert_ptr_ne(r, null); 2322 s = toStringO(r); 2323 ck_assert_str_eq(s, "^^ee#ee#ad"); 2324 free(s); 2325 // replace one time 2326 setValO(self, "AA#ee##ee#"); 2327 freeO(news); 2328 olds = '#'; 2329 setTopSO(news, "|"); 2330 r = replaceCharSmallJsonO(self, olds, news,1); 2331 ck_assert_ptr_ne(r, null); 2332 s = toStringO(r); 2333 ck_assert_str_eq(s, "AA|ee##ee#"); 2334 free(s); 2335 // NULL new delimiter, one time: same as empty delimiter 2336 setValO(self, "AA#ee##ee#"); 2337 olds = '#'; 2338 r = replaceCharSmallJsonO(self, olds, NULL,1); 2339 ck_assert_ptr_ne(r, null); 2340 s = toStringO(r); 2341 ck_assert_str_eq(s, "AAee##ee#"); 2342 free(s); 2343 // non json string 2344 freeO(news); 2345 olds = 'e'; 2346 setTopIntO(news, 1); 2347 r = replaceCharSmallJsonO(self, olds, news,1); 2348 ck_assert_ptr_eq(r, null); 2349 // non json object 2350 terminateO(news); 2351 news = (smallJsont*) allocSmallInt(1); 2352 r = replaceCharSmallJsonO(self, olds, news,1); 2353 ck_assert_ptr_eq(r, null); 2354 terminateO(news); 2355 news = allocSmallJson(); 2356 // empty string 2357 setValO(self, ""); 2358 olds = '#'; 2359 r = replaceCharSmallJsonO(self, olds, NULL,1); 2360 ck_assert_ptr_ne(r, null); 2361 s = toStringO(r); 2362 ck_assert_str_eq(s, ""); 2363 free(s); 2364 // NULL string 2365 freeO(self); 2366 freeO(news); 2367 setTopSO(news, "|"); 2368 ck_assert_ptr_eq(replaceCharSmallJsonO(self, olds, news,1), NULL); 2369 terminateO(news); 2370 terminateO(self); 2371 2372 } 2373 2374 2375 void replaceCharSmallStringSmallStringT(CuTest *tc UNUSED) { 2376 2377 smallStringt* r; 2378 smallStringt *self = allocG("#ee#ee#ad"); 2379 char olds; 2380 smallStringt *news = allocSmallString(""); 2381 2382 // replace string, multiple character new delimeter 2383 olds = '#'; 2384 setValO(news, "^^"); 2385 r = replaceCharSmallStringO(self, olds, news, 0); 2386 ck_assert_ptr_ne(r, null); 2387 char *s = toStringO(r); 2388 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2389 free(s); 2390 // replace string, multiple character old delimeter 2391 setValO(self, "AA#ee#ee"); 2392 olds = '#'; 2393 setValO(news, "|"); 2394 r = replaceCharSmallStringO(self, olds, news, 0); 2395 ck_assert_ptr_ne(r, null); 2396 s = toStringO(r); 2397 ck_assert_str_eq(s, "AA|ee|ee"); 2398 free(s); 2399 // replace one time at the start of string 2400 setValO(self, "#ee#ee#ad"); 2401 olds = '#'; 2402 setValO(news, "^^"); 2403 r = replaceCharSmallStringO(self, olds, news,1); 2404 ck_assert_ptr_ne(r, null); 2405 s = toStringO(r); 2406 ck_assert_str_eq(s, "^^ee#ee#ad"); 2407 free(s); 2408 // replace one time 2409 setValO(self, "AA#ee##ee#"); 2410 olds = '#'; 2411 setValO(news, "|"); 2412 r = replaceCharSmallStringO(self, olds, news,1); 2413 ck_assert_ptr_ne(r, null); 2414 s = toStringO(r); 2415 ck_assert_str_eq(s, "AA|ee##ee#"); 2416 free(s); 2417 // NULL new delimiter, one time: same as empty delimiter 2418 setValO(self, "AA#ee##ee#"); 2419 olds = '#'; 2420 r = replaceCharSmallStringO(self, olds, NULL,1); 2421 ck_assert_ptr_ne(r, null); 2422 s = toStringO(r); 2423 ck_assert_str_eq(s, "AAee##ee#"); 2424 free(s); 2425 // non smallString object 2426 terminateO(news); 2427 news = (smallStringt*) allocSmallInt(1); 2428 r = replaceCharSmallStringO(self, olds, news,1); 2429 ck_assert_ptr_eq(r, null); 2430 terminateO(news); 2431 news = allocSmallString(""); 2432 // empty string 2433 setValO(self, ""); 2434 olds = '#'; 2435 r = replaceCharSmallStringO(self, olds, NULL,1); 2436 ck_assert_ptr_ne(r, null); 2437 s = toStringO(r); 2438 ck_assert_str_eq(s, ""); 2439 free(s); 2440 // NULL string 2441 freeO(self); 2442 setValO(news, "|"); 2443 ck_assert_ptr_eq(replaceCharSmallStringO(self, olds, news,1), NULL); 2444 terminateO(news); 2445 terminateO(self); 2446 2447 } 2448 2449 2450 void replaceManySmallStringT(CuTest *tc UNUSED) { 2451 2452 smallStringt* r; 2453 smallStringt *self = allocG(""); 2454 2455 // replace string, multiple character new delimeter 2456 setValO(self, "#ee#ee#ad"); 2457 r = replaceManyO(self, "#","^^","ad","AD"); 2458 ck_assert_ptr_ne(r, null); 2459 char *s = toStringO(r); 2460 ck_assert_str_eq(s, "^^ee^^ee^^AD"); 2461 free(s); 2462 // replace string, empty new delimeter 2463 setValO(self, "#ee#ee#ad"); 2464 r = replaceManyO(self, "#","","ad","AD"); 2465 ck_assert_ptr_ne(r, null); 2466 s = toStringO(r); 2467 ck_assert_str_eq(s, "eeeeAD"); 2468 free(s); 2469 // not enough olds:news pairs 2470 setValO(self, "#ee#ee#ad"); 2471 r = replaceManyO(self, "#","","ad"); 2472 ck_assert_ptr_ne(r, null); 2473 s = toStringO(r); 2474 ck_assert_str_eq(s, "eeeead"); 2475 free(s); 2476 // NULL new delimiter: same as only 2 parameters or not enough olds:news pairs 2477 setValO(self, "AA##ee##ee#"); 2478 r = replaceManyO(self, "##",NULL); 2479 ck_assert_ptr_eq(r, null); 2480 // empty string 2481 setValO(self, ""); 2482 r = replaceManyO(self, "##", ""); 2483 ck_assert_ptr_ne(r, null); 2484 s = toStringO(r); 2485 ck_assert_str_eq(s, ""); 2486 free(s); 2487 // empty string many pairs 2488 setValO(self, ""); 2489 r = replaceManyO(self, "##", "", "$$", ""); 2490 ck_assert_ptr_ne(r, null); 2491 s = toStringO(r); 2492 ck_assert_str_eq(s, ""); 2493 free(s); 2494 // empty string many pairs empty olds 2495 setValO(self, ""); 2496 r = replaceManyO(self, "##", "", "", ""); 2497 ck_assert_ptr_ne(r, null); 2498 s = toStringO(r); 2499 ck_assert_str_eq(s, ""); 2500 free(s); 2501 // empty string and NULL old delimiter 2502 setValO(self, ""); 2503 r = replaceManyO(self, NULL,"|"); 2504 ck_assert_ptr_ne(r, null); 2505 s = toStringO(r); 2506 ck_assert_str_eq(s, ""); 2507 free(s); 2508 // empty string and NULL old delimiter not first - same as replace empty string 2509 setValO(self, ""); 2510 r = replaceManyO(self,"##","|", NULL,"|"); 2511 ck_assert_ptr_ne(r, null); 2512 s = toStringO(r); 2513 ck_assert_str_eq(s, ""); 2514 free(s); 2515 // empty old delimiter 2516 setValO(self, "AA##ee##ee#"); 2517 ck_assert_ptr_eq(replaceManyO(self, "","|", "AA", "BB"), NULL); 2518 // empty old delimiter not first 2519 ck_assert_ptr_eq(replaceManyO(self, "##","|", "", "BB"), NULL); 2520 // NULL string 2521 freeO(self); 2522 ck_assert_ptr_eq(replaceManyO(self, "##","|"), NULL); 2523 terminateO(self); 2524 2525 } 2526 2527 2528 void icReplaceSmallStringT(CuTest *tc UNUSED) { 2529 2530 smallStringt* r; 2531 smallStringt *self = allocG("BeebeeBad"); 2532 2533 // replace string, multiple character new delimeter 2534 r = icReplaceO(self, "b","^^", 0); 2535 ck_assert_ptr_ne(r, null); 2536 char *s = toStringO(r); 2537 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2538 free(s); 2539 // replace string, multiple character old delimeter 2540 setValO(self, "AA##ee##ee#"); 2541 r = icReplaceO(self, "##","|", 0); 2542 ck_assert_ptr_ne(r, null); 2543 s = toStringO(r); 2544 ck_assert_str_eq(s, "AA|ee|ee#"); 2545 free(s); 2546 // replace one time at the start of string 2547 setValO(self, "#ee#ee#ad"); 2548 r = icReplaceO(self, "#","^^",1); 2549 ck_assert_ptr_ne(r, null); 2550 s = toStringO(r); 2551 ck_assert_str_eq(s, "^^ee#ee#ad"); 2552 free(s); 2553 // replace one time 2554 setValO(self, "AA##ee##ee#"); 2555 r = icReplaceO(self, "##","|",1); 2556 ck_assert_ptr_ne(r, null); 2557 s = toStringO(r); 2558 ck_assert_str_eq(s, "AA|ee##ee#"); 2559 free(s); 2560 // NULL new delimiter, one time: same as empty delimiter 2561 setValO(self, "AA##ee##ee#"); 2562 r = icReplaceO(self, "##",NULL,1); 2563 ck_assert_ptr_ne(r, null); 2564 s = toStringO(r); 2565 ck_assert_str_eq(s, "AAee##ee#"); 2566 free(s); 2567 // empty string 2568 setValO(self, ""); 2569 r = icReplaceO(self, "##",NULL,1); 2570 ck_assert_ptr_ne(r, null); 2571 s = toStringO(r); 2572 ck_assert_str_eq(s, ""); 2573 free(s); 2574 // empty old delimiter 2575 setValO(self, "qwe"); 2576 ck_assert_ptr_eq(icReplaceO(self, "","|",1), NULL); 2577 // NULL old delimiter 2578 ck_assert_ptr_eq(icReplaceO(self, NULL,"|",1), NULL); 2579 // empty old delimiter 2580 ck_assert_ptr_eq(icReplaceO(self, "","|",1), NULL); 2581 // NULL string 2582 freeO(self); 2583 ck_assert_ptr_eq(icReplaceO(self, "##","|",1), NULL); 2584 terminateO(self); 2585 2586 } 2587 2588 2589 void icReplaceCharSSmallStringT(CuTest *tc UNUSED) { 2590 2591 smallStringt* r; 2592 smallStringt *self = allocG(""); 2593 2594 // replace string, multiple character new delimeter 2595 setValO(self, "BeebeeBad"); 2596 r = icReplaceCharSO(self, 'B',"^^", 0); 2597 ck_assert_ptr_ne(r, null); 2598 char *s = toStringO(r); 2599 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2600 free(s); 2601 // replace one time at the start of string 2602 setValO(self, "#ee#ee#ad"); 2603 r = icReplaceCharSO(self, '#',"^^",1); 2604 ck_assert_ptr_ne(r, null); 2605 s = toStringO(r); 2606 ck_assert_str_eq(s, "^^ee#ee#ad"); 2607 free(s); 2608 // replace one time 2609 setValO(self, "AA##ee##ee#"); 2610 r = icReplaceCharSO(self, '#',"|",1); 2611 ck_assert_ptr_ne(r, null); 2612 s = toStringO(r); 2613 ck_assert_str_eq(s, "AA|#ee##ee#"); 2614 free(s); 2615 // NULL new delimiter, one time: same as empty delimiter 2616 setValO(self, "AA#ee##ee#"); 2617 r = icReplaceCharSO(self, '#',NULL,1); 2618 ck_assert_ptr_ne(r, null); 2619 s = toStringO(r); 2620 ck_assert_str_eq(s, "AAee##ee#"); 2621 free(s); 2622 // empty string 2623 setValO(self, ""); 2624 r = icReplaceCharSO(self, '#',NULL,1); 2625 ck_assert_ptr_ne(r, null); 2626 s = toStringO(r); 2627 ck_assert_str_eq(s, ""); 2628 free(s); 2629 // empty old delimiter 2630 setValO(self, "qwe"); 2631 ck_assert_ptr_eq(icReplaceCharSO(self, 0,"|",1), NULL); 2632 // NULL string 2633 freeO(self); 2634 ck_assert_ptr_eq(icReplaceCharSO(self, '#',"|",1), NULL); 2635 terminateO(self); 2636 2637 } 2638 2639 2640 void icReplaceSCharSmallStringT(CuTest *tc UNUSED) { 2641 2642 smallStringt* r; 2643 smallStringt *self = allocG(""); 2644 2645 // replace string, multiple character new delimeter 2646 setValO(self, "BeebeeBad"); 2647 r = icReplaceSCharO(self, "b",'^',0); 2648 ck_assert_ptr_ne(r, null); 2649 char *s = toStringO(r); 2650 ck_assert_str_eq(s, "^ee^ee^ad"); 2651 free(s); 2652 // replace string, multiple character old delimeter 2653 setValO(self, "AA##ee##ee#"); 2654 r = icReplaceSCharO(self, "##",'|',0); 2655 ck_assert_ptr_ne(r, null); 2656 s = toStringO(r); 2657 ck_assert_str_eq(s, "AA|ee|ee#"); 2658 free(s); 2659 // replace string empty char, multiple character old delimeter 2660 setValO(self, "AA##ee##ee#"); 2661 r = icReplaceSCharO(self, "##", 0,0); 2662 ck_assert_ptr_ne(r, null); 2663 s = toStringO(r); 2664 ck_assert_str_eq(s, "AAeeee#"); 2665 free(s); 2666 // replace one time at the start of string 2667 setValO(self, "#ee#ee#ad"); 2668 r = icReplaceSCharO(self, "#",'^',1); 2669 ck_assert_ptr_ne(r, null); 2670 s = toStringO(r); 2671 ck_assert_str_eq(s, "^ee#ee#ad"); 2672 free(s); 2673 // replace one time 2674 setValO(self, "AA##ee##ee#"); 2675 r = icReplaceSCharO(self, "##",'|',1); 2676 ck_assert_ptr_ne(r, null); 2677 s = toStringO(r); 2678 ck_assert_str_eq(s, "AA|ee##ee#"); 2679 free(s); 2680 // empty string 2681 setValO(self, ""); 2682 r = icReplaceSCharO(self, "##",0,1); 2683 ck_assert_ptr_ne(r, null); 2684 s = toStringO(r); 2685 ck_assert_str_eq(s, ""); 2686 free(s); 2687 // empty old delimiter 2688 setValO(self, "qwe"); 2689 ck_assert_ptr_eq(icReplaceSCharO(self, "",'|',1), NULL); 2690 // NULL old delimiter 2691 ck_assert_ptr_eq(icReplaceSCharO(self, NULL,'|',1), NULL); 2692 // NULL string 2693 freeO(self); 2694 ck_assert_ptr_eq(icReplaceSCharO(self, "##",'|',1), NULL); 2695 terminateO(self); 2696 2697 } 2698 2699 2700 void icReplaceCharCharSmallStringT(CuTest *tc UNUSED) { 2701 2702 smallStringt* r; 2703 smallStringt *self = allocG(""); 2704 2705 // replace string, multiple character new delimeter 2706 setValO(self, "beeBeebad"); 2707 r = icReplaceCharCharO(self, 'b','^', 0); 2708 ck_assert_ptr_ne(r, null); 2709 char *s = toStringO(r); 2710 ck_assert_str_eq(s, "^ee^ee^ad"); 2711 free(s); 2712 // replace one time at the start of string 2713 setValO(self, "#ee#ee#ad"); 2714 r = icReplaceCharCharO(self, '#','^',1); 2715 ck_assert_ptr_ne(r, null); 2716 s = toStringO(r); 2717 ck_assert_str_eq(s, "^ee#ee#ad"); 2718 free(s); 2719 // replace one time 2720 setValO(self, "AA#ee##ee#"); 2721 r = icReplaceCharCharO(self, '#','|',1); 2722 ck_assert_ptr_ne(r, null); 2723 s = toStringO(r); 2724 ck_assert_str_eq(s, "AA|ee##ee#"); 2725 free(s); 2726 // empty string 2727 setValO(self, ""); 2728 r = icReplaceCharCharO(self, '#','^',1); 2729 ck_assert_ptr_ne(r, null); 2730 s = toStringO(r); 2731 ck_assert_str_eq(s, ""); 2732 free(s); 2733 // empty old delimiter 2734 setValO(self, "qwe"); 2735 ck_assert_ptr_eq(icReplaceCharCharO(self, 0,'|',1), NULL); 2736 // NULL string 2737 freeO(self); 2738 ck_assert_ptr_eq(icReplaceCharCharO(self, '#','|',1), NULL); 2739 terminateO(self); 2740 2741 } 2742 2743 2744 void icReplaceSmallJsonSmallJsonSmallStringT(CuTest *tc UNUSED) { 2745 2746 smallStringt* r; 2747 smallStringt *self = allocG("BeebeeBad"); 2748 smallJsont *olds = allocSmallJson(); 2749 smallJsont *news = allocSmallJson(); 2750 2751 // replace string, multiple character new delimeter 2752 freeO(olds); 2753 freeO(news); 2754 setTopSO(olds, "B"); 2755 setTopSO(news, "^^"); 2756 r = icReplaceSmallJsonSmallJsonO(self, olds, news, 0); 2757 ck_assert_ptr_ne(r, null); 2758 char *s = toStringO(r); 2759 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2760 free(s); 2761 // replace string, multiple character old delimeter 2762 setValO(self, "AA##ee##ee#"); 2763 freeO(olds); 2764 freeO(news); 2765 setTopSO(olds, "##"); 2766 setTopSO(news, "|"); 2767 r = icReplaceSmallJsonSmallJsonO(self, olds, news, 0); 2768 ck_assert_ptr_ne(r, null); 2769 s = toStringO(r); 2770 ck_assert_str_eq(s, "AA|ee|ee#"); 2771 free(s); 2772 // replace one time at the start of string 2773 setValO(self, "#ee#ee#ad"); 2774 freeO(olds); 2775 freeO(news); 2776 setTopSO(olds, "#"); 2777 setTopSO(news, "^^"); 2778 r = icReplaceSmallJsonSmallJsonO(self, olds, news,1); 2779 ck_assert_ptr_ne(r, null); 2780 s = toStringO(r); 2781 ck_assert_str_eq(s, "^^ee#ee#ad"); 2782 free(s); 2783 // replace one time 2784 setValO(self, "AA##ee##ee#"); 2785 freeO(olds); 2786 freeO(news); 2787 setTopSO(olds, "##"); 2788 setTopSO(news, "|"); 2789 r = icReplaceSmallJsonSmallJsonO(self, olds, news,1); 2790 ck_assert_ptr_ne(r, null); 2791 s = toStringO(r); 2792 ck_assert_str_eq(s, "AA|ee##ee#"); 2793 free(s); 2794 // NULL new delimiter, one time: same as empty delimiter 2795 setValO(self, "AA##ee##ee#"); 2796 freeO(olds); 2797 setTopSO(olds, "##"); 2798 r = icReplaceSmallJsonSmallJsonO(self, olds, NULL,1); 2799 ck_assert_ptr_ne(r, null); 2800 s = toStringO(r); 2801 ck_assert_str_eq(s, "AAee##ee#"); 2802 free(s); 2803 // non json string 2804 freeO(olds); 2805 setTopIntO(olds, 1); 2806 r = icReplaceSmallJsonSmallJsonO(self, olds, news,1); 2807 ck_assert_ptr_eq(r, null); 2808 freeO(olds); 2809 freeO(news); 2810 setTopSO(olds, "e"); 2811 setTopIntO(news, 1); 2812 r = icReplaceSmallJsonSmallJsonO(self, olds, news,1); 2813 ck_assert_ptr_eq(r, null); 2814 // non json object 2815 terminateO(olds); 2816 olds = (smallJsont*) allocSmallInt(1); 2817 r = icReplaceSmallJsonSmallJsonO(self, olds, news,1); 2818 ck_assert_ptr_eq(r, null); 2819 terminateO(olds); 2820 terminateO(news); 2821 olds = allocSmallJson(); 2822 news = (smallJsont*) allocSmallInt(1); 2823 r = icReplaceSmallJsonSmallJsonO(self, olds, news,1); 2824 ck_assert_ptr_eq(r, null); 2825 terminateO(news); 2826 news = allocSmallJson(); 2827 // empty string 2828 setValO(self, ""); 2829 freeO(olds); 2830 setTopSO(olds, "##"); 2831 r = icReplaceSmallJsonSmallJsonO(self, olds, NULL,1); 2832 ck_assert_ptr_ne(r, null); 2833 s = toStringO(r); 2834 ck_assert_str_eq(s, ""); 2835 free(s); 2836 // empty old delimiter 2837 setValO(self, "qwe"); 2838 freeO(olds); 2839 freeO(news); 2840 setTopSO(olds, ""); 2841 setTopSO(news, "|"); 2842 ck_assert_ptr_eq(icReplaceSmallJsonSmallJsonO(self, olds, news,1), NULL); 2843 // NULL old delimiter 2844 ck_assert_ptr_eq(icReplaceSmallJsonSmallJsonO(self, NULL, news,1), NULL); 2845 // NULL string 2846 freeO(self); 2847 ck_assert_ptr_eq(icReplaceSmallJsonSmallJsonO(self, olds, news,1), NULL); 2848 terminateO(olds); 2849 terminateO(news); 2850 terminateO(self); 2851 2852 } 2853 2854 2855 void icReplaceSmallJsonSmallStringSmallStringT(CuTest *tc UNUSED) { 2856 2857 smallStringt* r; 2858 smallStringt *self = allocG("BeebeeBad"); 2859 smallJsont *olds = allocSmallJson(); 2860 smallStringt *news = allocSmallString(""); 2861 2862 // replace string, multiple character new delimeter 2863 freeO(olds); 2864 setTopSO(olds, "B"); 2865 setValO(news, "^^"); 2866 r = icReplaceSmallJsonSmallStringO(self, olds, news, 0); 2867 ck_assert_ptr_ne(r, null); 2868 char *s = toStringO(r); 2869 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2870 free(s); 2871 // replace string, multiple character old delimeter 2872 setValO(self, "AA##ee##ee#"); 2873 freeO(olds); 2874 setTopSO(olds, "##"); 2875 setValO(news, "|"); 2876 r = icReplaceSmallJsonSmallStringO(self, olds, news, 0); 2877 ck_assert_ptr_ne(r, null); 2878 s = toStringO(r); 2879 ck_assert_str_eq(s, "AA|ee|ee#"); 2880 free(s); 2881 // replace one time at the start of string 2882 setValO(self, "#ee#ee#ad"); 2883 freeO(olds); 2884 setTopSO(olds, "#"); 2885 setValO(news, "^^"); 2886 r = icReplaceSmallJsonSmallStringO(self, olds, news,1); 2887 ck_assert_ptr_ne(r, null); 2888 s = toStringO(r); 2889 ck_assert_str_eq(s, "^^ee#ee#ad"); 2890 free(s); 2891 // replace one time 2892 setValO(self, "AA##ee##ee#"); 2893 freeO(olds); 2894 setTopSO(olds, "##"); 2895 setValO(news, "|"); 2896 r = icReplaceSmallJsonSmallStringO(self, olds, news,1); 2897 ck_assert_ptr_ne(r, null); 2898 s = toStringO(r); 2899 ck_assert_str_eq(s, "AA|ee##ee#"); 2900 free(s); 2901 // NULL new delimiter, one time: same as empty delimiter 2902 setValO(self, "AA##ee##ee#"); 2903 freeO(olds); 2904 setTopSO(olds, "##"); 2905 r = icReplaceSmallJsonSmallStringO(self, olds, NULL,1); 2906 ck_assert_ptr_ne(r, null); 2907 s = toStringO(r); 2908 ck_assert_str_eq(s, "AAee##ee#"); 2909 free(s); 2910 // non json string 2911 freeO(olds); 2912 setTopIntO(olds, 1); 2913 r = icReplaceSmallJsonSmallStringO(self, olds, news,1); 2914 ck_assert_ptr_eq(r, null); 2915 // non json object 2916 terminateO(olds); 2917 olds = (smallJsont*) allocSmallInt(1); 2918 r = icReplaceSmallJsonSmallStringO(self, olds, news,1); 2919 ck_assert_ptr_eq(r, null); 2920 terminateO(olds); 2921 terminateO(news); 2922 olds = allocSmallJson(); 2923 news = (smallStringt*) allocSmallInt(1); 2924 r = icReplaceSmallJsonSmallStringO(self, olds, news,1); 2925 ck_assert_ptr_eq(r, null); 2926 terminateO(news); 2927 news = allocSmallString(""); 2928 // empty string 2929 setValO(self, ""); 2930 freeO(olds); 2931 setTopSO(olds, "##"); 2932 r = icReplaceSmallJsonSmallStringO(self, olds, NULL,1); 2933 ck_assert_ptr_ne(r, null); 2934 s = toStringO(r); 2935 ck_assert_str_eq(s, ""); 2936 free(s); 2937 // empty old delimiter 2938 setValO(self, "qwe"); 2939 freeO(olds); 2940 setTopSO(olds, ""); 2941 setValO(news, "|"); 2942 ck_assert_ptr_eq(icReplaceSmallJsonSmallStringO(self, olds, news,1), NULL); 2943 // NULL old delimiter 2944 ck_assert_ptr_eq(icReplaceSmallJsonSmallStringO(self, NULL, news,1), NULL); 2945 // NULL string 2946 freeO(self); 2947 ck_assert_ptr_eq(icReplaceSmallJsonSmallStringO(self, olds, news,1), NULL); 2948 terminateO(olds); 2949 terminateO(news); 2950 terminateO(self); 2951 2952 } 2953 2954 2955 void icReplaceSmallJsonSSmallStringT(CuTest *tc UNUSED) { 2956 2957 smallStringt* r; 2958 smallStringt *self = allocG("BeebeeBad"); 2959 smallJsont *olds = allocSmallJson(); 2960 const char *news; 2961 2962 // replace string, multiple character new delimeter 2963 freeO(olds); 2964 setTopSO(olds, "b"); 2965 news = "^^"; 2966 r = icReplaceSmallJsonSO(self, olds, news, 0); 2967 ck_assert_ptr_ne(r, null); 2968 char *s = toStringO(r); 2969 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 2970 free(s); 2971 // replace string, multiple character old delimeter 2972 setValO(self, "AA##ee##ee#"); 2973 freeO(olds); 2974 setTopSO(olds, "##"); 2975 news = "|"; 2976 r = icReplaceSmallJsonSO(self, olds, news, 0); 2977 ck_assert_ptr_ne(r, null); 2978 s = toStringO(r); 2979 ck_assert_str_eq(s, "AA|ee|ee#"); 2980 free(s); 2981 // replace one time at the start of string 2982 setValO(self, "#ee#ee#ad"); 2983 freeO(olds); 2984 setTopSO(olds, "#"); 2985 news = "^^"; 2986 r = icReplaceSmallJsonSO(self, olds, news,1); 2987 ck_assert_ptr_ne(r, null); 2988 s = toStringO(r); 2989 ck_assert_str_eq(s, "^^ee#ee#ad"); 2990 free(s); 2991 // replace one time 2992 setValO(self, "AA##ee##ee#"); 2993 freeO(olds); 2994 setTopSO(olds, "##"); 2995 news = "|"; 2996 r = icReplaceSmallJsonSO(self, olds, news,1); 2997 ck_assert_ptr_ne(r, null); 2998 s = toStringO(r); 2999 ck_assert_str_eq(s, "AA|ee##ee#"); 3000 free(s); 3001 // NULL new delimiter, one time: same as empty delimiter 3002 setValO(self, "AA##ee##ee#"); 3003 freeO(olds); 3004 setTopSO(olds, "##"); 3005 r = icReplaceSmallJsonSO(self, olds, NULL,1); 3006 ck_assert_ptr_ne(r, null); 3007 s = toStringO(r); 3008 ck_assert_str_eq(s, "AAee##ee#"); 3009 free(s); 3010 // non json string 3011 freeO(olds); 3012 setTopIntO(olds, 1); 3013 r = icReplaceSmallJsonSO(self, olds, news,1); 3014 ck_assert_ptr_eq(r, null); 3015 // non json object 3016 terminateO(olds); 3017 olds = (smallJsont*) allocSmallInt(1); 3018 r = icReplaceSmallJsonSO(self, olds, news,1); 3019 ck_assert_ptr_eq(r, null); 3020 terminateO(olds); 3021 // empty string 3022 olds = allocSmallJson(); 3023 setValO(self, ""); 3024 setTopSO(olds, "##"); 3025 r = icReplaceSmallJsonSO(self, olds, NULL,1); 3026 ck_assert_ptr_ne(r, null); 3027 s = toStringO(r); 3028 ck_assert_str_eq(s, ""); 3029 free(s); 3030 // empty old delimiter 3031 setValO(self, "qwe"); 3032 freeO(olds); 3033 setTopSO(olds, ""); 3034 news = "|"; 3035 ck_assert_ptr_eq(icReplaceSmallJsonSO(self, olds, news,1), NULL); 3036 // NULL old delimiter 3037 ck_assert_ptr_eq(icReplaceSmallJsonSO(self, NULL, news,1), NULL); 3038 // NULL string 3039 freeO(self); 3040 ck_assert_ptr_eq(icReplaceSmallJsonSO(self, olds, news,1), NULL); 3041 terminateO(olds); 3042 terminateO(self); 3043 3044 } 3045 3046 3047 void icReplaceSmallJsonCharSmallStringT(CuTest *tc UNUSED) { 3048 3049 smallStringt* r; 3050 smallStringt *self = allocG("beeBeebad"); 3051 smallJsont *olds = allocSmallJson(); 3052 char news; 3053 3054 // replace string, multiple character new delimeter 3055 freeO(olds); 3056 setTopSO(olds, "B"); 3057 news = '^'; 3058 r = icReplaceSmallJsonCharO(self, olds, news, 0); 3059 ck_assert_ptr_ne(r, null); 3060 char *s = toStringO(r); 3061 ck_assert_str_eq(s, "^ee^ee^ad"); 3062 free(s); 3063 // replace string, multiple character old delimeter 3064 setValO(self, "AA##ee##ee#"); 3065 freeO(olds); 3066 setTopSO(olds, "##"); 3067 news = '|'; 3068 r = icReplaceSmallJsonCharO(self, olds, news, 0); 3069 ck_assert_ptr_ne(r, null); 3070 s = toStringO(r); 3071 ck_assert_str_eq(s, "AA|ee|ee#"); 3072 free(s); 3073 // replace one time at the start of string 3074 setValO(self, "#ee#ee#ad"); 3075 freeO(olds); 3076 setTopSO(olds, "#"); 3077 news = '^'; 3078 r = icReplaceSmallJsonCharO(self, olds, news,1); 3079 ck_assert_ptr_ne(r, null); 3080 s = toStringO(r); 3081 ck_assert_str_eq(s, "^ee#ee#ad"); 3082 free(s); 3083 // replace one time 3084 setValO(self, "AA##ee##ee#"); 3085 freeO(olds); 3086 setTopSO(olds, "##"); 3087 news = '|'; 3088 r = icReplaceSmallJsonCharO(self, olds, news,1); 3089 ck_assert_ptr_ne(r, null); 3090 s = toStringO(r); 3091 ck_assert_str_eq(s, "AA|ee##ee#"); 3092 free(s); 3093 // non json string 3094 setValO(self, "AA##ee##ee#"); 3095 freeO(olds); 3096 setTopIntO(olds, 1); 3097 r = icReplaceSmallJsonCharO(self, olds, news,1); 3098 ck_assert_ptr_eq(r, null); 3099 // non json object 3100 terminateO(olds); 3101 olds = (smallJsont*) allocSmallInt(1); 3102 r = icReplaceSmallJsonCharO(self, olds, news,1); 3103 ck_assert_ptr_eq(r, null); 3104 terminateO(olds); 3105 // empty string 3106 olds = allocSmallJson(); 3107 setValO(self, ""); 3108 setTopSO(olds, "##"); 3109 r = icReplaceSmallJsonCharO(self, olds, news,1); 3110 ck_assert_ptr_ne(r, null); 3111 s = toStringO(r); 3112 ck_assert_str_eq(s, ""); 3113 free(s); 3114 // empty old delimiter 3115 setValO(self, "qwe"); 3116 freeO(olds); 3117 setTopSO(olds, ""); 3118 news = '|'; 3119 ck_assert_ptr_eq(icReplaceSmallJsonCharO(self, olds, news,1), NULL); 3120 // NULL old delimiter 3121 ck_assert_ptr_eq(icReplaceSmallJsonCharO(self, NULL, news,1), NULL); 3122 // NULL string 3123 freeO(self); 3124 ck_assert_ptr_eq(icReplaceSmallJsonCharO(self, olds, news,1), NULL); 3125 terminateO(olds); 3126 terminateO(self); 3127 3128 } 3129 3130 3131 void icReplaceSmallStringSmallJsonSmallStringT(CuTest *tc UNUSED) { 3132 3133 smallStringt* r; 3134 smallStringt *self = allocG("BeeBeeBad"); 3135 smallStringt *olds = allocSmallString(""); 3136 smallJsont *news = allocSmallJson(); 3137 3138 // replace string, multiple character new delimeter 3139 freeO(news); 3140 setValO(olds, "b"); 3141 setTopSO(news, "^^"); 3142 r = self->f->icReplaceSmallStringSmallJson(self, olds, news, 0); 3143 ck_assert_ptr_ne(r, null); 3144 char *s = toStringO(r); 3145 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 3146 free(s); 3147 // replace string, multiple character old delimeter 3148 setValO(self, "AA##ee##ee#"); 3149 freeO(news); 3150 setValO(olds, "##"); 3151 setTopSO(news, "|"); 3152 r = self->f->icReplaceSmallStringSmallJson(self, olds, news, 0); 3153 ck_assert_ptr_ne(r, null); 3154 s = toStringO(r); 3155 ck_assert_str_eq(s, "AA|ee|ee#"); 3156 free(s); 3157 // replace one time at the start of string 3158 setValO(self, "#ee#ee#ad"); 3159 freeO(news); 3160 setValO(olds, "#"); 3161 setTopSO(news, "^^"); 3162 r = self->f->icReplaceSmallStringSmallJson(self, olds, news,1); 3163 ck_assert_ptr_ne(r, null); 3164 s = toStringO(r); 3165 ck_assert_str_eq(s, "^^ee#ee#ad"); 3166 free(s); 3167 // replace one time 3168 setValO(self, "AA##ee##ee#"); 3169 freeO(news); 3170 setValO(olds, "##"); 3171 setTopSO(news, "|"); 3172 r = self->f->icReplaceSmallStringSmallJson(self, olds, news,1); 3173 ck_assert_ptr_ne(r, null); 3174 s = toStringO(r); 3175 ck_assert_str_eq(s, "AA|ee##ee#"); 3176 free(s); 3177 // NULL new delimiter, one time: same as empty delimiter 3178 setValO(self, "AA##ee##ee#"); 3179 setValO(olds, "##"); 3180 r = self->f->icReplaceSmallStringSmallJson(self, olds, NULL,1); 3181 ck_assert_ptr_ne(r, null); 3182 s = toStringO(r); 3183 ck_assert_str_eq(s, "AAee##ee#"); 3184 free(s); 3185 // non json string 3186 freeO(news); 3187 setTopIntO(news, 1); 3188 r = self->f->icReplaceSmallStringSmallJson(self, olds, news,1); 3189 ck_assert_ptr_eq(r, null); 3190 // non json object 3191 terminateO(olds); 3192 olds = (smallStringt*) allocSmallInt(1); 3193 r = self->f->icReplaceSmallStringSmallJson(self, olds, news,1); 3194 ck_assert_ptr_eq(r, null); 3195 terminateO(olds); 3196 terminateO(news); 3197 olds = allocSmallString(""); 3198 news = (smallJsont*) allocSmallInt(1); 3199 r = self->f->icReplaceSmallStringSmallJson(self, olds, news,1); 3200 ck_assert_ptr_eq(r, null); 3201 terminateO(news); 3202 news = allocSmallJson(); 3203 // empty string 3204 setValO(self, ""); 3205 setValO(olds, "##"); 3206 r = self->f->icReplaceSmallStringSmallJson(self, olds, NULL,1); 3207 ck_assert_ptr_ne(r, null); 3208 s = toStringO(r); 3209 ck_assert_str_eq(s, ""); 3210 free(s); 3211 // empty old delimiter 3212 setValO(self, "qwe"); 3213 freeO(news); 3214 setValO(olds, ""); 3215 setTopSO(news, "|"); 3216 ck_assert_ptr_eq(self->f->icReplaceSmallStringSmallJson(self, olds, news,1), NULL); 3217 // NULL old delimiter 3218 ck_assert_ptr_eq(self->f->icReplaceSmallStringSmallJson(self, NULL, news,1), NULL); 3219 // NULL string 3220 freeO(self); 3221 ck_assert_ptr_eq(self->f->icReplaceSmallStringSmallJson(self, olds, news,1), NULL); 3222 terminateO(olds); 3223 terminateO(news); 3224 terminateO(self); 3225 3226 } 3227 3228 3229 void icReplaceSmallStringSmallStringSmallStringT(CuTest *tc UNUSED) { 3230 3231 smallStringt* r; 3232 smallStringt *self = allocG("beebeebad"); 3233 smallStringt *olds = allocSmallString(""); 3234 smallStringt *news = allocSmallString(""); 3235 3236 // replace string, multiple character new delimeter 3237 setValO(olds, "B"); 3238 setValO(news, "^^"); 3239 r = icReplaceSmallStringSmallStringO(self, olds, news, 0); 3240 ck_assert_ptr_ne(r, null); 3241 char *s = toStringO(r); 3242 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 3243 free(s); 3244 // replace string, multiple character old delimeter 3245 setValO(self, "AA##ee##ee#"); 3246 setValO(olds, "##"); 3247 setValO(news, "|"); 3248 r = icReplaceSmallStringSmallStringO(self, olds, news, 0); 3249 ck_assert_ptr_ne(r, null); 3250 s = toStringO(r); 3251 ck_assert_str_eq(s, "AA|ee|ee#"); 3252 free(s); 3253 // replace one time at the start of string 3254 setValO(self, "#ee#ee#ad"); 3255 setValO(olds, "#"); 3256 setValO(news, "^^"); 3257 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 3258 ck_assert_ptr_ne(r, null); 3259 s = toStringO(r); 3260 ck_assert_str_eq(s, "^^ee#ee#ad"); 3261 free(s); 3262 // replace one time 3263 setValO(self, "AA##ee##ee#"); 3264 setValO(olds, "##"); 3265 setValO(news, "|"); 3266 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 3267 ck_assert_ptr_ne(r, null); 3268 s = toStringO(r); 3269 ck_assert_str_eq(s, "AA|ee##ee#"); 3270 free(s); 3271 // NULL new delimiter, one time: same as empty delimiter 3272 setValO(self, "AA##ee##ee#"); 3273 setValO(olds, "##"); 3274 r = icReplaceSmallStringSmallStringO(self, olds, NULL,1); 3275 ck_assert_ptr_ne(r, null); 3276 s = toStringO(r); 3277 ck_assert_str_eq(s, "AAee##ee#"); 3278 free(s); 3279 // non smallString object 3280 terminateO(olds); 3281 olds = (smallStringt*) allocSmallInt(1); 3282 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 3283 ck_assert_ptr_eq(r, null); 3284 terminateO(olds); 3285 terminateO(news); 3286 olds = allocSmallString(""); 3287 news = (smallStringt*) allocSmallInt(1); 3288 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 3289 ck_assert_ptr_eq(r, null); 3290 terminateO(news); 3291 news = allocSmallString(""); 3292 // empty string 3293 setValO(self, ""); 3294 setValO(olds, "##"); 3295 r = icReplaceSmallStringSmallStringO(self, olds, NULL,1); 3296 ck_assert_ptr_ne(r, null); 3297 s = toStringO(r); 3298 ck_assert_str_eq(s, ""); 3299 free(s); 3300 // empty old delimiter 3301 setValO(self, "qwe"); 3302 setValO(olds, ""); 3303 setValO(news, "|"); 3304 ck_assert_ptr_eq(icReplaceSmallStringSmallStringO(self, olds, news,1), NULL); 3305 // NULL old delimiter 3306 ck_assert_ptr_eq(icReplaceSmallStringSmallStringO(self, NULL, news,1), NULL); 3307 // NULL string 3308 freeO(self); 3309 ck_assert_ptr_eq(icReplaceSmallStringSmallStringO(self, olds, news,1), NULL); 3310 terminateO(olds); 3311 terminateO(news); 3312 terminateO(self); 3313 3314 } 3315 3316 3317 void icReplaceSmallStringSSmallStringT(CuTest *tc UNUSED) { 3318 3319 smallStringt* r; 3320 smallStringt *self = allocG("beebeebad"); 3321 smallStringt *olds = allocSmallString(""); 3322 const char *news; 3323 3324 // replace string, multiple character new delimeter 3325 setValO(olds, "B"); 3326 news = "^^"; 3327 r = icReplaceSmallStringSO(self, olds, news, 0); 3328 ck_assert_ptr_ne(r, null); 3329 char *s = toStringO(r); 3330 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 3331 free(s); 3332 // replace string, multiple character old delimeter 3333 setValO(self, "AA##ee##ee#"); 3334 setValO(olds, "##"); 3335 news = "|"; 3336 r = icReplaceSmallStringSO(self, olds, news, 0); 3337 ck_assert_ptr_ne(r, null); 3338 s = toStringO(r); 3339 ck_assert_str_eq(s, "AA|ee|ee#"); 3340 free(s); 3341 // replace one time at the start of string 3342 setValO(self, "#ee#ee#ad"); 3343 setValO(olds, "#"); 3344 news = "^^"; 3345 r = icReplaceSmallStringSO(self, olds, news,1); 3346 ck_assert_ptr_ne(r, null); 3347 s = toStringO(r); 3348 ck_assert_str_eq(s, "^^ee#ee#ad"); 3349 free(s); 3350 // replace one time 3351 setValO(self, "AA##ee##ee#"); 3352 setValO(olds, "##"); 3353 news = "|"; 3354 r = icReplaceSmallStringSO(self, olds, news,1); 3355 ck_assert_ptr_ne(r, null); 3356 s = toStringO(r); 3357 ck_assert_str_eq(s, "AA|ee##ee#"); 3358 free(s); 3359 // NULL new delimiter, one time: same as empty delimiter 3360 setValO(self, "AA##ee##ee#"); 3361 setValO(olds, "##"); 3362 r = icReplaceSmallStringSO(self, olds, NULL,1); 3363 ck_assert_ptr_ne(r, null); 3364 s = toStringO(r); 3365 ck_assert_str_eq(s, "AAee##ee#"); 3366 free(s); 3367 // non smallString object 3368 terminateO(olds); 3369 olds = (smallStringt*) allocSmallInt(1); 3370 r = icReplaceSmallStringSO(self, olds, news,1); 3371 ck_assert_ptr_eq(r, null); 3372 terminateO(olds); 3373 olds = allocSmallString(""); 3374 // empty string 3375 setValO(self, ""); 3376 setValO(olds, "##"); 3377 r = icReplaceSmallStringSO(self, olds, NULL,1); 3378 ck_assert_ptr_ne(r, null); 3379 s = toStringO(r); 3380 ck_assert_str_eq(s, ""); 3381 free(s); 3382 // empty old delimiter 3383 setValO(self, "qwe"); 3384 setValO(olds, ""); 3385 news = "|"; 3386 ck_assert_ptr_eq(icReplaceSmallStringSO(self, olds, news,1), NULL); 3387 // NULL old delimiter 3388 ck_assert_ptr_eq(icReplaceSmallStringSO(self, NULL, news,1), NULL); 3389 // NULL string 3390 freeO(self); 3391 ck_assert_ptr_eq(icReplaceSmallStringSO(self, olds, news,1), NULL); 3392 terminateO(olds); 3393 terminateO(self); 3394 3395 } 3396 3397 3398 void icReplaceSmallStringCharSmallStringT(CuTest *tc UNUSED) { 3399 3400 smallStringt* r; 3401 smallStringt *self = allocG("beebeebad"); 3402 smallStringt *olds = allocSmallString(""); 3403 char news; 3404 3405 // replace string, multiple character new delimeter 3406 setValO(olds, "B"); 3407 news = '^'; 3408 r = icReplaceSmallStringCharO(self, olds, news, 0); 3409 ck_assert_ptr_ne(r, null); 3410 char *s = toStringO(r); 3411 ck_assert_str_eq(s, "^ee^ee^ad"); 3412 free(s); 3413 // replace string, multiple character old delimeter 3414 setValO(self, "AA##ee##ee#"); 3415 setValO(olds, "##"); 3416 news = '|'; 3417 r = icReplaceSmallStringCharO(self, olds, news, 0); 3418 ck_assert_ptr_ne(r, null); 3419 s = toStringO(r); 3420 ck_assert_str_eq(s, "AA|ee|ee#"); 3421 free(s); 3422 // replace one time at the start of string 3423 setValO(self, "#ee#ee#ad"); 3424 setValO(olds, "#"); 3425 news = '^'; 3426 r = icReplaceSmallStringCharO(self, olds, news,1); 3427 ck_assert_ptr_ne(r, null); 3428 s = toStringO(r); 3429 ck_assert_str_eq(s, "^ee#ee#ad"); 3430 free(s); 3431 // replace one time 3432 setValO(self, "AA##ee##ee#"); 3433 setValO(olds, "##"); 3434 news = '|'; 3435 r = icReplaceSmallStringCharO(self, olds, news,1); 3436 ck_assert_ptr_ne(r, null); 3437 s = toStringO(r); 3438 ck_assert_str_eq(s, "AA|ee##ee#"); 3439 free(s); 3440 // non smallString object 3441 terminateO(olds); 3442 olds = (smallStringt*) allocSmallInt(1); 3443 r = icReplaceSmallStringCharO(self, olds, news,1); 3444 ck_assert_ptr_eq(r, null); 3445 terminateO(olds); 3446 olds = allocSmallString(""); 3447 // empty string 3448 setValO(self, ""); 3449 setValO(olds, "##"); 3450 r = icReplaceSmallStringCharO(self, olds, news,1); 3451 ck_assert_ptr_ne(r, null); 3452 s = toStringO(r); 3453 ck_assert_str_eq(s, ""); 3454 free(s); 3455 // empty old delimiter 3456 setValO(self, "qwe"); 3457 setValO(olds, ""); 3458 news = '|'; 3459 ck_assert_ptr_eq(icReplaceSmallStringCharO(self, olds, news,1), NULL); 3460 // NULL old delimiter 3461 ck_assert_ptr_eq(icReplaceSmallStringCharO(self, NULL, news,1), NULL); 3462 // NULL string 3463 freeO(self); 3464 ck_assert_ptr_eq(icReplaceSmallStringCharO(self, olds, news,1), NULL); 3465 terminateO(olds); 3466 terminateO(self); 3467 3468 } 3469 3470 3471 void icReplaceSSmallJsonSmallStringT(CuTest *tc UNUSED) { 3472 3473 smallStringt* r; 3474 smallStringt *self = allocG("beebeebad"); 3475 const char *olds; 3476 smallJsont *news = allocSmallJson(); 3477 3478 // replace string, multiple character new delimeter 3479 freeO(news); 3480 olds = "B"; 3481 setTopSO(news, "^^"); 3482 r = icReplaceSSmallJsonO(self, olds, news, 0); 3483 ck_assert_ptr_ne(r, null); 3484 char *s = toStringO(r); 3485 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 3486 free(s); 3487 // replace string, multiple character old delimeter 3488 setValO(self, "AA##ee##ee#"); 3489 freeO(news); 3490 olds = "##"; 3491 setTopSO(news, "|"); 3492 r = icReplaceSSmallJsonO(self, olds, news, 0); 3493 ck_assert_ptr_ne(r, null); 3494 s = toStringO(r); 3495 ck_assert_str_eq(s, "AA|ee|ee#"); 3496 free(s); 3497 // replace one time at the start of string 3498 setValO(self, "#ee#ee#ad"); 3499 freeO(news); 3500 olds = "#"; 3501 setTopSO(news, "^^"); 3502 r = icReplaceSSmallJsonO(self, olds, news,1); 3503 ck_assert_ptr_ne(r, null); 3504 s = toStringO(r); 3505 ck_assert_str_eq(s, "^^ee#ee#ad"); 3506 free(s); 3507 // replace one time 3508 setValO(self, "AA##ee##ee#"); 3509 freeO(news); 3510 olds = "##"; 3511 setTopSO(news, "|"); 3512 r = icReplaceSSmallJsonO(self, olds, news,1); 3513 ck_assert_ptr_ne(r, null); 3514 s = toStringO(r); 3515 ck_assert_str_eq(s, "AA|ee##ee#"); 3516 free(s); 3517 // NULL new delimiter, one time: same as empty delimiter 3518 setValO(self, "AA##ee##ee#"); 3519 olds = "##"; 3520 r = icReplaceSSmallJsonO(self, olds, NULL,1); 3521 ck_assert_ptr_ne(r, null); 3522 s = toStringO(r); 3523 ck_assert_str_eq(s, "AAee##ee#"); 3524 free(s); 3525 // non json string 3526 freeO(news); 3527 olds = "e"; 3528 setTopIntO(news, 1); 3529 r = icReplaceSSmallJsonO(self, olds, news,1); 3530 ck_assert_ptr_eq(r, null); 3531 // non json object 3532 terminateO(news); 3533 news = (smallJsont*) allocSmallInt(1); 3534 r = icReplaceSSmallJsonO(self, olds, news,1); 3535 ck_assert_ptr_eq(r, null); 3536 terminateO(news); 3537 news = allocSmallJson(); 3538 // empty string 3539 setValO(self, ""); 3540 olds = "##"; 3541 r = icReplaceSSmallJsonO(self, olds, NULL,1); 3542 ck_assert_ptr_ne(r, null); 3543 s = toStringO(r); 3544 ck_assert_str_eq(s, ""); 3545 free(s); 3546 // empty old delimiter 3547 setValO(self, "qwe"); 3548 freeO(news); 3549 olds = ""; 3550 setTopSO(news, "|"); 3551 ck_assert_ptr_eq(icReplaceSSmallJsonO(self, olds, news,1), NULL); 3552 // NULL old delimiter 3553 ck_assert_ptr_eq(icReplaceSSmallJsonO(self, NULL, news,1), NULL); 3554 // NULL string 3555 freeO(self); 3556 ck_assert_ptr_eq(icReplaceSSmallJsonO(self, olds, news,1), NULL); 3557 terminateO(news); 3558 terminateO(self); 3559 3560 } 3561 3562 3563 void icReplaceSSmallStringSmallStringT(CuTest *tc UNUSED) { 3564 3565 smallStringt* r; 3566 smallStringt *self = allocG("beebeebad"); 3567 const char *olds; 3568 smallStringt *news = allocSmallString(""); 3569 3570 // replace string, multiple character new delimeter 3571 olds = "B"; 3572 setValO(news, "^^"); 3573 r = icReplaceSSmallStringO(self, olds, news, 0); 3574 ck_assert_ptr_ne(r, null); 3575 char *s = toStringO(r); 3576 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 3577 free(s); 3578 // replace string, multiple character old delimeter 3579 setValO(self, "AA##ee##ee#"); 3580 olds = "##"; 3581 setValO(news, "|"); 3582 r = icReplaceSSmallStringO(self, olds, news, 0); 3583 ck_assert_ptr_ne(r, null); 3584 s = toStringO(r); 3585 ck_assert_str_eq(s, "AA|ee|ee#"); 3586 free(s); 3587 // replace one time at the start of string 3588 setValO(self, "#ee#ee#ad"); 3589 olds = "#"; 3590 setValO(news, "^^"); 3591 r = icReplaceSSmallStringO(self, olds, news,1); 3592 ck_assert_ptr_ne(r, null); 3593 s = toStringO(r); 3594 ck_assert_str_eq(s, "^^ee#ee#ad"); 3595 free(s); 3596 // replace one time 3597 setValO(self, "AA##ee##ee#"); 3598 olds = "##"; 3599 setValO(news, "|"); 3600 r = icReplaceSSmallStringO(self, olds, news,1); 3601 ck_assert_ptr_ne(r, null); 3602 s = toStringO(r); 3603 ck_assert_str_eq(s, "AA|ee##ee#"); 3604 free(s); 3605 // NULL new delimiter, one time: same as empty delimiter 3606 setValO(self, "AA##ee##ee#"); 3607 olds = "##"; 3608 r = icReplaceSSmallStringO(self, olds, NULL,1); 3609 ck_assert_ptr_ne(r, null); 3610 s = toStringO(r); 3611 ck_assert_str_eq(s, "AAee##ee#"); 3612 free(s); 3613 // non smallString object 3614 terminateO(news); 3615 news = (smallStringt*) allocSmallInt(1); 3616 r = icReplaceSSmallStringO(self, olds, news,1); 3617 ck_assert_ptr_eq(r, null); 3618 terminateO(news); 3619 news = allocSmallString(""); 3620 // empty string 3621 setValO(self, ""); 3622 olds = "##"; 3623 r = icReplaceSSmallStringO(self, olds, NULL,1); 3624 ck_assert_ptr_ne(r, null); 3625 s = toStringO(r); 3626 ck_assert_str_eq(s, ""); 3627 free(s); 3628 // empty old delimiter 3629 setValO(self, "qwe"); 3630 olds = ""; 3631 setValO(news, "|"); 3632 ck_assert_ptr_eq(icReplaceSSmallStringO(self, olds, news,1), NULL); 3633 // NULL old delimiter 3634 ck_assert_ptr_eq(icReplaceSSmallStringO(self, NULL, news,1), NULL); 3635 // NULL string 3636 freeO(self); 3637 ck_assert_ptr_eq(icReplaceSSmallStringO(self, olds, news,1), NULL); 3638 terminateO(news); 3639 terminateO(self); 3640 3641 } 3642 3643 3644 void icReplaceCharSmallJsonSmallStringT(CuTest *tc UNUSED) { 3645 3646 smallStringt* r; 3647 smallStringt *self = allocG("beebeebad"); 3648 char olds; 3649 smallJsont *news = allocSmallJson(); 3650 3651 // replace string, multiple character new delimeter 3652 freeO(news); 3653 olds = 'B'; 3654 setTopSO(news, "^^"); 3655 r = icReplaceCharSmallJsonO(self, olds, news, 0); 3656 ck_assert_ptr_ne(r, null); 3657 char *s = toStringO(r); 3658 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 3659 free(s); 3660 // replace string, multiple character old delimeter 3661 setValO(self, "AA#ee#ee"); 3662 freeO(news); 3663 olds = '#'; 3664 setTopSO(news, "|"); 3665 r = icReplaceCharSmallJsonO(self, olds, news, 0); 3666 ck_assert_ptr_ne(r, null); 3667 s = toStringO(r); 3668 ck_assert_str_eq(s, "AA|ee|ee"); 3669 free(s); 3670 // replace one time at the start of string 3671 setValO(self, "#ee#ee#ad"); 3672 freeO(news); 3673 olds = '#'; 3674 setTopSO(news, "^^"); 3675 r = icReplaceCharSmallJsonO(self, olds, news,1); 3676 ck_assert_ptr_ne(r, null); 3677 s = toStringO(r); 3678 ck_assert_str_eq(s, "^^ee#ee#ad"); 3679 free(s); 3680 // replace one time 3681 setValO(self, "AA#ee##ee#"); 3682 freeO(news); 3683 olds = '#'; 3684 setTopSO(news, "|"); 3685 r = icReplaceCharSmallJsonO(self, olds, news,1); 3686 ck_assert_ptr_ne(r, null); 3687 s = toStringO(r); 3688 ck_assert_str_eq(s, "AA|ee##ee#"); 3689 free(s); 3690 // NULL new delimiter, one time: same as empty delimiter 3691 setValO(self, "AA#ee##ee#"); 3692 olds = '#'; 3693 r = icReplaceCharSmallJsonO(self, olds, NULL,1); 3694 ck_assert_ptr_ne(r, null); 3695 s = toStringO(r); 3696 ck_assert_str_eq(s, "AAee##ee#"); 3697 free(s); 3698 // non json string 3699 freeO(news); 3700 olds = 'e'; 3701 setTopIntO(news, 1); 3702 r = icReplaceCharSmallJsonO(self, olds, news,1); 3703 ck_assert_ptr_eq(r, null); 3704 // non json object 3705 terminateO(news); 3706 news = (smallJsont*) allocSmallInt(1); 3707 r = icReplaceCharSmallJsonO(self, olds, news,1); 3708 ck_assert_ptr_eq(r, null); 3709 terminateO(news); 3710 news = allocSmallJson(); 3711 // empty string 3712 setValO(self, ""); 3713 olds = '#'; 3714 r = icReplaceCharSmallJsonO(self, olds, NULL,1); 3715 ck_assert_ptr_ne(r, null); 3716 s = toStringO(r); 3717 ck_assert_str_eq(s, ""); 3718 free(s); 3719 // NULL string 3720 freeO(self); 3721 freeO(news); 3722 setTopSO(news, "|"); 3723 ck_assert_ptr_eq(icReplaceCharSmallJsonO(self, olds, news,1), NULL); 3724 terminateO(news); 3725 terminateO(self); 3726 3727 } 3728 3729 3730 void icReplaceCharSmallStringSmallStringT(CuTest *tc UNUSED) { 3731 3732 smallStringt* r; 3733 smallStringt *self = allocG("beebeebad"); 3734 char olds; 3735 smallStringt *news = allocSmallString(""); 3736 3737 // replace string, multiple character new delimeter 3738 olds = 'B'; 3739 setValO(news, "^^"); 3740 r = icReplaceCharSmallStringO(self, olds, news, 0); 3741 ck_assert_ptr_ne(r, null); 3742 char *s = toStringO(r); 3743 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 3744 free(s); 3745 // replace string, multiple character old delimeter 3746 setValO(self, "AA#ee#ee"); 3747 olds = '#'; 3748 setValO(news, "|"); 3749 r = icReplaceCharSmallStringO(self, olds, news, 0); 3750 ck_assert_ptr_ne(r, null); 3751 s = toStringO(r); 3752 ck_assert_str_eq(s, "AA|ee|ee"); 3753 free(s); 3754 // replace one time at the start of string 3755 setValO(self, "#ee#ee#ad"); 3756 olds = '#'; 3757 setValO(news, "^^"); 3758 r = icReplaceCharSmallStringO(self, olds, news,1); 3759 ck_assert_ptr_ne(r, null); 3760 s = toStringO(r); 3761 ck_assert_str_eq(s, "^^ee#ee#ad"); 3762 free(s); 3763 // replace one time 3764 setValO(self, "AA#ee##ee#"); 3765 olds = '#'; 3766 setValO(news, "|"); 3767 r = icReplaceCharSmallStringO(self, olds, news,1); 3768 ck_assert_ptr_ne(r, null); 3769 s = toStringO(r); 3770 ck_assert_str_eq(s, "AA|ee##ee#"); 3771 free(s); 3772 // NULL new delimiter, one time: same as empty delimiter 3773 setValO(self, "AA#ee##ee#"); 3774 olds = '#'; 3775 r = icReplaceCharSmallStringO(self, olds, NULL,1); 3776 ck_assert_ptr_ne(r, null); 3777 s = toStringO(r); 3778 ck_assert_str_eq(s, "AAee##ee#"); 3779 free(s); 3780 // non smallString object 3781 terminateO(news); 3782 news = (smallStringt*) allocSmallInt(1); 3783 r = icReplaceCharSmallStringO(self, olds, news,1); 3784 ck_assert_ptr_eq(r, null); 3785 terminateO(news); 3786 news = allocSmallString(""); 3787 // empty string 3788 setValO(self, ""); 3789 olds = '#'; 3790 r = icReplaceCharSmallStringO(self, olds, NULL,1); 3791 ck_assert_ptr_ne(r, null); 3792 s = toStringO(r); 3793 ck_assert_str_eq(s, ""); 3794 free(s); 3795 // NULL string 3796 freeO(self); 3797 setValO(news, "|"); 3798 ck_assert_ptr_eq(icReplaceCharSmallStringO(self, olds, news,1), NULL); 3799 terminateO(news); 3800 terminateO(self); 3801 3802 } 3803 3804 3805 void icReplaceManySmallStringT(CuTest *tc UNUSED) { 3806 3807 smallStringt* r; 3808 smallStringt *self = allocG(""); 3809 3810 // replace string, multiple character new delimeter 3811 setValO(self, "beebeebad"); 3812 r = icReplaceManyO(self, "B","^^","aD","AD"); 3813 ck_assert_ptr_ne(r, null); 3814 char *s = toStringO(r); 3815 ck_assert_str_eq(s, "^^ee^^ee^^AD"); 3816 free(s); 3817 // replace string, empty new delimeter 3818 setValO(self, "#ee#ee#ad"); 3819 r = icReplaceManyO(self, "#","","ad","AD"); 3820 ck_assert_ptr_ne(r, null); 3821 s = toStringO(r); 3822 ck_assert_str_eq(s, "eeeeAD"); 3823 free(s); 3824 // not enough olds:news pairs 3825 setValO(self, "#ee#ee#ad"); 3826 r = icReplaceManyO(self, "#","","ad"); 3827 ck_assert_ptr_ne(r, null); 3828 s = toStringO(r); 3829 ck_assert_str_eq(s, "eeeead"); 3830 free(s); 3831 // NULL new delimiter: same as only 2 parameters or not enough olds:news pairs 3832 setValO(self, "AA##ee##ee#"); 3833 r = icReplaceManyO(self, "##",NULL); 3834 ck_assert_ptr_eq(r, null); 3835 // empty string 3836 setValO(self, ""); 3837 r = icReplaceManyO(self, "##", ""); 3838 ck_assert_ptr_ne(r, null); 3839 s = toStringO(r); 3840 ck_assert_str_eq(s, ""); 3841 free(s); 3842 // empty string many pairs 3843 setValO(self, ""); 3844 r = icReplaceManyO(self, "##", "", "$$", ""); 3845 ck_assert_ptr_ne(r, null); 3846 s = toStringO(r); 3847 ck_assert_str_eq(s, ""); 3848 free(s); 3849 // empty string many pairs empty olds 3850 setValO(self, ""); 3851 r = icReplaceManyO(self, "##", "", "", ""); 3852 ck_assert_ptr_ne(r, null); 3853 s = toStringO(r); 3854 ck_assert_str_eq(s, ""); 3855 free(s); 3856 // empty string and NULL old delimiter 3857 setValO(self, ""); 3858 r = icReplaceManyO(self, NULL,"|"); 3859 ck_assert_ptr_ne(r, null); 3860 s = toStringO(r); 3861 ck_assert_str_eq(s, ""); 3862 free(s); 3863 // empty string and NULL old delimiter not first - same as replace empty string 3864 setValO(self, ""); 3865 r = icReplaceManyO(self,"##","|", NULL,"|"); 3866 ck_assert_ptr_ne(r, null); 3867 s = toStringO(r); 3868 ck_assert_str_eq(s, ""); 3869 free(s); 3870 // empty old delimiter 3871 setValO(self, "AA##ee##ee#"); 3872 ck_assert_ptr_eq(icReplaceManyO(self, "","|", "AA", "BB"), NULL); 3873 // empty old delimiter not first 3874 ck_assert_ptr_eq(icReplaceManyO(self, "##","|", "", "BB"), NULL); 3875 // NULL string 3876 freeO(self); 3877 ck_assert_ptr_eq(icReplaceManyO(self, "##","|"), NULL); 3878 terminateO(self); 3879 3880 } 3881 3882 3883 void equalSmallStringT(CuTest *tc UNUSED) { 3884 3885 bool r; 3886 smallStringt *self = allocG(""); 3887 smallStringt *string = allocSmallString("qwe"); 3888 3889 r = equalO(self,string); 3890 ck_assert(!r); 3891 setValO(self, "qwe"); 3892 r = equalO(self,string); 3893 ck_assert(r); 3894 // empty strings 3895 freeO(string); 3896 r = equalO(self,string); 3897 ck_assert(!r); 3898 freeO(self); 3899 r = equalO(self,string); 3900 ck_assert(!r); 3901 // non smallString object 3902 setValO(self, "qwe"); 3903 terminateO(string); 3904 string = (smallStringt*) allocSmallInt(1); 3905 r = equalO(self,string); 3906 ck_assert(!r); 3907 terminateO(string); 3908 // null object 3909 r = equalO(self, null); 3910 ck_assert(!r); 3911 terminateO(self); 3912 3913 } 3914 3915 3916 void equalSSmallStringT(CuTest *tc UNUSED) { 3917 3918 bool r; 3919 smallStringt *self = allocG(""); 3920 3921 r = equalSO(self,"qwe"); 3922 ck_assert(!r); 3923 setValO(self, "qwe"); 3924 r = equalSO(self,"qwe"); 3925 ck_assert(r); 3926 // empty strings 3927 freeO(self); 3928 r = equalSO(self, ""); 3929 ck_assert(!r); 3930 // null object 3931 setValO(self, "qwe"); 3932 r = equalSO(self, null); 3933 ck_assert(!r); 3934 terminateO(self); 3935 3936 } 3937 3938 3939 void equalCharSmallStringT(CuTest *tc UNUSED) { 3940 3941 bool r; 3942 smallStringt *self = allocG(""); 3943 3944 r = equalCharO(self,'q'); 3945 ck_assert(!r); 3946 setValO(self, "q"); 3947 r = equalCharO(self,'q'); 3948 ck_assert(r); 3949 // empty strings 3950 freeO(self); 3951 r = equalCharO(self, ' '); 3952 ck_assert(!r); 3953 terminateO(self); 3954 3955 } 3956 3957 3958 void equalSmallStringBaseT(CuTest *tc UNUSED) { 3959 3960 bool r; 3961 smallStringt *self = allocG("12"); 3962 baset* p2 = (baset*) allocSmallInt(12); 3963 3964 r = self->f->equalBase(self, p2); 3965 ck_assert(r); 3966 // empty self 3967 freeO(self); 3968 r = self->f->equalBase(self, p2); 3969 ck_assert(!r); 3970 // null object 3971 setValO(self, "qwe"); 3972 r = self->f->equalBase(self, null); 3973 ck_assert(!r); 3974 terminateO(p2); 3975 terminateO(self); 3976 3977 } 3978 3979 3980 void equalSmallStringBoolT(CuTest *tc UNUSED) { 3981 3982 bool r; 3983 smallStringt* self = allocG("TRUE"); 3984 3985 r = self->f->equalBool(self, true); 3986 ck_assert(r); 3987 setValO(self, "true"); 3988 r = self->f->equalBool(self, true); 3989 ck_assert(r); 3990 setValO(self, "FALSE"); 3991 r = self->f->equalBool(self, false); 3992 ck_assert(r); 3993 setValO(self, "false"); 3994 r = self->f->equalBool(self, false); 3995 ck_assert(r); 3996 r = self->f->equalBool(self, true); 3997 ck_assert(!r); 3998 setValO(self, ""); 3999 r = self->f->equalBool(self, true); 4000 ck_assert(!r); 4001 // empty self 4002 freeO(self); 4003 r = self->f->equalBool(self, true); 4004 ck_assert(!r); 4005 terminateO(self); 4006 4007 } 4008 4009 4010 void equalSmallStringDoubleT(CuTest *tc UNUSED) { 4011 4012 bool r; 4013 smallStringt* self = allocG("2.2"); 4014 4015 r = self->f->equalDouble(self, 2.2); 4016 ck_assert(r); 4017 r = self->f->equalDouble(self, 2.22); 4018 ck_assert(!r); 4019 // not a double 4020 setValO(self, "2"); 4021 r = self->f->equalDouble(self, 2); 4022 ck_assert(!r); 4023 setValO(self, "qwe"); 4024 r = self->f->equalDouble(self, 2); 4025 ck_assert(!r); 4026 // empty self 4027 freeO(self); 4028 r = self->f->equalDouble(self, 2); 4029 ck_assert(!r); 4030 terminateO(self); 4031 4032 } 4033 4034 4035 void equalSmallStringInt64T(CuTest *tc UNUSED) { 4036 4037 bool r; 4038 smallStringt* self = allocG("2"); 4039 4040 r = self->f->equalInt64(self, 2); 4041 ck_assert(r); 4042 r = self->f->equalInt64(self, 3); 4043 ck_assert(!r); 4044 // not a double 4045 setValO(self, "2.2"); 4046 r = self->f->equalInt64(self, 2); 4047 ck_assert(!r); 4048 setValO(self, "qwe"); 4049 r = self->f->equalInt64(self, 2); 4050 ck_assert(!r); 4051 // empty self 4052 freeO(self); 4053 r = self->f->equalInt64(self, 2); 4054 ck_assert(!r); 4055 terminateO(self); 4056 4057 } 4058 4059 4060 void equalSmallStringInt32T(CuTest *tc UNUSED) { 4061 4062 bool r; 4063 smallStringt* self = allocG("2"); 4064 4065 r = self->f->equalInt32(self, 2); 4066 ck_assert(r); 4067 r = self->f->equalInt32(self, 3); 4068 ck_assert(!r); 4069 // not a double 4070 setValO(self, "2.2"); 4071 r = self->f->equalInt32(self, 2); 4072 ck_assert(!r); 4073 setValO(self, "qwe"); 4074 r = self->f->equalInt32(self, 2); 4075 ck_assert(!r); 4076 // empty self 4077 freeO(self); 4078 r = self->f->equalInt32(self, 2); 4079 ck_assert(!r); 4080 terminateO(self); 4081 4082 } 4083 4084 4085 void equalSmallStringUint32T(CuTest *tc UNUSED) { 4086 4087 bool r; 4088 smallStringt* self = allocG("2"); 4089 4090 r = self->f->equalUint32(self, 2); 4091 ck_assert(r); 4092 r = self->f->equalUint32(self, 3); 4093 ck_assert(!r); 4094 // not a double 4095 setValO(self, "2.2"); 4096 r = self->f->equalUint32(self, 2); 4097 ck_assert(!r); 4098 setValO(self, "qwe"); 4099 r = self->f->equalUint32(self, 2); 4100 ck_assert(!r); 4101 // empty self 4102 freeO(self); 4103 r = self->f->equalUint32(self, 2); 4104 ck_assert(!r); 4105 terminateO(self); 4106 4107 } 4108 4109 4110 void equalSmallStringUint64T(CuTest *tc UNUSED) { 4111 4112 bool r; 4113 smallStringt* self = allocG("2"); 4114 4115 r = self->f->equalUint64(self, 2); 4116 ck_assert(r); 4117 r = self->f->equalUint64(self, 3); 4118 ck_assert(!r); 4119 // not a double 4120 setValO(self, "2.2"); 4121 r = self->f->equalUint64(self, 2); 4122 ck_assert(!r); 4123 setValO(self, "qwe"); 4124 r = self->f->equalUint64(self, 2); 4125 ck_assert(!r); 4126 // empty self 4127 freeO(self); 4128 r = self->f->equalUint64(self, 2); 4129 ck_assert(!r); 4130 terminateO(self); 4131 4132 } 4133 4134 4135 void equalSmallStringSmallBoolT(CuTest *tc UNUSED) { 4136 4137 bool r; 4138 smallStringt* self = allocG("TRUE"); 4139 smallBoolt* p2 = allocSmallBool(true); 4140 4141 r = self->f->equalSmallBool(self, p2); 4142 ck_assert(r); 4143 setValO(self, "true"); 4144 r = self->f->equalSmallBool(self, p2); 4145 ck_assert(r); 4146 setValO(self, "FALSE"); 4147 setValO(p2, false); 4148 r = self->f->equalSmallBool(self, p2); 4149 ck_assert(r); 4150 setValO(self, "false"); 4151 r = self->f->equalSmallBool(self, p2); 4152 ck_assert(r); 4153 setValO(p2, true); 4154 r = self->f->equalSmallBool(self, p2); 4155 ck_assert(!r); 4156 // empty p2 4157 freeO(p2); 4158 r = self->f->equalSmallBool(self, p2); 4159 ck_assert(!r); 4160 setValO(p2, true); 4161 // empty string 4162 setValO(self, ""); 4163 r = self->f->equalSmallBool(self, p2); 4164 ck_assert(!r); 4165 // non smallBool object 4166 terminateO(p2); 4167 p2 = (smallBoolt*) allocSmallInt(2); 4168 r = self->f->equalSmallBool(self, p2); 4169 ck_assert(!r); 4170 terminateO(p2); 4171 p2 = allocSmallBool(true); 4172 // null p2 4173 r = self->f->equalSmallBool(self, null); 4174 ck_assert(!r); 4175 // empty self 4176 freeO(self); 4177 r = self->f->equalSmallBool(self, p2); 4178 ck_assert(!r); 4179 terminateO(p2); 4180 terminateO(self); 4181 4182 } 4183 4184 4185 void equalSmallStringSmallBytesT(CuTest *tc UNUSED) { 4186 4187 bool r; 4188 smallStringt* self = allocG("qwe"); 4189 smallBytest* p2 = allocSmallBytes("qwe", sizeof("qwe")); 4190 4191 r = self->f->equalSmallBytes(self, p2); 4192 ck_assert(r); 4193 // different length 4194 setValO(self, "qw"); 4195 r = self->f->equalSmallBytes(self, p2); 4196 ck_assert(!r); 4197 // empty p2 4198 freeO(p2); 4199 r = self->f->equalSmallBytes(self, p2); 4200 ck_assert(!r); 4201 // non smallBytes object 4202 terminateO(p2); 4203 p2 = (smallBytest*) allocSmallInt(2); 4204 r = self->f->equalSmallBytes(self, p2); 4205 ck_assert(!r); 4206 // null p2 4207 r = self->f->equalSmallBytes(self, null); 4208 ck_assert(!r); 4209 // empty self 4210 freeO(self); 4211 r = self->f->equalSmallBytes(self, p2); 4212 ck_assert(!r); 4213 terminateO(p2); 4214 terminateO(self); 4215 4216 } 4217 4218 4219 void equalSmallStringSmallDoubleT(CuTest *tc UNUSED) { 4220 4221 bool r; 4222 smallStringt* self = allocG("2.2"); 4223 smallDoublet* p2 = allocSmallDouble(2.2); 4224 4225 r = self->f->equalSmallDouble(self, p2); 4226 ck_assert(r); 4227 setValO(p2, 2.22); 4228 r = self->f->equalSmallDouble(self, p2); 4229 ck_assert(!r); 4230 // not a double 4231 setValO(self, "2"); 4232 r = self->f->equalSmallDouble(self, setValO(p2, 2)); 4233 ck_assert(!r); 4234 setValO(self, "qwe"); 4235 r = self->f->equalSmallDouble(self, p2); 4236 ck_assert(!r); 4237 // empty p2 4238 freeO(p2); 4239 r = self->f->equalSmallDouble(self, p2); 4240 ck_assert(!r); 4241 // non smallDouble object 4242 terminateO(p2); 4243 p2 = (smallDoublet*) allocSmallInt(2); 4244 r = self->f->equalSmallDouble(self, p2); 4245 ck_assert(!r); 4246 // null p2 4247 r = self->f->equalSmallDouble(self, null); 4248 ck_assert(!r); 4249 // empty self 4250 freeO(self); 4251 r = self->f->equalSmallDouble(self, p2); 4252 ck_assert(!r); 4253 terminateO(p2); 4254 terminateO(self); 4255 4256 } 4257 4258 4259 void equalSmallStringSmallIntT(CuTest *tc UNUSED) { 4260 4261 bool r; 4262 smallStringt* self = allocG("2"); 4263 smallIntt* p2 = allocSmallInt(2); 4264 4265 r = self->f->equalSmallInt(self, p2); 4266 ck_assert(r); 4267 setValO(p2, 3); 4268 r = self->f->equalSmallInt(self, p2); 4269 ck_assert(!r); 4270 // not an int 4271 setValO(self, "2.2"); 4272 r = self->f->equalSmallInt(self, setValO(p2, 2)); 4273 ck_assert(!r); 4274 setValO(self, "qwe"); 4275 r = self->f->equalSmallInt(self, p2); 4276 ck_assert(!r); 4277 // empty p2 4278 freeO(p2); 4279 r = self->f->equalSmallInt(self, p2); 4280 ck_assert(!r); 4281 // non smallDouble object 4282 terminateO(p2); 4283 p2 = (smallIntt*) allocSmallDouble(2); 4284 r = self->f->equalSmallInt(self, p2); 4285 ck_assert(!r); 4286 // null p2 4287 r = self->f->equalSmallInt(self, null); 4288 ck_assert(!r); 4289 // empty self 4290 freeO(self); 4291 r = self->f->equalSmallInt(self, p2); 4292 ck_assert(!r); 4293 terminateO(p2); 4294 terminateO(self); 4295 4296 } 4297 4298 4299 void equalSmallStringSmallJsonT(CuTest *tc UNUSED) { 4300 4301 bool r; 4302 smallStringt* self = allocG("qwe"); 4303 smallJsont* p2 = allocSmallJson(); 4304 4305 setTopSO(p2, "qwe"); 4306 r = self->f->equalSmallJson(self, p2); 4307 ck_assert(r); 4308 // non json object 4309 terminateO(p2); 4310 p2 = (smallJsont*) allocSmallInt(2); 4311 r = self->f->equalSmallJson(self, p2); 4312 ck_assert(!r); 4313 // null p2 4314 r = self->f->equalSmallJson(self, null); 4315 ck_assert(!r); 4316 terminateO(p2); 4317 terminateO(self); 4318 4319 } 4320 4321 4322 void icEqualSmallStringT(CuTest *tc UNUSED) { 4323 4324 bool r; 4325 smallStringt *self = allocG(""); 4326 smallStringt *string = allocSmallString("Qwe"); 4327 4328 r = icEqualO(self,string); 4329 ck_assert(!r); 4330 setValO(self, "qwe"); 4331 r = icEqualO(self,string); 4332 ck_assert(r); 4333 // empty strings 4334 freeO(string); 4335 r = icEqualO(self,string); 4336 ck_assert(!r); 4337 freeO(self); 4338 r = icEqualO(self,string); 4339 ck_assert(!r); 4340 // non smallString object 4341 setValO(self, "qwe"); 4342 terminateO(string); 4343 string = (smallStringt*) allocSmallInt(1); 4344 r = icEqualO(self,string); 4345 ck_assert(!r); 4346 terminateO(string); 4347 // null object 4348 r = icEqualO(self, null); 4349 ck_assert(!r); 4350 terminateO(self); 4351 4352 } 4353 4354 4355 void icEqualSSmallStringT(CuTest *tc UNUSED) { 4356 4357 bool r; 4358 smallStringt *self = allocG(""); 4359 4360 r = icEqualSO(self,"qwe"); 4361 ck_assert(!r); 4362 setValO(self, "qwe"); 4363 r = icEqualSO(self, "Qwe"); 4364 ck_assert(r); 4365 // empty strings 4366 freeO(self); 4367 r = icEqualSO(self, ""); 4368 ck_assert(!r); 4369 // null object 4370 setValO(self, "qwe"); 4371 r = icEqualSO(self, null); 4372 ck_assert(!r); 4373 terminateO(self); 4374 4375 } 4376 4377 4378 void icEqualCharSmallStringT(CuTest *tc UNUSED) { 4379 4380 bool r; 4381 smallStringt *self = allocG(""); 4382 4383 r = icEqualCharO(self,'q'); 4384 ck_assert(!r); 4385 setValO(self, "q"); 4386 r = icEqualCharO(self,'Q'); 4387 ck_assert(r); 4388 // empty strings 4389 freeO(self); 4390 r = icEqualCharO(self, ' '); 4391 ck_assert(!r); 4392 terminateO(self); 4393 4394 } 4395 4396 4397 void icEqualSmallStringBaseT(CuTest *tc UNUSED) { 4398 4399 bool r; 4400 smallStringt* self = allocG("qwe"); 4401 baset* p2 = (baset*) allocSmallString("QWE"); 4402 4403 r = self->f->icEqualBase(self, p2); 4404 ck_assert(r); 4405 // empty self 4406 freeO(self); 4407 r = self->f->icEqualBase(self, p2); 4408 ck_assert(!r); 4409 // null object 4410 setValO(self, "qwe"); 4411 r = self->f->icEqualBase(self, null); 4412 ck_assert(!r); 4413 terminateO(p2); 4414 terminateO(self); 4415 4416 } 4417 4418 4419 void icEqualSmallStringSmallJsonT(CuTest *tc UNUSED) { 4420 4421 bool r; 4422 smallStringt* self = allocG("qwe"); 4423 smallJsont* p2 = allocSmallJson(); 4424 4425 setTopSO(p2, "Qwe"); 4426 r = self->f->icEqualSmallJson(self, p2); 4427 ck_assert(r); 4428 // non json object 4429 terminateO(p2); 4430 p2 = (smallJsont*) allocSmallInt(2); 4431 r = self->f->icEqualSmallJson(self, p2); 4432 ck_assert(!r); 4433 // null p2 4434 r = self->f->icEqualSmallJson(self, null); 4435 ck_assert(!r); 4436 terminateO(p2); 4437 terminateO(self); 4438 4439 } 4440 4441 4442 void equalISSmallStringT(CuTest *tc UNUSED) { 4443 4444 smallStringt *self = allocG("Ashee|"); 4445 4446 // identical strings 4447 ck_assert(equalISO(self, "shee", 1)); 4448 setValO(self, "Ashee"); 4449 ck_assert(equalISO(self, "shee", -4)); 4450 // string at index shorter than string2 4451 ck_assert(!equalISO(self, "shee", 2)); 4452 // empty string 4453 setValO(self, ""); 4454 ck_assert(!equalISO(self, "shee", 0)); 4455 ck_assert(equalISO(self, "", 0)); 4456 setValO(self, "Ashee"); 4457 ck_assert(!equalISO(self, "", 0)); 4458 // index mismatch 4459 ck_assert(!equalISO(self, "shee", 0)); 4460 // index outside 4461 ck_assert(!equalISO(self, "shee", 10)); 4462 ck_assert(!equalISO(self, "shee", -10)); 4463 // different strings 4464 ck_assert(!equalISO(self, "SH",0)); 4465 // empty self 4466 freeO(self); 4467 ck_assert(!equalISO(self, "SH",0)); 4468 // NULL string 4469 setValO(self, "Ashee"); 4470 ck_assert(!equalISO(self, NULL, 0)); 4471 terminateO(self); 4472 4473 } 4474 4475 4476 void equalICharSmallStringT(CuTest *tc UNUSED) { 4477 4478 smallStringt *self = allocG("Ashee"); 4479 4480 // identical strings 4481 ck_assert(equalICharO(self, 's', 1)); 4482 ck_assert(equalICharO(self, 's', -4)); 4483 ck_assert(!equalICharO(self, 's', 2)); 4484 // empty string 4485 setValO(self, ""); 4486 ck_assert(!equalICharO(self, 's', 0)); 4487 ck_assert(equalICharO(self, 0, 0)); 4488 setValO(self, "Ashee"); 4489 ck_assert(!equalICharO(self, 0, 0)); 4490 // index mismatch 4491 ck_assert(!equalICharO(self, 's', 0)); 4492 // index outside 4493 ck_assert(!equalICharO(self, 's', 10)); 4494 ck_assert(!equalICharO(self, 's', -10)); 4495 // different strings 4496 setValO(self, "shee"); 4497 ck_assert(!equalICharO(self, 'S',0)); 4498 // NULL string 4499 ck_assert(!equalICharO(self, 0, 0)); 4500 // empty self 4501 freeO(self); 4502 ck_assert(!equalICharO(self, 'S',0)); 4503 terminateO(self); 4504 4505 } 4506 4507 4508 void equalISmallJsonSmallStringT(CuTest *tc UNUSED) { 4509 4510 smallStringt *self = allocG("Ashee|"); 4511 smallJsont *string = allocSmallJson(); 4512 4513 // identical strings 4514 setTopSO(string, "shee"); 4515 ck_assert(equalISmallJsonO(self, string, 1)); 4516 setValO(self, "Ashee"); 4517 ck_assert(equalISmallJsonO(self, string, -4)); 4518 // string at index shorter than string2 4519 ck_assert(!equalISmallJsonO(self, string, 2)); 4520 // empty string 4521 setValO(self, ""); 4522 ck_assert(!equalISmallJsonO(self, string, 0)); 4523 freeO(string); 4524 setTopSO(string, ""); 4525 ck_assert(equalISmallJsonO(self, string, 0)); 4526 setValO(self, "Ashee"); 4527 ck_assert(!equalISmallJsonO(self, string, 0)); 4528 // index mismatch 4529 freeO(string); 4530 setTopSO(string, "shee"); 4531 ck_assert(!equalISmallJsonO(self, string, 0)); 4532 // index outside 4533 ck_assert(!equalISmallJsonO(self, string, 10)); 4534 ck_assert(!equalISmallJsonO(self, string, -10)); 4535 // different strings 4536 freeO(string); 4537 setTopSO(string, "SH"); 4538 ck_assert(!equalISmallJsonO(self, string,0)); 4539 // non json string 4540 freeO(string); 4541 setTopIntO(string, 1); 4542 ck_assert(!equalISmallJsonO(self, string,0)); 4543 // non json object 4544 terminateO(string); 4545 string = (smallJsont*) allocSmallInt(2); 4546 ck_assert(!equalISmallJsonO(self, string,0)); 4547 // empty self 4548 terminateO(string); 4549 string = allocSmallJson(); 4550 setTopSO(string, "SH"); 4551 freeO(self); 4552 ck_assert(!equalISmallJsonO(self, string,0)); 4553 // NULL string 4554 setValO(self, "Ashee"); 4555 ck_assert(!equalISmallJsonO(self, NULL, 0)); 4556 terminateO(string); 4557 terminateO(self); 4558 4559 } 4560 4561 4562 void equalISmallStringSmallStringT(CuTest *tc UNUSED) { 4563 4564 smallStringt *self = allocG("Ashee|"); 4565 smallStringt *string = allocSmallString("shee"); 4566 4567 // identical strings 4568 ck_assert(equalISmallStringO(self, string, 1)); 4569 setValO(self, "Ashee"); 4570 ck_assert(equalISmallStringO(self, string, -4)); 4571 // string at index shorter than string2 4572 ck_assert(!equalISmallStringO(self, string, 2)); 4573 // empty string 4574 setValO(self, ""); 4575 ck_assert(!equalISmallStringO(self, string, 0)); 4576 setValO(string, ""); 4577 ck_assert(equalISmallStringO(self, string, 0)); 4578 setValO(self, "Ashee"); 4579 ck_assert(!equalISmallStringO(self, string, 0)); 4580 // index mismatch 4581 freeO(string); 4582 setValO(string, "shee"); 4583 ck_assert(!equalISmallStringO(self, string, 0)); 4584 // index outside 4585 ck_assert(!equalISmallStringO(self, string, 10)); 4586 ck_assert(!equalISmallStringO(self, string, -10)); 4587 // different strings 4588 setValO(string, "SH"); 4589 ck_assert(!equalISmallStringO(self, string,0)); 4590 // non smallString object 4591 terminateO(string); 4592 string = (smallStringt*) allocSmallInt(2); 4593 ck_assert(!equalISmallStringO(self, string,0)); 4594 // empty self 4595 terminateO(string); 4596 string = allocSmallString("SH"); 4597 freeO(self); 4598 ck_assert(!equalISmallStringO(self, string,0)); 4599 // NULL string 4600 setValO(self, "Ashee"); 4601 ck_assert(!equalISmallStringO(self, NULL, 0)); 4602 terminateO(string); 4603 terminateO(self); 4604 4605 } 4606 4607 4608 void startsWithSSmallStringT(CuTest *tc UNUSED) { 4609 4610 smallStringt *self = allocG("shee"); 4611 4612 // identical strings 4613 ck_assert(startsWithSO(self, "shee")); 4614 setValO(self, "sheepy"); 4615 ck_assert(startsWithSO(self, "shee")); 4616 // different strings 4617 setValO(self, "shee"); 4618 ck_assert(!startsWithSO(self, "SH")); 4619 ck_assert(!startsWithSO(self, "sheep")); 4620 setValO(self, "-shee"); 4621 ck_assert(!startsWithSO(self, "shee")); 4622 // NULL string 4623 ck_assert(!startsWithSO(self, NULL)); 4624 // empty self 4625 freeO(self); 4626 ck_assert(!startsWithSO(self, "shee")); 4627 terminateO(self); 4628 4629 } 4630 4631 4632 void startsWithCharSmallStringT(CuTest *tc UNUSED) { 4633 4634 smallStringt *self = allocG("shee"); 4635 4636 // identical strings 4637 ck_assert(startsWithCharO(self, 's')); 4638 setValO(self, "sheepy"); 4639 ck_assert(startsWithCharO(self, 's')); 4640 setValO(self, ""); 4641 ck_assert(startsWithCharO(self, 0)); 4642 // different strings 4643 setValO(self, "shee"); 4644 ck_assert(!startsWithCharO(self, 'S')); 4645 setValO(self, "-shee"); 4646 ck_assert(!startsWithCharO(self, 's')); 4647 setValO(self, ""); 4648 ck_assert(!startsWithCharO(self, '0')); 4649 // NULL string 4650 setValO(self, "shee"); 4651 ck_assert(!startsWithCharO(self, 0)); 4652 // empty self 4653 freeO(self); 4654 ck_assert(!startsWithCharO(self, '0')); 4655 terminateO(self); 4656 4657 } 4658 4659 4660 void startsWithSmallJsonSmallStringT(CuTest *tc UNUSED) { 4661 4662 smallStringt *self = allocG("shee"); 4663 smallJsont *string = allocSmallJson(); 4664 4665 // identical strings 4666 setTopSO(string, "shee"); 4667 ck_assert(startsWithSmallJsonO(self, string)); 4668 setValO(self, "sheepy"); 4669 ck_assert(startsWithSmallJsonO(self, string)); 4670 // different strings 4671 setValO(self, "shee"); 4672 freeO(string); 4673 setTopSO(string, "SH"); 4674 ck_assert(!startsWithSmallJsonO(self, string)); 4675 freeO(string); 4676 setTopSO(string, "sheep"); 4677 ck_assert(!startsWithSmallJsonO(self, string)); 4678 setValO(self, "-shee"); 4679 freeO(string); 4680 setTopSO(string, "shee"); 4681 ck_assert(!startsWithSmallJsonO(self, string)); 4682 // non json string 4683 freeO(string); 4684 setTopIntO(string, 1); 4685 ck_assert(!startsWithSmallJsonO(self, string)); 4686 // non json object 4687 terminateO(string); 4688 string = (smallJsont*) allocSmallInt(1); 4689 ck_assert(!startsWithSmallJsonO(self, string)); 4690 terminateO(string); 4691 string = allocSmallJson(); 4692 // NULL string 4693 ck_assert(!startsWithSmallJsonO(self, NULL)); 4694 // empty self 4695 freeO(self); 4696 setTopSO(string, "shee"); 4697 ck_assert(!startsWithSmallJsonO(self, string)); 4698 terminateO(string); 4699 terminateO(self); 4700 4701 } 4702 4703 4704 void startsWithSmallStringSmallStringT(CuTest *tc UNUSED) { 4705 4706 smallStringt *self = allocG("shee"); 4707 smallStringt *string = allocSmallString("shee"); 4708 4709 // identical strings 4710 ck_assert(startsWithSmallStringO(self, string)); 4711 setValO(self, "sheepy"); 4712 ck_assert(startsWithSmallStringO(self, string)); 4713 // different strings 4714 setValO(self, "shee"); 4715 setValO(string, "SH"); 4716 ck_assert(!startsWithSmallStringO(self, string)); 4717 setValO(string, "sheep"); 4718 ck_assert(!startsWithSmallStringO(self, string)); 4719 setValO(self, "-shee"); 4720 setValO(string, "shee"); 4721 ck_assert(!startsWithSmallStringO(self, string)); 4722 // non smallString object 4723 terminateO(string); 4724 string = (smallStringt*) allocSmallInt(1); 4725 ck_assert(!startsWithSmallStringO(self, string)); 4726 terminateO(string); 4727 string = allocSmallString("shee"); 4728 // NULL string 4729 ck_assert(!startsWithSmallStringO(self, NULL)); 4730 // empty self 4731 freeO(self); 4732 ck_assert(!startsWithSmallStringO(self, string)); 4733 terminateO(string); 4734 terminateO(self); 4735 4736 } 4737 4738 4739 void endsWithSSmallStringT(CuTest *tc UNUSED) { 4740 4741 smallStringt *self = allocG("shee"); 4742 4743 // identical strings 4744 ck_assert(endsWithSO(self, "shee")); 4745 setValO(self, "sheepy"); 4746 ck_assert(endsWithSO(self, "eepy")); 4747 // different strings 4748 setValO(self, "shee"); 4749 ck_assert(!endsWithSO(self, "SH")); 4750 ck_assert(!endsWithSO(self, "sheep")); 4751 setValO(self, "shee-"); 4752 ck_assert(!endsWithSO(self, "shee")); 4753 // NULL string 4754 ck_assert(!endsWithSO(self, NULL)); 4755 // empty self 4756 freeO(self); 4757 ck_assert(!endsWithSO(self, "shee")); 4758 terminateO(self); 4759 4760 } 4761 4762 4763 void endsWithCharSmallStringT(CuTest *tc UNUSED) { 4764 4765 smallStringt *self = allocG("shee"); 4766 4767 // identical strings 4768 ck_assert(endsWithCharO(self, 'e')); 4769 setValO(self, "sheepy"); 4770 ck_assert(endsWithCharO(self, 'y')); 4771 setValO(self, ""); 4772 ck_assert(endsWithCharO(self, 0)); 4773 // different strings 4774 setValO(self, "shee"); 4775 ck_assert(!endsWithCharO(self, 'E')); 4776 ck_assert(!endsWithCharO(self, 'p')); 4777 setValO(self, "shee-"); 4778 ck_assert(!endsWithCharO(self, 'e')); 4779 setValO(self, ""); 4780 ck_assert(!endsWithCharO(self, '0')); 4781 // NULL string 4782 setValO(self, "a"); 4783 ck_assert(!endsWithCharO(self, 0)); 4784 // empty self 4785 freeO(self); 4786 ck_assert(!endsWithCharO(self, '0')); 4787 terminateO(self); 4788 4789 } 4790 4791 4792 void endsWithSmallJsonSmallStringT(CuTest *tc UNUSED) { 4793 4794 smallStringt *self = allocG("shee"); 4795 smallJsont *string = allocSmallJson(); 4796 4797 // identical strings 4798 setTopSO(string, "shee"); 4799 ck_assert(endsWithSmallJsonO(self, string)); 4800 setValO(self, "sheepy"); 4801 freeO(string); 4802 setTopSO(string, "eepy"); 4803 ck_assert(endsWithSmallJsonO(self, string)); 4804 // different strings 4805 setValO(self, "shee"); 4806 freeO(string); 4807 setTopSO(string, "SH"); 4808 ck_assert(!endsWithSmallJsonO(self, string)); 4809 freeO(string); 4810 setTopSO(string, "sheep"); 4811 ck_assert(!endsWithSmallJsonO(self, string)); 4812 setValO(self, "shee-"); 4813 freeO(string); 4814 setTopSO(string, "shee"); 4815 ck_assert(!endsWithSmallJsonO(self, string)); 4816 // non json string 4817 freeO(string); 4818 setTopIntO(string, 1); 4819 ck_assert(!endsWithSmallJsonO(self, string)); 4820 // non json object 4821 terminateO(string); 4822 string = (smallJsont*) allocSmallInt(1); 4823 ck_assert(!endsWithSmallJsonO(self, string)); 4824 terminateO(string); 4825 string = allocSmallJson(); 4826 setTopSO(string, "shee"); 4827 // NULL string 4828 ck_assert(!endsWithSmallJsonO(self, NULL)); 4829 // empty self 4830 freeO(self); 4831 ck_assert(!endsWithSmallJsonO(self, string)); 4832 terminateO(string); 4833 terminateO(self); 4834 4835 } 4836 4837 4838 void endsWithSmallStringSmallStringT(CuTest *tc UNUSED) { 4839 4840 smallStringt *self = allocG("shee"); 4841 smallStringt *string = allocSmallString("shee"); 4842 4843 // identical strings 4844 ck_assert(endsWithSmallStringO(self, string)); 4845 setValO(self, "sheepy"); 4846 setValO(string, "eepy"); 4847 ck_assert(endsWithSmallStringO(self, string)); 4848 // different strings 4849 setValO(self, "shee"); 4850 ck_assert(!endsWithSmallStringO(self, string)); 4851 setValO(string, "sheep"); 4852 ck_assert(!endsWithSmallStringO(self, string)); 4853 setValO(self, "shee-"); 4854 setValO(string, "shee"); 4855 ck_assert(!endsWithSmallStringO(self, string)); 4856 // non smallString object 4857 terminateO(string); 4858 string = (smallStringt*) allocSmallInt(1); 4859 ck_assert(!endsWithSmallStringO(self, string)); 4860 terminateO(string); 4861 string = allocSmallString("shee"); 4862 // NULL string 4863 ck_assert(!endsWithSmallStringO(self, NULL)); 4864 // empty self 4865 freeO(self); 4866 ck_assert(!endsWithSmallStringO(self, string)); 4867 terminateO(string); 4868 terminateO(self); 4869 4870 } 4871 4872 4873 void countSSmallStringT(CuTest *tc UNUSED) { 4874 4875 smallStringt *self = allocG("sheepy"); 4876 4877 // positive count 4878 ck_assert_int_eq(countSO(self, "shee"), 1); 4879 setValO(self, "aaa aaa"); 4880 ck_assert_int_eq(countSO(self, "a"), 6); 4881 ck_assert_int_eq(countSO(self, "aa"), 2); 4882 // 0 count 4883 setValO(self, "shee"); 4884 ck_assert_int_eq(countSO(self, "SH"), 0); 4885 ck_assert_int_eq(countSO(self, "sheepy"), 0); 4886 setValO(self, "aaa aaa"); 4887 ck_assert_int_eq(countSO(self, "ab"), 0); 4888 // empty string 4889 ck_assert_int_eq(countSO(self, ""), -1); 4890 // NULL string 4891 ck_assert_int_eq(countSO(self, NULL), -1); 4892 // empty self 4893 freeO(self); 4894 ck_assert_int_eq(countSO(self, "ab"), -1); 4895 terminateO(self); 4896 4897 } 4898 4899 4900 void countCharSmallStringT(CuTest *tc UNUSED) { 4901 4902 smallStringt *self = allocG("shee"); 4903 4904 // positive count 4905 ck_assert_int_eq(countCharO(self, 's'), 1); 4906 setValO(self, "aaa aaa"); 4907 ck_assert_int_eq(countCharO(self, 'a'), 6); 4908 // 0 count 4909 setValO(self, "shee"); 4910 ck_assert_int_eq(countCharO(self, 'S'), 0); 4911 ck_assert_int_eq(countCharO(self, 'y'), 0); 4912 setValO(self, "aaa aaa"); 4913 ck_assert_int_eq(countCharO(self, 'b'), 0); 4914 // empty string 4915 setValO(self, ""); 4916 ck_assert_int_eq(countCharO(self, 'a'), 0); 4917 ck_assert_int_eq(countCharO(self, 0), -1); 4918 // NULL string 4919 setValO(self, "a"); 4920 ck_assert_int_eq(countCharO(self, 0), -1); 4921 // empty self 4922 freeO(self); 4923 ck_assert_int_eq(countCharO(self, 'a'), -1); 4924 terminateO(self); 4925 4926 } 4927 4928 4929 void countSmallJsonSmallStringT(CuTest *tc UNUSED) { 4930 4931 smallStringt *self = allocG("sheepy"); 4932 smallJsont *string = allocSmallJson(); 4933 4934 // positive count 4935 setTopSO(string, "shee"); 4936 ck_assert_int_eq(countSmallJsonO(self, string), 1); 4937 setValO(self, "aaa aaa"); 4938 freeO(string); 4939 setTopSO(string, "a"); 4940 ck_assert_int_eq(countSmallJsonO(self, string), 6); 4941 freeO(string); 4942 setTopSO(string, "aa"); 4943 ck_assert_int_eq(countSmallJsonO(self, string), 2); 4944 // 0 count 4945 setValO(self, "shee"); 4946 freeO(string); 4947 setTopSO(string, "SH"); 4948 ck_assert_int_eq(countSmallJsonO(self, string), 0); 4949 freeO(string); 4950 setTopSO(string, "sheepy"); 4951 ck_assert_int_eq(countSmallJsonO(self, string), 0); 4952 setValO(self, "aaa aaa"); 4953 freeO(string); 4954 setTopSO(string, "ab"); 4955 ck_assert_int_eq(countSmallJsonO(self, string), 0); 4956 // non json string 4957 freeO(string); 4958 setTopIntO(string, -1); 4959 ck_assert_int_eq(countSmallJsonO(self, string), -1); 4960 // non json object 4961 terminateO(string); 4962 string = (smallJsont*) allocSmallInt(1); 4963 ck_assert_int_eq(countSmallJsonO(self, string), -1); 4964 terminateO(string); 4965 string = allocSmallJson(); 4966 // empty string 4967 setTopSO(string, ""); 4968 ck_assert_int_eq(countSmallJsonO(self, string), -1); 4969 // NULL string 4970 ck_assert_int_eq(countSmallJsonO(self, NULL), -1); 4971 // empty self 4972 freeO(self); 4973 freeO(string); 4974 setTopSO(string, "ab"); 4975 ck_assert_int_eq(countSmallJsonO(self, string), -1); 4976 terminateO(string); 4977 terminateO(self); 4978 4979 } 4980 4981 4982 void countSmallStringSmallStringT(CuTest *tc UNUSED) { 4983 4984 smallStringt *self = allocG("sheepy"); 4985 smallStringt *string = allocSmallString("shee"); 4986 4987 // positive count 4988 ck_assert_int_eq(countSmallStringO(self, string), 1); 4989 setValO(self, "aaa aaa"); 4990 setValO(string, "a"); 4991 ck_assert_int_eq(countSmallStringO(self, string), 6); 4992 setValO(string, "aa"); 4993 ck_assert_int_eq(countSmallStringO(self, string), 2); 4994 // 0 count 4995 setValO(self, "shee"); 4996 setValO(string, "SH"); 4997 ck_assert_int_eq(countSmallStringO(self, string), 0); 4998 setValO(string, "sheepy"); 4999 ck_assert_int_eq(countSmallStringO(self, string), 0); 5000 setValO(self, "aaa aaa"); 5001 setValO(string, "ab"); 5002 ck_assert_int_eq(countSmallStringO(self, string), 0); 5003 // non json object 5004 terminateO(string); 5005 string = (smallStringt*) allocSmallInt(1); 5006 ck_assert_int_eq(countSmallStringO(self, string), -1); 5007 terminateO(string); 5008 string = allocSmallString(""); 5009 // empty string 5010 ck_assert_int_eq(countSmallStringO(self, string), -1); 5011 freeO(string); 5012 ck_assert_int_eq(countSmallStringO(self, string), -1); 5013 // NULL string 5014 ck_assert_int_eq(countSmallStringO(self, NULL), -1); 5015 // empty self 5016 freeO(self); 5017 setValO(string, "ab"); 5018 ck_assert_int_eq(countSmallStringO(self, string), -1); 5019 terminateO(string); 5020 terminateO(self); 5021 5022 } 5023 5024 5025 void icStartsWithSSmallStringT(CuTest *tc UNUSED) { 5026 5027 smallStringt *self = allocG("shee"); 5028 5029 // identical strings 5030 ck_assert(icStartsWithSO(self, "shee")); 5031 setValO(self, "sheepy"); 5032 ck_assert(icStartsWithSO(self, "shee")); 5033 // different strings 5034 setValO(self, "shee"); 5035 ck_assert(icStartsWithSO(self, "SH")); 5036 ck_assert(!icStartsWithSO(self, "sheep")); 5037 setValO(self, "-shee"); 5038 ck_assert(!icStartsWithSO(self, "shee")); 5039 // NULL string 5040 ck_assert(!icStartsWithSO(self, NULL)); 5041 // empty self 5042 freeO(self); 5043 ck_assert(!icStartsWithSO(self, "shee")); 5044 terminateO(self); 5045 5046 } 5047 5048 5049 void icStartsWithCharSmallStringT(CuTest *tc UNUSED) { 5050 5051 smallStringt *self = allocG("shee"); 5052 5053 // identical strings 5054 ck_assert(icStartsWithCharO(self, 's')); 5055 setValO(self, "sheepy"); 5056 ck_assert(icStartsWithCharO(self, 's')); 5057 setValO(self, ""); 5058 ck_assert(icStartsWithCharO(self, 0)); 5059 // different strings 5060 setValO(self, "shee"); 5061 ck_assert(icStartsWithCharO(self, 'S')); 5062 setValO(self, "-shee"); 5063 ck_assert(!icStartsWithCharO(self, 's')); 5064 setValO(self, ""); 5065 ck_assert(!icStartsWithCharO(self, '0')); 5066 // NULL string 5067 setValO(self, "shee"); 5068 ck_assert(!icStartsWithCharO(self, 0)); 5069 // empty self 5070 freeO(self); 5071 ck_assert(!icStartsWithCharO(self, '0')); 5072 terminateO(self); 5073 5074 } 5075 5076 5077 void icStartsWithSmallJsonSmallStringT(CuTest *tc UNUSED) { 5078 5079 smallStringt *self = allocG("shee"); 5080 smallJsont *string = allocSmallJson(); 5081 5082 // identical strings 5083 setTopSO(string, "shee"); 5084 ck_assert(icStartsWithSmallJsonO(self, string)); 5085 setValO(self, "sheepy"); 5086 ck_assert(icStartsWithSmallJsonO(self, string)); 5087 // different strings 5088 setValO(self, "shee"); 5089 freeO(string); 5090 setTopSO(string, "SH"); 5091 ck_assert(icStartsWithSmallJsonO(self, string)); 5092 freeO(string); 5093 setTopSO(string, "sheep"); 5094 ck_assert(!icStartsWithSmallJsonO(self, string)); 5095 setValO(self, "-shee"); 5096 freeO(string); 5097 setTopSO(string, "shee"); 5098 ck_assert(!icStartsWithSmallJsonO(self, string)); 5099 // non json string 5100 freeO(string); 5101 setTopIntO(string, 1); 5102 ck_assert(!icStartsWithSmallJsonO(self, string)); 5103 // non json object 5104 terminateO(string); 5105 string = (smallJsont*) allocSmallInt(1); 5106 ck_assert(!icStartsWithSmallJsonO(self, string)); 5107 terminateO(string); 5108 string = allocSmallJson(); 5109 // NULL string 5110 ck_assert(!icStartsWithSmallJsonO(self, NULL)); 5111 // empty self 5112 freeO(self); 5113 setTopSO(string, "shee"); 5114 ck_assert(!icStartsWithSmallJsonO(self, string)); 5115 terminateO(string); 5116 terminateO(self); 5117 5118 } 5119 5120 5121 void icStartsWithSmallStringSmallStringT(CuTest *tc UNUSED) { 5122 5123 smallStringt *self = allocG("shee"); 5124 smallStringt *string = allocSmallString("shee"); 5125 5126 // identical strings 5127 ck_assert(icStartsWithSmallStringO(self, string)); 5128 setValO(self, "sheepy"); 5129 ck_assert(icStartsWithSmallStringO(self, string)); 5130 // different strings 5131 setValO(self, "shee"); 5132 setValO(string, "SH"); 5133 ck_assert(icStartsWithSmallStringO(self, string)); 5134 setValO(string, "sheep"); 5135 ck_assert(!icStartsWithSmallStringO(self, string)); 5136 setValO(self, "-shee"); 5137 setValO(string, "shee"); 5138 ck_assert(!icStartsWithSmallStringO(self, string)); 5139 // non smallString object 5140 terminateO(string); 5141 string = (smallStringt*) allocSmallInt(1); 5142 ck_assert(!icStartsWithSmallStringO(self, string)); 5143 terminateO(string); 5144 string = allocSmallString("shee"); 5145 // NULL string 5146 ck_assert(!icStartsWithSmallStringO(self, NULL)); 5147 // empty self 5148 freeO(self); 5149 ck_assert(!icStartsWithSmallStringO(self, string)); 5150 terminateO(string); 5151 terminateO(self); 5152 5153 } 5154 5155 5156 void icEndsWithSSmallStringT(CuTest *tc UNUSED) { 5157 5158 smallStringt *self = allocG("shee"); 5159 5160 // identical strings 5161 ck_assert(icEndsWithSO(self, "shee")); 5162 setValO(self, "sheepy"); 5163 ck_assert(icEndsWithSO(self, "EEPY")); 5164 // different strings 5165 setValO(self, "shee"); 5166 ck_assert(!icEndsWithSO(self, "SH")); 5167 ck_assert(!icEndsWithSO(self, "sheep")); 5168 setValO(self, "shee-"); 5169 ck_assert(!icEndsWithSO(self, "shee")); 5170 // NULL string 5171 ck_assert(!icEndsWithSO(self, NULL)); 5172 // empty self 5173 freeO(self); 5174 ck_assert(!icEndsWithSO(self, "shee")); 5175 terminateO(self); 5176 5177 } 5178 5179 5180 void icEndsWithCharSmallStringT(CuTest *tc UNUSED) { 5181 5182 smallStringt *self = allocG("shee"); 5183 5184 // identical strings 5185 ck_assert(icEndsWithCharO(self, 'e')); 5186 setValO(self, "sheepy"); 5187 ck_assert(icEndsWithCharO(self, 'y')); 5188 setValO(self, ""); 5189 ck_assert(icEndsWithCharO(self, 0)); 5190 // different strings 5191 setValO(self, "shee"); 5192 ck_assert(icEndsWithCharO(self, 'E')); 5193 ck_assert(!icEndsWithCharO(self, 'p')); 5194 setValO(self, "shee-"); 5195 ck_assert(!icEndsWithCharO(self, 'e')); 5196 setValO(self, ""); 5197 ck_assert(!icEndsWithCharO(self, '0')); 5198 // NULL string 5199 setValO(self, "a"); 5200 ck_assert(!icEndsWithCharO(self, 0)); 5201 // empty self 5202 freeO(self); 5203 ck_assert(!icEndsWithCharO(self, '0')); 5204 terminateO(self); 5205 5206 } 5207 5208 5209 void icEndsWithSmallJsonSmallStringT(CuTest *tc UNUSED) { 5210 5211 smallStringt *self = allocG("shee"); 5212 smallJsont *string = allocSmallJson(); 5213 5214 // identical strings 5215 setTopSO(string, "shee"); 5216 ck_assert(icEndsWithSmallJsonO(self, string)); 5217 setValO(self, "sheepy"); 5218 freeO(string); 5219 setTopSO(string, "EEPY"); 5220 ck_assert(icEndsWithSmallJsonO(self, string)); 5221 // different strings 5222 setValO(self, "shee"); 5223 freeO(string); 5224 setTopSO(string, "SH"); 5225 ck_assert(!icEndsWithSmallJsonO(self, string)); 5226 freeO(string); 5227 setTopSO(string, "sheep"); 5228 ck_assert(!icEndsWithSmallJsonO(self, string)); 5229 setValO(self, "shee-"); 5230 freeO(string); 5231 setTopSO(string, "shee"); 5232 ck_assert(!icEndsWithSmallJsonO(self, string)); 5233 // non json string 5234 freeO(string); 5235 setTopIntO(string, 1); 5236 ck_assert(!icEndsWithSmallJsonO(self, string)); 5237 // non json object 5238 terminateO(string); 5239 string = (smallJsont*) allocSmallInt(1); 5240 ck_assert(!icEndsWithSmallJsonO(self, string)); 5241 terminateO(string); 5242 string = allocSmallJson(); 5243 setTopSO(string, "shee"); 5244 // NULL string 5245 ck_assert(!icEndsWithSmallJsonO(self, NULL)); 5246 // empty self 5247 freeO(self); 5248 ck_assert(!icEndsWithSmallJsonO(self, string)); 5249 terminateO(string); 5250 terminateO(self); 5251 5252 } 5253 5254 5255 void icEndsWithSmallStringSmallStringT(CuTest *tc UNUSED) { 5256 5257 smallStringt *self = allocG("shee"); 5258 smallStringt *string = allocSmallString("shee"); 5259 5260 // identical strings 5261 ck_assert(icEndsWithSmallStringO(self, string)); 5262 setValO(self, "sheepy"); 5263 setValO(string, "EEPY"); 5264 ck_assert(icEndsWithSmallStringO(self, string)); 5265 // different strings 5266 setValO(self, "shee"); 5267 ck_assert(!icEndsWithSmallStringO(self, string)); 5268 setValO(string, "sheep"); 5269 ck_assert(!icEndsWithSmallStringO(self, string)); 5270 setValO(self, "shee-"); 5271 setValO(string, "shee"); 5272 ck_assert(!icEndsWithSmallStringO(self, string)); 5273 // non smallString object 5274 terminateO(string); 5275 string = (smallStringt*) allocSmallInt(1); 5276 ck_assert(!icEndsWithSmallStringO(self, string)); 5277 terminateO(string); 5278 string = allocSmallString("shee"); 5279 // NULL string 5280 ck_assert(!icEndsWithSmallStringO(self, NULL)); 5281 // empty self 5282 freeO(self); 5283 ck_assert(!icEndsWithSmallStringO(self, string)); 5284 terminateO(string); 5285 terminateO(self); 5286 5287 } 5288 5289 5290 void icCountSSmallStringT(CuTest *tc UNUSED) { 5291 5292 smallStringt *self = allocG("sheepy"); 5293 5294 // positive count 5295 ck_assert_int_eq(icCountSO(self, "shee"), 1); 5296 setValO(self, "aaa aaa"); 5297 ck_assert_int_eq(icCountSO(self, "a"), 6); 5298 ck_assert_int_eq(icCountSO(self, "Aa"), 2); 5299 // 0 icCount 5300 setValO(self, "shee"); 5301 ck_assert_int_eq(icCountSO(self, "SH"), 1); 5302 ck_assert_int_eq(icCountSO(self, "sheepy"), 0); 5303 setValO(self, "aaa aaa"); 5304 ck_assert_int_eq(icCountSO(self, "ab"), 0); 5305 // empty string 5306 ck_assert_int_eq(icCountSO(self, ""), -1); 5307 // NULL string 5308 ck_assert_int_eq(icCountSO(self, NULL), -1); 5309 // empty self 5310 freeO(self); 5311 ck_assert_int_eq(icCountSO(self, "ab"), -1); 5312 terminateO(self); 5313 5314 } 5315 5316 5317 void icCountCharSmallStringT(CuTest *tc UNUSED) { 5318 5319 smallStringt *self = allocG("shee"); 5320 5321 // positive count 5322 ck_assert_int_eq(icCountCharO(self, 's'), 1); 5323 setValO(self, "aaa aaa"); 5324 ck_assert_int_eq(icCountCharO(self, 'a'), 6); 5325 // 0 icCount 5326 setValO(self, "shee"); 5327 ck_assert_int_eq(icCountCharO(self, 'S'), 1); 5328 ck_assert_int_eq(icCountCharO(self, 'y'), 0); 5329 setValO(self, "aaa aaa"); 5330 ck_assert_int_eq(icCountCharO(self, 'b'), 0); 5331 // empty string 5332 setValO(self, ""); 5333 ck_assert_int_eq(icCountCharO(self, 'a'), 0); 5334 ck_assert_int_eq(icCountCharO(self, 0), -1); 5335 // NULL string 5336 setValO(self, "a"); 5337 ck_assert_int_eq(icCountCharO(self, 0), -1); 5338 // empty self 5339 freeO(self); 5340 ck_assert_int_eq(icCountCharO(self, 'a'), -1); 5341 terminateO(self); 5342 5343 } 5344 5345 5346 void icCountSmallJsonSmallStringT(CuTest *tc UNUSED) { 5347 5348 smallStringt *self = allocG("sheepy"); 5349 smallJsont *string = allocSmallJson(); 5350 5351 // positive count 5352 setTopSO(string, "shee"); 5353 ck_assert_int_eq(icCountSmallJsonO(self, string), 1); 5354 setValO(self, "aaa aaa"); 5355 freeO(string); 5356 setTopSO(string, "a"); 5357 ck_assert_int_eq(icCountSmallJsonO(self, string), 6); 5358 freeO(string); 5359 setTopSO(string, "aa"); 5360 ck_assert_int_eq(icCountSmallJsonO(self, string), 2); 5361 // 0 icCount 5362 setValO(self, "shee"); 5363 freeO(string); 5364 setTopSO(string, "SH"); 5365 ck_assert_int_eq(icCountSmallJsonO(self, string), 1); 5366 freeO(string); 5367 setTopSO(string, "sheepy"); 5368 ck_assert_int_eq(icCountSmallJsonO(self, string), 0); 5369 setValO(self, "aaa aaa"); 5370 freeO(string); 5371 setTopSO(string, "ab"); 5372 ck_assert_int_eq(icCountSmallJsonO(self, string), 0); 5373 // non json string 5374 freeO(string); 5375 setTopIntO(string, -1); 5376 ck_assert_int_eq(icCountSmallJsonO(self, string), -1); 5377 // non json object 5378 terminateO(string); 5379 string = (smallJsont*) allocSmallInt(1); 5380 ck_assert_int_eq(icCountSmallJsonO(self, string), -1); 5381 terminateO(string); 5382 string = allocSmallJson(); 5383 // empty string 5384 setTopSO(string, ""); 5385 ck_assert_int_eq(icCountSmallJsonO(self, string), -1); 5386 // NULL string 5387 ck_assert_int_eq(icCountSmallJsonO(self, NULL), -1); 5388 // empty self 5389 freeO(self); 5390 freeO(string); 5391 setTopSO(string, "ab"); 5392 ck_assert_int_eq(icCountSmallJsonO(self, string), -1); 5393 terminateO(string); 5394 terminateO(self); 5395 5396 } 5397 5398 5399 void icCountSmallStringSmallStringT(CuTest *tc UNUSED) { 5400 5401 smallStringt *self = allocG("sheepy"); 5402 smallStringt *string = allocSmallString("shee"); 5403 5404 // positive count 5405 ck_assert_int_eq(icCountSmallStringO(self, string), 1); 5406 setValO(self, "aaa aaa"); 5407 setValO(string, "a"); 5408 ck_assert_int_eq(icCountSmallStringO(self, string), 6); 5409 setValO(string, "aa"); 5410 ck_assert_int_eq(icCountSmallStringO(self, string), 2); 5411 // 0 icCount 5412 setValO(self, "shee"); 5413 setValO(string, "SH"); 5414 ck_assert_int_eq(icCountSmallStringO(self, string), 1); 5415 setValO(string, "sheepy"); 5416 ck_assert_int_eq(icCountSmallStringO(self, string), 0); 5417 setValO(self, "aaa aaa"); 5418 setValO(string, "ab"); 5419 ck_assert_int_eq(icCountSmallStringO(self, string), 0); 5420 // non json object 5421 terminateO(string); 5422 string = (smallStringt*) allocSmallInt(1); 5423 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 5424 terminateO(string); 5425 string = allocSmallString(""); 5426 // empty string 5427 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 5428 freeO(string); 5429 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 5430 // NULL string 5431 ck_assert_int_eq(icCountSmallStringO(self, NULL), -1); 5432 // empty self 5433 freeO(self); 5434 setValO(string, "ab"); 5435 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 5436 terminateO(string); 5437 terminateO(self); 5438 5439 } 5440 5441 5442 void isNumberSmallStringT(CuTest *tc UNUSED) { 5443 5444 smallStringt *self = allocG(""); 5445 5446 // number 5447 setValO(self, "-12.3"); 5448 ck_assert(isNumberO(self)); 5449 setValO(self, "-123"); 5450 ck_assert(isNumberO(self)); 5451 setValO(self, "123"); 5452 ck_assert(isNumberO(self)); 5453 setValO(self, "1e23"); 5454 ck_assert(isNumberO(self)); 5455 setValO(self, "12E-3"); 5456 ck_assert(isNumberO(self)); 5457 setValO(self, ".123"); 5458 ck_assert(isNumberO(self)); 5459 setValO(self, "-.123"); 5460 ck_assert(isNumberO(self)); 5461 setValO(self, "1E+32"); 5462 ck_assert(isNumberO(self)); 5463 // not a number 5464 setValO(self, ".12e3"); 5465 ck_assert(!isNumberO(self)); 5466 setValO(self, "-.12e3"); 5467 ck_assert(!isNumberO(self)); 5468 setValO(self, "-1-23"); 5469 ck_assert(!isNumberO(self)); 5470 setValO(self, "123-"); 5471 ck_assert(!isNumberO(self)); 5472 setValO(self, "-"); 5473 ck_assert(!isNumberO(self)); 5474 setValO(self, "-123."); 5475 ck_assert(!isNumberO(self)); 5476 setValO(self, "-1.2.3"); 5477 ck_assert(!isNumberO(self)); 5478 setValO(self, "1-2.3"); 5479 ck_assert(!isNumberO(self)); 5480 setValO(self, "12..3"); 5481 ck_assert(!isNumberO(self)); 5482 setValO(self, ".12.3"); 5483 ck_assert(!isNumberO(self)); 5484 setValO(self, "."); 5485 ck_assert(!isNumberO(self)); 5486 setValO(self, "E12"); 5487 ck_assert(!isNumberO(self)); 5488 setValO(self, "E1E2"); 5489 ck_assert(!isNumberO(self)); 5490 setValO(self, "E1.2"); 5491 ck_assert(!isNumberO(self)); 5492 setValO(self, "1E"); 5493 ck_assert(!isNumberO(self)); 5494 setValO(self, "1E2.3"); 5495 ck_assert(!isNumberO(self)); 5496 setValO(self, "1-"); 5497 ck_assert(!isNumberO(self)); 5498 setValO(self, "1E-"); 5499 ck_assert(!isNumberO(self)); 5500 setValO(self, "lib123sheepy"); 5501 ck_assert(!isNumberO(self)); 5502 // string without number 5503 setValO(self, "s"); 5504 ck_assert(!isNumberO(self)); 5505 // empty string 5506 setValO(self, ""); 5507 ck_assert(!isNumberO(self)); 5508 // NULL string 5509 freeO(self); 5510 ck_assert(!isNumberO(self)); 5511 terminateO(self); 5512 5513 } 5514 5515 5516 void isIntSmallStringT(CuTest *tc UNUSED) { 5517 5518 smallStringt *self = allocG(""); 5519 5520 // integer 5521 setValO(self, "-123"); 5522 ck_assert(isIntO(self)); 5523 setValO(self, "123"); 5524 ck_assert(isIntO(self)); 5525 // not a integer 5526 setValO(self, "1e23"); 5527 ck_assert(!isIntO(self)); 5528 setValO(self, "12E-3"); 5529 ck_assert(!isIntO(self)); 5530 setValO(self, "-12.3"); 5531 ck_assert(!isIntO(self)); 5532 setValO(self, "-1-23"); 5533 ck_assert(!isIntO(self)); 5534 setValO(self, "123-"); 5535 ck_assert(!isIntO(self)); 5536 setValO(self, "-"); 5537 ck_assert(!isIntO(self)); 5538 setValO(self, "-123."); 5539 ck_assert(!isIntO(self)); 5540 setValO(self, ".123"); 5541 ck_assert(!isIntO(self)); 5542 setValO(self, "-1.2.3"); 5543 ck_assert(!isIntO(self)); 5544 setValO(self, "1-2.3"); 5545 ck_assert(!isIntO(self)); 5546 setValO(self, "12..3"); 5547 ck_assert(!isIntO(self)); 5548 setValO(self, "."); 5549 ck_assert(!isIntO(self)); 5550 setValO(self, "1E"); 5551 ck_assert(!isIntO(self)); 5552 setValO(self, "1-"); 5553 ck_assert(!isIntO(self)); 5554 setValO(self, "1E-"); 5555 ck_assert(!isIntO(self)); 5556 setValO(self, "lib123sheepy"); 5557 ck_assert(!isIntO(self)); 5558 // string without number 5559 setValO(self, "s"); 5560 ck_assert(!isIntO(self)); 5561 // empty string 5562 setValO(self, ""); 5563 ck_assert(!isIntO(self)); 5564 // NULL string 5565 freeO(self); 5566 ck_assert(!isIntO(self)); 5567 terminateO(self); 5568 5569 } 5570 5571 5572 void parseIntSmallStringT(CuTest *tc UNUSED) { 5573 5574 smallStringt *self = allocG(""); 5575 5576 // number 5577 setValO(self, "123sheepy"); 5578 ck_assert_int_eq(parseIntO(self), 123); 5579 setValO(self, "lib123sheepy"); 5580 ck_assert_int_eq(parseIntO(self), 123); 5581 setValO(self, "-123"); 5582 ck_assert_int_eq(parseIntO(self), -123); 5583 // out of range - TODO check stderr 5584 setValO(self, "999999999999999999999999999999999999999"); 5585 parseIntO(self); 5586 // string without number 5587 setValO(self, "sheepy"); 5588 ck_assert_int_eq(parseIntO(self), 0); 5589 // NULL string 5590 freeO(self); 5591 ck_assert_int_eq(parseIntO(self), 0); 5592 terminateO(self); 5593 5594 } 5595 5596 5597 void parseDoubleSmallStringT(CuTest *tc UNUSED) { 5598 5599 smallStringt *self = allocG(""); 5600 5601 // number 5602 setValO(self, "123.2sheepy"); 5603 ck_assert_int_eq(parseDoubleO(self), 123); 5604 setValO(self, "lib123sheepy"); 5605 ck_assert_int_eq(parseDoubleO(self), 123); 5606 setValO(self, "-123"); 5607 ck_assert_int_eq(parseDoubleO(self), -123); 5608 // out of range - TODO check stderr 5609 setValO(self, "999999999999999999999999999999999999999"); 5610 parseDoubleO(self); 5611 // string without number 5612 setValO(self, "sheepy"); 5613 ck_assert_int_eq(parseDoubleO(self), 0); 5614 // NULL string 5615 freeO(self); 5616 ck_assert_int_eq(parseDoubleO(self), 0); 5617 terminateO(self); 5618 5619 } 5620 5621 5622 void intToSmallStringT(CuTest *tc UNUSED) { 5623 5624 smallStringt* r; 5625 smallStringt *self = allocG(""); 5626 5627 // number 5628 r = intToO(self, 123); 5629 ck_assert_ptr_ne(r, null); 5630 char *s = toStringO(r); 5631 ck_assert_str_eq(s, "123"); 5632 free(s); 5633 r = intToO(self, -465464123); 5634 ck_assert_ptr_ne(r, null); 5635 s = toStringO(r); 5636 ck_assert_str_eq(s, "-465464123"); 5637 free(s); 5638 terminateO(self); 5639 5640 } 5641 5642 5643 void doubleToSmallStringT(CuTest *tc UNUSED) { 5644 5645 smallStringt* r; 5646 smallStringt *self = allocG(""); 5647 5648 // number 5649 r = doubleToO(self, 123.4); 5650 ck_assert_ptr_ne(r, null); 5651 char *s = toStringO(r); 5652 ck_assert_str_eq(s, "1.234000e+02"); 5653 free(s); 5654 r = doubleToO(self, -4652445e5); 5655 ck_assert_ptr_ne(r, null); 5656 s = toStringO(r); 5657 ck_assert_str_eq(s, "-4.652445e+11"); 5658 free(s); 5659 terminateO(self); 5660 5661 } 5662 5663 5664 void lenSmallStringT(CuTest *tc UNUSED) { 5665 5666 size_t r; 5667 smallStringt *self = allocG(""); 5668 5669 r = lenO(self); 5670 ck_assert_int_eq(r, 0); 5671 setValO(self, "123"); 5672 r = lenO(self); 5673 ck_assert_int_eq(r, 3); 5674 freeO(self); 5675 r = lenO(self); 5676 ck_assert_int_eq(r, 0); 5677 terminateO(self); 5678 5679 } 5680 5681 5682 void upperSmallStringT(CuTest *tc UNUSED) { 5683 5684 smallStringt* r; 5685 smallStringt *self = allocG("sheepy"); 5686 5687 // string 5688 r = upperO(self); 5689 ck_assert_ptr_ne(r, null); 5690 char *s = toStringO(r); 5691 ck_assert_str_eq(s, "SHEEPY"); 5692 free(s); 5693 // NULL string 5694 freeO(self); 5695 ck_assert_ptr_eq(upperO(self), NULL); 5696 terminateO(self); 5697 5698 } 5699 5700 5701 void lowerSmallStringT(CuTest *tc UNUSED) { 5702 5703 smallStringt* r; 5704 smallStringt *self = allocG("SHeePY"); 5705 5706 // string 5707 r = lowerO(self); 5708 ck_assert_ptr_ne(r, null); 5709 char *s = toStringO(r); 5710 ck_assert_str_eq(s, "sheepy"); 5711 free(s); 5712 // NULL string 5713 freeO(self); 5714 ck_assert_ptr_eq(lowerO(self), NULL); 5715 terminateO(self); 5716 5717 } 5718 5719 5720 void trimSmallStringT(CuTest *tc UNUSED) { 5721 5722 smallStringt* r; 5723 smallStringt *self = allocG(""); 5724 5725 // no spaces 5726 setValO(self, "SHeePY"); 5727 r = trimO(self); 5728 ck_assert_ptr_ne(r, null); 5729 char *s = toStringO(r); 5730 ck_assert_str_eq(s, "SHeePY"); 5731 free(s); 5732 // heading spaces 5733 setValO(self, " SHeePY"); 5734 r = trimO(self); 5735 ck_assert_ptr_ne(r, null); 5736 s = toStringO(r); 5737 ck_assert_str_eq(s, "SHeePY"); 5738 free(s); 5739 // trailing spaces 5740 setValO(self, "SHeePY "); 5741 r = trimO(self); 5742 ck_assert_ptr_ne(r, null); 5743 s = toStringO(r); 5744 ck_assert_str_eq(s, "SHeePY"); 5745 free(s); 5746 // string with spaces in the middle 5747 setValO(self, " SHe ePY "); 5748 r = trimO(self); 5749 ck_assert_ptr_ne(r, null); 5750 s = toStringO(r); 5751 ck_assert_str_eq(s, "SHe ePY"); 5752 free(s); 5753 // all spaces 5754 setValO(self, " "); 5755 r = trimO(self); 5756 ck_assert_ptr_ne(r, null); 5757 s = toStringO(r); 5758 ck_assert_str_eq(s, ""); 5759 free(s); 5760 // empty string 5761 setValO(self, ""); 5762 r = trimO(self); 5763 ck_assert_ptr_ne(r, null); 5764 s = toStringO(r); 5765 ck_assert_str_eq(s, ""); 5766 free(s); 5767 // NULL string 5768 freeO(self); 5769 ck_assert_ptr_eq(trimO(self), NULL); 5770 terminateO(self); 5771 5772 } 5773 5774 5775 void lTrimSmallStringT(CuTest *tc UNUSED) { 5776 5777 smallStringt* r; 5778 smallStringt *self = allocG(""); 5779 5780 // no spaces 5781 setValO(self, "SHeePY"); 5782 r = lTrimO(self); 5783 ck_assert_ptr_ne(r, null); 5784 char *s = toStringO(r); 5785 ck_assert_str_eq(s, "SHeePY"); 5786 free(s); 5787 // heading spaces 5788 setValO(self, " SHeePY"); 5789 r = lTrimO(self); 5790 ck_assert_ptr_ne(r, null); 5791 s = toStringO(r); 5792 ck_assert_str_eq(s, "SHeePY"); 5793 free(s); 5794 // trailing spaces 5795 setValO(self, "SHeePY "); 5796 r = lTrimO(self); 5797 ck_assert_ptr_ne(r, null); 5798 s = toStringO(r); 5799 ck_assert_str_eq(s, "SHeePY "); 5800 free(s); 5801 // string with spaces in the middle 5802 setValO(self, " SHe ePY "); 5803 r = lTrimO(self); 5804 ck_assert_ptr_ne(r, null); 5805 s = toStringO(r); 5806 ck_assert_str_eq(s, "SHe ePY "); 5807 free(s); 5808 // all spaces 5809 setValO(self, " "); 5810 r = lTrimO(self); 5811 ck_assert_ptr_ne(r, null); 5812 s = toStringO(r); 5813 ck_assert_str_eq(s, ""); 5814 free(s); 5815 setValO(self, ""); 5816 r = lTrimO(self); 5817 ck_assert_ptr_ne(r, null); 5818 s = toStringO(r); 5819 ck_assert_str_eq(s, ""); 5820 free(s); 5821 // NULL string 5822 freeO(self); 5823 ck_assert_ptr_eq(lTrimO(self), NULL); 5824 terminateO(self); 5825 5826 } 5827 5828 5829 void rTrimSmallStringT(CuTest *tc UNUSED) { 5830 5831 smallStringt* r; 5832 smallStringt *self = allocG(""); 5833 5834 // no spaces 5835 setValO(self, "SHeePY"); 5836 r = rTrimO(self); 5837 ck_assert_ptr_ne(r, null); 5838 char *s = toStringO(r); 5839 ck_assert_str_eq(s, "SHeePY"); 5840 free(s); 5841 // heading spaces 5842 setValO(self, " SHeePY"); 5843 r = rTrimO(self); 5844 ck_assert_ptr_ne(r, null); 5845 s = toStringO(r); 5846 ck_assert_str_eq(s, " SHeePY"); 5847 free(s); 5848 // trailing spaces 5849 setValO(self, "SHeePY "); 5850 r = rTrimO(self); 5851 ck_assert_ptr_ne(r, null); 5852 s = toStringO(r); 5853 ck_assert_str_eq(s, "SHeePY"); 5854 free(s); 5855 // string with spaces in the middle 5856 setValO(self, " SHe ePY "); 5857 r = rTrimO(self); 5858 ck_assert_ptr_ne(r, null); 5859 s = toStringO(r); 5860 ck_assert_str_eq(s, " SHe ePY"); 5861 free(s); 5862 // all spaces 5863 setValO(self, " "); 5864 r = rTrimO(self); 5865 ck_assert_ptr_ne(r, null); 5866 s = toStringO(r); 5867 ck_assert_str_eq(s, ""); 5868 free(s); 5869 // empty string 5870 setValO(self, ""); 5871 r = rTrimO(self); 5872 ck_assert_ptr_ne(r, null); 5873 s = toStringO(r); 5874 ck_assert_str_eq(s, ""); 5875 free(s); 5876 // NULL string 5877 freeO(self); 5878 ck_assert_ptr_eq(rTrimO(self), NULL); 5879 terminateO(self); 5880 5881 } 5882 5883 5884 void uniqSmallStringT(CuTest *tc UNUSED) { 5885 5886 smallStringt* r; 5887 smallStringt *self = allocG(""); 5888 5889 // uniquify 5890 setValO(self, "/qwd///"); 5891 r = uniqO(self, '/'); 5892 ck_assert_ptr_ne(r, null); 5893 char *s = toStringO(r); 5894 ck_assert_str_eq(s, "/qwd/"); 5895 free(s); 5896 // short string 5897 setValO(self, "?"); 5898 r = uniqO(self, '/'); 5899 ck_assert_ptr_ne(r, null); 5900 s = toStringO(r); 5901 ck_assert_str_eq(s, "?"); 5902 free(s); 5903 // NULL 5904 freeO(self); 5905 ck_assert_ptr_eq(uniqO(self, '/'), NULL); 5906 terminateO(self); 5907 5908 } 5909 5910 5911 void icUniqSmallStringT(CuTest *tc UNUSED) { 5912 5913 smallStringt* r; 5914 smallStringt *self = allocG(""); 5915 5916 // uniquify 5917 setValO(self, "/qQwd///"); 5918 r = icUniqO(self, 'q'); 5919 ck_assert_ptr_ne(r, null); 5920 char *s = toStringO(r); 5921 ck_assert_str_eq(s, "/qwd///"); 5922 free(s); 5923 // short string 5924 setValO(self, "?"); 5925 r = icUniqO(self, '/'); 5926 ck_assert_ptr_ne(r, null); 5927 s = toStringO(r); 5928 ck_assert_str_eq(s, "?"); 5929 free(s); 5930 // NULL 5931 freeO(self); 5932 ck_assert_ptr_eq(icUniqO(self, '/'), NULL); 5933 terminateO(self); 5934 5935 } 5936 5937 5938 void getAtSmallStringT(CuTest *tc UNUSED) { 5939 5940 smallStringt *self = allocG(""); 5941 5942 // get char 5943 setValO(self, "sheepy"); 5944 ck_assert_uint_eq(getAtO(self, 0), 's'); 5945 // negative index 5946 ck_assert_uint_eq(getAtO(self, -1), 'y'); 5947 // outside string 5948 ck_assert_uint_eq(getAtO(self, 10), 0); 5949 ck_assert_uint_eq(getAtO(self, -10), 0); 5950 // negative index in a one char string 5951 setValO(self, "z"); 5952 ck_assert_uint_eq(getAtO(self, -1), 'z'); 5953 // empty string 5954 setValO(self, ""); 5955 ck_assert_uint_eq(getAtO(self, 0), 0); 5956 // NULL string 5957 freeO(self); 5958 ck_assert_uint_eq(getAtO(self, 0), 0); 5959 terminateO(self); 5960 5961 } 5962 5963 5964 void setAtSmallStringT(CuTest *tc UNUSED) { 5965 5966 smallStringt* r; 5967 smallStringt *self = allocG("sheepy"); 5968 5969 // set char 5970 r = setAtO(self, 0, 'S'); 5971 ck_assert_ptr_ne(r, null); 5972 ck_assert_uint_eq(ssGet(self)[0], 'S'); 5973 // negative index 5974 r = setAtO(self, -2, 'P'); 5975 ck_assert_ptr_ne(r, null); 5976 ck_assert_uint_eq(ssGet(self)[4], 'P'); 5977 // outside string 5978 r = setAtO(self, 20, 'Y'); 5979 ck_assert_ptr_eq(r, null); 5980 r = setAtO(self, -20, 'Y'); 5981 ck_assert_ptr_eq(r, null); 5982 ck_assert_str_eq(ssGet(self), "SheePy"); 5983 // negative index in a one char string 5984 setValO(self, "s"); 5985 r = setAtO(self, -1, 'S'); 5986 ck_assert_ptr_ne(r, null); 5987 ck_assert_uint_eq(ssGet(self)[0], 'S'); 5988 // empty string 5989 setValO(self, ""); 5990 r = setAtO(self, -1, 'S'); 5991 ck_assert_ptr_eq(r, null); 5992 ck_assert_str_eq(ssGet(self), ""); 5993 // NULL string 5994 freeO(self); 5995 r = setAtO(self, 0, 's'); 5996 ck_assert_ptr_eq(r, null); 5997 terminateO(self); 5998 5999 } 6000 6001 6002 void sliceSmallStringT(CuTest *tc UNUSED) { 6003 6004 smallStringt* r; 6005 smallStringt *self = allocG(""); 6006 6007 // slice 6008 setValO(self, "sheepy"); 6009 r = sliceO(self, 0,2); 6010 ck_assert_ptr_ne(r, null); 6011 ck_assert_str_eq(ssGet(self), "sh"); 6012 // negative index 6013 setValO(self, "sheepy"); 6014 r = sliceO(self, -2,0); 6015 ck_assert_ptr_ne(r, null); 6016 ck_assert_str_eq(ssGet(self), "py"); 6017 // positive and negative indexes 6018 setValO(self, "sheepy"); 6019 r = sliceO(self, 2,-2); 6020 ck_assert_ptr_ne(r, null); 6021 ck_assert_str_eq(ssGet(self), "ee"); 6022 // start = end 6023 setValO(self, "sheepy"); 6024 r = sliceO(self, 2,-4); 6025 ck_assert_ptr_ne(r, null); 6026 ck_assert_str_eq(ssGet(self), ""); 6027 // end of string 6028 setValO(self, "sheepy"); 6029 r = sliceO(self, 2,6); 6030 ck_assert_ptr_ne(r, null); 6031 ck_assert_str_eq(ssGet(self), "eepy"); 6032 // NULL string 6033 freeO(self); 6034 ck_assert_ptr_eq(sliceO(self, 2,-4), NULL); 6035 // start outside string 6036 setValO(self, "sheepy"); 6037 ck_assert_ptr_eq(sliceO(self, 20,-4), NULL); 6038 // end outside string 6039 setValO(self, "sheepy"); 6040 r = sliceO(self, 2,40); 6041 ck_assert_ptr_ne(r, null); 6042 ck_assert_str_eq(ssGet(self), "eepy"); 6043 setValO(self, "sheepy"); 6044 r = sliceO(self, -22,3); 6045 ck_assert_ptr_ne(r, null); 6046 ck_assert_str_eq(ssGet(self), "she"); 6047 setValO(self, "sheepy"); 6048 ck_assert_ptr_eq(sliceO(self, 2,-40), NULL); 6049 // end before start 6050 setValO(self, "sheepy"); 6051 ck_assert_ptr_eq(sliceO(self, 4,2), NULL); 6052 terminateO(self); 6053 6054 } 6055 6056 6057 void cropSmallStringT(CuTest *tc UNUSED) { 6058 6059 smallStringt* r; 6060 smallStringt *self = allocG(""); 6061 6062 // crop 6063 setValO(self, "sheepy"); 6064 r = cropO(self, 0,2); 6065 ck_assert_ptr_ne(r, null); 6066 ck_assert_str_eq(ssGet(r), "sh"); 6067 ck_assert_str_eq(ssGet(self), "eepy"); 6068 terminateO(r); 6069 // negative index 6070 setValO(self, "sheepy"); 6071 r = cropO(self, -2,0); 6072 ck_assert_ptr_ne(r, null); 6073 ck_assert_str_eq(ssGet(r), "py"); 6074 ck_assert_str_eq(ssGet(self), "shee"); 6075 terminateO(r); 6076 // positive and negative indexes 6077 setValO(self, "sheepy"); 6078 r = cropO(self, 2,-2); 6079 ck_assert_ptr_ne(r, null); 6080 ck_assert_str_eq(ssGet(r), "ee"); 6081 ck_assert_str_eq(ssGet(self), "shpy"); 6082 terminateO(r); 6083 // start = end 6084 setValO(self, "sheepy"); 6085 r = cropO(self, 2,-4); 6086 ck_assert_ptr_ne(r, null); 6087 ck_assert_str_eq(ssGet(r), ""); 6088 ck_assert_str_eq(ssGet(self), "sheepy"); 6089 terminateO(r); 6090 // end of string 6091 setValO(self, "sheepy"); 6092 r = cropO(self, 2,6); 6093 ck_assert_ptr_ne(r, null); 6094 ck_assert_str_eq(ssGet(r), "eepy"); 6095 ck_assert_str_eq(ssGet(self), "sh"); 6096 terminateO(r); 6097 // NULL string 6098 freeO(self); 6099 ck_assert_ptr_eq(cropO(self, 2,-4), NULL); 6100 // start outside string 6101 setValO(self, "sheepy"); 6102 ck_assert_ptr_eq(cropO(self, 20,-4), NULL); 6103 // end outside string 6104 setValO(self, "sheepy"); 6105 r = cropO(self, 2,40); 6106 ck_assert_ptr_ne(r, null); 6107 ck_assert_str_eq(ssGet(r), "eepy"); 6108 ck_assert_str_eq(ssGet(self), "sh"); 6109 terminateO(r); 6110 setValO(self, "sheepy"); 6111 r = cropO(self, -22,3); 6112 ck_assert_ptr_ne(r, null); 6113 ck_assert_str_eq(ssGet(r), "she"); 6114 ck_assert_str_eq(ssGet(self), "epy"); 6115 terminateO(r); 6116 setValO(self, "sheepy"); 6117 ck_assert_ptr_eq(cropO(self, 2,-40), NULL); 6118 // end before start 6119 ck_assert_ptr_eq(cropO(self, 4,2), NULL); 6120 terminateO(self); 6121 6122 } 6123 6124 6125 void cropSSmallStringT(CuTest *tc UNUSED) { 6126 6127 char* s; 6128 smallStringt *self = allocG(""); 6129 6130 // crop 6131 setValO(self, "sheepy"); 6132 s = cropSO(self, 0,2); 6133 ck_assert_str_eq(s, "sh"); 6134 ck_assert_str_eq(ssGet(self), "eepy"); 6135 free(s); 6136 // negative index 6137 setValO(self, "sheepy"); 6138 s = cropSO(self, -2,0); 6139 ck_assert_str_eq(s, "py"); 6140 ck_assert_str_eq(ssGet(self), "shee"); 6141 free(s); 6142 // positive and negative indexes 6143 setValO(self, "sheepy"); 6144 s = cropSO(self, 2,-2); 6145 ck_assert_str_eq(s, "ee"); 6146 ck_assert_str_eq(ssGet(self), "shpy"); 6147 free(s); 6148 // start = end 6149 setValO(self, "sheepy"); 6150 s = cropSO(self, 2,-4); 6151 ck_assert_str_eq(s, ""); 6152 ck_assert_str_eq(ssGet(self), "sheepy"); 6153 free(s); 6154 // end of string 6155 setValO(self, "sheepy"); 6156 s = cropSO(self, 2,6); 6157 ck_assert_str_eq(s, "eepy"); 6158 ck_assert_str_eq(ssGet(self), "sh"); 6159 free(s); 6160 // NULL string 6161 freeO(self); 6162 ck_assert_ptr_eq(cropSO(self, 2,-4), NULL); 6163 // start outside string 6164 setValO(self, "sheepy"); 6165 ck_assert_ptr_eq(cropSO(self, 20,-4), NULL); 6166 // end outside string 6167 setValO(self, "sheepy"); 6168 s = cropSO(self, 2,40); 6169 ck_assert_str_eq(s, "eepy"); 6170 ck_assert_str_eq(ssGet(self), "sh"); 6171 free(s); 6172 setValO(self, "sheepy"); 6173 s = cropSO(self, -22,3); 6174 ck_assert_str_eq(s, "she"); 6175 ck_assert_str_eq(ssGet(self), "epy"); 6176 free(s); 6177 setValO(self, "sheepy"); 6178 ck_assert_ptr_eq(cropSO(self, 2,-40), NULL); 6179 // end before start 6180 ck_assert_ptr_eq(cropSO(self, 4,2), NULL); 6181 terminateO(self); 6182 6183 } 6184 6185 6186 void cropSmallJsonSmallStringT(CuTest *tc UNUSED) { 6187 6188 smallJsont* r; 6189 smallStringt *self = allocG(""); 6190 6191 // crop 6192 setValO(self, "sheepy"); 6193 r = cropSmallJsonO(self, 0,2); 6194 ck_assert_ptr_ne(r, null); 6195 ck_assert_str_eq(sjGet(r), "sh"); 6196 ck_assert_str_eq(ssGet(self), "eepy"); 6197 terminateO(r); 6198 // negative index 6199 setValO(self, "sheepy"); 6200 r = cropSmallJsonO(self, -2,0); 6201 ck_assert_ptr_ne(r, null); 6202 ck_assert_str_eq(sjGet(r), "py"); 6203 ck_assert_str_eq(ssGet(self), "shee"); 6204 terminateO(r); 6205 // positive and negative indexes 6206 setValO(self, "sheepy"); 6207 r = cropSmallJsonO(self, 2,-2); 6208 ck_assert_ptr_ne(r, null); 6209 ck_assert_str_eq(sjGet(r), "ee"); 6210 ck_assert_str_eq(ssGet(self), "shpy"); 6211 terminateO(r); 6212 // start = end 6213 setValO(self, "sheepy"); 6214 r = cropSmallJsonO(self, 2,-4); 6215 ck_assert_ptr_ne(r, null); 6216 ck_assert_str_eq(sjGet(r), ""); 6217 ck_assert_str_eq(ssGet(self), "sheepy"); 6218 terminateO(r); 6219 // end of string 6220 setValO(self, "sheepy"); 6221 r = cropSmallJsonO(self, 2,6); 6222 ck_assert_ptr_ne(r, null); 6223 ck_assert_str_eq(sjGet(r), "eepy"); 6224 ck_assert_str_eq(ssGet(self), "sh"); 6225 terminateO(r); 6226 // NULL string 6227 freeO(self); 6228 ck_assert_ptr_eq(cropSmallJsonO(self, 2,-4), NULL); 6229 // start outside string 6230 setValO(self, "sheepy"); 6231 ck_assert_ptr_eq(cropSmallJsonO(self, 20,-4), NULL); 6232 // end outside string 6233 setValO(self, "sheepy"); 6234 r = cropSmallJsonO(self, 2,40); 6235 ck_assert_ptr_ne(r, null); 6236 ck_assert_str_eq(sjGet(r), "eepy"); 6237 ck_assert_str_eq(ssGet(self), "sh"); 6238 terminateO(r); 6239 setValO(self, "sheepy"); 6240 r = cropSmallJsonO(self, -22,3); 6241 ck_assert_ptr_ne(r, null); 6242 ck_assert_str_eq(sjGet(r), "she"); 6243 ck_assert_str_eq(ssGet(self), "epy"); 6244 terminateO(r); 6245 setValO(self, "sheepy"); 6246 ck_assert_ptr_eq(cropSmallJsonO(self, 2,-40), NULL); 6247 // end before start 6248 ck_assert_ptr_eq(cropSmallJsonO(self, 4,2), NULL); 6249 terminateO(self); 6250 terminateO(self); 6251 6252 } 6253 6254 6255 void cropElemSmallStringT(CuTest *tc UNUSED) { 6256 6257 char r; 6258 smallStringt *self = allocG(""); 6259 6260 // crop 6261 setValO(self, "sheepy"); 6262 r = cropElemO(self, 0); 6263 ck_assert_int_eq(r, 's'); 6264 ck_assert_str_eq(ssGet(self), "heepy"); 6265 setValO(self, "sheepy"); 6266 r = cropElemO(self, 5); 6267 ck_assert_int_eq(r, 'y'); 6268 ck_assert_str_eq(ssGet(self), "sheep"); 6269 // negative index 6270 setValO(self, "sheepy"); 6271 r = cropElemO(self, -1); 6272 ck_assert_int_eq(r, 'y'); 6273 ck_assert_str_eq(ssGet(self), "sheep"); 6274 setValO(self, "sheepy"); 6275 r = cropElemO(self, -6); 6276 ck_assert_int_eq(r, 's'); 6277 ck_assert_str_eq(ssGet(self), "heepy"); 6278 // index outside string 6279 setValO(self, "sheepy"); 6280 r = cropElemO(self, 6); 6281 ck_assert_int_eq(r, 0); 6282 ck_assert_str_eq(ssGet(self), "sheepy"); 6283 setValO(self, "sheepy"); 6284 r = cropElemO(self, -7); 6285 ck_assert_int_eq(r, 0); 6286 ck_assert_str_eq(ssGet(self), "sheepy"); 6287 // null string 6288 freeO(self); 6289 ck_assert_int_eq(cropElemO(self, 0), 0); 6290 terminateO(self); 6291 6292 } 6293 6294 6295 void copySmallStringT(CuTest *tc UNUSED) { 6296 6297 smallStringt* r; 6298 smallStringt *self = allocG(""); 6299 6300 // copy range 6301 setValO(self, "sheepy"); 6302 r = copyRngO(self, 0,2); 6303 ck_assert_ptr_ne(r, null); 6304 ck_assert_str_eq(ssGet(r), "sh"); 6305 ck_assert_str_eq(ssGet(self), "sheepy"); 6306 terminateO(r); 6307 // negative index 6308 r = copyRngO(self, -2,0); 6309 ck_assert_ptr_ne(r, null); 6310 ck_assert_str_eq(ssGet(r), "py"); 6311 ck_assert_str_eq(ssGet(self), "sheepy"); 6312 terminateO(r); 6313 // positive and negative indexes 6314 r = copyRngO(self, 2,-2); 6315 ck_assert_ptr_ne(r, null); 6316 ck_assert_str_eq(ssGet(r), "ee"); 6317 ck_assert_str_eq(ssGet(self), "sheepy"); 6318 terminateO(r); 6319 // start = end 6320 r = copyRngO(self, 2,-4); 6321 ck_assert_ptr_ne(r, null); 6322 ck_assert_str_eq(ssGet(r), ""); 6323 ck_assert_str_eq(ssGet(self), "sheepy"); 6324 terminateO(r); 6325 // end of string 6326 r = copyRngO(self, 2,6); 6327 ck_assert_ptr_ne(r, null); 6328 ck_assert_str_eq(ssGet(r), "eepy"); 6329 ck_assert_str_eq(ssGet(self), "sheepy"); 6330 terminateO(r); 6331 // NULL string 6332 freeO(self); 6333 ck_assert_ptr_eq(copyRngO(self, 2,-4), NULL); 6334 // start outside string 6335 setValO(self, "sheepy"); 6336 ck_assert_ptr_eq(copyRngO(self, 20,-4), NULL); 6337 // end outside string 6338 r = copyRngO(self, 2,40); 6339 ck_assert_ptr_ne(r, null); 6340 ck_assert_str_eq(ssGet(r), "eepy"); 6341 ck_assert_str_eq(ssGet(self), "sheepy"); 6342 terminateO(r); 6343 r = copyRngO(self, -22,3); 6344 ck_assert_ptr_ne(r, null); 6345 ck_assert_str_eq(ssGet(r), "she"); 6346 ck_assert_str_eq(ssGet(self), "sheepy"); 6347 terminateO(r); 6348 ck_assert_ptr_eq(copyRngO(self, 2,-40), NULL); 6349 // end before start 6350 ck_assert_ptr_eq(copyRngO(self, 4,2), NULL); 6351 terminateO(self); 6352 6353 } 6354 6355 6356 void insertSmallStringT(CuTest *tc UNUSED) { 6357 6358 smallStringt* r; 6359 smallStringt *self = allocG(""); 6360 smallStringt *toInsert = allocSmallString(""); 6361 6362 // insert 6363 setValO(self, "sheepy"); 6364 setValO(toInsert, "lib"); 6365 r = insertO(self, 0, toInsert); 6366 ck_assert_ptr_ne(r, null); 6367 char *s = toStringO(r); 6368 ck_assert_str_eq(s, "libsheepy"); 6369 free(s); 6370 // negative index 6371 setValO(toInsert, "P"); 6372 r = insertO(self, -2, toInsert); 6373 ck_assert_ptr_ne(r, null); 6374 s = toStringO(r); 6375 ck_assert_str_eq(s, "libsheepPy"); 6376 free(s); 6377 // edge 6378 setValO(self, "qwe"); 6379 setValO(toInsert, "C"); 6380 r = insertO(self, 3, toInsert); 6381 ck_assert_ptr_ne(r, null); 6382 s = toStringO(r); 6383 ck_assert_str_eq(s, "qweC"); 6384 free(s); 6385 // outside string 6386 setValO(self, "qwe"); 6387 r = insertO(self, 4, toInsert); 6388 ck_assert_ptr_eq(r, NULL); 6389 r = insertO(self, -5, toInsert); 6390 ck_assert_ptr_eq(r, NULL); 6391 // negative index in a one char string 6392 setValO(self, "s"); 6393 setValO(toInsert, "S"); 6394 r = insertO(self, -1, toInsert); 6395 ck_assert_ptr_ne(r, null); 6396 s = toStringO(r); 6397 ck_assert_str_eq(s, "sS"); 6398 free(s); 6399 // empty string 6400 setValO(self, ""); 6401 setValO(toInsert, "s"); 6402 r = insertO(self, 0, toInsert); 6403 ck_assert_ptr_ne(r, null); 6404 s = toStringO(r); 6405 ck_assert_str_eq(s, "s"); 6406 free(s); 6407 setValO(self, ""); 6408 r = insertO(self, -1, toInsert); 6409 ck_assert_ptr_ne(r, null); 6410 s = toStringO(r); 6411 ck_assert_str_eq(s, "s"); 6412 free(s); 6413 // empty insert string 6414 setValO(self, "a"); 6415 setValO(toInsert, ""); 6416 r = insertO(self, 0, toInsert); 6417 ck_assert_ptr_ne(r, null); 6418 s = toStringO(r); 6419 ck_assert_str_eq(s, "a"); 6420 free(s); 6421 freeO(toInsert); 6422 r = insertO(self, 0, toInsert); 6423 ck_assert_ptr_ne(r, null); 6424 s = toStringO(r); 6425 ck_assert_str_eq(s, "a"); 6426 free(s); 6427 // non smallString toInsert 6428 terminateO(toInsert); 6429 toInsert = (smallStringt*) allocSmallInt(1); 6430 r = insertO(self, 0, toInsert); 6431 ck_assert_ptr_eq(r, null); 6432 terminateO(toInsert); 6433 toInsert = allocSmallString(""); 6434 // NULL insert string 6435 r = insertO(self, 0, NULL); 6436 ck_assert_ptr_eq(r, null); 6437 // NULL string 6438 freeO(self); 6439 setValO(toInsert, "s"); 6440 r = insertO(self, 1, toInsert); 6441 ck_assert_ptr_eq(r, null); 6442 r = insertO(self, 0, toInsert); 6443 ck_assert_ptr_ne(r, null); 6444 s = toStringO(r); 6445 ck_assert_str_eq(s, "s"); 6446 free(s); 6447 terminateO(toInsert); 6448 terminateO(self); 6449 6450 } 6451 6452 6453 void insertSmallJsonSmallStringT(CuTest *tc UNUSED) { 6454 6455 smallStringt* r; 6456 smallStringt *self = allocG(""); 6457 smallJsont *toInsert = allocSmallJson(); 6458 6459 // insert 6460 setValO(self, "sheepy"); 6461 freeO(toInsert); 6462 setTopSO(toInsert, "lib"); 6463 r = self->f->insertSmallJson(self, 0, toInsert); 6464 ck_assert_ptr_ne(r, null); 6465 char *s = toStringO(r); 6466 ck_assert_str_eq(s, "libsheepy"); 6467 free(s); 6468 // negative index 6469 freeO(toInsert); 6470 setTopSO(toInsert, "P"); 6471 r = self->f->insertSmallJson(self, -2, toInsert); 6472 ck_assert_ptr_ne(r, null); 6473 s = toStringO(r); 6474 ck_assert_str_eq(s, "libsheepPy"); 6475 free(s); 6476 // edge 6477 setValO(self, "qwe"); 6478 freeO(toInsert); 6479 setTopSO(toInsert, "C"); 6480 r = self->f->insertSmallJson(self, 3, toInsert); 6481 ck_assert_ptr_ne(r, null); 6482 s = toStringO(r); 6483 ck_assert_str_eq(s, "qweC"); 6484 free(s); 6485 // outside string 6486 setValO(self, "qwe"); 6487 r = self->f->insertSmallJson(self, 4, toInsert); 6488 ck_assert_ptr_eq(r, NULL); 6489 r = self->f->insertSmallJson(self, -5, toInsert); 6490 ck_assert_ptr_eq(r, NULL); 6491 // negative index in a one char string 6492 setValO(self, "s"); 6493 freeO(toInsert); 6494 setTopSO(toInsert, "S"); 6495 r = self->f->insertSmallJson(self, -1, toInsert); 6496 ck_assert_ptr_ne(r, null); 6497 s = toStringO(r); 6498 ck_assert_str_eq(s, "sS"); 6499 free(s); 6500 // empty string 6501 setValO(self, ""); 6502 freeO(toInsert); 6503 setTopSO(toInsert, "s"); 6504 r = self->f->insertSmallJson(self, 0, toInsert); 6505 ck_assert_ptr_ne(r, null); 6506 s = toStringO(r); 6507 ck_assert_str_eq(s, "s"); 6508 free(s); 6509 setValO(self, ""); 6510 r = self->f->insertSmallJson(self, -1, toInsert); 6511 ck_assert_ptr_ne(r, null); 6512 s = toStringO(r); 6513 ck_assert_str_eq(s, "s"); 6514 free(s); 6515 // empty insert string 6516 setValO(self, "a"); 6517 freeO(toInsert); 6518 setTopSO(toInsert, ""); 6519 r = self->f->insertSmallJson(self, 0, toInsert); 6520 ck_assert_ptr_ne(r, null); 6521 s = toStringO(r); 6522 ck_assert_str_eq(s, "a"); 6523 free(s); 6524 freeO(toInsert); 6525 r = self->f->insertSmallJson(self, 0, toInsert); 6526 ck_assert_ptr_ne(r, null); 6527 s = toStringO(r); 6528 ck_assert_str_eq(s, "a"); 6529 free(s); 6530 // non json string toInsert 6531 freeO(toInsert); 6532 setTopIntO(toInsert, 2); 6533 r = self->f->insertSmallJson(self, 0, toInsert); 6534 ck_assert_ptr_eq(r, null); 6535 // non smallJson toInsert 6536 terminateO(toInsert); 6537 toInsert = (smallJsont*) allocSmallInt(1); 6538 r = self->f->insertSmallJson(self, 0, toInsert); 6539 ck_assert_ptr_eq(r, null); 6540 terminateO(toInsert); 6541 toInsert = allocSmallJson(); 6542 // NULL insert string 6543 r = self->f->insertSmallJson(self, 0, NULL); 6544 ck_assert_ptr_eq(r, null); 6545 // NULL string 6546 freeO(self); 6547 freeO(toInsert); 6548 setTopSO(toInsert, "s"); 6549 r = self->f->insertSmallJson(self, 1, toInsert); 6550 ck_assert_ptr_eq(r, null); 6551 r = self->f->insertSmallJson(self, 0, toInsert); 6552 ck_assert_ptr_ne(r, null); 6553 s = toStringO(r); 6554 ck_assert_str_eq(s, "s"); 6555 free(s); 6556 terminateO(toInsert); 6557 terminateO(self); 6558 6559 } 6560 6561 6562 void insertSSmallStringT(CuTest *tc UNUSED) { 6563 6564 smallStringt* r; 6565 smallStringt *self = allocG(""); 6566 6567 // insert 6568 setValO(self, "sheepy"); 6569 r = insertSO(self, 0, "lib"); 6570 ck_assert_ptr_ne(r, null); 6571 char *s = toStringO(r); 6572 ck_assert_str_eq(s, "libsheepy"); 6573 free(s); 6574 // negative index 6575 r = insertSO(self, -2, "P"); 6576 ck_assert_ptr_ne(r, null); 6577 s = toStringO(r); 6578 ck_assert_str_eq(s, "libsheepPy"); 6579 free(s); 6580 // edge 6581 setValO(self, "qwe"); 6582 r = insertSO(self, 3, "C"); 6583 ck_assert_ptr_ne(r, null); 6584 s = toStringO(r); 6585 ck_assert_str_eq(s, "qweC"); 6586 free(s); 6587 // outside string 6588 setValO(self, "qwe"); 6589 r = insertSO(self, 4, "C"); 6590 ck_assert_ptr_eq(r, NULL); 6591 r = insertSO(self, -5, "C"); 6592 ck_assert_ptr_eq(r, NULL); 6593 // negative index in a one char string 6594 setValO(self, "s"); 6595 r = insertSO(self, -1, "S"); 6596 ck_assert_ptr_ne(r, null); 6597 s = toStringO(r); 6598 ck_assert_str_eq(s, "sS"); 6599 free(s); 6600 // empty string 6601 setValO(self, ""); 6602 r = insertSO(self, 0, "s"); 6603 ck_assert_ptr_ne(r, null); 6604 s = toStringO(r); 6605 ck_assert_str_eq(s, "s"); 6606 free(s); 6607 setValO(self, ""); 6608 r = insertSO(self, -1, "s"); 6609 ck_assert_ptr_ne(r, null); 6610 s = toStringO(r); 6611 ck_assert_str_eq(s, "s"); 6612 free(s); 6613 // empty insert string 6614 setValO(self, "a"); 6615 r = insertSO(self, 0, ""); 6616 ck_assert_ptr_ne(r, null); 6617 s = toStringO(r); 6618 ck_assert_str_eq(s, "a"); 6619 free(s); 6620 // NULL insert string 6621 r = insertSO(self, 0, NULL); 6622 ck_assert_ptr_ne(r, null); 6623 s = toStringO(r); 6624 ck_assert_str_eq(s, "a"); 6625 free(s); 6626 // NULL string 6627 freeO(self); 6628 r = insertSO(self, 0, "s"); 6629 ck_assert_ptr_ne(r, null); 6630 s = toStringO(r); 6631 ck_assert_str_eq(s, "s"); 6632 free(s); 6633 terminateO(self); 6634 6635 } 6636 6637 6638 void insertNFreeSmallStringT(CuTest *tc UNUSED) { 6639 6640 smallStringt* r; 6641 smallStringt *self = allocG(""); 6642 smallStringt *toInsert = allocSmallString(""); 6643 6644 // insert 6645 setValO(self, "sheepy"); 6646 setValO(toInsert, "lib"); 6647 r = self->f->insertNFree(self, 0, toInsert); 6648 ck_assert_ptr_ne(r, null); 6649 char *s = toStringO(r); 6650 ck_assert_str_eq(s, "libsheepy"); 6651 free(s); 6652 // negative index 6653 toInsert = allocSmallString("P"); 6654 r = self->f->insertNFree(self, -2, toInsert); 6655 ck_assert_ptr_ne(r, null); 6656 s = toStringO(r); 6657 ck_assert_str_eq(s, "libsheepPy"); 6658 free(s); 6659 // edge 6660 setValO(self, "qwe"); 6661 toInsert = allocSmallString("C"); 6662 r = self->f->insertNFree(self, 3, toInsert); 6663 ck_assert_ptr_ne(r, null); 6664 s = toStringO(r); 6665 ck_assert_str_eq(s, "qweC"); 6666 free(s); 6667 // outside string 6668 setValO(self, "qwe"); 6669 toInsert = allocSmallString("S"); 6670 r = self->f->insertNFree(self, 4, toInsert); 6671 ck_assert_ptr_eq(r, NULL); 6672 r = self->f->insertNFree(self, -5, toInsert); 6673 ck_assert_ptr_eq(r, NULL); 6674 // negative index in a one char string 6675 setValO(self, "s"); 6676 r = self->f->insertNFree(self, -1, toInsert); 6677 ck_assert_ptr_ne(r, null); 6678 s = toStringO(r); 6679 ck_assert_str_eq(s, "sS"); 6680 free(s); 6681 // empty string 6682 setValO(self, ""); 6683 toInsert = allocSmallString("s"); 6684 r = self->f->insertNFree(self, 0, toInsert); 6685 ck_assert_ptr_ne(r, null); 6686 s = toStringO(r); 6687 ck_assert_str_eq(s, "s"); 6688 free(s); 6689 setValO(self, ""); 6690 toInsert = allocSmallString("s"); 6691 r = self->f->insertNFree(self, -1, toInsert); 6692 ck_assert_ptr_ne(r, null); 6693 s = toStringO(r); 6694 ck_assert_str_eq(s, "s"); 6695 free(s); 6696 // empty insert string 6697 setValO(self, "a"); 6698 toInsert = allocSmallString(""); 6699 r = self->f->insertNFree(self, 0, toInsert); 6700 ck_assert_ptr_ne(r, null); 6701 s = toStringO(r); 6702 ck_assert_str_eq(s, "a"); 6703 free(s); 6704 toInsert = allocSmallString(""); 6705 freeO(toInsert); 6706 r = self->f->insertNFree(self, 0, toInsert); 6707 ck_assert_ptr_ne(r, null); 6708 s = toStringO(r); 6709 ck_assert_str_eq(s, "a"); 6710 free(s); 6711 // non smallString toInsert 6712 toInsert = (smallStringt*) allocSmallInt(1); 6713 r = self->f->insertNFree(self, 0, toInsert); 6714 ck_assert_ptr_eq(r, null); 6715 terminateO(toInsert); 6716 toInsert = allocSmallString("s"); 6717 // NULL insert string 6718 r = self->f->insertNFree(self, 0, NULL); 6719 ck_assert_ptr_eq(r, null); 6720 // NULL string 6721 freeO(self); 6722 r = self->f->insertNFree(self, 1, toInsert); 6723 ck_assert_ptr_eq(r, null); 6724 r = self->f->insertNFree(self, 0, toInsert); 6725 ck_assert_ptr_ne(r, null); 6726 s = toStringO(r); 6727 ck_assert_str_eq(s, "s"); 6728 free(s); 6729 terminateO(self); 6730 6731 } 6732 6733 6734 void insertNFreeSmallJsonSmallStringT(CuTest *tc UNUSED) { 6735 6736 smallStringt* r; 6737 smallStringt *self = allocG(""); 6738 smallJsont *toInsert = allocSmallJson(); 6739 6740 // insert 6741 setValO(self, "sheepy"); 6742 setTopSO(toInsert, "lib"); 6743 r = self->f->insertNFreeSmallJson(self, 0, toInsert); 6744 ck_assert_ptr_ne(r, null); 6745 char *s = toStringO(r); 6746 ck_assert_str_eq(s, "libsheepy"); 6747 free(s); 6748 // negative index 6749 toInsert = allocSmallJson(); 6750 setTopSO(toInsert, "P"); 6751 r = self->f->insertNFreeSmallJson(self, -2, toInsert); 6752 ck_assert_ptr_ne(r, null); 6753 s = toStringO(r); 6754 ck_assert_str_eq(s, "libsheepPy"); 6755 free(s); 6756 // edge 6757 setValO(self, "qwe"); 6758 toInsert = allocSmallJson(); 6759 setTopSO(toInsert, "C"); 6760 r = self->f->insertNFreeSmallJson(self, 3, toInsert); 6761 ck_assert_ptr_ne(r, null); 6762 s = toStringO(r); 6763 ck_assert_str_eq(s, "qweC"); 6764 free(s); 6765 // outside string 6766 setValO(self, "qwe"); 6767 toInsert = allocSmallJson(); 6768 setTopSO(toInsert, "S"); 6769 r = self->f->insertNFreeSmallJson(self, 4, toInsert); 6770 ck_assert_ptr_eq(r, NULL); 6771 r = self->f->insertNFreeSmallJson(self, -5, toInsert); 6772 ck_assert_ptr_eq(r, NULL); 6773 // negative index in a one char string 6774 setValO(self, "s"); 6775 r = self->f->insertNFreeSmallJson(self, -1, toInsert); 6776 ck_assert_ptr_ne(r, null); 6777 s = toStringO(r); 6778 ck_assert_str_eq(s, "sS"); 6779 free(s); 6780 // empty string 6781 setValO(self, ""); 6782 toInsert = allocSmallJson(); 6783 setTopSO(toInsert, "s"); 6784 r = self->f->insertNFreeSmallJson(self, 0, toInsert); 6785 ck_assert_ptr_ne(r, null); 6786 s = toStringO(r); 6787 ck_assert_str_eq(s, "s"); 6788 free(s); 6789 setValO(self, ""); 6790 toInsert = allocSmallJson(); 6791 setTopSO(toInsert, "s"); 6792 r = self->f->insertNFreeSmallJson(self, -1, toInsert); 6793 ck_assert_ptr_ne(r, null); 6794 s = toStringO(r); 6795 ck_assert_str_eq(s, "s"); 6796 free(s); 6797 // empty insert string 6798 setValO(self, "a"); 6799 toInsert = allocSmallJson(); 6800 setTopSO(toInsert, ""); 6801 r = self->f->insertNFreeSmallJson(self, 0, toInsert); 6802 ck_assert_ptr_ne(r, null); 6803 s = toStringO(r); 6804 ck_assert_str_eq(s, "a"); 6805 free(s); 6806 toInsert = allocSmallJson(); 6807 r = self->f->insertNFreeSmallJson(self, 0, toInsert); 6808 ck_assert_ptr_ne(r, null); 6809 s = toStringO(r); 6810 ck_assert_str_eq(s, "a"); 6811 free(s); 6812 // non json string toInsert 6813 toInsert = allocSmallJson(); 6814 setTopIntO(toInsert, 2); 6815 r = self->f->insertNFreeSmallJson(self, 0, toInsert); 6816 ck_assert_ptr_eq(r, null); 6817 // non smallJson toInsert 6818 terminateO(toInsert); 6819 toInsert = (smallJsont*) allocSmallInt(1); 6820 r = self->f->insertNFreeSmallJson(self, 0, toInsert); 6821 ck_assert_ptr_eq(r, null); 6822 terminateO(toInsert); 6823 toInsert = allocSmallJson(); 6824 // NULL insert string 6825 r = self->f->insertNFreeSmallJson(self, 0, NULL); 6826 ck_assert_ptr_eq(r, null); 6827 // NULL string 6828 freeO(self); 6829 setTopSO(toInsert, "s"); 6830 r = self->f->insertNFreeSmallJson(self, 1, toInsert); 6831 ck_assert_ptr_eq(r, null); 6832 r = self->f->insertNFreeSmallJson(self, 0, toInsert); 6833 ck_assert_ptr_ne(r, null); 6834 s = toStringO(r); 6835 ck_assert_str_eq(s, "s"); 6836 free(s); 6837 terminateO(self); 6838 6839 } 6840 6841 6842 void insertSNFreeSmallStringT(CuTest *tc UNUSED) { 6843 6844 smallStringt* r; 6845 smallStringt *self = allocG(""); 6846 6847 // insert 6848 setValO(self, "sheepy"); 6849 r = insertSNFreeO(self, 0, strdup("lib")); 6850 ck_assert_ptr_ne(r, null); 6851 char *s = toStringO(r); 6852 ck_assert_str_eq(s, "libsheepy"); 6853 free(s); 6854 // negative index 6855 r = insertSNFreeO(self, -2, strdup("P")); 6856 ck_assert_ptr_ne(r, null); 6857 s = toStringO(r); 6858 ck_assert_str_eq(s, "libsheepPy"); 6859 free(s); 6860 // edge 6861 setValO(self, "qwe"); 6862 r = insertSNFreeO(self, 3, strdup("C")); 6863 ck_assert_ptr_ne(r, null); 6864 s = toStringO(r); 6865 ck_assert_str_eq(s, "qweC"); 6866 free(s); 6867 // outside string 6868 setValO(self, "qwe"); 6869 r = insertSNFreeO(self, 4, "C"); 6870 ck_assert_ptr_eq(r, NULL); 6871 r = insertSNFreeO(self, -5, "C"); 6872 ck_assert_ptr_eq(r, NULL); 6873 // negative index in a one char string 6874 setValO(self, "s"); 6875 r = insertSNFreeO(self, -1, strdup("S")); 6876 ck_assert_ptr_ne(r, null); 6877 s = toStringO(r); 6878 ck_assert_str_eq(s, "sS"); 6879 free(s); 6880 // empty string 6881 setValO(self, ""); 6882 r = insertSNFreeO(self, 0, strdup("s")); 6883 ck_assert_ptr_ne(r, null); 6884 s = toStringO(r); 6885 ck_assert_str_eq(s, "s"); 6886 free(s); 6887 setValO(self, ""); 6888 r = insertSNFreeO(self, -1, strdup("s")); 6889 ck_assert_ptr_ne(r, null); 6890 s = toStringO(r); 6891 ck_assert_str_eq(s, "s"); 6892 free(s); 6893 // empty insert string 6894 setValO(self, "a"); 6895 r = insertSNFreeO(self, 0, strdup("")); 6896 ck_assert_ptr_ne(r, null); 6897 s = toStringO(r); 6898 ck_assert_str_eq(s, "a"); 6899 free(s); 6900 // NULL insert string 6901 r = insertSNFreeO(self, 0, NULL); 6902 ck_assert_ptr_ne(r, null); 6903 s = toStringO(r); 6904 ck_assert_str_eq(s, "a"); 6905 free(s); 6906 // NULL string 6907 freeO(self); 6908 r = insertSNFreeO(self, 0, strdup("s")); 6909 ck_assert_ptr_ne(r, null); 6910 s = toStringO(r); 6911 ck_assert_str_eq(s, "s"); 6912 free(s); 6913 terminateO(self); 6914 6915 } 6916 6917 6918 void injectSmallStringT(CuTest *tc UNUSED) { 6919 6920 smallStringt* r; 6921 smallStringt *self = allocG(""); 6922 6923 // insert 6924 setValO(self, "sheepy"); 6925 r = self->f->inject(self, 0, 'L'); 6926 ck_assert_ptr_ne(r, null); 6927 char *s = toStringO(r); 6928 ck_assert_str_eq(s, "Lsheepy"); 6929 free(s); 6930 // negative index 6931 setValO(self, "libsheepy"); 6932 r = self->f->inject(self, -2, 'P'); 6933 ck_assert_ptr_ne(r, null); 6934 s = toStringO(r); 6935 ck_assert_str_eq(s, "libsheepPy"); 6936 free(s); 6937 // edge 6938 setValO(self, "qwe"); 6939 r = self->f->inject(self, 3, 'C'); 6940 ck_assert_ptr_ne(r, null); 6941 s = toStringO(r); 6942 ck_assert_str_eq(s, "qweC"); 6943 free(s); 6944 // outside string 6945 setValO(self, "qwe"); 6946 r = self->f->inject(self, 4, 'C'); 6947 ck_assert_ptr_eq(r, NULL); 6948 r = self->f->inject(self, -5, 'C'); 6949 ck_assert_ptr_eq(r, NULL); 6950 // negative index in a one char string 6951 setValO(self, "s"); 6952 r = self->f->inject(self, -2, 'S'); 6953 ck_assert_ptr_ne(r, null); 6954 s = toStringO(r); 6955 ck_assert_str_eq(s, "Ss"); 6956 free(s); 6957 // empty string 6958 setValO(self, ""); 6959 r = self->f->inject(self, 0, 's'); 6960 ck_assert_ptr_ne(r, null); 6961 s = toStringO(r); 6962 ck_assert_str_eq(s, "s"); 6963 free(s); 6964 setValO(self, ""); 6965 r = self->f->inject(self, -1, 's'); 6966 ck_assert_ptr_ne(r, null); 6967 s = toStringO(r); 6968 ck_assert_str_eq(s, "s"); 6969 free(s); 6970 // NULL string 6971 freeO(self); 6972 r = self->f->inject(self, 1, 's'); 6973 ck_assert_ptr_eq(r, NULL); 6974 r = self->f->inject(self, 0, 's'); 6975 ck_assert_ptr_ne(r, null); 6976 s = toStringO(r); 6977 ck_assert_str_eq(s, "s"); 6978 free(s); 6979 terminateO(self); 6980 6981 } 6982 6983 6984 void delSmallStringT(CuTest *tc UNUSED) { 6985 6986 smallStringt* r; 6987 smallStringt *self = allocG(""); 6988 6989 // del 6990 setValO(self, "sheepy"); 6991 r = delO(self, 0,2); 6992 ck_assert_ptr_ne(r, null); 6993 char *s = toStringO(r); 6994 ck_assert_str_eq(s, "eepy"); 6995 free(s); 6996 // negative index 6997 setValO(self, "sheepy"); 6998 r = delO(self, -2,0); 6999 ck_assert_ptr_ne(r, null); 7000 s = toStringO(r); 7001 ck_assert_str_eq(s, "shee"); 7002 free(s); 7003 // positive and negative indexes 7004 setValO(self, "sheepy"); 7005 r = delO(self, 2,-2); 7006 ck_assert_ptr_ne(r, null); 7007 s = toStringO(r); 7008 ck_assert_str_eq(s, "shpy"); 7009 free(s); 7010 // start = end 7011 setValO(self, "sheepy"); 7012 r = delO(self, 2,-4); 7013 ck_assert_ptr_ne(r, null); 7014 s = toStringO(r); 7015 ck_assert_str_eq(s, "sheepy"); 7016 free(s); 7017 // delete entire string 7018 setValO(self, "sheepy"); 7019 r = delO(self, 0,0); 7020 ck_assert_ptr_ne(r, null); 7021 s = toStringO(r); 7022 ck_assert_str_eq(s, ""); 7023 free(s); 7024 // end of string 7025 setValO(self, "sheepy"); 7026 r = delO(self, 2,6); 7027 ck_assert_ptr_ne(r, null); 7028 s = toStringO(r); 7029 ck_assert_str_eq(s, "sh"); 7030 free(s); 7031 // NULL string 7032 freeO(self); 7033 r = delO(self, 2,-4); 7034 ck_assert_ptr_eq(r, NULL); 7035 // start outside string 7036 setValO(self, "sheepy"); 7037 r = delO(self, 20,-4); 7038 ck_assert_ptr_eq(r, null); 7039 s = toStringO(self); 7040 ck_assert_str_eq(s, "sheepy"); 7041 free(s); 7042 r = delO(self, -20,-4); 7043 ck_assert_ptr_ne(r, null); 7044 s = toStringO(r); 7045 ck_assert_str_eq(s, "eepy"); 7046 free(s); 7047 // end outside string 7048 setValO(self, "sheepy"); 7049 r = delO(self, 2,40); 7050 ck_assert_ptr_ne(r, null); 7051 s = toStringO(r); 7052 ck_assert_str_eq(s, "sh"); 7053 free(s); 7054 setValO(self, "sheepy"); 7055 r = delO(self, 2,-40); 7056 ck_assert_ptr_eq(r, null); 7057 s = toStringO(self); 7058 ck_assert_str_eq(s, "sheepy"); 7059 free(s); 7060 // end before start 7061 setValO(self, "sheepy"); 7062 r = delO(self, 4,2); 7063 ck_assert_ptr_eq(r, null); 7064 s = toStringO(self); 7065 ck_assert_str_eq(s, "sheepy"); 7066 free(s); 7067 terminateO(self); 7068 7069 } 7070 7071 7072 void delElemSmallStringT(CuTest *tc UNUSED) { 7073 7074 smallStringt* r; 7075 smallStringt *self = allocG(""); 7076 7077 // del 7078 setValO(self, "sheepy"); 7079 r = delElemO(self, 0); 7080 ck_assert_ptr_ne(r, null); 7081 char *s = toStringO(r); 7082 ck_assert_str_eq(s, "heepy"); 7083 free(s); 7084 setValO(self, "sheepy"); 7085 r = delElemO(self, 5); 7086 ck_assert_ptr_ne(r, null); 7087 s = toStringO(r); 7088 ck_assert_str_eq(s, "sheep"); 7089 free(s); 7090 // negative index 7091 setValO(self, "sheepy"); 7092 r = delElemO(self, -1); 7093 ck_assert_ptr_ne(r, null); 7094 s = toStringO(r); 7095 ck_assert_str_eq(s, "sheep"); 7096 free(s); 7097 setValO(self, "sheepy"); 7098 r = delElemO(self, -6); 7099 ck_assert_ptr_ne(r, null); 7100 s = toStringO(r); 7101 ck_assert_str_eq(s, "heepy"); 7102 free(s); 7103 // index outside string 7104 setValO(self, "sheepy"); 7105 r = delElemO(self, 6); 7106 ck_assert_ptr_eq(r, null); 7107 r = delElemO(self, -7); 7108 ck_assert_ptr_eq(r, null); 7109 // empty string 7110 setValO(self, ""); 7111 ck_assert_ptr_eq(delElemO(self, 0), null); 7112 // null string 7113 freeO(self); 7114 ck_assert_ptr_eq(delElemO(self, 0), null); 7115 terminateO(self); 7116 7117 } 7118 7119 7120 void hasSmallStringT(CuTest *tc UNUSED) { 7121 7122 smallStringt *self = allocG(""); 7123 7124 // find string in the middle 7125 setValO(self, "sheepy"); 7126 ck_assert_str_eq(hasO(self, "ee"), "eepy"); 7127 // find non existing string 7128 ck_assert_ptr_eq(hasO(self, "$"), NULL); 7129 // find NULL 7130 ck_assert_ptr_eq(hasO(self, NULL), NULL); 7131 // empty string 7132 setValO(self, ""); 7133 ck_assert_ptr_eq(hasO(self, "$"), NULL); 7134 // NULL string 7135 freeO(self); 7136 ck_assert_ptr_eq(hasO(self, "$"), NULL); 7137 terminateO(self); 7138 7139 } 7140 7141 7142 void hasCharSmallStringT(CuTest *tc UNUSED) { 7143 7144 smallStringt *self = allocG(""); 7145 7146 // find string in the middle 7147 setValO(self, "sheepy"); 7148 ck_assert_str_eq(hasCharO(self, 'e'), "eepy"); 7149 // find non existing string 7150 ck_assert_ptr_eq(hasCharO(self, '$'), NULL); 7151 // find 0 7152 ck_assert_str_eq(hasCharO(self, 0), ""); 7153 // empty string 7154 setValO(self, ""); 7155 ck_assert_ptr_eq(hasCharO(self, '$'), NULL); 7156 // NULL string 7157 freeO(self); 7158 ck_assert_ptr_eq(hasCharO(self, '$'), NULL); 7159 terminateO(self); 7160 7161 } 7162 7163 7164 void hasSmallJsonSmallStringT(CuTest *tc UNUSED) { 7165 7166 smallStringt *self = allocG(""); 7167 smallJsont *needle = allocSmallJson(); 7168 7169 // find string in the middle 7170 setValO(self, "sheepy"); 7171 setTopSO(needle, "ee"); 7172 ck_assert_str_eq(self->f->hasSmallJson(self, needle), "eepy"); 7173 // find non existing string 7174 freeO(needle); 7175 setTopSO(needle, "$"); 7176 ck_assert_ptr_eq(self->f->hasSmallJson(self, needle), NULL); 7177 // non json string 7178 freeO(needle); 7179 ck_assert_ptr_eq(self->f->hasSmallJson(self, needle), NULL); 7180 // non json object 7181 terminateO(needle); 7182 needle = (smallJsont*) allocSmallInt(1); 7183 ck_assert_ptr_eq(self->f->hasSmallJson(self, needle), NULL); 7184 terminateO(needle); 7185 // find NULL 7186 ck_assert_ptr_eq(self->f->hasSmallJson(self, NULL), NULL); 7187 // empty string 7188 setValO(self, ""); 7189 needle = allocSmallJson(); 7190 setTopSO(needle, "$"); 7191 ck_assert_ptr_eq(self->f->hasSmallJson(self, needle), NULL); 7192 // NULL string 7193 freeO(self); 7194 ck_assert_ptr_eq(self->f->hasSmallJson(self, needle), NULL); 7195 terminateO(needle); 7196 terminateO(self); 7197 7198 } 7199 7200 7201 void hasSmallStringSmallStringT(CuTest *tc UNUSED) { 7202 7203 smallStringt *self = allocG(""); 7204 smallStringt *needle = allocSmallString("ee"); 7205 7206 // find string in the middle 7207 setValO(self, "sheepy"); 7208 ck_assert_str_eq(self->f->hasSmallString(self, needle), "eepy"); 7209 // find non existing string 7210 setValO(needle, "$"); 7211 ck_assert_ptr_eq(self->f->hasSmallString(self, needle), NULL); 7212 // non smallString object 7213 terminateO(needle); 7214 needle = (smallStringt*) allocSmallInt(1); 7215 ck_assert_ptr_eq(self->f->hasSmallString(self, needle), NULL); 7216 terminateO(needle); 7217 // find NULL 7218 ck_assert_ptr_eq(self->f->hasSmallString(self, NULL), NULL); 7219 // empty string 7220 setValO(self, ""); 7221 needle = allocSmallString("$"); 7222 ck_assert_ptr_eq(self->f->hasSmallString(self, needle), NULL); 7223 // NULL string 7224 freeO(self); 7225 ck_assert_ptr_eq(self->f->hasSmallString(self, needle), NULL); 7226 terminateO(needle); 7227 terminateO(self); 7228 7229 } 7230 7231 7232 void findSmallStringT(CuTest *tc UNUSED) { 7233 7234 smallStringt* r; 7235 smallStringt *self = allocG(""); 7236 7237 // find string in the middle 7238 setValO(self, "sheepy"); 7239 r = findO(self, "ee"); 7240 ck_assert_ptr_ne(r, null); 7241 ck_assert_str_eq(ssGet(r), "eepy"); 7242 terminateO(r); 7243 // find non existing string 7244 ck_assert_ptr_eq(findO(self, "$"), NULL); 7245 // find NULL 7246 ck_assert_ptr_eq(findO(self, NULL), NULL); 7247 // empty string 7248 setValO(self, ""); 7249 ck_assert_ptr_eq(findO(self, "$"), NULL); 7250 // NULL string 7251 freeO(self); 7252 ck_assert_ptr_eq(findO(self, "$"), NULL); 7253 terminateO(self); 7254 7255 } 7256 7257 7258 void findCharSmallStringT(CuTest *tc UNUSED) { 7259 7260 smallStringt* r; 7261 smallStringt *self = allocG(""); 7262 7263 // find string in the middle 7264 setValO(self, "sheepy"); 7265 r = findCharO(self, 'e'); 7266 ck_assert_ptr_ne(r, null); 7267 ck_assert_str_eq(ssGet(r), "eepy"); 7268 terminateO(r); 7269 // find non existing string 7270 ck_assert_ptr_eq(findCharO(self, '$'), NULL); 7271 // find 0 7272 r = findCharO(self, 0); 7273 ck_assert_ptr_ne(r, null); 7274 ck_assert_str_eq(ssGet(r), ""); 7275 terminateO(r); 7276 // empty string 7277 setValO(self, ""); 7278 ck_assert_ptr_eq(findCharO(self, '$'), NULL); 7279 // NULL string 7280 freeO(self); 7281 ck_assert_ptr_eq(findCharO(self, '$'), NULL); 7282 terminateO(self); 7283 7284 } 7285 7286 7287 void findSmallJsonSmallStringT(CuTest *tc UNUSED) { 7288 7289 smallStringt* r; 7290 smallStringt *self = allocG(""); 7291 smallJsont *needle = allocSmallJson(); 7292 7293 // find string in the middle 7294 setValO(self, "sheepy"); 7295 setTopSO(needle, "ee"); 7296 r = self->f->findSmallJson(self, needle); 7297 ck_assert_ptr_ne(r, null); 7298 ck_assert_str_eq(ssGet(r), "eepy"); 7299 terminateO(r); 7300 // find non existing string 7301 freeO(needle); 7302 setTopSO(needle, "$"); 7303 ck_assert_ptr_eq(self->f->findSmallJson(self, needle), NULL); 7304 // non json string 7305 freeO(needle); 7306 ck_assert_ptr_eq(self->f->findSmallJson(self, needle), NULL); 7307 // non json object 7308 terminateO(needle); 7309 needle = (smallJsont*) allocSmallInt(1); 7310 ck_assert_ptr_eq(self->f->findSmallJson(self, needle), NULL); 7311 terminateO(needle); 7312 // find NULL 7313 ck_assert_ptr_eq(self->f->findSmallJson(self, NULL), NULL); 7314 // empty string 7315 setValO(self, ""); 7316 needle = allocSmallJson(); 7317 setTopSO(needle, "$"); 7318 ck_assert_ptr_eq(self->f->findSmallJson(self, needle), NULL); 7319 // NULL string 7320 freeO(self); 7321 ck_assert_ptr_eq(self->f->findSmallJson(self, needle), NULL); 7322 terminateO(needle); 7323 terminateO(self); 7324 7325 } 7326 7327 7328 void findSmallStringSmallStringT(CuTest *tc UNUSED) { 7329 7330 smallStringt* r; 7331 smallStringt *self = allocG(""); 7332 smallStringt *needle = allocSmallString("ee"); 7333 7334 // find string in the middle 7335 setValO(self, "sheepy"); 7336 r = self->f->findSmallString(self, needle); 7337 ck_assert_ptr_ne(r, null); 7338 ck_assert_str_eq(ssGet(r), "eepy"); 7339 terminateO(r); 7340 // find non existing string 7341 setValO(needle, "$"); 7342 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 7343 // non smallString object 7344 terminateO(needle); 7345 needle = (smallStringt*) allocSmallInt(1); 7346 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 7347 terminateO(needle); 7348 // find NULL 7349 ck_assert_ptr_eq(self->f->findSmallString(self, NULL), NULL); 7350 // empty string 7351 setValO(self, ""); 7352 needle = allocSmallString("$"); 7353 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 7354 // NULL string 7355 freeO(self); 7356 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 7357 terminateO(needle); 7358 terminateO(self); 7359 7360 } 7361 7362 7363 void indexOfSmallStringT(CuTest *tc UNUSED) { 7364 7365 smallStringt *self = allocG(""); 7366 7367 // indexOf string in the middle 7368 setValO(self, "sheepy"); 7369 ck_assert_int_eq(indexOfO(self, "ee"), 2); 7370 // indexOf non existing string 7371 ck_assert_int_eq(indexOfO(self, "$"), -1); 7372 // indexOf NULL 7373 ck_assert_int_eq(indexOfO(self, NULL), -1); 7374 // NULL string 7375 freeO(self); 7376 ck_assert_int_eq(indexOfO(self, "$"), -1); 7377 terminateO(self); 7378 7379 } 7380 7381 7382 void indexOfCharSmallStringT(CuTest *tc UNUSED) { 7383 7384 smallStringt *self = allocG(""); 7385 7386 // indexOf string in the middle 7387 setValO(self, "sheepy"); 7388 ck_assert_int_eq(indexOfCharO(self, 'e'), 2); 7389 // indexOf non existing string 7390 ck_assert_int_eq(indexOfCharO(self, '$'), -1); 7391 // indexOf 0 7392 ck_assert_int_eq(indexOfCharO(self, 0), 6); 7393 // NULL string 7394 freeO(self); 7395 ck_assert_int_eq(indexOfCharO(self, '$'), -1); 7396 terminateO(self); 7397 7398 } 7399 7400 7401 void indexOfSmallJsonSmallStringT(CuTest *tc UNUSED) { 7402 7403 smallStringt *self = allocG(""); 7404 smallJsont *needle = allocSmallJson(); 7405 7406 // indexOf string in the middle 7407 setValO(self, "sheepy"); 7408 setTopSO(needle, "ee"); 7409 ck_assert_int_eq(self->f->indexOfSmallJson(self, needle), 2); 7410 // indexOf non existing string 7411 freeO(needle); 7412 setTopSO(needle, "$"); 7413 ck_assert_int_eq(self->f->indexOfSmallJson(self, needle), -1); 7414 // non json string 7415 freeO(needle); 7416 ck_assert_int_eq(self->f->indexOfSmallJson(self, needle), -1); 7417 // non json object 7418 terminateO(needle); 7419 needle = (smallJsont*) allocSmallInt(1); 7420 ck_assert_int_eq(self->f->indexOfSmallJson(self, needle), -1); 7421 terminateO(needle); 7422 // indexOf NULL 7423 ck_assert_int_eq(self->f->indexOfSmallJson(self, NULL), -1); 7424 // empty string 7425 setValO(self, ""); 7426 needle = allocSmallJson(); 7427 setTopSO(needle, "$"); 7428 ck_assert_int_eq(self->f->indexOfSmallJson(self, needle), -1); 7429 // NULL string 7430 freeO(self); 7431 ck_assert_int_eq(self->f->indexOfSmallJson(self, needle), -1); 7432 terminateO(needle); 7433 terminateO(self); 7434 7435 } 7436 7437 7438 void indexOfSmallStringSmallStringT(CuTest *tc UNUSED) { 7439 7440 smallStringt *self = allocG(""); 7441 smallStringt *needle = allocSmallString("ee"); 7442 7443 // indexOf string in the middle 7444 setValO(self, "sheepy"); 7445 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), 2); 7446 // indexOf non existing string 7447 setValO(needle, "$"); 7448 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), -1); 7449 // non smallString object 7450 terminateO(needle); 7451 needle = (smallStringt*) allocSmallInt(1); 7452 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), -1); 7453 terminateO(needle); 7454 // indexOf NULL 7455 ck_assert_int_eq(self->f->indexOfSmallString(self, NULL), -1); 7456 // empty string 7457 setValO(self, ""); 7458 needle = allocSmallString("$"); 7459 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), -1); 7460 // NULL string 7461 freeO(self); 7462 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), -1); 7463 terminateO(needle); 7464 terminateO(self); 7465 7466 } 7467 7468 7469 void icHasSmallStringT(CuTest *tc UNUSED) { 7470 7471 smallStringt *self = allocG(""); 7472 7473 // find string in the middle 7474 setValO(self, "sheepy"); 7475 ck_assert_str_eq(icHasO(self, "EE"), "eepy"); 7476 // find non existing string 7477 ck_assert_ptr_eq(icHasO(self, "$"), NULL); 7478 // find NULL 7479 ck_assert_ptr_eq(icHasO(self, NULL), NULL); 7480 // empty string 7481 setValO(self, ""); 7482 ck_assert_ptr_eq(icHasO(self, "$"), NULL); 7483 // NULL string 7484 freeO(self); 7485 ck_assert_ptr_eq(icHasO(self, "$"), NULL); 7486 terminateO(self); 7487 7488 } 7489 7490 7491 void icHasCharSmallStringT(CuTest *tc UNUSED) { 7492 7493 smallStringt *self = allocG(""); 7494 7495 // find string in the middle 7496 setValO(self, "sheepy"); 7497 ck_assert_str_eq(icHasCharO(self, 'E'), "eepy"); 7498 // find non existing string 7499 ck_assert_ptr_eq(icHasCharO(self, '$'), NULL); 7500 // find 0 7501 ck_assert_str_eq(icHasCharO(self, 0), ""); 7502 // empty string 7503 setValO(self, ""); 7504 ck_assert_ptr_eq(icHasCharO(self, '$'), NULL); 7505 ck_assert_ptr_eq(icHasCharO(self, 0), NULL); 7506 // NULL string 7507 freeO(self); 7508 ck_assert_ptr_eq(icHasCharO(self, '$'), NULL); 7509 ck_assert_ptr_eq(icHasCharO(self, 0), NULL); 7510 terminateO(self); 7511 7512 } 7513 7514 7515 void icHasSmallJsonSmallStringT(CuTest *tc UNUSED) { 7516 7517 smallStringt *self = allocG(""); 7518 smallJsont *needle = allocSmallJson(); 7519 7520 // find string in the middle 7521 setValO(self, "sheepy"); 7522 setTopSO(needle, "EE"); 7523 ck_assert_str_eq(self->f->icHasSmallJson(self, needle), "eepy"); 7524 // find non existing string 7525 freeO(needle); 7526 setTopSO(needle, "$"); 7527 ck_assert_ptr_eq(self->f->icHasSmallJson(self, needle), NULL); 7528 // non json string 7529 freeO(needle); 7530 ck_assert_ptr_eq(self->f->icHasSmallJson(self, needle), NULL); 7531 // non json object 7532 terminateO(needle); 7533 needle = (smallJsont*) allocSmallInt(1); 7534 ck_assert_ptr_eq(self->f->icHasSmallJson(self, needle), NULL); 7535 terminateO(needle); 7536 // find NULL 7537 ck_assert_ptr_eq(self->f->icHasSmallJson(self, NULL), NULL); 7538 // empty string 7539 setValO(self, ""); 7540 needle = allocSmallJson(); 7541 setTopSO(needle, "$"); 7542 ck_assert_ptr_eq(self->f->icHasSmallJson(self, needle), NULL); 7543 // NULL string 7544 freeO(self); 7545 ck_assert_ptr_eq(self->f->icHasSmallJson(self, needle), NULL); 7546 terminateO(needle); 7547 terminateO(self); 7548 7549 } 7550 7551 7552 void icHasSmallStringSmallStringT(CuTest *tc UNUSED) { 7553 7554 smallStringt *self = allocG(""); 7555 smallStringt *needle = allocSmallString("EE"); 7556 7557 // find string in the middle 7558 setValO(self, "sheepy"); 7559 ck_assert_str_eq(self->f->icHasSmallString(self, needle), "eepy"); 7560 // find non existing string 7561 setValO(needle, "$"); 7562 ck_assert_ptr_eq(self->f->icHasSmallString(self, needle), NULL); 7563 // non smallString object 7564 terminateO(needle); 7565 needle = (smallStringt*) allocSmallInt(1); 7566 ck_assert_ptr_eq(self->f->icHasSmallString(self, needle), NULL); 7567 terminateO(needle); 7568 // find NULL 7569 ck_assert_ptr_eq(self->f->icHasSmallString(self, NULL), NULL); 7570 // empty string 7571 setValO(self, ""); 7572 needle = allocSmallString("$"); 7573 ck_assert_ptr_eq(self->f->icHasSmallString(self, needle), NULL); 7574 // NULL string 7575 freeO(self); 7576 ck_assert_ptr_eq(self->f->icHasSmallString(self, needle), NULL); 7577 terminateO(needle); 7578 terminateO(self); 7579 7580 } 7581 7582 7583 void icFindSmallStringT(CuTest *tc UNUSED) { 7584 7585 smallStringt* r; 7586 smallStringt *self = allocG(""); 7587 7588 // icFind string in the middle 7589 setValO(self, "sheepy"); 7590 r = icFindO(self, "EE"); 7591 ck_assert_ptr_ne(r, null); 7592 ck_assert_str_eq(ssGet(r), "eepy"); 7593 terminateO(r); 7594 // find non existing string 7595 ck_assert_ptr_eq(icFindO(self, "$"), NULL); 7596 // find NULL 7597 ck_assert_ptr_eq(icFindO(self, NULL), NULL); 7598 // empty string 7599 setValO(self, ""); 7600 ck_assert_ptr_eq(icFindO(self, "$"), NULL); 7601 // NULL string 7602 freeO(self); 7603 ck_assert_ptr_eq(icFindO(self, "$"), NULL); 7604 terminateO(self); 7605 7606 } 7607 7608 7609 void icFindCharSmallStringT(CuTest *tc UNUSED) { 7610 7611 smallStringt* r; 7612 smallStringt *self = allocG(""); 7613 7614 // find string in the middle 7615 setValO(self, "sheepy"); 7616 r = icFindCharO(self, 'E'); 7617 ck_assert_ptr_ne(r, null); 7618 ck_assert_str_eq(ssGet(r), "eepy"); 7619 terminateO(r); 7620 // find non existing string 7621 ck_assert_ptr_eq(icFindCharO(self, '$'), NULL); 7622 // find 0 7623 r = icFindCharO(self, 0); 7624 ck_assert_ptr_ne(r, null); 7625 ck_assert_str_eq(ssGet(r), ""); 7626 terminateO(r); 7627 // empty string 7628 setValO(self, ""); 7629 ck_assert_ptr_eq(icFindCharO(self, '$'), NULL); 7630 ck_assert_ptr_eq(icFindCharO(self, 0), NULL); 7631 // NULL string 7632 freeO(self); 7633 ck_assert_ptr_eq(icFindCharO(self, '$'), NULL); 7634 ck_assert_ptr_eq(icFindCharO(self, 0), NULL); 7635 terminateO(self); 7636 7637 } 7638 7639 7640 void icFindSmallJsonSmallStringT(CuTest *tc UNUSED) { 7641 7642 smallStringt* r; 7643 smallStringt *self = allocG(""); 7644 smallJsont *needle = allocSmallJson(); 7645 7646 // find string in the middle 7647 setValO(self, "sheepy"); 7648 setTopSO(needle, "EE"); 7649 r = self->f->icFindSmallJson(self, needle); 7650 ck_assert_ptr_ne(r, null); 7651 ck_assert_str_eq(ssGet(r), "eepy"); 7652 terminateO(r); 7653 // find non existing string 7654 freeO(needle); 7655 setTopSO(needle, "$"); 7656 ck_assert_ptr_eq(self->f->icFindSmallJson(self, needle), NULL); 7657 // non json string 7658 freeO(needle); 7659 ck_assert_ptr_eq(self->f->icFindSmallJson(self, needle), NULL); 7660 // non json object 7661 terminateO(needle); 7662 needle = (smallJsont*) allocSmallInt(1); 7663 ck_assert_ptr_eq(self->f->icFindSmallJson(self, needle), NULL); 7664 terminateO(needle); 7665 // find NULL 7666 ck_assert_ptr_eq(self->f->icFindSmallJson(self, NULL), NULL); 7667 // empty string 7668 setValO(self, ""); 7669 needle = allocSmallJson(); 7670 setTopSO(needle, "$"); 7671 ck_assert_ptr_eq(self->f->icFindSmallJson(self, needle), NULL); 7672 // NULL string 7673 freeO(self); 7674 ck_assert_ptr_eq(self->f->icFindSmallJson(self, needle), NULL); 7675 terminateO(needle); 7676 terminateO(self); 7677 7678 } 7679 7680 7681 void icFindSmallStringSmallStringT(CuTest *tc UNUSED) { 7682 7683 smallStringt* r; 7684 smallStringt *self = allocG(""); 7685 smallStringt *needle = allocSmallString("EE"); 7686 7687 // find string in the middle 7688 setValO(self, "sheepy"); 7689 r = self->f->icFindSmallString(self, needle); 7690 ck_assert_ptr_ne(r, null); 7691 ck_assert_str_eq(ssGet(r), "eepy"); 7692 terminateO(r); 7693 // find non existing string 7694 setValO(needle, "$"); 7695 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 7696 // non smallString object 7697 terminateO(needle); 7698 needle = (smallStringt*) allocSmallInt(1); 7699 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 7700 terminateO(needle); 7701 // find NULL 7702 ck_assert_ptr_eq(self->f->icFindSmallString(self, NULL), NULL); 7703 // empty string 7704 setValO(self, ""); 7705 needle = allocSmallString("$"); 7706 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 7707 // NULL string 7708 freeO(self); 7709 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 7710 terminateO(needle); 7711 terminateO(self); 7712 7713 } 7714 7715 7716 void icIndexOfSmallStringT(CuTest *tc UNUSED) { 7717 7718 smallStringt *self = allocG(""); 7719 7720 // indexOf string in the middle 7721 setValO(self, "sheepy"); 7722 ck_assert_int_eq(icIndexOfO(self, "EE"), 2); 7723 // indexOf non existing string 7724 ck_assert_int_eq(icIndexOfO(self, "$"), -1); 7725 // indexOf NULL 7726 ck_assert_int_eq(icIndexOfO(self, NULL), -1); 7727 // NULL string 7728 freeO(self); 7729 ck_assert_int_eq(icIndexOfO(self, "$"), -1); 7730 terminateO(self); 7731 7732 } 7733 7734 7735 void icIndexOfCharSmallStringT(CuTest *tc UNUSED) { 7736 7737 smallStringt *self = allocG(""); 7738 7739 // indexOf string in the middle 7740 setValO(self, "sheepy"); 7741 ck_assert_int_eq(icIndexOfCharO(self, 'E'), 2); 7742 // indexOf non existing string 7743 ck_assert_int_eq(icIndexOfCharO(self, '$'), -1); 7744 // indexOf 0 7745 ck_assert_int_eq(icIndexOfCharO(self, 0), 6); 7746 // NULL string 7747 freeO(self); 7748 ck_assert_int_eq(icIndexOfCharO(self, '$'), -1); 7749 terminateO(self); 7750 7751 } 7752 7753 7754 void icIndexOfSmallJsonSmallStringT(CuTest *tc UNUSED) { 7755 7756 smallStringt *self = allocG(""); 7757 smallJsont *needle = allocSmallJson(); 7758 7759 // indexOf string in the middle 7760 setValO(self, "sheepy"); 7761 setTopSO(needle, "EE"); 7762 ck_assert_int_eq(self->f->icIndexOfSmallJson(self, needle), 2); 7763 // indexOf non existing string 7764 freeO(needle); 7765 setTopSO(needle, "$"); 7766 ck_assert_int_eq(self->f->icIndexOfSmallJson(self, needle), -1); 7767 // non json string 7768 freeO(needle); 7769 ck_assert_int_eq(self->f->icIndexOfSmallJson(self, needle), -1); 7770 // non json object 7771 terminateO(needle); 7772 needle = (smallJsont*) allocSmallInt(1); 7773 ck_assert_int_eq(self->f->icIndexOfSmallJson(self, needle), -1); 7774 terminateO(needle); 7775 // indexOf NULL 7776 ck_assert_int_eq(self->f->icIndexOfSmallJson(self, NULL), -1); 7777 // empty string 7778 setValO(self, ""); 7779 needle = allocSmallJson(); 7780 setTopSO(needle, "$"); 7781 ck_assert_int_eq(self->f->icIndexOfSmallJson(self, needle), -1); 7782 // NULL string 7783 freeO(self); 7784 ck_assert_int_eq(self->f->icIndexOfSmallJson(self, needle), -1); 7785 terminateO(needle); 7786 terminateO(self); 7787 7788 } 7789 7790 7791 void icIndexOfSmallStringSmallStringT(CuTest *tc UNUSED) { 7792 7793 smallStringt *self = allocG(""); 7794 smallStringt *needle = allocSmallString("EE"); 7795 7796 // indexOf string in the middle 7797 setValO(self, "sheepy"); 7798 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), 2); 7799 // indexOf non existing string 7800 setValO(needle, "$"); 7801 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), -1); 7802 // non smallString object 7803 terminateO(needle); 7804 needle = (smallStringt*) allocSmallInt(1); 7805 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), -1); 7806 terminateO(needle); 7807 // indexOf NULL 7808 ck_assert_int_eq(self->f->icIndexOfSmallString(self, NULL), -1); 7809 // empty string 7810 setValO(self, ""); 7811 needle = allocSmallString("$"); 7812 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), -1); 7813 // NULL string 7814 freeO(self); 7815 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), -1); 7816 terminateO(needle); 7817 terminateO(self); 7818 7819 } 7820 7821 7822 void emptySmallStringT(CuTest *tc UNUSED) { 7823 7824 smallStringt* r; 7825 smallStringt *self = allocG("qwe"); 7826 7827 r = emptyO(self); 7828 ck_assert_ptr_ne(r, null); 7829 char *s = toStringO(r); 7830 ck_assert_str_eq(s, ""); 7831 free(s); 7832 terminateO(self); 7833 7834 } 7835 7836 7837 void isEmptySmallStringT(CuTest *tc UNUSED) { 7838 7839 smallStringt *self = allocG("qwe"); 7840 7841 ck_assert(!isEmptyO(self)); 7842 emptyO(self); 7843 ck_assert(isEmptyO(self)); 7844 freeO(self); 7845 ck_assert(isEmptyO(self)); 7846 terminateO(self); 7847 7848 } 7849 7850 7851 void isBlankSmallStringT(CuTest *tc UNUSED) { 7852 7853 smallStringt *self = allocG("q w"); 7854 7855 ck_assert(!isBlankO(self)); 7856 setValO(self, " "); 7857 ck_assert(isBlankO(self)); 7858 emptyO(self); 7859 ck_assert(isBlankO(self)); 7860 freeO(self); 7861 ck_assert(isBlankO(self)); 7862 terminateO(self); 7863 7864 } 7865 7866 7867 void splitSmallStringT(CuTest *tc UNUSED) { 7868 7869 smallArrayt* r; 7870 smallStringt *self = allocG(""); 7871 7872 // string 7873 setValO(self, "one/two"); 7874 r = splitO(self, "/"); 7875 ck_assert_ptr_ne(r, null); 7876 char *s = toStringO(r); 7877 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 7878 free(s); 7879 terminateO(r); 7880 // delimiter on the edge 7881 setValO(self, "/one"); 7882 r = splitO(self, "/"); 7883 ck_assert_ptr_ne(r, null); 7884 s = toStringO(r); 7885 ck_assert_str_eq(s, "[\"\",\"one\"]"); 7886 free(s); 7887 terminateO(r); 7888 setValO(self, "one/"); 7889 r = splitO(self, "/"); 7890 ck_assert_ptr_ne(r, null); 7891 s = toStringO(r); 7892 ck_assert_str_eq(s, "[\"one\",\"\"]"); 7893 free(s); 7894 terminateO(r); 7895 // delimiter not found 7896 setValO(self, "one/two"); 7897 r = splitO(self, "||"); 7898 ck_assert_ptr_ne(r, null); 7899 s = toStringO(r); 7900 ck_assert_str_eq(s, "[\"one/two\"]"); 7901 free(s); 7902 terminateO(r); 7903 // split with several delimiters after each other 7904 setValO(self, "one/two three "); 7905 r = splitO(self, " "); 7906 ck_assert_ptr_ne(r, null); 7907 s = toStringO(r); 7908 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 7909 free(s); 7910 terminateO(r); 7911 // multiple character delimiter 7912 setValO(self, "AAe three extract"); 7913 r = splitO(self, "e "); 7914 ck_assert_ptr_ne(r, null); 7915 s = toStringO(r); 7916 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 7917 free(s); 7918 terminateO(r); 7919 // empty delimiter 7920 setValO(self, "AAd"); 7921 r = splitO(self, ""); 7922 ck_assert_ptr_ne(r, null); 7923 s = toStringO(r); 7924 ck_assert_str_eq(s, "[\"AAd\"]"); 7925 free(s); 7926 terminateO(r); 7927 // empty string 7928 emptyO(self); 7929 r = splitO(self, "$"); 7930 ck_assert_ptr_ne(r, null); 7931 s = toStringO(r); 7932 ck_assert_str_eq(s, "[\"\"]"); 7933 free(s); 7934 terminateO(r); 7935 // NULL list 7936 freeO(self); 7937 ck_assert_ptr_eq(splitO(self, ";"), NULL); 7938 // NULL delimiter 7939 setValO(self, "test"); 7940 ck_assert_ptr_eq(splitO(self, NULL), NULL); 7941 terminateO(self); 7942 7943 } 7944 7945 7946 void splitCharSmallStringT(CuTest *tc UNUSED) { 7947 7948 smallArrayt* r; 7949 smallStringt *self = allocG(""); 7950 7951 // string 7952 setValO(self, "one/two"); 7953 r = splitCharO(self, '/'); 7954 ck_assert_ptr_ne(r, null); 7955 char *s = toStringO(r); 7956 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 7957 free(s); 7958 terminateO(r); 7959 // delimiter on the edge 7960 setValO(self, "/one"); 7961 r = splitCharO(self, '/'); 7962 ck_assert_ptr_ne(r, null); 7963 s = toStringO(r); 7964 ck_assert_str_eq(s, "[\"\",\"one\"]"); 7965 free(s); 7966 terminateO(r); 7967 setValO(self, "one/"); 7968 r = splitCharO(self, '/'); 7969 ck_assert_ptr_ne(r, null); 7970 s = toStringO(r); 7971 ck_assert_str_eq(s, "[\"one\",\"\"]"); 7972 free(s); 7973 terminateO(r); 7974 // delimiter not found 7975 setValO(self, "one/two"); 7976 r = splitCharO(self, '|'); 7977 ck_assert_ptr_ne(r, null); 7978 s = toStringO(r); 7979 ck_assert_str_eq(s, "[\"one/two\"]"); 7980 free(s); 7981 terminateO(r); 7982 // split with several delimiters after each other 7983 setValO(self, "one/two three "); 7984 r = splitCharO(self, ' '); 7985 ck_assert_ptr_ne(r, null); 7986 s = toStringO(r); 7987 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 7988 free(s); 7989 terminateO(r); 7990 // empty string 7991 emptyO(self); 7992 r = splitCharO(self, '$'); 7993 ck_assert_ptr_ne(r, null); 7994 s = toStringO(r); 7995 ck_assert_str_eq(s, "[\"\"]"); 7996 free(s); 7997 terminateO(r); 7998 // NULL list 7999 freeO(self); 8000 ck_assert_ptr_eq(splitCharO(self, ';'), NULL); 8001 terminateO(self); 8002 8003 } 8004 8005 8006 void splitSmallJsonSmallStringT(CuTest *tc UNUSED) { 8007 8008 smallArrayt* r; 8009 smallStringt *self = allocG(""); 8010 smallJsont *delim = allocSmallJson(); 8011 8012 // string 8013 setValO(self, "one/two"); 8014 setTopSO(delim, "/"); 8015 r = self->f->splitSmallJson(self, delim); 8016 ck_assert_ptr_ne(r, null); 8017 char *s = toStringO(r); 8018 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 8019 free(s); 8020 terminateO(r); 8021 // delimiter on the edge 8022 setValO(self, "/one"); 8023 r = self->f->splitSmallJson(self, delim); 8024 ck_assert_ptr_ne(r, null); 8025 s = toStringO(r); 8026 ck_assert_str_eq(s, "[\"\",\"one\"]"); 8027 free(s); 8028 terminateO(r); 8029 setValO(self, "one/"); 8030 r = self->f->splitSmallJson(self, delim); 8031 ck_assert_ptr_ne(r, null); 8032 s = toStringO(r); 8033 ck_assert_str_eq(s, "[\"one\",\"\"]"); 8034 free(s); 8035 terminateO(r); 8036 // delimiter not found 8037 setValO(self, "one/two"); 8038 freeO(delim); 8039 setTopSO(delim, "||"); 8040 r = self->f->splitSmallJson(self, delim); 8041 ck_assert_ptr_ne(r, null); 8042 s = toStringO(r); 8043 ck_assert_str_eq(s, "[\"one/two\"]"); 8044 free(s); 8045 terminateO(r); 8046 // split with several delimiters after each other 8047 setValO(self, "one/two three "); 8048 freeO(delim); 8049 setTopSO(delim, " "); 8050 r = self->f->splitSmallJson(self, delim); 8051 ck_assert_ptr_ne(r, null); 8052 s = toStringO(r); 8053 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 8054 free(s); 8055 terminateO(r); 8056 // multiple character delimiter 8057 setValO(self, "AAe three extract"); 8058 freeO(delim); 8059 setTopSO(delim, "e "); 8060 r = self->f->splitSmallJson(self, delim); 8061 ck_assert_ptr_ne(r, null); 8062 s = toStringO(r); 8063 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 8064 free(s); 8065 terminateO(r); 8066 // empty delimiter 8067 setValO(self, "AAd"); 8068 freeO(delim); 8069 setTopSO(delim, ""); 8070 r = self->f->splitSmallJson(self, delim); 8071 ck_assert_ptr_ne(r, null); 8072 s = toStringO(r); 8073 ck_assert_str_eq(s, "[\"AAd\"]"); 8074 free(s); 8075 terminateO(r); 8076 // empty string 8077 emptyO(self); 8078 freeO(delim); 8079 setTopSO(delim, "$"); 8080 r = self->f->splitSmallJson(self, delim); 8081 ck_assert_ptr_ne(r, null); 8082 s = toStringO(r); 8083 ck_assert_str_eq(s, "[\"\"]"); 8084 free(s); 8085 terminateO(r); 8086 // non json string delimiter 8087 freeO(delim); 8088 ck_assert_ptr_eq(self->f->splitSmallJson(self, delim), NULL); 8089 // non json object delimiter 8090 terminateO(delim); 8091 delim = (smallJsont*) allocSmallInt(1); 8092 ck_assert_ptr_eq(self->f->splitSmallJson(self, delim), NULL); 8093 terminateO(delim); 8094 delim = allocSmallJson(); 8095 // NULL list 8096 freeO(self); 8097 freeO(delim); 8098 setTopSO(delim, ";"); 8099 ck_assert_ptr_eq(self->f->splitSmallJson(self, delim), NULL); 8100 // NULL delimiter 8101 setValO(self, "test"); 8102 ck_assert_ptr_eq(self->f->splitSmallJson(self, NULL), NULL); 8103 terminateO(delim); 8104 terminateO(self); 8105 8106 } 8107 8108 8109 void splitSmallStringSmallStringT(CuTest *tc UNUSED) { 8110 8111 smallArrayt* r; 8112 smallStringt *self = allocG(""); 8113 smallStringt *delim = allocSmallString("/"); 8114 8115 // string 8116 setValO(self, "one/two"); 8117 r = self->f->splitSmallString(self, delim); 8118 ck_assert_ptr_ne(r, null); 8119 char *s = toStringO(r); 8120 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 8121 free(s); 8122 terminateO(r); 8123 // delimiter on the edge 8124 setValO(self, "/one"); 8125 r = self->f->splitSmallString(self, delim); 8126 ck_assert_ptr_ne(r, null); 8127 s = toStringO(r); 8128 ck_assert_str_eq(s, "[\"\",\"one\"]"); 8129 free(s); 8130 terminateO(r); 8131 setValO(self, "one/"); 8132 r = self->f->splitSmallString(self, delim); 8133 ck_assert_ptr_ne(r, null); 8134 s = toStringO(r); 8135 ck_assert_str_eq(s, "[\"one\",\"\"]"); 8136 free(s); 8137 terminateO(r); 8138 // delimiter not found 8139 setValO(self, "one/two"); 8140 setValO(delim, "||"); 8141 r = self->f->splitSmallString(self, delim); 8142 ck_assert_ptr_ne(r, null); 8143 s = toStringO(r); 8144 ck_assert_str_eq(s, "[\"one/two\"]"); 8145 free(s); 8146 terminateO(r); 8147 // split with several delimiters after each other 8148 setValO(self, "one/two three "); 8149 setValO(delim, " "); 8150 r = self->f->splitSmallString(self, delim); 8151 ck_assert_ptr_ne(r, null); 8152 s = toStringO(r); 8153 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 8154 free(s); 8155 terminateO(r); 8156 // multiple character delimiter 8157 setValO(self, "AAe three extract"); 8158 setValO(delim, "e "); 8159 r = self->f->splitSmallString(self, delim); 8160 ck_assert_ptr_ne(r, null); 8161 s = toStringO(r); 8162 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 8163 free(s); 8164 terminateO(r); 8165 // empty delimiter 8166 setValO(self, "AAd"); 8167 setValO(delim, ""); 8168 r = self->f->splitSmallString(self, delim); 8169 ck_assert_ptr_ne(r, null); 8170 s = toStringO(r); 8171 ck_assert_str_eq(s, "[\"AAd\"]"); 8172 free(s); 8173 terminateO(r); 8174 // empty string 8175 emptyO(self); 8176 setValO(delim, "$"); 8177 r = self->f->splitSmallString(self, delim); 8178 ck_assert_ptr_ne(r, null); 8179 s = toStringO(r); 8180 ck_assert_str_eq(s, "[\"\"]"); 8181 free(s); 8182 terminateO(r); 8183 // null string delimiter 8184 freeO(delim); 8185 ck_assert_ptr_eq(self->f->splitSmallString(self, delim), NULL); 8186 // non json object delimiter 8187 terminateO(delim); 8188 delim = (smallStringt*) allocSmallInt(1); 8189 ck_assert_ptr_eq(self->f->splitSmallString(self, delim), NULL); 8190 terminateO(delim); 8191 // NULL list 8192 freeO(self); 8193 delim = allocSmallString(";"); 8194 ck_assert_ptr_eq(self->f->splitSmallString(self, delim), NULL); 8195 // NULL delimiter 8196 setValO(self, "test"); 8197 ck_assert_ptr_eq(self->f->splitSmallString(self, NULL), NULL); 8198 terminateO(delim); 8199 terminateO(self); 8200 8201 } 8202 8203 8204 void splitSSmallStringT(CuTest *tc UNUSED) { 8205 8206 char** r; 8207 smallStringt *self = allocG(""); 8208 8209 // string 8210 setValO(self, "one/two"); 8211 r = splitSO(self, "/"); 8212 ck_assert_uint_eq(listLengthS(r),2); 8213 ck_assert_str_eq(r[0], "one"); 8214 ck_assert_str_eq(r[1], "two"); 8215 listFreeS(r); 8216 // delimiter on the edge 8217 setValO(self, "/one"); 8218 r = splitSO(self, "/"); 8219 ck_assert_uint_eq(listLengthS(r),2); 8220 ck_assert_str_eq(r[0], ""); 8221 ck_assert_str_eq(r[1], "one"); 8222 listFreeS(r); 8223 setValO(self, "one/"); 8224 r = splitSO(self, "/"); 8225 ck_assert_uint_eq(listLengthS(r),2); 8226 ck_assert_str_eq(r[0], "one"); 8227 ck_assert_str_eq(r[1], ""); 8228 listFreeS(r); 8229 // delimiter not found 8230 setValO(self, "one/two"); 8231 r = splitSO(self, "||"); 8232 ck_assert_uint_eq(listLengthS(r),1); 8233 ck_assert_str_eq(r[0], "one/two"); 8234 listFreeS(r); 8235 // split with several delimiters after each other 8236 setValO(self, "one/two three "); 8237 r = splitSO(self, " "); 8238 ck_assert_uint_eq(listLengthS(r),4); 8239 ck_assert_str_eq(r[0], "one/two"); 8240 ck_assert_str_eq(r[1], ""); 8241 ck_assert_str_eq(r[2], "three"); 8242 ck_assert_str_eq(r[3], ""); 8243 listFreeS(r); 8244 // multiple character delimiter 8245 setValO(self, "AAe three extract"); 8246 r = splitSO(self, "e "); 8247 ck_assert_uint_eq(listLengthS(r),3); 8248 ck_assert_str_eq(r[0], "AA"); 8249 ck_assert_str_eq(r[1], "thre"); 8250 ck_assert_str_eq(r[2], "extract"); 8251 listFreeS(r); 8252 // empty delimiter 8253 setValO(self, "AAd"); 8254 r = splitSO(self, ""); 8255 ck_assert_uint_eq(listLengthS(r),1); 8256 ck_assert_str_eq(r[0], "AAd"); 8257 listFreeS(r); 8258 // empty string 8259 emptyO(self); 8260 r = splitSO(self, "$"); 8261 ck_assert_uint_eq(listLengthS(r),1); 8262 ck_assert_str_eq(r[0], ""); 8263 listFreeS(r); 8264 // NULL list 8265 freeO(self); 8266 ck_assert_ptr_eq(splitSO(self, ";"), NULL); 8267 // NULL delimiter 8268 setValO(self, "test"); 8269 ck_assert_ptr_eq(splitSO(self, NULL), NULL); 8270 terminateO(self); 8271 8272 } 8273 8274 8275 void splitCharSSmallStringT(CuTest *tc UNUSED) { 8276 8277 char** r; 8278 smallStringt *self = allocG(""); 8279 8280 // string 8281 setValO(self, "one/two"); 8282 r = splitCharSO(self, '/'); 8283 ck_assert_uint_eq(listLengthS(r),2); 8284 ck_assert_str_eq(r[0], "one"); 8285 ck_assert_str_eq(r[1], "two"); 8286 listFreeS(r); 8287 // delimiter on the edge 8288 setValO(self, "/one"); 8289 r = splitCharSO(self, '/'); 8290 ck_assert_uint_eq(listLengthS(r),2); 8291 ck_assert_str_eq(r[0], ""); 8292 ck_assert_str_eq(r[1], "one"); 8293 listFreeS(r); 8294 setValO(self, "one/"); 8295 r = splitCharSO(self, '/'); 8296 ck_assert_uint_eq(listLengthS(r),2); 8297 ck_assert_str_eq(r[0], "one"); 8298 ck_assert_str_eq(r[1], ""); 8299 listFreeS(r); 8300 // delimiter not found 8301 setValO(self, "one/two"); 8302 r = splitCharSO(self, '|'); 8303 ck_assert_uint_eq(listLengthS(r),1); 8304 ck_assert_str_eq(r[0], "one/two"); 8305 listFreeS(r); 8306 // split with several delimiters after each other 8307 setValO(self, "one/two three "); 8308 r = splitCharSO(self, ' '); 8309 ck_assert_uint_eq(listLengthS(r),4); 8310 ck_assert_str_eq(r[0], "one/two"); 8311 ck_assert_str_eq(r[1], ""); 8312 ck_assert_str_eq(r[2], "three"); 8313 ck_assert_str_eq(r[3], ""); 8314 listFreeS(r); 8315 // empty string 8316 emptyO(self); 8317 r = splitCharSO(self, '$'); 8318 ck_assert_uint_eq(listLengthS(r),1); 8319 ck_assert_str_eq(r[0], ""); 8320 listFreeS(r); 8321 // NULL list 8322 freeO(self); 8323 ck_assert_ptr_eq(splitCharSO(self, ';'), NULL); 8324 terminateO(self); 8325 8326 } 8327 8328 8329 void splitSmallJsonSSmallStringT(CuTest *tc UNUSED) { 8330 8331 char** r; 8332 smallStringt *self = allocG(""); 8333 smallJsont *delim = allocSmallJson(); 8334 8335 // string 8336 setValO(self, "one/two"); 8337 setTopSO(delim, "/"); 8338 r = splitSmallJsonSO(self, delim); 8339 ck_assert_uint_eq(listLengthS(r),2); 8340 ck_assert_str_eq(r[0], "one"); 8341 ck_assert_str_eq(r[1], "two"); 8342 listFreeS(r); 8343 // delimiter on the edge 8344 setValO(self, "/one"); 8345 r = splitSmallJsonSO(self, delim); 8346 ck_assert_uint_eq(listLengthS(r),2); 8347 ck_assert_str_eq(r[0], ""); 8348 ck_assert_str_eq(r[1], "one"); 8349 listFreeS(r); 8350 setValO(self, "one/"); 8351 r = splitSmallJsonSO(self, delim); 8352 ck_assert_uint_eq(listLengthS(r),2); 8353 ck_assert_str_eq(r[0], "one"); 8354 ck_assert_str_eq(r[1], ""); 8355 listFreeS(r); 8356 // delimiter not found 8357 setValO(self, "one/two"); 8358 freeO(delim); 8359 setTopSO(delim, "||"); 8360 r = splitSmallJsonSO(self, delim); 8361 ck_assert_uint_eq(listLengthS(r),1); 8362 ck_assert_str_eq(r[0], "one/two"); 8363 listFreeS(r); 8364 // split with several delimiters after each other 8365 setValO(self, "one/two three "); 8366 freeO(delim); 8367 setTopSO(delim, " "); 8368 r = splitSmallJsonSO(self, delim); 8369 ck_assert_uint_eq(listLengthS(r),4); 8370 ck_assert_str_eq(r[0], "one/two"); 8371 ck_assert_str_eq(r[1], ""); 8372 ck_assert_str_eq(r[2], "three"); 8373 ck_assert_str_eq(r[3], ""); 8374 listFreeS(r); 8375 // multiple character delimiter 8376 setValO(self, "AAe three extract"); 8377 freeO(delim); 8378 setTopSO(delim, "e "); 8379 r = splitSmallJsonSO(self, delim); 8380 ck_assert_uint_eq(listLengthS(r),3); 8381 ck_assert_str_eq(r[0], "AA"); 8382 ck_assert_str_eq(r[1], "thre"); 8383 ck_assert_str_eq(r[2], "extract"); 8384 listFreeS(r); 8385 // empty delimiter 8386 setValO(self, "AAd"); 8387 freeO(delim); 8388 setTopSO(delim, ""); 8389 r = splitSmallJsonSO(self, delim); 8390 ck_assert_uint_eq(listLengthS(r),1); 8391 ck_assert_str_eq(r[0], "AAd"); 8392 listFreeS(r); 8393 // empty string 8394 emptyO(self); 8395 freeO(delim); 8396 setTopSO(delim, "$"); 8397 r = splitSmallJsonSO(self, delim); 8398 ck_assert_uint_eq(listLengthS(r),1); 8399 ck_assert_str_eq(r[0], ""); 8400 listFreeS(r); 8401 // non json string delimiter 8402 freeO(delim); 8403 ck_assert_ptr_eq(splitSmallJsonSO(self, delim), NULL); 8404 // non json object delimiter 8405 terminateO(delim); 8406 delim = (smallJsont*) allocSmallInt(1); 8407 ck_assert_ptr_eq(splitSmallJsonSO(self, delim), NULL); 8408 terminateO(delim); 8409 delim = allocSmallJson(); 8410 // NULL list 8411 freeO(self); 8412 freeO(delim); 8413 setTopSO(delim, ";"); 8414 ck_assert_ptr_eq(splitSmallJsonSO(self, delim), NULL); 8415 // NULL delimiter 8416 setValO(self, "test"); 8417 ck_assert_ptr_eq(splitSmallJsonSO(self, NULL), NULL); 8418 terminateO(delim); 8419 terminateO(self); 8420 8421 } 8422 8423 8424 void splitSmallStringSSmallStringT(CuTest *tc UNUSED) { 8425 8426 char** r; 8427 smallStringt *self = allocG(""); 8428 smallStringt *delim = allocSmallString("/"); 8429 8430 // string 8431 setValO(self, "one/two"); 8432 r = splitSmallStringSO(self, delim); 8433 ck_assert_uint_eq(listLengthS(r),2); 8434 ck_assert_str_eq(r[0], "one"); 8435 ck_assert_str_eq(r[1], "two"); 8436 listFreeS(r); 8437 // delimiter on the edge 8438 setValO(self, "/one"); 8439 r = splitSmallStringSO(self, delim); 8440 ck_assert_uint_eq(listLengthS(r),2); 8441 ck_assert_str_eq(r[0], ""); 8442 ck_assert_str_eq(r[1], "one"); 8443 listFreeS(r); 8444 setValO(self, "one/"); 8445 r = splitSmallStringSO(self, delim); 8446 ck_assert_uint_eq(listLengthS(r),2); 8447 ck_assert_str_eq(r[0], "one"); 8448 ck_assert_str_eq(r[1], ""); 8449 listFreeS(r); 8450 // delimiter not found 8451 setValO(self, "one/two"); 8452 setValO(delim, "||"); 8453 r = splitSmallStringSO(self, delim); 8454 ck_assert_uint_eq(listLengthS(r),1); 8455 ck_assert_str_eq(r[0], "one/two"); 8456 listFreeS(r); 8457 // split with several delimiters after each other 8458 setValO(self, "one/two three "); 8459 setValO(delim, " "); 8460 r = splitSmallStringSO(self, delim); 8461 ck_assert_uint_eq(listLengthS(r),4); 8462 ck_assert_str_eq(r[0], "one/two"); 8463 ck_assert_str_eq(r[1], ""); 8464 ck_assert_str_eq(r[2], "three"); 8465 ck_assert_str_eq(r[3], ""); 8466 listFreeS(r); 8467 // multiple character delimiter 8468 setValO(self, "AAe three extract"); 8469 setValO(delim, "e "); 8470 r = splitSmallStringSO(self, delim); 8471 ck_assert_uint_eq(listLengthS(r),3); 8472 ck_assert_str_eq(r[0], "AA"); 8473 ck_assert_str_eq(r[1], "thre"); 8474 ck_assert_str_eq(r[2], "extract"); 8475 listFreeS(r); 8476 // empty delimiter 8477 setValO(self, "AAd"); 8478 setValO(delim, ""); 8479 r = splitSmallStringSO(self, delim); 8480 ck_assert_uint_eq(listLengthS(r),1); 8481 ck_assert_str_eq(r[0], "AAd"); 8482 listFreeS(r); 8483 // empty string 8484 emptyO(self); 8485 setValO(delim, "$"); 8486 r = splitSmallStringSO(self, delim); 8487 ck_assert_uint_eq(listLengthS(r),1); 8488 ck_assert_str_eq(r[0], ""); 8489 listFreeS(r); 8490 // non smallString object delimiter 8491 terminateO(delim); 8492 delim = (smallStringt*) allocSmallInt(1); 8493 ck_assert_ptr_eq(splitSmallStringSO(self, delim), NULL); 8494 terminateO(delim); 8495 // NULL list 8496 freeO(self); 8497 delim = allocSmallString(";"); 8498 ck_assert_ptr_eq(splitSmallStringSO(self, delim), NULL); 8499 // NULL delimiter 8500 setValO(self, "test"); 8501 ck_assert_ptr_eq(splitSmallStringSO(self, NULL), NULL); 8502 terminateO(delim); 8503 terminateO(self); 8504 8505 } 8506 8507 8508 void extractSmallStringT(CuTest *tc UNUSED) { 8509 8510 smallArrayt* r; 8511 smallStringt *self = allocG(""); 8512 8513 // string 8514 setValO(self, "one/two|"); 8515 r = extractO(self, "/", "|"); 8516 ck_assert_ptr_ne(r, null); 8517 char *s = toStringO(r); 8518 ck_assert_str_eq(s, "[\"two\"]"); 8519 free(s); 8520 terminateO(r); 8521 // delimiter not found 8522 setValO(self, "one/two"); 8523 r = extractO(self, "||", "/"); 8524 ck_assert_ptr_eq(r, NULL); 8525 // extractO with several delimiters after each other 8526 setValO(self, "one/ two /three "); 8527 r = extractO(self, "/", " "); 8528 ck_assert_ptr_ne(r, null); 8529 s = toStringO(r); 8530 ck_assert_str_eq(s, "[\"\",\"three\"]"); 8531 free(s); 8532 terminateO(r); 8533 // multiple character delimiter 8534 setValO(self, "AAe thre|e extract"); 8535 r = extractO(self, "e ", "|"); 8536 ck_assert_ptr_ne(r, null); 8537 s = toStringO(r); 8538 ck_assert_str_eq(s, "[\"thre\"]"); 8539 free(s); 8540 terminateO(r); 8541 // empty delimiter 8542 setValO(self, "AAd"); 8543 r = extractO(self, "", "Ad"); 8544 ck_assert_ptr_eq(r, NULL); 8545 setValO(self, "AAd"); 8546 r = extractO(self, "A", ""); 8547 ck_assert_ptr_eq(r, NULL); 8548 // empty string 8549 setValO(self, ""); 8550 r = extractO(self, "$", "#"); 8551 ck_assert_ptr_eq(r, NULL); 8552 // delim1 = delim2 8553 setValO(self, ""); 8554 r = extractO(self, "$", "$"); 8555 ck_assert_ptr_eq(r, NULL); 8556 // NULL string 8557 freeO(self); 8558 ck_assert_ptr_eq(extractO(self, ";", ","), NULL); 8559 // NULL delimiter 8560 setValO(self, "test"); 8561 ck_assert_ptr_eq(extractO(self, NULL, ","), NULL); 8562 ck_assert_ptr_eq(extractO(self, ",", NULL), NULL); 8563 terminateO(self); 8564 8565 } 8566 8567 8568 void extractCharSSmallStringT(CuTest *tc UNUSED) { 8569 8570 smallArrayt* r; 8571 smallStringt *self = allocG(""); 8572 8573 // string 8574 setValO(self, "one/two|"); 8575 r = extractCharSO(self, '/', "|"); 8576 ck_assert_ptr_ne(r, null); 8577 char *s = toStringO(r); 8578 ck_assert_str_eq(s, "[\"two\"]"); 8579 free(s); 8580 terminateO(r); 8581 // delimiter not found 8582 setValO(self, "one/two"); 8583 r = extractCharSO(self, '|', "/"); 8584 ck_assert_ptr_eq(r, NULL); 8585 // extractCharSO with several delimiters after each other 8586 setValO(self, "one/ two /three "); 8587 r = extractCharSO(self, '/', " "); 8588 ck_assert_ptr_ne(r, null); 8589 s = toStringO(r); 8590 ck_assert_str_eq(s, "[\"\",\"three\"]"); 8591 free(s); 8592 terminateO(r); 8593 // multiple character delimiter 8594 setValO(self, "AAe thre|e extract"); 8595 r = extractCharSO(self, ' ', "|e"); 8596 ck_assert_ptr_ne(r, null); 8597 s = toStringO(r); 8598 ck_assert_str_eq(s, "[\"thre\"]"); 8599 free(s); 8600 terminateO(r); 8601 // empty delimiter 8602 setValO(self, "AAd"); 8603 r = extractCharSO(self, 'A', ""); 8604 ck_assert_ptr_eq(r, NULL); 8605 // empty string 8606 setValO(self, ""); 8607 r = extractCharSO(self, '$', "#"); 8608 ck_assert_ptr_eq(r, NULL); 8609 // delim1 = delim2 8610 setValO(self, ""); 8611 r = extractCharSO(self, '$', "$"); 8612 ck_assert_ptr_eq(r, NULL); 8613 // NULL string 8614 freeO(self); 8615 ck_assert_ptr_eq(extractCharSO(self, ';', ","), NULL); 8616 // NULL delimiter 8617 setValO(self, "test"); 8618 ck_assert_ptr_eq(extractCharSO(self, ',', NULL), NULL); 8619 terminateO(self); 8620 8621 } 8622 8623 8624 void extractSCharSmallStringT(CuTest *tc UNUSED) { 8625 8626 smallArrayt* r; 8627 smallStringt *self = allocG(""); 8628 8629 // string 8630 setValO(self, "one/two|"); 8631 r = extractSCharO(self, "/", '|'); 8632 ck_assert_ptr_ne(r, null); 8633 char *s = toStringO(r); 8634 ck_assert_str_eq(s, "[\"two\"]"); 8635 free(s); 8636 terminateO(r); 8637 // delimiter not found 8638 setValO(self, "one/two"); 8639 r = extractSCharO(self, "||", '/'); 8640 ck_assert_ptr_eq(r, NULL); 8641 // extractSCharO with several delimiters after each other 8642 setValO(self, "one/ two /three "); 8643 r = extractSCharO(self, "/", ' '); 8644 ck_assert_ptr_ne(r, null); 8645 s = toStringO(r); 8646 ck_assert_str_eq(s, "[\"\",\"three\"]"); 8647 free(s); 8648 terminateO(r); 8649 // multiple character delimiter 8650 setValO(self, "AAe thre|e extract"); 8651 r = extractSCharO(self, "e ", '|'); 8652 ck_assert_ptr_ne(r, null); 8653 s = toStringO(r); 8654 ck_assert_str_eq(s, "[\"thre\"]"); 8655 free(s); 8656 terminateO(r); 8657 // empty delimiter 8658 setValO(self, "AAd"); 8659 r = extractSCharO(self, "", 'A'); 8660 ck_assert_ptr_eq(r, NULL); 8661 // empty string 8662 setValO(self, ""); 8663 r = extractSCharO(self, "$", '#'); 8664 ck_assert_ptr_eq(r, NULL); 8665 // delim1 = delim2 8666 setValO(self, ""); 8667 r = extractSCharO(self, "$", '$'); 8668 ck_assert_ptr_eq(r, NULL); 8669 // NULL string 8670 freeO(self); 8671 ck_assert_ptr_eq(extractSCharO(self, ";", ','), NULL); 8672 // NULL delimiter 8673 setValO(self, "test"); 8674 ck_assert_ptr_eq(extractSCharO(self, NULL, ','), NULL); 8675 terminateO(self); 8676 8677 } 8678 8679 8680 void extractCharCharSmallStringT(CuTest *tc UNUSED) { 8681 8682 smallArrayt* r; 8683 smallStringt *self = allocG(""); 8684 8685 // string 8686 setValO(self, "one/two|"); 8687 r = extractCharCharO(self, '/', '|'); 8688 ck_assert_ptr_ne(r, null); 8689 char *s = toStringO(r); 8690 ck_assert_str_eq(s, "[\"two\"]"); 8691 free(s); 8692 terminateO(r); 8693 // delimiter not found 8694 setValO(self, "one/two"); 8695 r = extractCharCharO(self, '|', '/'); 8696 ck_assert_ptr_eq(r, NULL); 8697 // extractCharCharO with several delimiters after each other 8698 setValO(self, "one/ two /three "); 8699 r = extractCharCharO(self, '/', ' '); 8700 ck_assert_ptr_ne(r, null); 8701 s = toStringO(r); 8702 ck_assert_str_eq(s, "[\"\",\"three\"]"); 8703 free(s); 8704 terminateO(r); 8705 // multiple character delimiter 8706 setValO(self, "AAe thre|e extract"); 8707 r = extractCharCharO(self, ' ', '|'); 8708 ck_assert_ptr_ne(r, null); 8709 s = toStringO(r); 8710 ck_assert_str_eq(s, "[\"thre\"]"); 8711 free(s); 8712 terminateO(r); 8713 // empty string 8714 setValO(self, ""); 8715 r = extractCharCharO(self, '$', '#'); 8716 ck_assert_ptr_eq(r, NULL); 8717 // delim1 = delim2 8718 setValO(self, ""); 8719 r = extractCharCharO(self, '$', '$'); 8720 ck_assert_ptr_eq(r, NULL); 8721 // NULL string 8722 freeO(self); 8723 ck_assert_ptr_eq(extractCharCharO(self, ';', ','), NULL); 8724 terminateO(self); 8725 8726 } 8727 8728 8729 void extractSmallJsonSmallJsonSmallStringT(CuTest *tc UNUSED) { 8730 8731 smallArrayt* r; 8732 smallStringt *self = allocG(""); 8733 smallJsont* delim1 = allocSmallJson(); 8734 smallJsont* delim2 = allocSmallJson(); 8735 8736 // string 8737 setValO(self, "one/two|"); 8738 setTopSO(delim1, "/"); 8739 setTopSO(delim2, "|"); 8740 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8741 ck_assert_ptr_ne(r, null); 8742 char *s = toStringO(r); 8743 ck_assert_str_eq(s, "[\"two\"]"); 8744 free(s); 8745 terminateO(r); 8746 // delimiter not found 8747 setValO(self, "one/two"); 8748 freeO(delim1); 8749 freeO(delim2); 8750 setTopSO(delim1, "||"); 8751 setTopSO(delim2, "/"); 8752 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8753 ck_assert_ptr_eq(r, NULL); 8754 // extractSmallJsonSmallJsonO with several delimiters after each other 8755 setValO(self, "one/ two /three "); 8756 freeO(delim1); 8757 freeO(delim2); 8758 setTopSO(delim1, "/"); 8759 setTopSO(delim2, " "); 8760 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8761 ck_assert_ptr_ne(r, null); 8762 s = toStringO(r); 8763 ck_assert_str_eq(s, "[\"\",\"three\"]"); 8764 free(s); 8765 terminateO(r); 8766 // multiple character delimiter 8767 setValO(self, "AAe thre|e extract"); 8768 freeO(delim1); 8769 freeO(delim2); 8770 setTopSO(delim1, "e "); 8771 setTopSO(delim2, "|"); 8772 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8773 ck_assert_ptr_ne(r, null); 8774 s = toStringO(r); 8775 ck_assert_str_eq(s, "[\"thre\"]"); 8776 free(s); 8777 terminateO(r); 8778 // empty delimiter 8779 setValO(self, "AAd"); 8780 freeO(delim1); 8781 freeO(delim2); 8782 setTopSO(delim1, ""); 8783 setTopSO(delim2, "Ad"); 8784 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8785 ck_assert_ptr_eq(r, NULL); 8786 setValO(self, "AAd"); 8787 freeO(delim1); 8788 freeO(delim2); 8789 setTopSO(delim1, "A"); 8790 setTopSO(delim2, ""); 8791 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8792 ck_assert_ptr_eq(r, NULL); 8793 // empty string 8794 setValO(self, ""); 8795 freeO(delim1); 8796 freeO(delim2); 8797 setTopSO(delim1, "$"); 8798 setTopSO(delim2, "#"); 8799 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8800 ck_assert_ptr_eq(r, NULL); 8801 // delim1 = delim2 8802 setValO(self, "$qwe$"); 8803 freeO(delim1); 8804 freeO(delim2); 8805 setTopSO(delim1, "$"); 8806 setTopSO(delim2, "$"); 8807 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8808 ck_assert_ptr_eq(r, NULL); 8809 // non json string 8810 freeO(delim1); 8811 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8812 ck_assert_ptr_eq(r, NULL); 8813 setTopSO(delim1, "$"); 8814 freeO(delim2); 8815 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8816 ck_assert_ptr_eq(r, NULL); 8817 // non json object 8818 terminateO(delim1); 8819 delim1 = (smallJsont*) allocSmallInt(1); 8820 setTopSO(delim2, "$"); 8821 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8822 ck_assert_ptr_eq(r, NULL); 8823 terminateO(delim1); 8824 delim1 = allocSmallJson(); 8825 setTopSO(delim1, ";"); 8826 terminateO(delim2); 8827 delim2 = (smallJsont*) allocSmallInt(1); 8828 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 8829 ck_assert_ptr_eq(r, NULL); 8830 terminateO(delim2); 8831 delim2 = allocSmallJson(); 8832 // NULL string 8833 freeO(self); 8834 freeO(delim1); 8835 freeO(delim2); 8836 setTopSO(delim1, ";"); 8837 setTopSO(delim2, ","); 8838 ck_assert_ptr_eq(extractSmallJsonSmallJsonO(self, delim1, delim2), NULL); 8839 // NULL delimiter 8840 setValO(self, "test"); 8841 ck_assert_ptr_eq(extractSmallJsonSmallJsonO(self, NULL, delim2), NULL); 8842 ck_assert_ptr_eq(extractSmallJsonSmallJsonO(self, delim1, NULL), NULL); 8843 terminateO(delim1); 8844 terminateO(delim2); 8845 terminateO(self); 8846 8847 } 8848 8849 8850 void extractSmallJsonSmallStringSmallStringT(CuTest *tc UNUSED) { 8851 8852 smallArrayt* r; 8853 smallStringt *self = allocG(""); 8854 smallJsont* delim1 = allocSmallJson(); 8855 smallStringt* delim2 = allocSmallString("|"); 8856 8857 // string 8858 setValO(self, "one/two|"); 8859 setTopSO(delim1, "/"); 8860 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8861 ck_assert_ptr_ne(r, null); 8862 char *s = toStringO(r); 8863 ck_assert_str_eq(s, "[\"two\"]"); 8864 free(s); 8865 terminateO(r); 8866 // delimiter not found 8867 setValO(self, "one/two"); 8868 freeO(delim1); 8869 setTopSO(delim1, "||"); 8870 setValO(delim2, "/"); 8871 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8872 ck_assert_ptr_eq(r, NULL); 8873 // extractSmallJsonSmallStringO with several delimiters after each other 8874 setValO(self, "one/ two /three "); 8875 freeO(delim1); 8876 setTopSO(delim1, "/"); 8877 setValO(delim2, " "); 8878 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8879 ck_assert_ptr_ne(r, null); 8880 s = toStringO(r); 8881 ck_assert_str_eq(s, "[\"\",\"three\"]"); 8882 free(s); 8883 terminateO(r); 8884 // multiple character delimiter 8885 setValO(self, "AAe thre|e extract"); 8886 freeO(delim1); 8887 setTopSO(delim1, "e "); 8888 setValO(delim2, "|"); 8889 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8890 ck_assert_ptr_ne(r, null); 8891 s = toStringO(r); 8892 ck_assert_str_eq(s, "[\"thre\"]"); 8893 free(s); 8894 terminateO(r); 8895 // empty delimiter 8896 setValO(self, "AAd"); 8897 freeO(delim1); 8898 setTopSO(delim1, ""); 8899 setValO(delim2, "Ad"); 8900 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8901 ck_assert_ptr_eq(r, NULL); 8902 setValO(self, "AAd"); 8903 freeO(delim1); 8904 setTopSO(delim1, "A"); 8905 setValO(delim2, ""); 8906 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8907 ck_assert_ptr_eq(r, NULL); 8908 // empty string 8909 setValO(self, ""); 8910 freeO(delim1); 8911 setTopSO(delim1, "$"); 8912 setValO(delim2, "#"); 8913 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8914 ck_assert_ptr_eq(r, NULL); 8915 // delim1 = delim2 8916 setValO(self, "$qwe$"); 8917 freeO(delim1); 8918 setTopSO(delim1, "$"); 8919 setValO(delim2, "$"); 8920 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8921 ck_assert_ptr_eq(r, NULL); 8922 // non json string 8923 freeO(delim1); 8924 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8925 ck_assert_ptr_eq(r, NULL); 8926 // non json object 8927 terminateO(delim1); 8928 delim1 = (smallJsont*) allocSmallInt(1); 8929 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8930 ck_assert_ptr_eq(r, NULL); 8931 terminateO(delim1); 8932 delim1 = allocSmallJson(); 8933 setTopSO(delim1, ";"); 8934 terminateO(delim2); 8935 delim2 = (smallStringt*) allocSmallInt(1); 8936 r = extractSmallJsonSmallStringO(self, delim1, delim2); 8937 ck_assert_ptr_eq(r, NULL); 8938 terminateO(delim2); 8939 delim2 = allocSmallString(","); 8940 // NULL string 8941 freeO(self); 8942 freeO(delim1); 8943 setTopSO(delim1, ";"); 8944 ck_assert_ptr_eq(extractSmallJsonSmallStringO(self, delim1, delim2), NULL); 8945 // NULL delimiter 8946 setValO(self, "test"); 8947 ck_assert_ptr_eq(extractSmallJsonSmallStringO(self, NULL, delim2), NULL); 8948 ck_assert_ptr_eq(extractSmallJsonSmallStringO(self, delim1, NULL), NULL); 8949 terminateO(delim1); 8950 terminateO(delim2); 8951 terminateO(self); 8952 8953 } 8954 8955 8956 void extractSmallJsonSSmallStringT(CuTest *tc UNUSED) { 8957 8958 smallArrayt* r; 8959 smallStringt *self = allocG(""); 8960 smallJsont* delim1 = allocSmallJson(); 8961 8962 // string 8963 setValO(self, "one/two|"); 8964 setTopSO(delim1, "/"); 8965 r = extractSmallJsonSO(self, delim1, "|"); 8966 ck_assert_ptr_ne(r, null); 8967 char *s = toStringO(r); 8968 ck_assert_str_eq(s, "[\"two\"]"); 8969 free(s); 8970 terminateO(r); 8971 // delimiter not found 8972 setValO(self, "one/two"); 8973 freeO(delim1); 8974 setTopSO(delim1, "||"); 8975 r = extractSmallJsonSO(self, delim1, "/"); 8976 ck_assert_ptr_eq(r, NULL); 8977 // extractSmallJsonSO with several delimiters after each other 8978 setValO(self, "one/ two /three "); 8979 freeO(delim1); 8980 setTopSO(delim1, "/"); 8981 r = extractSmallJsonSO(self, delim1, " "); 8982 ck_assert_ptr_ne(r, null); 8983 s = toStringO(r); 8984 ck_assert_str_eq(s, "[\"\",\"three\"]"); 8985 free(s); 8986 terminateO(r); 8987 // multiple character delimiter 8988 setValO(self, "AAe thre|e extract"); 8989 freeO(delim1); 8990 setTopSO(delim1, "e "); 8991 r = extractSmallJsonSO(self, delim1, "|"); 8992 ck_assert_ptr_ne(r, null); 8993 s = toStringO(r); 8994 ck_assert_str_eq(s, "[\"thre\"]"); 8995 free(s); 8996 terminateO(r); 8997 // empty delimiter 8998 setValO(self, "AAd"); 8999 freeO(delim1); 9000 setTopSO(delim1, ""); 9001 r = extractSmallJsonSO(self, delim1, "Ad"); 9002 ck_assert_ptr_eq(r, NULL); 9003 setValO(self, "AAd"); 9004 freeO(delim1); 9005 setTopSO(delim1, "A"); 9006 r = extractSmallJsonSO(self, delim1, ""); 9007 ck_assert_ptr_eq(r, NULL); 9008 // empty string 9009 setValO(self, ""); 9010 freeO(delim1); 9011 setTopSO(delim1, "$"); 9012 r = extractSmallJsonSO(self, delim1, "#"); 9013 ck_assert_ptr_eq(r, NULL); 9014 // delim1 = delim2 9015 setValO(self, "$qwe$"); 9016 freeO(delim1); 9017 setTopSO(delim1, "$"); 9018 r = extractSmallJsonSO(self, delim1, "$"); 9019 ck_assert_ptr_eq(r, NULL); 9020 // non json string 9021 freeO(delim1); 9022 r = extractSmallJsonSO(self, delim1, "$"); 9023 ck_assert_ptr_eq(r, NULL); 9024 // non json object 9025 terminateO(delim1); 9026 delim1 = (smallJsont*) allocSmallInt(1); 9027 r = extractSmallJsonSO(self, delim1, "$"); 9028 ck_assert_ptr_eq(r, NULL); 9029 terminateO(delim1); 9030 delim1 = allocSmallJson(); 9031 // NULL string 9032 freeO(self); 9033 freeO(delim1); 9034 setTopSO(delim1, ";"); 9035 ck_assert_ptr_eq(extractSmallJsonSO(self, delim1, ","), NULL); 9036 // NULL delimiter 9037 setValO(self, "test"); 9038 ck_assert_ptr_eq(extractSmallJsonSO(self, NULL, ","), NULL); 9039 ck_assert_ptr_eq(extractSmallJsonSO(self, delim1, NULL), NULL); 9040 terminateO(delim1); 9041 terminateO(self); 9042 9043 } 9044 9045 9046 void extractSmallJsonCharSmallStringT(CuTest *tc UNUSED) { 9047 9048 smallArrayt* r; 9049 smallStringt *self = allocG(""); 9050 smallJsont* delim1 = allocSmallJson(); 9051 9052 // string 9053 setValO(self, "one/two|"); 9054 setTopSO(delim1, "/"); 9055 r = extractSmallJsonCharO(self, delim1, '|'); 9056 ck_assert_ptr_ne(r, null); 9057 char *s = toStringO(r); 9058 ck_assert_str_eq(s, "[\"two\"]"); 9059 free(s); 9060 terminateO(r); 9061 // delimiter not found 9062 setValO(self, "one/two"); 9063 freeO(delim1); 9064 setTopSO(delim1, "||"); 9065 r = extractSmallJsonCharO(self, delim1, '/'); 9066 ck_assert_ptr_eq(r, NULL); 9067 // extractSmallJsonCharO with several delimiters after each other 9068 setValO(self, "one/ two /three "); 9069 freeO(delim1); 9070 setTopSO(delim1, "/"); 9071 r = extractSmallJsonCharO(self, delim1, ' '); 9072 ck_assert_ptr_ne(r, null); 9073 s = toStringO(r); 9074 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9075 free(s); 9076 terminateO(r); 9077 // multiple character delimiter 9078 setValO(self, "AAe thre|e extract"); 9079 freeO(delim1); 9080 setTopSO(delim1, "e "); 9081 r = extractSmallJsonCharO(self, delim1, '|'); 9082 ck_assert_ptr_ne(r, null); 9083 s = toStringO(r); 9084 ck_assert_str_eq(s, "[\"thre\"]"); 9085 free(s); 9086 terminateO(r); 9087 // empty delimiter 9088 setValO(self, "AAd"); 9089 freeO(delim1); 9090 setTopSO(delim1, ""); 9091 r = extractSmallJsonCharO(self, delim1, 'd'); 9092 ck_assert_ptr_eq(r, NULL); 9093 setValO(self, "AAd"); 9094 // empty string 9095 setValO(self, ""); 9096 freeO(delim1); 9097 setTopSO(delim1, "$"); 9098 r = extractSmallJsonCharO(self, delim1, '#'); 9099 ck_assert_ptr_eq(r, NULL); 9100 // delim1 = delim2 9101 setValO(self, "$qwe$"); 9102 freeO(delim1); 9103 setTopSO(delim1, "$"); 9104 r = extractSmallJsonCharO(self, delim1, '$'); 9105 ck_assert_ptr_eq(r, NULL); 9106 // non json string 9107 freeO(delim1); 9108 r = extractSmallJsonCharO(self, delim1, '$'); 9109 ck_assert_ptr_eq(r, NULL); 9110 // non json object 9111 terminateO(delim1); 9112 delim1 = (smallJsont*) allocSmallInt(1); 9113 r = extractSmallJsonCharO(self, delim1, '$'); 9114 ck_assert_ptr_eq(r, NULL); 9115 terminateO(delim1); 9116 delim1 = allocSmallJson(); 9117 // NULL string 9118 freeO(self); 9119 freeO(delim1); 9120 setTopSO(delim1, ";"); 9121 ck_assert_ptr_eq(extractSmallJsonCharO(self, delim1, ','), NULL); 9122 // NULL delimiter 9123 setValO(self, "test"); 9124 ck_assert_ptr_eq(extractSmallJsonCharO(self, NULL, ','), NULL); 9125 terminateO(delim1); 9126 terminateO(self); 9127 9128 } 9129 9130 9131 void extractSmallStringSmallJsonSmallStringT(CuTest *tc UNUSED) { 9132 9133 smallArrayt* r; 9134 smallStringt *self = allocG(""); 9135 smallStringt* delim1 = allocSmallString("/"); 9136 smallJsont* delim2 = allocSmallJson(); 9137 9138 // string 9139 setValO(self, "one/two|"); 9140 setTopSO(delim2, "|"); 9141 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9142 ck_assert_ptr_ne(r, null); 9143 char *s = toStringO(r); 9144 ck_assert_str_eq(s, "[\"two\"]"); 9145 free(s); 9146 terminateO(r); 9147 // delimiter not found 9148 setValO(self, "one/two"); 9149 freeO(delim2); 9150 setValO(delim1, "||"); 9151 setTopSO(delim2, "/"); 9152 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9153 ck_assert_ptr_eq(r, NULL); 9154 // extractSmallStringSmallJsonO with several delimiters after each other 9155 setValO(self, "one/ two /three "); 9156 freeO(delim2); 9157 setValO(delim1, "/"); 9158 setTopSO(delim2, " "); 9159 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9160 ck_assert_ptr_ne(r, null); 9161 s = toStringO(r); 9162 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9163 free(s); 9164 terminateO(r); 9165 // multiple character delimiter 9166 setValO(self, "AAe thre|e extract"); 9167 freeO(delim2); 9168 setValO(delim1, "e "); 9169 setTopSO(delim2, "|"); 9170 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9171 ck_assert_ptr_ne(r, null); 9172 s = toStringO(r); 9173 ck_assert_str_eq(s, "[\"thre\"]"); 9174 free(s); 9175 terminateO(r); 9176 // empty delimiter 9177 setValO(self, "AAd"); 9178 freeO(delim2); 9179 setValO(delim1, ""); 9180 setTopSO(delim2, "Ad"); 9181 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9182 ck_assert_ptr_eq(r, NULL); 9183 setValO(self, "AAd"); 9184 freeO(delim2); 9185 setValO(delim1, "A"); 9186 setTopSO(delim2, ""); 9187 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9188 ck_assert_ptr_eq(r, NULL); 9189 // empty string 9190 setValO(self, ""); 9191 freeO(delim2); 9192 setValO(delim1, "$"); 9193 setTopSO(delim2, "#"); 9194 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9195 ck_assert_ptr_eq(r, NULL); 9196 // delim1 = delim2 9197 setValO(self, "$qwe$"); 9198 freeO(delim2); 9199 setValO(delim1, "$"); 9200 setTopSO(delim2, "$"); 9201 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9202 ck_assert_ptr_eq(r, NULL); 9203 // non json string 9204 freeO(delim2); 9205 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9206 ck_assert_ptr_eq(r, NULL); 9207 // non json object 9208 terminateO(delim1); 9209 delim1 = (smallStringt*) allocSmallInt(1); 9210 setTopSO(delim2, "$"); 9211 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9212 ck_assert_ptr_eq(r, NULL); 9213 terminateO(delim1); 9214 delim1 = allocSmallString(";"); 9215 terminateO(delim2); 9216 delim2 = (smallJsont*) allocSmallInt(1); 9217 r = extractSmallStringSmallJsonO(self, delim1, delim2); 9218 ck_assert_ptr_eq(r, NULL); 9219 terminateO(delim2); 9220 delim2 = allocSmallJson(); 9221 // NULL string 9222 freeO(self); 9223 freeO(delim2); 9224 setValO(delim1, ";"); 9225 setTopSO(delim2, ","); 9226 ck_assert_ptr_eq(extractSmallStringSmallJsonO(self, delim1, delim2), NULL); 9227 // NULL delimiter 9228 setValO(self, "test"); 9229 ck_assert_ptr_eq(extractSmallStringSmallJsonO(self, NULL, delim2), NULL); 9230 ck_assert_ptr_eq(extractSmallStringSmallJsonO(self, delim1, NULL), NULL); 9231 terminateO(delim1); 9232 terminateO(delim2); 9233 terminateO(self); 9234 9235 } 9236 9237 9238 void extractSmallStringSmallStringSmallStringT(CuTest *tc UNUSED) { 9239 9240 smallArrayt* r; 9241 smallStringt *self = allocG(""); 9242 smallStringt* delim1 = allocSmallString("/"); 9243 smallStringt* delim2 = allocSmallString("|"); 9244 9245 // string 9246 setValO(self, "one/two|"); 9247 setValO(delim2, "|"); 9248 r = extractSmallStringSmallStringO(self, delim1, delim2); 9249 ck_assert_ptr_ne(r, null); 9250 char *s = toStringO(r); 9251 ck_assert_str_eq(s, "[\"two\"]"); 9252 free(s); 9253 terminateO(r); 9254 // delimiter not found 9255 setValO(self, "one/two"); 9256 setValO(delim1, "||"); 9257 setValO(delim2, "/"); 9258 r = extractSmallStringSmallStringO(self, delim1, delim2); 9259 ck_assert_ptr_eq(r, NULL); 9260 // extractSmallStringSmallStringO with several delimiters after each other 9261 setValO(self, "one/ two /three "); 9262 setValO(delim1, "/"); 9263 setValO(delim2, " "); 9264 r = extractSmallStringSmallStringO(self, delim1, delim2); 9265 ck_assert_ptr_ne(r, null); 9266 s = toStringO(r); 9267 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9268 free(s); 9269 terminateO(r); 9270 // multiple character delimiter 9271 setValO(self, "AAe thre|e extract"); 9272 setValO(delim1, "e "); 9273 setValO(delim2, "|"); 9274 r = extractSmallStringSmallStringO(self, delim1, delim2); 9275 ck_assert_ptr_ne(r, null); 9276 s = toStringO(r); 9277 ck_assert_str_eq(s, "[\"thre\"]"); 9278 free(s); 9279 terminateO(r); 9280 // empty delimiter 9281 setValO(self, "AAd"); 9282 setValO(delim1, ""); 9283 setValO(delim2, "Ad"); 9284 r = extractSmallStringSmallStringO(self, delim1, delim2); 9285 ck_assert_ptr_eq(r, NULL); 9286 setValO(self, "AAd"); 9287 setValO(delim1, "A"); 9288 setValO(delim2, ""); 9289 r = extractSmallStringSmallStringO(self, delim1, delim2); 9290 ck_assert_ptr_eq(r, NULL); 9291 // empty string 9292 setValO(self, ""); 9293 setValO(delim1, "$"); 9294 setValO(delim2, "#"); 9295 r = extractSmallStringSmallStringO(self, delim1, delim2); 9296 ck_assert_ptr_eq(r, NULL); 9297 // delim1 = delim2 9298 setValO(self, "$qwe$"); 9299 setValO(delim1, "$"); 9300 setValO(delim2, "$"); 9301 r = extractSmallStringSmallStringO(self, delim1, delim2); 9302 ck_assert_ptr_eq(r, NULL); 9303 // non json object 9304 terminateO(delim1); 9305 delim1 = (smallStringt*) allocSmallInt(1); 9306 r = extractSmallStringSmallStringO(self, delim1, delim2); 9307 ck_assert_ptr_eq(r, NULL); 9308 terminateO(delim1); 9309 delim1 = allocSmallString(";"); 9310 terminateO(delim2); 9311 delim2 = (smallStringt*) allocSmallInt(1); 9312 r = extractSmallStringSmallStringO(self, delim1, delim2); 9313 ck_assert_ptr_eq(r, NULL); 9314 terminateO(delim2); 9315 delim2 = allocSmallString(","); 9316 // NULL string 9317 freeO(self); 9318 setValO(delim1, ";"); 9319 ck_assert_ptr_eq(extractSmallStringSmallStringO(self, delim1, delim2), NULL); 9320 // NULL delimiter 9321 setValO(self, "test"); 9322 ck_assert_ptr_eq(extractSmallStringSmallStringO(self, NULL, delim2), NULL); 9323 ck_assert_ptr_eq(extractSmallStringSmallStringO(self, delim1, NULL), NULL); 9324 terminateO(delim1); 9325 terminateO(delim2); 9326 terminateO(self); 9327 9328 } 9329 9330 9331 void extractSmallStringSSmallStringT(CuTest *tc UNUSED) { 9332 9333 smallArrayt* r; 9334 smallStringt *self = allocG(""); 9335 smallStringt* delim1 = allocSmallString("/"); 9336 9337 // string 9338 setValO(self, "one/two|"); 9339 r = extractSmallStringSO(self, delim1, "|"); 9340 ck_assert_ptr_ne(r, null); 9341 char *s = toStringO(r); 9342 ck_assert_str_eq(s, "[\"two\"]"); 9343 free(s); 9344 terminateO(r); 9345 // delimiter not found 9346 setValO(self, "one/two"); 9347 setValO(delim1, "||"); 9348 r = extractSmallStringSO(self, delim1, "/"); 9349 ck_assert_ptr_eq(r, NULL); 9350 // extractSmallStringSO with several delimiters after each other 9351 setValO(self, "one/ two /three "); 9352 setValO(delim1, "/"); 9353 r = extractSmallStringSO(self, delim1, " "); 9354 ck_assert_ptr_ne(r, null); 9355 s = toStringO(r); 9356 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9357 free(s); 9358 terminateO(r); 9359 // multiple character delimiter 9360 setValO(self, "AAe thre|e extract"); 9361 setValO(delim1, "e "); 9362 r = extractSmallStringSO(self, delim1, "|"); 9363 ck_assert_ptr_ne(r, null); 9364 s = toStringO(r); 9365 ck_assert_str_eq(s, "[\"thre\"]"); 9366 free(s); 9367 terminateO(r); 9368 // empty delimiter 9369 setValO(self, "AAd"); 9370 setValO(delim1, ""); 9371 r = extractSmallStringSO(self, delim1, "Ad"); 9372 ck_assert_ptr_eq(r, NULL); 9373 setValO(self, "AAd"); 9374 setValO(delim1, "A"); 9375 r = extractSmallStringSO(self, delim1, ""); 9376 ck_assert_ptr_eq(r, NULL); 9377 // empty string 9378 setValO(self, ""); 9379 setValO(delim1, "$"); 9380 r = extractSmallStringSO(self, delim1, "#"); 9381 ck_assert_ptr_eq(r, NULL); 9382 // delim1 = delim2 9383 setValO(self, "$qwe$"); 9384 setValO(delim1, "$"); 9385 r = extractSmallStringSO(self, delim1, "$"); 9386 ck_assert_ptr_eq(r, NULL); 9387 // non json object 9388 terminateO(delim1); 9389 delim1 = (smallStringt*) allocSmallInt(1); 9390 r = extractSmallStringSO(self, delim1, "$"); 9391 ck_assert_ptr_eq(r, NULL); 9392 terminateO(delim1); 9393 delim1 = allocSmallString(";"); 9394 // NULL string 9395 freeO(self); 9396 setValO(delim1, ";"); 9397 ck_assert_ptr_eq(extractSmallStringSO(self, delim1, ","), NULL); 9398 // NULL delimiter 9399 setValO(self, "test"); 9400 ck_assert_ptr_eq(extractSmallStringSO(self, NULL, ","), NULL); 9401 ck_assert_ptr_eq(extractSmallStringSO(self, delim1, NULL), NULL); 9402 terminateO(delim1); 9403 terminateO(self); 9404 9405 } 9406 9407 9408 void extractSmallStringCharSmallStringT(CuTest *tc UNUSED) { 9409 9410 smallArrayt* r; 9411 smallStringt *self = allocG(""); 9412 smallStringt* delim1 = allocSmallString("/"); 9413 9414 // string 9415 setValO(self, "one/two|"); 9416 r = extractSmallStringCharO(self, delim1, '|'); 9417 ck_assert_ptr_ne(r, null); 9418 char *s = toStringO(r); 9419 ck_assert_str_eq(s, "[\"two\"]"); 9420 free(s); 9421 terminateO(r); 9422 // delimiter not found 9423 setValO(self, "one/two"); 9424 setValO(delim1, "||"); 9425 r = extractSmallStringCharO(self, delim1, '/'); 9426 ck_assert_ptr_eq(r, NULL); 9427 // extractSmallStringCharO with several delimiters after each other 9428 setValO(self, "one/ two /three "); 9429 setValO(delim1, "/"); 9430 r = extractSmallStringCharO(self, delim1, ' '); 9431 ck_assert_ptr_ne(r, null); 9432 s = toStringO(r); 9433 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9434 free(s); 9435 terminateO(r); 9436 // multiple character delimiter 9437 setValO(self, "AAe thre|e extract"); 9438 setValO(delim1, "e "); 9439 r = extractSmallStringCharO(self, delim1, '|'); 9440 ck_assert_ptr_ne(r, null); 9441 s = toStringO(r); 9442 ck_assert_str_eq(s, "[\"thre\"]"); 9443 free(s); 9444 terminateO(r); 9445 // empty delimiter 9446 setValO(self, "AAd"); 9447 setValO(delim1, ""); 9448 r = extractSmallStringCharO(self, delim1, 'A'); 9449 ck_assert_ptr_eq(r, NULL); 9450 setValO(self, "AAd"); 9451 setValO(delim1, "A"); 9452 // empty string 9453 setValO(self, ""); 9454 setValO(delim1, "$"); 9455 r = extractSmallStringCharO(self, delim1, '#'); 9456 ck_assert_ptr_eq(r, NULL); 9457 // delim1 = delim2 9458 setValO(self, "$qwe$"); 9459 setValO(delim1, "$"); 9460 r = extractSmallStringCharO(self, delim1, '$'); 9461 ck_assert_ptr_eq(r, NULL); 9462 // non json object 9463 terminateO(delim1); 9464 delim1 = (smallStringt*) allocSmallInt(1); 9465 r = extractSmallStringCharO(self, delim1, '$'); 9466 ck_assert_ptr_eq(r, NULL); 9467 terminateO(delim1); 9468 delim1 = allocSmallString(";"); 9469 // NULL string 9470 freeO(self); 9471 setValO(delim1, ";"); 9472 ck_assert_ptr_eq(extractSmallStringCharO(self, delim1, ','), NULL); 9473 // NULL delimiter 9474 setValO(self, "test"); 9475 ck_assert_ptr_eq(extractSmallStringCharO(self, NULL, ','), NULL); 9476 terminateO(delim1); 9477 terminateO(self); 9478 9479 } 9480 9481 9482 void extractSSmallJsonSmallStringT(CuTest *tc UNUSED) { 9483 9484 smallArrayt* r; 9485 smallStringt *self = allocG(""); 9486 smallJsont* delim2 = allocSmallJson(); 9487 9488 // string 9489 setValO(self, "one/two|"); 9490 setTopSO(delim2, "|"); 9491 r = extractSSmallJsonO(self, "/", delim2); 9492 ck_assert_ptr_ne(r, null); 9493 char *s = toStringO(r); 9494 ck_assert_str_eq(s, "[\"two\"]"); 9495 free(s); 9496 terminateO(r); 9497 // delimiter not found 9498 setValO(self, "one/two"); 9499 freeO(delim2); 9500 setTopSO(delim2, "/"); 9501 r = extractSSmallJsonO(self, "||", delim2); 9502 ck_assert_ptr_eq(r, NULL); 9503 // extractSSmallJsonO with several delimiters after each other 9504 setValO(self, "one/ two /three "); 9505 freeO(delim2); 9506 setTopSO(delim2, " "); 9507 r = extractSSmallJsonO(self, "/", delim2); 9508 ck_assert_ptr_ne(r, null); 9509 s = toStringO(r); 9510 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9511 free(s); 9512 terminateO(r); 9513 // multiple character delimiter 9514 setValO(self, "AAe thre|e extract"); 9515 freeO(delim2); 9516 setTopSO(delim2, "|"); 9517 r = extractSSmallJsonO(self, "e ", delim2); 9518 ck_assert_ptr_ne(r, null); 9519 s = toStringO(r); 9520 ck_assert_str_eq(s, "[\"thre\"]"); 9521 free(s); 9522 terminateO(r); 9523 // empty delimiter 9524 setValO(self, "AAd"); 9525 freeO(delim2); 9526 setTopSO(delim2, "Ad"); 9527 r = extractSSmallJsonO(self, "", delim2); 9528 ck_assert_ptr_eq(r, NULL); 9529 setValO(self, "AAd"); 9530 freeO(delim2); 9531 setTopSO(delim2, ""); 9532 r = extractSSmallJsonO(self, "A", delim2); 9533 ck_assert_ptr_eq(r, NULL); 9534 // empty string 9535 setValO(self, ""); 9536 freeO(delim2); 9537 setTopSO(delim2, "#"); 9538 r = extractSSmallJsonO(self, "$", delim2); 9539 ck_assert_ptr_eq(r, NULL); 9540 // delim1 = delim2 9541 setValO(self, "$qwe$"); 9542 freeO(delim2); 9543 setTopSO(delim2, "$"); 9544 r = extractSSmallJsonO(self, "$", delim2); 9545 ck_assert_ptr_eq(r, NULL); 9546 // non json string 9547 freeO(delim2); 9548 r = extractSSmallJsonO(self, "$", delim2); 9549 ck_assert_ptr_eq(r, NULL); 9550 // non json object 9551 terminateO(delim2); 9552 delim2 = (smallJsont*) allocSmallInt(1); 9553 r = extractSSmallJsonO(self, ";", delim2); 9554 ck_assert_ptr_eq(r, NULL); 9555 terminateO(delim2); 9556 delim2 = allocSmallJson(); 9557 // NULL string 9558 freeO(self); 9559 freeO(delim2); 9560 setTopSO(delim2, ","); 9561 ck_assert_ptr_eq(extractSSmallJsonO(self, ";", delim2), NULL); 9562 // NULL delimiter 9563 setValO(self, "test"); 9564 ck_assert_ptr_eq(extractSSmallJsonO(self, NULL, delim2), NULL); 9565 ck_assert_ptr_eq(extractSSmallJsonO(self, ";", NULL), NULL); 9566 terminateO(delim2); 9567 terminateO(self); 9568 9569 } 9570 9571 9572 void extractSSmallStringSmallStringT(CuTest *tc UNUSED) { 9573 9574 smallArrayt* r; 9575 smallStringt *self = allocG(""); 9576 smallStringt* delim2 = allocSmallString("|"); 9577 9578 // string 9579 setValO(self, "one/two|"); 9580 setValO(delim2, "|"); 9581 r = extractSSmallStringO(self, "/", delim2); 9582 ck_assert_ptr_ne(r, null); 9583 char *s = toStringO(r); 9584 ck_assert_str_eq(s, "[\"two\"]"); 9585 free(s); 9586 terminateO(r); 9587 // delimiter not found 9588 setValO(self, "one/two"); 9589 setValO(delim2, "/"); 9590 r = extractSSmallStringO(self, "||", delim2); 9591 ck_assert_ptr_eq(r, NULL); 9592 // extractSSmallStringO with several delimiters after each other 9593 setValO(self, "one/ two /three "); 9594 setValO(delim2, " "); 9595 r = extractSSmallStringO(self, "/", delim2); 9596 ck_assert_ptr_ne(r, null); 9597 s = toStringO(r); 9598 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9599 free(s); 9600 terminateO(r); 9601 // multiple character delimiter 9602 setValO(self, "AAe thre|e extract"); 9603 setValO(delim2, "|"); 9604 r = extractSSmallStringO(self, "e ", delim2); 9605 ck_assert_ptr_ne(r, null); 9606 s = toStringO(r); 9607 ck_assert_str_eq(s, "[\"thre\"]"); 9608 free(s); 9609 terminateO(r); 9610 // empty delimiter 9611 setValO(self, "AAd"); 9612 setValO(delim2, "Ad"); 9613 r = extractSSmallStringO(self, "", delim2); 9614 ck_assert_ptr_eq(r, NULL); 9615 setValO(self, "AAd"); 9616 setValO(delim2, ""); 9617 r = extractSSmallStringO(self, "A", delim2); 9618 ck_assert_ptr_eq(r, NULL); 9619 // empty string 9620 setValO(self, ""); 9621 setValO(delim2, "#"); 9622 r = extractSSmallStringO(self, "$", delim2); 9623 ck_assert_ptr_eq(r, NULL); 9624 // delim1 = delim2 9625 setValO(self, "$qwe$"); 9626 setValO(delim2, "$"); 9627 r = extractSSmallStringO(self, "$", delim2); 9628 ck_assert_ptr_eq(r, NULL); 9629 // non json object 9630 terminateO(delim2); 9631 delim2 = (smallStringt*) allocSmallInt(1); 9632 r = extractSSmallStringO(self, ";", delim2); 9633 ck_assert_ptr_eq(r, NULL); 9634 terminateO(delim2); 9635 delim2 = allocSmallString(","); 9636 // NULL string 9637 freeO(self); 9638 ck_assert_ptr_eq(extractSSmallStringO(self, ";", delim2), NULL); 9639 // NULL delimiter 9640 setValO(self, "test"); 9641 ck_assert_ptr_eq(extractSSmallStringO(self, NULL, delim2), NULL); 9642 ck_assert_ptr_eq(extractSSmallStringO(self, ";", NULL), NULL); 9643 terminateO(delim2); 9644 terminateO(self); 9645 9646 } 9647 9648 9649 void extractCharSmallJsonSmallStringT(CuTest *tc UNUSED) { 9650 9651 smallArrayt* r; 9652 smallStringt *self = allocG(""); 9653 smallJsont* delim2 = allocSmallJson(); 9654 9655 // string 9656 setValO(self, "one/two|"); 9657 setTopSO(delim2, "|"); 9658 r = extractCharSmallJsonO(self, '/', delim2); 9659 ck_assert_ptr_ne(r, null); 9660 char *s = toStringO(r); 9661 ck_assert_str_eq(s, "[\"two\"]"); 9662 free(s); 9663 terminateO(r); 9664 // delimiter not found 9665 setValO(self, "one/two"); 9666 freeO(delim2); 9667 setTopSO(delim2, "/"); 9668 r = extractCharSmallJsonO(self, '|', delim2); 9669 ck_assert_ptr_eq(r, NULL); 9670 // extractCharSmallJsonO with several delimiters after each other 9671 setValO(self, "one/ two /three "); 9672 freeO(delim2); 9673 setTopSO(delim2, " "); 9674 r = extractCharSmallJsonO(self, '/', delim2); 9675 ck_assert_ptr_ne(r, null); 9676 s = toStringO(r); 9677 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9678 free(s); 9679 terminateO(r); 9680 // multiple character delimiter 9681 setValO(self, "AAe thre|e extract"); 9682 freeO(delim2); 9683 setTopSO(delim2, "|"); 9684 r = extractCharSmallJsonO(self, ' ', delim2); 9685 ck_assert_ptr_ne(r, null); 9686 s = toStringO(r); 9687 ck_assert_str_eq(s, "[\"thre\"]"); 9688 free(s); 9689 terminateO(r); 9690 // empty delimiter 9691 setValO(self, "AAd"); 9692 freeO(delim2); 9693 setTopSO(delim2, ""); 9694 r = extractCharSmallJsonO(self, 'A', delim2); 9695 ck_assert_ptr_eq(r, NULL); 9696 // empty string 9697 setValO(self, ""); 9698 freeO(delim2); 9699 setTopSO(delim2, "#"); 9700 r = extractCharSmallJsonO(self, '$', delim2); 9701 ck_assert_ptr_eq(r, NULL); 9702 // delim1 = delim2 9703 setValO(self, "$qwe$"); 9704 freeO(delim2); 9705 setTopSO(delim2, "$"); 9706 r = extractCharSmallJsonO(self, '$', delim2); 9707 ck_assert_ptr_eq(r, NULL); 9708 // non json string 9709 freeO(delim2); 9710 r = extractCharSmallJsonO(self, '$', delim2); 9711 ck_assert_ptr_eq(r, NULL); 9712 // non json object 9713 terminateO(delim2); 9714 delim2 = (smallJsont*) allocSmallInt(1); 9715 r = extractCharSmallJsonO(self, ';', delim2); 9716 ck_assert_ptr_eq(r, NULL); 9717 terminateO(delim2); 9718 delim2 = allocSmallJson(); 9719 // NULL string 9720 freeO(self); 9721 freeO(delim2); 9722 setTopSO(delim2, ","); 9723 ck_assert_ptr_eq(extractCharSmallJsonO(self, ';', delim2), NULL); 9724 // NULL delimiter 9725 setValO(self, "test"); 9726 ck_assert_ptr_eq(extractCharSmallJsonO(self, ';', NULL), NULL); 9727 terminateO(delim2); 9728 terminateO(self); 9729 9730 } 9731 9732 9733 void extractCharSmallStringSmallStringT(CuTest *tc UNUSED) { 9734 9735 smallArrayt* r; 9736 smallStringt *self = allocG(""); 9737 smallStringt* delim2 = allocSmallString("|"); 9738 9739 // string 9740 setValO(self, "one/two|"); 9741 setValO(delim2, "|"); 9742 r = extractCharSmallStringO(self, '/', delim2); 9743 ck_assert_ptr_ne(r, null); 9744 char *s = toStringO(r); 9745 ck_assert_str_eq(s, "[\"two\"]"); 9746 free(s); 9747 terminateO(r); 9748 // delimiter not found 9749 setValO(self, "one/two"); 9750 setValO(delim2, "/"); 9751 r = extractCharSmallStringO(self, '|', delim2); 9752 ck_assert_ptr_eq(r, NULL); 9753 // extractCharSmallStringO with several delimiters after each other 9754 setValO(self, "one/ two /three "); 9755 setValO(delim2, " "); 9756 r = extractCharSmallStringO(self, '/', delim2); 9757 ck_assert_ptr_ne(r, null); 9758 s = toStringO(r); 9759 ck_assert_str_eq(s, "[\"\",\"three\"]"); 9760 free(s); 9761 terminateO(r); 9762 // multiple character delimiter 9763 setValO(self, "AAe thre|e extract"); 9764 setValO(delim2, "|e"); 9765 r = extractCharSmallStringO(self, ' ', delim2); 9766 ck_assert_ptr_ne(r, null); 9767 s = toStringO(r); 9768 ck_assert_str_eq(s, "[\"thre\"]"); 9769 free(s); 9770 terminateO(r); 9771 // empty delimiter 9772 setValO(self, "AAd"); 9773 setValO(delim2, ""); 9774 r = extractCharSmallStringO(self, 'A', delim2); 9775 ck_assert_ptr_eq(r, NULL); 9776 // empty string 9777 setValO(self, ""); 9778 setValO(delim2, "#"); 9779 r = extractCharSmallStringO(self, '$', delim2); 9780 ck_assert_ptr_eq(r, NULL); 9781 // delim1 = delim2 9782 setValO(self, "$qwe$"); 9783 setValO(delim2, "$"); 9784 r = extractCharSmallStringO(self, '$', delim2); 9785 ck_assert_ptr_eq(r, NULL); 9786 // non json object 9787 terminateO(delim2); 9788 delim2 = (smallStringt*) allocSmallInt(1); 9789 r = extractCharSmallStringO(self, ';', delim2); 9790 ck_assert_ptr_eq(r, NULL); 9791 terminateO(delim2); 9792 delim2 = allocSmallString(","); 9793 // NULL string 9794 freeO(self); 9795 ck_assert_ptr_eq(extractCharSmallStringO(self, ';', delim2), NULL); 9796 // NULL delimiter 9797 setValO(self, "test"); 9798 ck_assert_ptr_eq(extractCharSmallStringO(self, ';', NULL), NULL); 9799 terminateO(delim2); 9800 terminateO(self); 9801 9802 } 9803 9804 9805 void icSplitSmallStringT(CuTest *tc UNUSED) { 9806 9807 smallArrayt* r; 9808 smallStringt *self = allocG(""); 9809 9810 // string 9811 setValO(self, "one/two"); 9812 r = icSplitO(self, "/"); 9813 ck_assert_ptr_ne(r, null); 9814 char *s = toStringO(r); 9815 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 9816 free(s); 9817 terminateO(r); 9818 // delimiter on the edge 9819 setValO(self, "/one"); 9820 r = icSplitO(self, "/"); 9821 ck_assert_ptr_ne(r, null); 9822 s = toStringO(r); 9823 ck_assert_str_eq(s, "[\"\",\"one\"]"); 9824 free(s); 9825 terminateO(r); 9826 setValO(self, "one/"); 9827 r = icSplitO(self, "/"); 9828 ck_assert_ptr_ne(r, null); 9829 s = toStringO(r); 9830 ck_assert_str_eq(s, "[\"one\",\"\"]"); 9831 free(s); 9832 terminateO(r); 9833 // delimiter not found 9834 setValO(self, "one/two"); 9835 r = icSplitO(self, "||"); 9836 ck_assert_ptr_ne(r, null); 9837 s = toStringO(r); 9838 ck_assert_str_eq(s, "[\"one/two\"]"); 9839 free(s); 9840 terminateO(r); 9841 // icSplit with several delimiters after each other 9842 setValO(self, "one/two three "); 9843 r = icSplitO(self, " "); 9844 ck_assert_ptr_ne(r, null); 9845 s = toStringO(r); 9846 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 9847 free(s); 9848 terminateO(r); 9849 // multiple character delimiter 9850 setValO(self, "AAe three extract"); 9851 r = icSplitO(self, "E "); 9852 ck_assert_ptr_ne(r, null); 9853 s = toStringO(r); 9854 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 9855 free(s); 9856 terminateO(r); 9857 // empty delimiter 9858 setValO(self, "AAd"); 9859 r = icSplitO(self, ""); 9860 ck_assert_ptr_ne(r, null); 9861 s = toStringO(r); 9862 ck_assert_str_eq(s, "[\"AAd\"]"); 9863 free(s); 9864 terminateO(r); 9865 // empty string 9866 emptyO(self); 9867 r = icSplitO(self, "$"); 9868 ck_assert_ptr_ne(r, null); 9869 s = toStringO(r); 9870 ck_assert_str_eq(s, "[\"\"]"); 9871 free(s); 9872 terminateO(r); 9873 // NULL list 9874 freeO(self); 9875 ck_assert_ptr_eq(icSplitO(self, ";"), NULL); 9876 // NULL delimiter 9877 setValO(self, "test"); 9878 ck_assert_ptr_eq(icSplitO(self, NULL), NULL); 9879 terminateO(self); 9880 9881 } 9882 9883 9884 void icSplitCharSmallStringT(CuTest *tc UNUSED) { 9885 9886 smallArrayt* r; 9887 smallStringt *self = allocG(""); 9888 9889 // string 9890 setValO(self, "one/two"); 9891 r = icSplitCharO(self, 'T'); 9892 ck_assert_ptr_ne(r, null); 9893 char *s = toStringO(r); 9894 ck_assert_str_eq(s, "[\"one/\",\"wo\"]"); 9895 free(s); 9896 terminateO(r); 9897 // delimiter on the edge 9898 setValO(self, "/one"); 9899 r = icSplitCharO(self, '/'); 9900 ck_assert_ptr_ne(r, null); 9901 s = toStringO(r); 9902 ck_assert_str_eq(s, "[\"\",\"one\"]"); 9903 free(s); 9904 terminateO(r); 9905 setValO(self, "one/"); 9906 r = icSplitCharO(self, '/'); 9907 ck_assert_ptr_ne(r, null); 9908 s = toStringO(r); 9909 ck_assert_str_eq(s, "[\"one\",\"\"]"); 9910 free(s); 9911 terminateO(r); 9912 // delimiter not found 9913 setValO(self, "one/two"); 9914 r = icSplitCharO(self, '|'); 9915 ck_assert_ptr_ne(r, null); 9916 s = toStringO(r); 9917 ck_assert_str_eq(s, "[\"one/two\"]"); 9918 free(s); 9919 terminateO(r); 9920 // icSplit with several delimiters after each other 9921 setValO(self, "one/two three "); 9922 r = icSplitCharO(self, ' '); 9923 ck_assert_ptr_ne(r, null); 9924 s = toStringO(r); 9925 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 9926 free(s); 9927 terminateO(r); 9928 // empty string 9929 emptyO(self); 9930 r = icSplitCharO(self, '$'); 9931 ck_assert_ptr_ne(r, null); 9932 s = toStringO(r); 9933 ck_assert_str_eq(s, "[\"\"]"); 9934 free(s); 9935 terminateO(r); 9936 // NULL list 9937 freeO(self); 9938 ck_assert_ptr_eq(icSplitCharO(self, ';'), NULL); 9939 terminateO(self); 9940 9941 } 9942 9943 9944 void icSplitSmallJsonSmallStringT(CuTest *tc UNUSED) { 9945 9946 smallArrayt* r; 9947 smallStringt *self = allocG(""); 9948 smallJsont *delim = allocSmallJson(); 9949 9950 // string 9951 setValO(self, "one/two"); 9952 setTopSO(delim, "/"); 9953 r = self->f->icSplitSmallJson(self, delim); 9954 ck_assert_ptr_ne(r, null); 9955 char *s = toStringO(r); 9956 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 9957 free(s); 9958 terminateO(r); 9959 // delimiter on the edge 9960 setValO(self, "/one"); 9961 r = self->f->icSplitSmallJson(self, delim); 9962 ck_assert_ptr_ne(r, null); 9963 s = toStringO(r); 9964 ck_assert_str_eq(s, "[\"\",\"one\"]"); 9965 free(s); 9966 terminateO(r); 9967 setValO(self, "one/"); 9968 r = self->f->icSplitSmallJson(self, delim); 9969 ck_assert_ptr_ne(r, null); 9970 s = toStringO(r); 9971 ck_assert_str_eq(s, "[\"one\",\"\"]"); 9972 free(s); 9973 terminateO(r); 9974 // delimiter not found 9975 setValO(self, "one/two"); 9976 freeO(delim); 9977 setTopSO(delim, "||"); 9978 r = self->f->icSplitSmallJson(self, delim); 9979 ck_assert_ptr_ne(r, null); 9980 s = toStringO(r); 9981 ck_assert_str_eq(s, "[\"one/two\"]"); 9982 free(s); 9983 terminateO(r); 9984 // icSplit with several delimiters after each other 9985 setValO(self, "one/two three "); 9986 freeO(delim); 9987 setTopSO(delim, " "); 9988 r = self->f->icSplitSmallJson(self, delim); 9989 ck_assert_ptr_ne(r, null); 9990 s = toStringO(r); 9991 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 9992 free(s); 9993 terminateO(r); 9994 // multiple character delimiter 9995 setValO(self, "AAe three extract"); 9996 freeO(delim); 9997 setTopSO(delim, "E "); 9998 r = self->f->icSplitSmallJson(self, delim); 9999 ck_assert_ptr_ne(r, null); 10000 s = toStringO(r); 10001 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 10002 free(s); 10003 terminateO(r); 10004 // empty delimiter 10005 setValO(self, "AAd"); 10006 freeO(delim); 10007 setTopSO(delim, ""); 10008 r = self->f->icSplitSmallJson(self, delim); 10009 ck_assert_ptr_ne(r, null); 10010 s = toStringO(r); 10011 ck_assert_str_eq(s, "[\"AAd\"]"); 10012 free(s); 10013 terminateO(r); 10014 // empty string 10015 emptyO(self); 10016 freeO(delim); 10017 setTopSO(delim, "$"); 10018 r = self->f->icSplitSmallJson(self, delim); 10019 ck_assert_ptr_ne(r, null); 10020 s = toStringO(r); 10021 ck_assert_str_eq(s, "[\"\"]"); 10022 free(s); 10023 terminateO(r); 10024 // non json string delimiter 10025 freeO(delim); 10026 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, delim), NULL); 10027 // non json object delimiter 10028 terminateO(delim); 10029 delim = (smallJsont*) allocSmallInt(1); 10030 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, delim), NULL); 10031 terminateO(delim); 10032 delim = allocSmallJson(); 10033 // NULL list 10034 freeO(self); 10035 freeO(delim); 10036 setTopSO(delim, ";"); 10037 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, delim), NULL); 10038 // NULL delimiter 10039 setValO(self, "test"); 10040 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, NULL), NULL); 10041 terminateO(delim); 10042 terminateO(self); 10043 10044 } 10045 10046 10047 void icSplitSmallStringSmallStringT(CuTest *tc UNUSED) { 10048 10049 smallArrayt* r; 10050 smallStringt *self = allocG(""); 10051 smallStringt *delim = allocSmallString("/"); 10052 10053 // string 10054 setValO(self, "one/two"); 10055 r = self->f->icSplitSmallString(self, delim); 10056 ck_assert_ptr_ne(r, null); 10057 char *s = toStringO(r); 10058 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 10059 free(s); 10060 terminateO(r); 10061 // delimiter on the edge 10062 setValO(self, "/one"); 10063 r = self->f->icSplitSmallString(self, delim); 10064 ck_assert_ptr_ne(r, null); 10065 s = toStringO(r); 10066 ck_assert_str_eq(s, "[\"\",\"one\"]"); 10067 free(s); 10068 terminateO(r); 10069 setValO(self, "one/"); 10070 r = self->f->icSplitSmallString(self, delim); 10071 ck_assert_ptr_ne(r, null); 10072 s = toStringO(r); 10073 ck_assert_str_eq(s, "[\"one\",\"\"]"); 10074 free(s); 10075 terminateO(r); 10076 // delimiter not found 10077 setValO(self, "one/two"); 10078 setValO(delim, "||"); 10079 r = self->f->icSplitSmallString(self, delim); 10080 ck_assert_ptr_ne(r, null); 10081 s = toStringO(r); 10082 ck_assert_str_eq(s, "[\"one/two\"]"); 10083 free(s); 10084 terminateO(r); 10085 // icSplit with several delimiters after each other 10086 setValO(self, "one/two three "); 10087 setValO(delim, " "); 10088 r = self->f->icSplitSmallString(self, delim); 10089 ck_assert_ptr_ne(r, null); 10090 s = toStringO(r); 10091 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 10092 free(s); 10093 terminateO(r); 10094 // multiple character delimiter 10095 setValO(self, "AAe three extract"); 10096 setValO(delim, "E "); 10097 r = self->f->icSplitSmallString(self, delim); 10098 ck_assert_ptr_ne(r, null); 10099 s = toStringO(r); 10100 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 10101 free(s); 10102 terminateO(r); 10103 // empty delimiter 10104 setValO(self, "AAd"); 10105 setValO(delim, ""); 10106 r = self->f->icSplitSmallString(self, delim); 10107 ck_assert_ptr_ne(r, null); 10108 s = toStringO(r); 10109 ck_assert_str_eq(s, "[\"AAd\"]"); 10110 free(s); 10111 terminateO(r); 10112 // empty string 10113 emptyO(self); 10114 setValO(delim, "$"); 10115 r = self->f->icSplitSmallString(self, delim); 10116 ck_assert_ptr_ne(r, null); 10117 s = toStringO(r); 10118 ck_assert_str_eq(s, "[\"\"]"); 10119 free(s); 10120 terminateO(r); 10121 // null string delimiter 10122 freeO(delim); 10123 ck_assert_ptr_eq(self->f->icSplitSmallString(self, delim), NULL); 10124 // non json object delimiter 10125 terminateO(delim); 10126 delim = (smallStringt*) allocSmallInt(1); 10127 ck_assert_ptr_eq(self->f->icSplitSmallString(self, delim), NULL); 10128 terminateO(delim); 10129 // NULL list 10130 freeO(self); 10131 delim = allocSmallString(";"); 10132 ck_assert_ptr_eq(self->f->icSplitSmallString(self, delim), NULL); 10133 // NULL delimiter 10134 setValO(self, "test"); 10135 ck_assert_ptr_eq(self->f->icSplitSmallString(self, NULL), NULL); 10136 terminateO(delim); 10137 terminateO(self); 10138 10139 } 10140 10141 10142 void icSplitSSmallStringT(CuTest *tc UNUSED) { 10143 10144 char** r; 10145 smallStringt *self = allocG(""); 10146 10147 // string 10148 setValO(self, "one/two"); 10149 r = icSplitSO(self, "/"); 10150 ck_assert_uint_eq(listLengthS(r),2); 10151 ck_assert_str_eq(r[0], "one"); 10152 ck_assert_str_eq(r[1], "two"); 10153 listFreeS(r); 10154 // delimiter on the edge 10155 setValO(self, "/one"); 10156 r = icSplitSO(self, "/"); 10157 ck_assert_uint_eq(listLengthS(r),2); 10158 ck_assert_str_eq(r[0], ""); 10159 ck_assert_str_eq(r[1], "one"); 10160 listFreeS(r); 10161 setValO(self, "one/"); 10162 r = icSplitSO(self, "/"); 10163 ck_assert_uint_eq(listLengthS(r),2); 10164 ck_assert_str_eq(r[0], "one"); 10165 ck_assert_str_eq(r[1], ""); 10166 listFreeS(r); 10167 // delimiter not found 10168 setValO(self, "one/two"); 10169 r = icSplitSO(self, "||"); 10170 ck_assert_uint_eq(listLengthS(r),1); 10171 ck_assert_str_eq(r[0], "one/two"); 10172 listFreeS(r); 10173 // icSplit with several delimiters after each other 10174 setValO(self, "one/two three "); 10175 r = icSplitSO(self, " "); 10176 ck_assert_uint_eq(listLengthS(r),4); 10177 ck_assert_str_eq(r[0], "one/two"); 10178 ck_assert_str_eq(r[1], ""); 10179 ck_assert_str_eq(r[2], "three"); 10180 ck_assert_str_eq(r[3], ""); 10181 listFreeS(r); 10182 // multiple character delimiter 10183 setValO(self, "AAe three extract"); 10184 r = icSplitSO(self, "E "); 10185 ck_assert_uint_eq(listLengthS(r),3); 10186 ck_assert_str_eq(r[0], "AA"); 10187 ck_assert_str_eq(r[1], "thre"); 10188 ck_assert_str_eq(r[2], "extract"); 10189 listFreeS(r); 10190 // empty delimiter 10191 setValO(self, "AAd"); 10192 r = icSplitSO(self, ""); 10193 ck_assert_uint_eq(listLengthS(r),1); 10194 ck_assert_str_eq(r[0], "AAd"); 10195 listFreeS(r); 10196 // empty string 10197 emptyO(self); 10198 r = icSplitSO(self, "$"); 10199 ck_assert_uint_eq(listLengthS(r),1); 10200 ck_assert_str_eq(r[0], ""); 10201 listFreeS(r); 10202 // NULL list 10203 freeO(self); 10204 ck_assert_ptr_eq(icSplitSO(self, ";"), NULL); 10205 // NULL delimiter 10206 setValO(self, "test"); 10207 ck_assert_ptr_eq(icSplitSO(self, NULL), NULL); 10208 terminateO(self); 10209 10210 } 10211 10212 10213 void icSplitCharSSmallStringT(CuTest *tc UNUSED) { 10214 10215 char** r; 10216 smallStringt *self = allocG(""); 10217 10218 // string 10219 setValO(self, "one/two"); 10220 r = icSplitCharSO(self, 'T'); 10221 ck_assert_uint_eq(listLengthS(r),2); 10222 ck_assert_str_eq(r[0], "one/"); 10223 ck_assert_str_eq(r[1], "wo"); 10224 listFreeS(r); 10225 // delimiter on the edge 10226 setValO(self, "/one"); 10227 r = icSplitCharSO(self, '/'); 10228 ck_assert_uint_eq(listLengthS(r),2); 10229 ck_assert_str_eq(r[0], ""); 10230 ck_assert_str_eq(r[1], "one"); 10231 listFreeS(r); 10232 setValO(self, "one/"); 10233 r = icSplitCharSO(self, '/'); 10234 ck_assert_uint_eq(listLengthS(r),2); 10235 ck_assert_str_eq(r[0], "one"); 10236 ck_assert_str_eq(r[1], ""); 10237 listFreeS(r); 10238 // delimiter not found 10239 setValO(self, "one/two"); 10240 r = icSplitCharSO(self, '|'); 10241 ck_assert_uint_eq(listLengthS(r),1); 10242 ck_assert_str_eq(r[0], "one/two"); 10243 listFreeS(r); 10244 // icSplit with several delimiters after each other 10245 setValO(self, "one/two three "); 10246 r = icSplitCharSO(self, ' '); 10247 ck_assert_uint_eq(listLengthS(r),4); 10248 ck_assert_str_eq(r[0], "one/two"); 10249 ck_assert_str_eq(r[1], ""); 10250 ck_assert_str_eq(r[2], "three"); 10251 ck_assert_str_eq(r[3], ""); 10252 listFreeS(r); 10253 // empty string 10254 emptyO(self); 10255 r = icSplitCharSO(self, '$'); 10256 ck_assert_uint_eq(listLengthS(r),1); 10257 ck_assert_str_eq(r[0], ""); 10258 listFreeS(r); 10259 // NULL list 10260 freeO(self); 10261 ck_assert_ptr_eq(icSplitCharSO(self, ';'), NULL); 10262 terminateO(self); 10263 10264 } 10265 10266 10267 void icSplitSmallJsonSSmallStringT(CuTest *tc UNUSED) { 10268 10269 char** r; 10270 smallStringt *self = allocG(""); 10271 smallJsont *delim = allocSmallJson(); 10272 10273 // string 10274 setValO(self, "one/two"); 10275 setTopSO(delim, "/"); 10276 r = icSplitSmallJsonSO(self, delim); 10277 ck_assert_uint_eq(listLengthS(r),2); 10278 ck_assert_str_eq(r[0], "one"); 10279 ck_assert_str_eq(r[1], "two"); 10280 listFreeS(r); 10281 // delimiter on the edge 10282 setValO(self, "/one"); 10283 r = icSplitSmallJsonSO(self, delim); 10284 ck_assert_uint_eq(listLengthS(r),2); 10285 ck_assert_str_eq(r[0], ""); 10286 ck_assert_str_eq(r[1], "one"); 10287 listFreeS(r); 10288 setValO(self, "one/"); 10289 r = icSplitSmallJsonSO(self, delim); 10290 ck_assert_uint_eq(listLengthS(r),2); 10291 ck_assert_str_eq(r[0], "one"); 10292 ck_assert_str_eq(r[1], ""); 10293 listFreeS(r); 10294 // delimiter not found 10295 setValO(self, "one/two"); 10296 freeO(delim); 10297 setTopSO(delim, "||"); 10298 r = icSplitSmallJsonSO(self, delim); 10299 ck_assert_uint_eq(listLengthS(r),1); 10300 ck_assert_str_eq(r[0], "one/two"); 10301 listFreeS(r); 10302 // icSplit with several delimiters after each other 10303 setValO(self, "one/two three "); 10304 freeO(delim); 10305 setTopSO(delim, " "); 10306 r = icSplitSmallJsonSO(self, delim); 10307 ck_assert_uint_eq(listLengthS(r),4); 10308 ck_assert_str_eq(r[0], "one/two"); 10309 ck_assert_str_eq(r[1], ""); 10310 ck_assert_str_eq(r[2], "three"); 10311 ck_assert_str_eq(r[3], ""); 10312 listFreeS(r); 10313 // multiple character delimiter 10314 setValO(self, "AAe three extract"); 10315 freeO(delim); 10316 setTopSO(delim, "E "); 10317 r = icSplitSmallJsonSO(self, delim); 10318 ck_assert_uint_eq(listLengthS(r),3); 10319 ck_assert_str_eq(r[0], "AA"); 10320 ck_assert_str_eq(r[1], "thre"); 10321 ck_assert_str_eq(r[2], "extract"); 10322 listFreeS(r); 10323 // empty delimiter 10324 setValO(self, "AAd"); 10325 freeO(delim); 10326 setTopSO(delim, ""); 10327 r = icSplitSmallJsonSO(self, delim); 10328 ck_assert_uint_eq(listLengthS(r),1); 10329 ck_assert_str_eq(r[0], "AAd"); 10330 listFreeS(r); 10331 // empty string 10332 emptyO(self); 10333 freeO(delim); 10334 setTopSO(delim, "$"); 10335 r = icSplitSmallJsonSO(self, delim); 10336 ck_assert_uint_eq(listLengthS(r),1); 10337 ck_assert_str_eq(r[0], ""); 10338 listFreeS(r); 10339 // non json string delimiter 10340 freeO(delim); 10341 ck_assert_ptr_eq(icSplitSmallJsonSO(self, delim), NULL); 10342 // non json object delimiter 10343 terminateO(delim); 10344 delim = (smallJsont*) allocSmallInt(1); 10345 ck_assert_ptr_eq(icSplitSmallJsonSO(self, delim), NULL); 10346 terminateO(delim); 10347 delim = allocSmallJson(); 10348 // NULL list 10349 freeO(self); 10350 freeO(delim); 10351 setTopSO(delim, ";"); 10352 ck_assert_ptr_eq(icSplitSmallJsonSO(self, delim), NULL); 10353 // NULL delimiter 10354 setValO(self, "test"); 10355 ck_assert_ptr_eq(icSplitSmallJsonSO(self, NULL), NULL); 10356 terminateO(delim); 10357 terminateO(self); 10358 10359 } 10360 10361 10362 void icSplitSmallStringSSmallStringT(CuTest *tc UNUSED) { 10363 10364 char** r; 10365 smallStringt *self = allocG(""); 10366 smallStringt *delim = allocSmallString("/"); 10367 10368 // string 10369 setValO(self, "one/two"); 10370 r = icSplitSmallStringSO(self, delim); 10371 ck_assert_uint_eq(listLengthS(r),2); 10372 ck_assert_str_eq(r[0], "one"); 10373 ck_assert_str_eq(r[1], "two"); 10374 listFreeS(r); 10375 // delimiter on the edge 10376 setValO(self, "/one"); 10377 r = icSplitSmallStringSO(self, delim); 10378 ck_assert_uint_eq(listLengthS(r),2); 10379 ck_assert_str_eq(r[0], ""); 10380 ck_assert_str_eq(r[1], "one"); 10381 listFreeS(r); 10382 setValO(self, "one/"); 10383 r = icSplitSmallStringSO(self, delim); 10384 ck_assert_uint_eq(listLengthS(r),2); 10385 ck_assert_str_eq(r[0], "one"); 10386 ck_assert_str_eq(r[1], ""); 10387 listFreeS(r); 10388 // delimiter not found 10389 setValO(self, "one/two"); 10390 setValO(delim, "||"); 10391 r = icSplitSmallStringSO(self, delim); 10392 ck_assert_uint_eq(listLengthS(r),1); 10393 ck_assert_str_eq(r[0], "one/two"); 10394 listFreeS(r); 10395 // icSplit with several delimiters after each other 10396 setValO(self, "one/two three "); 10397 setValO(delim, " "); 10398 r = icSplitSmallStringSO(self, delim); 10399 ck_assert_uint_eq(listLengthS(r),4); 10400 ck_assert_str_eq(r[0], "one/two"); 10401 ck_assert_str_eq(r[1], ""); 10402 ck_assert_str_eq(r[2], "three"); 10403 ck_assert_str_eq(r[3], ""); 10404 listFreeS(r); 10405 // multiple character delimiter 10406 setValO(self, "AAe three extract"); 10407 setValO(delim, "E "); 10408 r = icSplitSmallStringSO(self, delim); 10409 ck_assert_uint_eq(listLengthS(r),3); 10410 ck_assert_str_eq(r[0], "AA"); 10411 ck_assert_str_eq(r[1], "thre"); 10412 ck_assert_str_eq(r[2], "extract"); 10413 listFreeS(r); 10414 // empty delimiter 10415 setValO(self, "AAd"); 10416 setValO(delim, ""); 10417 r = icSplitSmallStringSO(self, delim); 10418 ck_assert_uint_eq(listLengthS(r),1); 10419 ck_assert_str_eq(r[0], "AAd"); 10420 listFreeS(r); 10421 // empty string 10422 emptyO(self); 10423 setValO(delim, "$"); 10424 r = icSplitSmallStringSO(self, delim); 10425 ck_assert_uint_eq(listLengthS(r),1); 10426 ck_assert_str_eq(r[0], ""); 10427 listFreeS(r); 10428 // non smallString object delimiter 10429 terminateO(delim); 10430 delim = (smallStringt*) allocSmallInt(1); 10431 ck_assert_ptr_eq(icSplitSmallStringSO(self, delim), NULL); 10432 terminateO(delim); 10433 // NULL list 10434 freeO(self); 10435 delim = allocSmallString(";"); 10436 ck_assert_ptr_eq(icSplitSmallStringSO(self, delim), NULL); 10437 // NULL delimiter 10438 setValO(self, "test"); 10439 ck_assert_ptr_eq(icSplitSmallStringSO(self, NULL), NULL); 10440 terminateO(delim); 10441 terminateO(self); 10442 10443 } 10444 10445 10446 void icExtractSmallStringT(CuTest *tc UNUSED) { 10447 10448 smallArrayt* r; 10449 smallStringt *self = allocG(""); 10450 10451 // string 10452 setValO(self, "one/twos"); 10453 r = icExtractO(self, "E", "S"); 10454 ck_assert_ptr_ne(r, null); 10455 char *s = toStringO(r); 10456 ck_assert_str_eq(s, "[\"/two\"]"); 10457 free(s); 10458 terminateO(r); 10459 // delimiter not found 10460 setValO(self, "one/two"); 10461 r = icExtractO(self, "||", "/"); 10462 ck_assert_ptr_eq(r, NULL); 10463 // icExtractO with several delimiters after each other 10464 setValO(self, "one/ two /three "); 10465 r = icExtractO(self, "/", " "); 10466 ck_assert_ptr_ne(r, null); 10467 s = toStringO(r); 10468 ck_assert_str_eq(s, "[\"\",\"three\"]"); 10469 free(s); 10470 terminateO(r); 10471 // multiple character delimiter 10472 setValO(self, "AAe thre|e icExtract"); 10473 r = icExtractO(self, "e ", "|"); 10474 ck_assert_ptr_ne(r, null); 10475 s = toStringO(r); 10476 ck_assert_str_eq(s, "[\"thre\"]"); 10477 free(s); 10478 terminateO(r); 10479 // empty delimiter 10480 setValO(self, "AAd"); 10481 r = icExtractO(self, "", "Ad"); 10482 ck_assert_ptr_eq(r, NULL); 10483 setValO(self, "AAd"); 10484 r = icExtractO(self, "A", ""); 10485 ck_assert_ptr_eq(r, NULL); 10486 // empty string 10487 setValO(self, ""); 10488 r = icExtractO(self, "$", "#"); 10489 ck_assert_ptr_eq(r, NULL); 10490 // delim1 = delim2 10491 setValO(self, ""); 10492 r = icExtractO(self, "$", "$"); 10493 ck_assert_ptr_eq(r, NULL); 10494 // NULL string 10495 freeO(self); 10496 ck_assert_ptr_eq(icExtractO(self, ";", ","), NULL); 10497 // NULL delimiter 10498 setValO(self, "test"); 10499 ck_assert_ptr_eq(icExtractO(self, NULL, ","), NULL); 10500 ck_assert_ptr_eq(icExtractO(self, ",", NULL), NULL); 10501 terminateO(self); 10502 10503 } 10504 10505 10506 void icExtractCharSSmallStringT(CuTest *tc UNUSED) { 10507 10508 smallArrayt* r; 10509 smallStringt *self = allocG(""); 10510 10511 // string 10512 setValO(self, "one/twos"); 10513 r = icExtractCharSO(self, 'E', "S"); 10514 ck_assert_ptr_ne(r, null); 10515 char *s = toStringO(r); 10516 ck_assert_str_eq(s, "[\"/two\"]"); 10517 free(s); 10518 terminateO(r); 10519 // delimiter not found 10520 setValO(self, "one/two"); 10521 r = icExtractCharSO(self, '|', "/"); 10522 ck_assert_ptr_eq(r, NULL); 10523 // icExtractCharSO with several delimiters after each other 10524 setValO(self, "one/ two /three "); 10525 r = icExtractCharSO(self, '/', " "); 10526 ck_assert_ptr_ne(r, null); 10527 s = toStringO(r); 10528 ck_assert_str_eq(s, "[\"\",\"three\"]"); 10529 free(s); 10530 terminateO(r); 10531 // multiple character delimiter 10532 setValO(self, "AAe thre|e icExtract"); 10533 r = icExtractCharSO(self, ' ', "|e"); 10534 ck_assert_ptr_ne(r, null); 10535 s = toStringO(r); 10536 ck_assert_str_eq(s, "[\"thre\"]"); 10537 free(s); 10538 terminateO(r); 10539 // empty delimiter 10540 setValO(self, "AAd"); 10541 r = icExtractCharSO(self, 'A', ""); 10542 ck_assert_ptr_eq(r, NULL); 10543 // empty string 10544 setValO(self, ""); 10545 r = icExtractCharSO(self, '$', "#"); 10546 ck_assert_ptr_eq(r, NULL); 10547 // delim1 = delim2 10548 setValO(self, ""); 10549 r = icExtractCharSO(self, '$', "$"); 10550 ck_assert_ptr_eq(r, NULL); 10551 // NULL string 10552 freeO(self); 10553 ck_assert_ptr_eq(icExtractCharSO(self, ';', ","), NULL); 10554 // NULL delimiter 10555 setValO(self, "test"); 10556 ck_assert_ptr_eq(icExtractCharSO(self, ',', NULL), NULL); 10557 terminateO(self); 10558 10559 } 10560 10561 10562 void icExtractSCharSmallStringT(CuTest *tc UNUSED) { 10563 10564 smallArrayt* r; 10565 smallStringt *self = allocG(""); 10566 10567 // string 10568 setValO(self, "one/twos"); 10569 r = icExtractSCharO(self, "E", 'S'); 10570 ck_assert_ptr_ne(r, null); 10571 char *s = toStringO(r); 10572 ck_assert_str_eq(s, "[\"/two\"]"); 10573 free(s); 10574 terminateO(r); 10575 // delimiter not found 10576 setValO(self, "one/two"); 10577 r = icExtractSCharO(self, "||", '/'); 10578 ck_assert_ptr_eq(r, NULL); 10579 // icExtractSCharO with several delimiters after each other 10580 setValO(self, "one/ two /three "); 10581 r = icExtractSCharO(self, "/", ' '); 10582 ck_assert_ptr_ne(r, null); 10583 s = toStringO(r); 10584 ck_assert_str_eq(s, "[\"\",\"three\"]"); 10585 free(s); 10586 terminateO(r); 10587 // multiple character delimiter 10588 setValO(self, "AAe thre|e icExtract"); 10589 r = icExtractSCharO(self, "e ", '|'); 10590 ck_assert_ptr_ne(r, null); 10591 s = toStringO(r); 10592 ck_assert_str_eq(s, "[\"thre\"]"); 10593 free(s); 10594 terminateO(r); 10595 // empty delimiter 10596 setValO(self, "AAd"); 10597 r = icExtractSCharO(self, "", 'A'); 10598 ck_assert_ptr_eq(r, NULL); 10599 // empty string 10600 setValO(self, ""); 10601 r = icExtractSCharO(self, "$", '#'); 10602 ck_assert_ptr_eq(r, NULL); 10603 // delim1 = delim2 10604 setValO(self, ""); 10605 r = icExtractSCharO(self, "$", '$'); 10606 ck_assert_ptr_eq(r, NULL); 10607 // NULL string 10608 freeO(self); 10609 ck_assert_ptr_eq(icExtractSCharO(self, ";", ','), NULL); 10610 // NULL delimiter 10611 setValO(self, "test"); 10612 ck_assert_ptr_eq(icExtractSCharO(self, NULL, ','), NULL); 10613 terminateO(self); 10614 10615 } 10616 10617 10618 void icExtractCharCharSmallStringT(CuTest *tc UNUSED) { 10619 10620 smallArrayt* r; 10621 smallStringt *self = allocG(""); 10622 10623 // string 10624 setValO(self, "one/twos"); 10625 r = icExtractCharCharO(self, 'E', 'S'); 10626 ck_assert_ptr_ne(r, null); 10627 char *s = toStringO(r); 10628 ck_assert_str_eq(s, "[\"/two\"]"); 10629 free(s); 10630 terminateO(r); 10631 // delimiter not found 10632 setValO(self, "one/two"); 10633 r = icExtractCharCharO(self, '|', '/'); 10634 ck_assert_ptr_eq(r, NULL); 10635 // icExtractCharCharO with several delimiters after each other 10636 setValO(self, "one/ two /three "); 10637 r = icExtractCharCharO(self, '/', ' '); 10638 ck_assert_ptr_ne(r, null); 10639 s = toStringO(r); 10640 ck_assert_str_eq(s, "[\"\",\"three\"]"); 10641 free(s); 10642 terminateO(r); 10643 // multiple character delimiter 10644 setValO(self, "AAe thre|e icExtract"); 10645 r = icExtractCharCharO(self, ' ', '|'); 10646 ck_assert_ptr_ne(r, null); 10647 s = toStringO(r); 10648 ck_assert_str_eq(s, "[\"thre\"]"); 10649 free(s); 10650 terminateO(r); 10651 // empty string 10652 setValO(self, ""); 10653 r = icExtractCharCharO(self, '$', '#'); 10654 ck_assert_ptr_eq(r, NULL); 10655 // delim1 = delim2 10656 setValO(self, ""); 10657 r = icExtractCharCharO(self, '$', '$'); 10658 ck_assert_ptr_eq(r, NULL); 10659 // NULL string 10660 freeO(self); 10661 ck_assert_ptr_eq(icExtractCharCharO(self, ';', ','), NULL); 10662 terminateO(self); 10663 10664 } 10665 10666 10667 void icExtractSmallJsonSmallJsonSmallStringT(CuTest *tc UNUSED) { 10668 10669 smallArrayt* r; 10670 smallStringt *self = allocG(""); 10671 smallJsont* delim1 = allocSmallJson(); 10672 smallJsont* delim2 = allocSmallJson(); 10673 10674 // string 10675 setValO(self, "one/twos"); 10676 setTopSO(delim1, "E"); 10677 setTopSO(delim2, "S"); 10678 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10679 ck_assert_ptr_ne(r, null); 10680 char *s = toStringO(r); 10681 ck_assert_str_eq(s, "[\"/two\"]"); 10682 free(s); 10683 terminateO(r); 10684 // delimiter not found 10685 setValO(self, "one/two"); 10686 freeO(delim1); 10687 freeO(delim2); 10688 setTopSO(delim1, "||"); 10689 setTopSO(delim2, "/"); 10690 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10691 ck_assert_ptr_eq(r, NULL); 10692 // icExtractSmallJsonSmallJsonO with several delimiters after each other 10693 setValO(self, "one/ two /three "); 10694 freeO(delim1); 10695 freeO(delim2); 10696 setTopSO(delim1, "/"); 10697 setTopSO(delim2, " "); 10698 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10699 ck_assert_ptr_ne(r, null); 10700 s = toStringO(r); 10701 ck_assert_str_eq(s, "[\"\",\"three\"]"); 10702 free(s); 10703 terminateO(r); 10704 // multiple character delimiter 10705 setValO(self, "AAe thre|e icExtract"); 10706 freeO(delim1); 10707 freeO(delim2); 10708 setTopSO(delim1, "e "); 10709 setTopSO(delim2, "|"); 10710 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10711 ck_assert_ptr_ne(r, null); 10712 s = toStringO(r); 10713 ck_assert_str_eq(s, "[\"thre\"]"); 10714 free(s); 10715 terminateO(r); 10716 // empty delimiter 10717 setValO(self, "AAd"); 10718 freeO(delim1); 10719 freeO(delim2); 10720 setTopSO(delim1, ""); 10721 setTopSO(delim2, "Ad"); 10722 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10723 ck_assert_ptr_eq(r, NULL); 10724 setValO(self, "AAd"); 10725 freeO(delim1); 10726 freeO(delim2); 10727 setTopSO(delim1, "A"); 10728 setTopSO(delim2, ""); 10729 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10730 ck_assert_ptr_eq(r, NULL); 10731 // empty string 10732 setValO(self, ""); 10733 freeO(delim1); 10734 freeO(delim2); 10735 setTopSO(delim1, "$"); 10736 setTopSO(delim2, "#"); 10737 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10738 ck_assert_ptr_eq(r, NULL); 10739 // delim1 = delim2 10740 setValO(self, "$qwe$"); 10741 freeO(delim1); 10742 freeO(delim2); 10743 setTopSO(delim1, "$"); 10744 setTopSO(delim2, "$"); 10745 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10746 ck_assert_ptr_eq(r, NULL); 10747 // non json string 10748 freeO(delim1); 10749 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10750 ck_assert_ptr_eq(r, NULL); 10751 setTopSO(delim1, "$"); 10752 freeO(delim2); 10753 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10754 ck_assert_ptr_eq(r, NULL); 10755 // non json object 10756 terminateO(delim1); 10757 delim1 = (smallJsont*) allocSmallInt(1); 10758 setTopSO(delim2, "$"); 10759 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10760 ck_assert_ptr_eq(r, NULL); 10761 terminateO(delim1); 10762 delim1 = allocSmallJson(); 10763 setTopSO(delim1, ";"); 10764 terminateO(delim2); 10765 delim2 = (smallJsont*) allocSmallInt(1); 10766 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 10767 ck_assert_ptr_eq(r, NULL); 10768 terminateO(delim2); 10769 delim2 = allocSmallJson(); 10770 // NULL string 10771 freeO(self); 10772 freeO(delim1); 10773 freeO(delim2); 10774 setTopSO(delim1, ";"); 10775 setTopSO(delim2, ","); 10776 ck_assert_ptr_eq(icExtractSmallJsonSmallJsonO(self, delim1, delim2), NULL); 10777 // NULL delimiter 10778 setValO(self, "test"); 10779 ck_assert_ptr_eq(icExtractSmallJsonSmallJsonO(self, NULL, delim2), NULL); 10780 ck_assert_ptr_eq(icExtractSmallJsonSmallJsonO(self, delim1, NULL), NULL); 10781 terminateO(delim1); 10782 terminateO(delim2); 10783 terminateO(self); 10784 10785 } 10786 10787 10788 void icExtractSmallJsonSmallStringSmallStringT(CuTest *tc UNUSED) { 10789 10790 smallArrayt* r; 10791 smallStringt *self = allocG(""); 10792 smallJsont* delim1 = allocSmallJson(); 10793 smallStringt* delim2 = allocSmallString("S"); 10794 10795 // string 10796 setValO(self, "one/twos"); 10797 setTopSO(delim1, "E"); 10798 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10799 ck_assert_ptr_ne(r, null); 10800 char *s = toStringO(r); 10801 ck_assert_str_eq(s, "[\"/two\"]"); 10802 free(s); 10803 terminateO(r); 10804 // delimiter not found 10805 setValO(self, "one/two"); 10806 freeO(delim1); 10807 setTopSO(delim1, "||"); 10808 setValO(delim2, "/"); 10809 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10810 ck_assert_ptr_eq(r, NULL); 10811 // icExtractSmallJsonSmallStringO with several delimiters after each other 10812 setValO(self, "one/ two /three "); 10813 freeO(delim1); 10814 setTopSO(delim1, "/"); 10815 setValO(delim2, " "); 10816 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10817 ck_assert_ptr_ne(r, null); 10818 s = toStringO(r); 10819 ck_assert_str_eq(s, "[\"\",\"three\"]"); 10820 free(s); 10821 terminateO(r); 10822 // multiple character delimiter 10823 setValO(self, "AAe thre|e icExtract"); 10824 freeO(delim1); 10825 setTopSO(delim1, "e "); 10826 setValO(delim2, "|"); 10827 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10828 ck_assert_ptr_ne(r, null); 10829 s = toStringO(r); 10830 ck_assert_str_eq(s, "[\"thre\"]"); 10831 free(s); 10832 terminateO(r); 10833 // empty delimiter 10834 setValO(self, "AAd"); 10835 freeO(delim1); 10836 setTopSO(delim1, ""); 10837 setValO(delim2, "Ad"); 10838 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10839 ck_assert_ptr_eq(r, NULL); 10840 setValO(self, "AAd"); 10841 freeO(delim1); 10842 setTopSO(delim1, "A"); 10843 setValO(delim2, ""); 10844 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10845 ck_assert_ptr_eq(r, NULL); 10846 // empty string 10847 setValO(self, ""); 10848 freeO(delim1); 10849 setTopSO(delim1, "$"); 10850 setValO(delim2, "#"); 10851 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10852 ck_assert_ptr_eq(r, NULL); 10853 // delim1 = delim2 10854 setValO(self, "$qwe$"); 10855 freeO(delim1); 10856 setTopSO(delim1, "$"); 10857 setValO(delim2, "$"); 10858 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10859 ck_assert_ptr_eq(r, NULL); 10860 // non json string 10861 freeO(delim1); 10862 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10863 ck_assert_ptr_eq(r, NULL); 10864 // non json object 10865 terminateO(delim1); 10866 delim1 = (smallJsont*) allocSmallInt(1); 10867 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10868 ck_assert_ptr_eq(r, NULL); 10869 terminateO(delim1); 10870 delim1 = allocSmallJson(); 10871 setTopSO(delim1, ";"); 10872 terminateO(delim2); 10873 delim2 = (smallStringt*) allocSmallInt(1); 10874 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 10875 ck_assert_ptr_eq(r, NULL); 10876 terminateO(delim2); 10877 delim2 = allocSmallString(","); 10878 // NULL string 10879 freeO(self); 10880 freeO(delim1); 10881 setTopSO(delim1, ";"); 10882 ck_assert_ptr_eq(icExtractSmallJsonSmallStringO(self, delim1, delim2), NULL); 10883 // NULL delimiter 10884 setValO(self, "test"); 10885 ck_assert_ptr_eq(icExtractSmallJsonSmallStringO(self, NULL, delim2), NULL); 10886 ck_assert_ptr_eq(icExtractSmallJsonSmallStringO(self, delim1, NULL), NULL); 10887 terminateO(delim1); 10888 terminateO(delim2); 10889 terminateO(self); 10890 10891 } 10892 10893 10894 void icExtractSmallJsonSSmallStringT(CuTest *tc UNUSED) { 10895 10896 smallArrayt* r; 10897 smallStringt *self = allocG(""); 10898 smallJsont* delim1 = allocSmallJson(); 10899 10900 // string 10901 setValO(self, "one/twos"); 10902 setTopSO(delim1, "E"); 10903 r = icExtractSmallJsonSO(self, delim1, "S"); 10904 ck_assert_ptr_ne(r, null); 10905 char *s = toStringO(r); 10906 ck_assert_str_eq(s, "[\"/two\"]"); 10907 free(s); 10908 terminateO(r); 10909 // delimiter not found 10910 setValO(self, "one/two"); 10911 freeO(delim1); 10912 setTopSO(delim1, "||"); 10913 r = icExtractSmallJsonSO(self, delim1, "/"); 10914 ck_assert_ptr_eq(r, NULL); 10915 // icExtractSmallJsonSO with several delimiters after each other 10916 setValO(self, "one/ two /three "); 10917 freeO(delim1); 10918 setTopSO(delim1, "/"); 10919 r = icExtractSmallJsonSO(self, delim1, " "); 10920 ck_assert_ptr_ne(r, null); 10921 s = toStringO(r); 10922 ck_assert_str_eq(s, "[\"\",\"three\"]"); 10923 free(s); 10924 terminateO(r); 10925 // multiple character delimiter 10926 setValO(self, "AAe thre|e icExtract"); 10927 freeO(delim1); 10928 setTopSO(delim1, "e "); 10929 r = icExtractSmallJsonSO(self, delim1, "|"); 10930 ck_assert_ptr_ne(r, null); 10931 s = toStringO(r); 10932 ck_assert_str_eq(s, "[\"thre\"]"); 10933 free(s); 10934 terminateO(r); 10935 // empty delimiter 10936 setValO(self, "AAd"); 10937 freeO(delim1); 10938 setTopSO(delim1, ""); 10939 r = icExtractSmallJsonSO(self, delim1, "Ad"); 10940 ck_assert_ptr_eq(r, NULL); 10941 setValO(self, "AAd"); 10942 freeO(delim1); 10943 setTopSO(delim1, "A"); 10944 r = icExtractSmallJsonSO(self, delim1, ""); 10945 ck_assert_ptr_eq(r, NULL); 10946 // empty string 10947 setValO(self, ""); 10948 freeO(delim1); 10949 setTopSO(delim1, "$"); 10950 r = icExtractSmallJsonSO(self, delim1, "#"); 10951 ck_assert_ptr_eq(r, NULL); 10952 // delim1 = delim2 10953 setValO(self, "$qwe$"); 10954 freeO(delim1); 10955 setTopSO(delim1, "$"); 10956 r = icExtractSmallJsonSO(self, delim1, "$"); 10957 ck_assert_ptr_eq(r, NULL); 10958 // non json string 10959 freeO(delim1); 10960 r = icExtractSmallJsonSO(self, delim1, "$"); 10961 ck_assert_ptr_eq(r, NULL); 10962 // non json object 10963 terminateO(delim1); 10964 delim1 = (smallJsont*) allocSmallInt(1); 10965 r = icExtractSmallJsonSO(self, delim1, "$"); 10966 ck_assert_ptr_eq(r, NULL); 10967 terminateO(delim1); 10968 delim1 = allocSmallJson(); 10969 // NULL string 10970 freeO(self); 10971 freeO(delim1); 10972 setTopSO(delim1, ";"); 10973 ck_assert_ptr_eq(icExtractSmallJsonSO(self, delim1, ","), NULL); 10974 // NULL delimiter 10975 setValO(self, "test"); 10976 ck_assert_ptr_eq(icExtractSmallJsonSO(self, NULL, ","), NULL); 10977 ck_assert_ptr_eq(icExtractSmallJsonSO(self, delim1, NULL), NULL); 10978 terminateO(delim1); 10979 terminateO(self); 10980 10981 } 10982 10983 10984 void icExtractSmallJsonCharSmallStringT(CuTest *tc UNUSED) { 10985 10986 smallArrayt* r; 10987 smallStringt *self = allocG(""); 10988 smallJsont* delim1 = allocSmallJson(); 10989 10990 // string 10991 setValO(self, "one/twos"); 10992 setTopSO(delim1, "E"); 10993 r = icExtractSmallJsonCharO(self, delim1, 'S'); 10994 ck_assert_ptr_ne(r, null); 10995 char *s = toStringO(r); 10996 ck_assert_str_eq(s, "[\"/two\"]"); 10997 free(s); 10998 terminateO(r); 10999 // delimiter not found 11000 setValO(self, "one/two"); 11001 freeO(delim1); 11002 setTopSO(delim1, "||"); 11003 r = icExtractSmallJsonCharO(self, delim1, '/'); 11004 ck_assert_ptr_eq(r, NULL); 11005 // icExtractSmallJsonCharO with several delimiters after each other 11006 setValO(self, "one/ two /three "); 11007 freeO(delim1); 11008 setTopSO(delim1, "/"); 11009 r = icExtractSmallJsonCharO(self, delim1, ' '); 11010 ck_assert_ptr_ne(r, null); 11011 s = toStringO(r); 11012 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11013 free(s); 11014 terminateO(r); 11015 // multiple character delimiter 11016 setValO(self, "AAe thre|e icExtract"); 11017 freeO(delim1); 11018 setTopSO(delim1, "e "); 11019 r = icExtractSmallJsonCharO(self, delim1, '|'); 11020 ck_assert_ptr_ne(r, null); 11021 s = toStringO(r); 11022 ck_assert_str_eq(s, "[\"thre\"]"); 11023 free(s); 11024 terminateO(r); 11025 // empty delimiter 11026 setValO(self, "AAd"); 11027 freeO(delim1); 11028 setTopSO(delim1, ""); 11029 r = icExtractSmallJsonCharO(self, delim1, 'd'); 11030 ck_assert_ptr_eq(r, NULL); 11031 setValO(self, "AAd"); 11032 // empty string 11033 setValO(self, ""); 11034 freeO(delim1); 11035 setTopSO(delim1, "$"); 11036 r = icExtractSmallJsonCharO(self, delim1, '#'); 11037 ck_assert_ptr_eq(r, NULL); 11038 // delim1 = delim2 11039 setValO(self, "$qwe$"); 11040 freeO(delim1); 11041 setTopSO(delim1, "$"); 11042 r = icExtractSmallJsonCharO(self, delim1, '$'); 11043 ck_assert_ptr_eq(r, NULL); 11044 // non json string 11045 freeO(delim1); 11046 r = icExtractSmallJsonCharO(self, delim1, '$'); 11047 ck_assert_ptr_eq(r, NULL); 11048 // non json object 11049 terminateO(delim1); 11050 delim1 = (smallJsont*) allocSmallInt(1); 11051 r = icExtractSmallJsonCharO(self, delim1, '$'); 11052 ck_assert_ptr_eq(r, NULL); 11053 terminateO(delim1); 11054 delim1 = allocSmallJson(); 11055 // NULL string 11056 freeO(self); 11057 freeO(delim1); 11058 setTopSO(delim1, ";"); 11059 ck_assert_ptr_eq(icExtractSmallJsonCharO(self, delim1, ','), NULL); 11060 // NULL delimiter 11061 setValO(self, "test"); 11062 ck_assert_ptr_eq(icExtractSmallJsonCharO(self, NULL, ','), NULL); 11063 terminateO(delim1); 11064 terminateO(self); 11065 11066 } 11067 11068 11069 void icExtractSmallStringSmallJsonSmallStringT(CuTest *tc UNUSED) { 11070 11071 smallArrayt* r; 11072 smallStringt *self = allocG(""); 11073 smallStringt* delim1 = allocSmallString("E"); 11074 smallJsont* delim2 = allocSmallJson(); 11075 11076 // string 11077 setValO(self, "one/twos"); 11078 setTopSO(delim2, "S"); 11079 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11080 ck_assert_ptr_ne(r, null); 11081 char *s = toStringO(r); 11082 ck_assert_str_eq(s, "[\"/two\"]"); 11083 free(s); 11084 terminateO(r); 11085 // delimiter not found 11086 setValO(self, "one/two"); 11087 freeO(delim2); 11088 setValO(delim1, "||"); 11089 setTopSO(delim2, "/"); 11090 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11091 ck_assert_ptr_eq(r, NULL); 11092 // icExtractSmallStringSmallJsonO with several delimiters after each other 11093 setValO(self, "one/ two /three "); 11094 freeO(delim2); 11095 setValO(delim1, "/"); 11096 setTopSO(delim2, " "); 11097 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11098 ck_assert_ptr_ne(r, null); 11099 s = toStringO(r); 11100 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11101 free(s); 11102 terminateO(r); 11103 // multiple character delimiter 11104 setValO(self, "AAe thre|e icExtract"); 11105 freeO(delim2); 11106 setValO(delim1, "e "); 11107 setTopSO(delim2, "|"); 11108 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11109 ck_assert_ptr_ne(r, null); 11110 s = toStringO(r); 11111 ck_assert_str_eq(s, "[\"thre\"]"); 11112 free(s); 11113 terminateO(r); 11114 // empty delimiter 11115 setValO(self, "AAd"); 11116 freeO(delim2); 11117 setValO(delim1, ""); 11118 setTopSO(delim2, "Ad"); 11119 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11120 ck_assert_ptr_eq(r, NULL); 11121 setValO(self, "AAd"); 11122 freeO(delim2); 11123 setValO(delim1, "A"); 11124 setTopSO(delim2, ""); 11125 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11126 ck_assert_ptr_eq(r, NULL); 11127 // empty string 11128 setValO(self, ""); 11129 freeO(delim2); 11130 setValO(delim1, "$"); 11131 setTopSO(delim2, "#"); 11132 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11133 ck_assert_ptr_eq(r, NULL); 11134 // delim1 = delim2 11135 setValO(self, "$qwe$"); 11136 freeO(delim2); 11137 setValO(delim1, "$"); 11138 setTopSO(delim2, "$"); 11139 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11140 ck_assert_ptr_eq(r, NULL); 11141 // non json string 11142 freeO(delim2); 11143 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11144 ck_assert_ptr_eq(r, NULL); 11145 // non json object 11146 terminateO(delim1); 11147 delim1 = (smallStringt*) allocSmallInt(1); 11148 setTopSO(delim2, "$"); 11149 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11150 ck_assert_ptr_eq(r, NULL); 11151 terminateO(delim1); 11152 delim1 = allocSmallString(";"); 11153 terminateO(delim2); 11154 delim2 = (smallJsont*) allocSmallInt(1); 11155 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 11156 ck_assert_ptr_eq(r, NULL); 11157 terminateO(delim2); 11158 delim2 = allocSmallJson(); 11159 // NULL string 11160 freeO(self); 11161 freeO(delim2); 11162 setValO(delim1, ";"); 11163 setTopSO(delim2, ","); 11164 ck_assert_ptr_eq(icExtractSmallStringSmallJsonO(self, delim1, delim2), NULL); 11165 // NULL delimiter 11166 setValO(self, "test"); 11167 ck_assert_ptr_eq(icExtractSmallStringSmallJsonO(self, NULL, delim2), NULL); 11168 ck_assert_ptr_eq(icExtractSmallStringSmallJsonO(self, delim1, NULL), NULL); 11169 terminateO(delim1); 11170 terminateO(delim2); 11171 terminateO(self); 11172 11173 } 11174 11175 11176 void icExtractSmallStringSmallStringSmallStringT(CuTest *tc UNUSED) { 11177 11178 smallArrayt* r; 11179 smallStringt *self = allocG(""); 11180 smallStringt* delim1 = allocSmallString("E"); 11181 smallStringt* delim2 = allocSmallString("|"); 11182 11183 // string 11184 setValO(self, "one/twos"); 11185 setValO(delim2, "S"); 11186 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11187 ck_assert_ptr_ne(r, null); 11188 char *s = toStringO(r); 11189 ck_assert_str_eq(s, "[\"/two\"]"); 11190 free(s); 11191 terminateO(r); 11192 // delimiter not found 11193 setValO(self, "one/two"); 11194 setValO(delim1, "||"); 11195 setValO(delim2, "/"); 11196 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11197 ck_assert_ptr_eq(r, NULL); 11198 // icExtractSmallStringSmallStringO with several delimiters after each other 11199 setValO(self, "one/ two /three "); 11200 setValO(delim1, "/"); 11201 setValO(delim2, " "); 11202 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11203 ck_assert_ptr_ne(r, null); 11204 s = toStringO(r); 11205 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11206 free(s); 11207 terminateO(r); 11208 // multiple character delimiter 11209 setValO(self, "AAe thre|e icExtract"); 11210 setValO(delim1, "e "); 11211 setValO(delim2, "|"); 11212 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11213 ck_assert_ptr_ne(r, null); 11214 s = toStringO(r); 11215 ck_assert_str_eq(s, "[\"thre\"]"); 11216 free(s); 11217 terminateO(r); 11218 // empty delimiter 11219 setValO(self, "AAd"); 11220 setValO(delim1, ""); 11221 setValO(delim2, "Ad"); 11222 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11223 ck_assert_ptr_eq(r, NULL); 11224 setValO(self, "AAd"); 11225 setValO(delim1, "A"); 11226 setValO(delim2, ""); 11227 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11228 ck_assert_ptr_eq(r, NULL); 11229 // empty string 11230 setValO(self, ""); 11231 setValO(delim1, "$"); 11232 setValO(delim2, "#"); 11233 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11234 ck_assert_ptr_eq(r, NULL); 11235 // delim1 = delim2 11236 setValO(self, "$qwe$"); 11237 setValO(delim1, "$"); 11238 setValO(delim2, "$"); 11239 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11240 ck_assert_ptr_eq(r, NULL); 11241 // non json object 11242 terminateO(delim1); 11243 delim1 = (smallStringt*) allocSmallInt(1); 11244 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11245 ck_assert_ptr_eq(r, NULL); 11246 terminateO(delim1); 11247 delim1 = allocSmallString(";"); 11248 terminateO(delim2); 11249 delim2 = (smallStringt*) allocSmallInt(1); 11250 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 11251 ck_assert_ptr_eq(r, NULL); 11252 terminateO(delim2); 11253 delim2 = allocSmallString(","); 11254 // NULL string 11255 freeO(self); 11256 setValO(delim1, ";"); 11257 ck_assert_ptr_eq(icExtractSmallStringSmallStringO(self, delim1, delim2), NULL); 11258 // NULL delimiter 11259 setValO(self, "test"); 11260 ck_assert_ptr_eq(icExtractSmallStringSmallStringO(self, NULL, delim2), NULL); 11261 ck_assert_ptr_eq(icExtractSmallStringSmallStringO(self, delim1, NULL), NULL); 11262 terminateO(delim1); 11263 terminateO(delim2); 11264 terminateO(self); 11265 11266 } 11267 11268 11269 void icExtractSmallStringSSmallStringT(CuTest *tc UNUSED) { 11270 11271 smallArrayt* r; 11272 smallStringt *self = allocG(""); 11273 smallStringt* delim1 = allocSmallString("E"); 11274 11275 // string 11276 setValO(self, "one/twos"); 11277 r = icExtractSmallStringSO(self, delim1, "S"); 11278 ck_assert_ptr_ne(r, null); 11279 char *s = toStringO(r); 11280 ck_assert_str_eq(s, "[\"/two\"]"); 11281 free(s); 11282 terminateO(r); 11283 // delimiter not found 11284 setValO(self, "one/two"); 11285 setValO(delim1, "||"); 11286 r = icExtractSmallStringSO(self, delim1, "/"); 11287 ck_assert_ptr_eq(r, NULL); 11288 // icExtractSmallStringSO with several delimiters after each other 11289 setValO(self, "one/ two /three "); 11290 setValO(delim1, "/"); 11291 r = icExtractSmallStringSO(self, delim1, " "); 11292 ck_assert_ptr_ne(r, null); 11293 s = toStringO(r); 11294 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11295 free(s); 11296 terminateO(r); 11297 // multiple character delimiter 11298 setValO(self, "AAe thre|e icExtract"); 11299 setValO(delim1, "e "); 11300 r = icExtractSmallStringSO(self, delim1, "|"); 11301 ck_assert_ptr_ne(r, null); 11302 s = toStringO(r); 11303 ck_assert_str_eq(s, "[\"thre\"]"); 11304 free(s); 11305 terminateO(r); 11306 // empty delimiter 11307 setValO(self, "AAd"); 11308 setValO(delim1, ""); 11309 r = icExtractSmallStringSO(self, delim1, "Ad"); 11310 ck_assert_ptr_eq(r, NULL); 11311 setValO(self, "AAd"); 11312 setValO(delim1, "A"); 11313 r = icExtractSmallStringSO(self, delim1, ""); 11314 ck_assert_ptr_eq(r, NULL); 11315 // empty string 11316 setValO(self, ""); 11317 setValO(delim1, "$"); 11318 r = icExtractSmallStringSO(self, delim1, "#"); 11319 ck_assert_ptr_eq(r, NULL); 11320 // delim1 = delim2 11321 setValO(self, "$qwe$"); 11322 setValO(delim1, "$"); 11323 r = icExtractSmallStringSO(self, delim1, "$"); 11324 ck_assert_ptr_eq(r, NULL); 11325 // non json object 11326 terminateO(delim1); 11327 delim1 = (smallStringt*) allocSmallInt(1); 11328 r = icExtractSmallStringSO(self, delim1, "$"); 11329 ck_assert_ptr_eq(r, NULL); 11330 terminateO(delim1); 11331 delim1 = allocSmallString(";"); 11332 // NULL string 11333 freeO(self); 11334 setValO(delim1, ";"); 11335 ck_assert_ptr_eq(icExtractSmallStringSO(self, delim1, ","), NULL); 11336 // NULL delimiter 11337 setValO(self, "test"); 11338 ck_assert_ptr_eq(icExtractSmallStringSO(self, NULL, ","), NULL); 11339 ck_assert_ptr_eq(icExtractSmallStringSO(self, delim1, NULL), NULL); 11340 terminateO(delim1); 11341 terminateO(self); 11342 11343 } 11344 11345 11346 void icExtractSmallStringCharSmallStringT(CuTest *tc UNUSED) { 11347 11348 smallArrayt* r; 11349 smallStringt *self = allocG(""); 11350 smallStringt* delim1 = allocSmallString("E"); 11351 11352 // string 11353 setValO(self, "one/twos"); 11354 r = icExtractSmallStringCharO(self, delim1, 'S'); 11355 ck_assert_ptr_ne(r, null); 11356 char *s = toStringO(r); 11357 ck_assert_str_eq(s, "[\"/two\"]"); 11358 free(s); 11359 terminateO(r); 11360 // delimiter not found 11361 setValO(self, "one/two"); 11362 setValO(delim1, "||"); 11363 r = icExtractSmallStringCharO(self, delim1, '/'); 11364 ck_assert_ptr_eq(r, NULL); 11365 // icExtractSmallStringCharO with several delimiters after each other 11366 setValO(self, "one/ two /three "); 11367 setValO(delim1, "/"); 11368 r = icExtractSmallStringCharO(self, delim1, ' '); 11369 ck_assert_ptr_ne(r, null); 11370 s = toStringO(r); 11371 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11372 free(s); 11373 terminateO(r); 11374 // multiple character delimiter 11375 setValO(self, "AAe thre|e icExtract"); 11376 setValO(delim1, "e "); 11377 r = icExtractSmallStringCharO(self, delim1, '|'); 11378 ck_assert_ptr_ne(r, null); 11379 s = toStringO(r); 11380 ck_assert_str_eq(s, "[\"thre\"]"); 11381 free(s); 11382 terminateO(r); 11383 // empty delimiter 11384 setValO(self, "AAd"); 11385 setValO(delim1, ""); 11386 r = icExtractSmallStringCharO(self, delim1, 'A'); 11387 ck_assert_ptr_eq(r, NULL); 11388 setValO(self, "AAd"); 11389 setValO(delim1, "A"); 11390 // empty string 11391 setValO(self, ""); 11392 setValO(delim1, "$"); 11393 r = icExtractSmallStringCharO(self, delim1, '#'); 11394 ck_assert_ptr_eq(r, NULL); 11395 // delim1 = delim2 11396 setValO(self, "$qwe$"); 11397 setValO(delim1, "$"); 11398 r = icExtractSmallStringCharO(self, delim1, '$'); 11399 ck_assert_ptr_eq(r, NULL); 11400 // non json object 11401 terminateO(delim1); 11402 delim1 = (smallStringt*) allocSmallInt(1); 11403 r = icExtractSmallStringCharO(self, delim1, '$'); 11404 ck_assert_ptr_eq(r, NULL); 11405 terminateO(delim1); 11406 delim1 = allocSmallString(";"); 11407 // NULL string 11408 freeO(self); 11409 setValO(delim1, ";"); 11410 ck_assert_ptr_eq(icExtractSmallStringCharO(self, delim1, ','), NULL); 11411 // NULL delimiter 11412 setValO(self, "test"); 11413 ck_assert_ptr_eq(icExtractSmallStringCharO(self, NULL, ','), NULL); 11414 terminateO(delim1); 11415 terminateO(self); 11416 11417 } 11418 11419 11420 void icExtractSSmallJsonSmallStringT(CuTest *tc UNUSED) { 11421 11422 smallArrayt* r; 11423 smallStringt *self = allocG(""); 11424 smallJsont* delim2 = allocSmallJson(); 11425 11426 // string 11427 setValO(self, "one/twos"); 11428 setTopSO(delim2, "S"); 11429 r = icExtractSSmallJsonO(self, "E", delim2); 11430 ck_assert_ptr_ne(r, null); 11431 char *s = toStringO(r); 11432 ck_assert_str_eq(s, "[\"/two\"]"); 11433 free(s); 11434 terminateO(r); 11435 // delimiter not found 11436 setValO(self, "one/two"); 11437 freeO(delim2); 11438 setTopSO(delim2, "/"); 11439 r = icExtractSSmallJsonO(self, "||", delim2); 11440 ck_assert_ptr_eq(r, NULL); 11441 // icExtractSSmallJsonO with several delimiters after each other 11442 setValO(self, "one/ two /three "); 11443 freeO(delim2); 11444 setTopSO(delim2, " "); 11445 r = icExtractSSmallJsonO(self, "/", delim2); 11446 ck_assert_ptr_ne(r, null); 11447 s = toStringO(r); 11448 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11449 free(s); 11450 terminateO(r); 11451 // multiple character delimiter 11452 setValO(self, "AAe thre|e icExtract"); 11453 freeO(delim2); 11454 setTopSO(delim2, "|"); 11455 r = icExtractSSmallJsonO(self, "e ", delim2); 11456 ck_assert_ptr_ne(r, null); 11457 s = toStringO(r); 11458 ck_assert_str_eq(s, "[\"thre\"]"); 11459 free(s); 11460 terminateO(r); 11461 // empty delimiter 11462 setValO(self, "AAd"); 11463 freeO(delim2); 11464 setTopSO(delim2, "Ad"); 11465 r = icExtractSSmallJsonO(self, "", delim2); 11466 ck_assert_ptr_eq(r, NULL); 11467 setValO(self, "AAd"); 11468 freeO(delim2); 11469 setTopSO(delim2, ""); 11470 r = icExtractSSmallJsonO(self, "A", delim2); 11471 ck_assert_ptr_eq(r, NULL); 11472 // empty string 11473 setValO(self, ""); 11474 freeO(delim2); 11475 setTopSO(delim2, "#"); 11476 r = icExtractSSmallJsonO(self, "$", delim2); 11477 ck_assert_ptr_eq(r, NULL); 11478 // delim1 = delim2 11479 setValO(self, "$qwe$"); 11480 freeO(delim2); 11481 setTopSO(delim2, "$"); 11482 r = icExtractSSmallJsonO(self, "$", delim2); 11483 ck_assert_ptr_eq(r, NULL); 11484 // non json string 11485 freeO(delim2); 11486 r = icExtractSSmallJsonO(self, "$", delim2); 11487 ck_assert_ptr_eq(r, NULL); 11488 // non json object 11489 terminateO(delim2); 11490 delim2 = (smallJsont*) allocSmallInt(1); 11491 r = icExtractSSmallJsonO(self, ";", delim2); 11492 ck_assert_ptr_eq(r, NULL); 11493 terminateO(delim2); 11494 delim2 = allocSmallJson(); 11495 // NULL string 11496 freeO(self); 11497 freeO(delim2); 11498 setTopSO(delim2, ","); 11499 ck_assert_ptr_eq(icExtractSSmallJsonO(self, ";", delim2), NULL); 11500 // NULL delimiter 11501 setValO(self, "test"); 11502 ck_assert_ptr_eq(icExtractSSmallJsonO(self, NULL, delim2), NULL); 11503 ck_assert_ptr_eq(icExtractSSmallJsonO(self, ";", NULL), NULL); 11504 terminateO(delim2); 11505 terminateO(self); 11506 11507 } 11508 11509 11510 void icExtractSSmallStringSmallStringT(CuTest *tc UNUSED) { 11511 11512 smallArrayt* r; 11513 smallStringt *self = allocG(""); 11514 smallStringt* delim2 = allocSmallString("|"); 11515 11516 // string 11517 setValO(self, "one/twos"); 11518 setValO(delim2, "S"); 11519 r = icExtractSSmallStringO(self, "E", delim2); 11520 ck_assert_ptr_ne(r, null); 11521 char *s = toStringO(r); 11522 ck_assert_str_eq(s, "[\"/two\"]"); 11523 free(s); 11524 terminateO(r); 11525 // delimiter not found 11526 setValO(self, "one/two"); 11527 setValO(delim2, "/"); 11528 r = icExtractSSmallStringO(self, "||", delim2); 11529 ck_assert_ptr_eq(r, NULL); 11530 // icExtractSSmallStringO with several delimiters after each other 11531 setValO(self, "one/ two /three "); 11532 setValO(delim2, " "); 11533 r = icExtractSSmallStringO(self, "/", delim2); 11534 ck_assert_ptr_ne(r, null); 11535 s = toStringO(r); 11536 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11537 free(s); 11538 terminateO(r); 11539 // multiple character delimiter 11540 setValO(self, "AAe thre|e icExtract"); 11541 setValO(delim2, "|"); 11542 r = icExtractSSmallStringO(self, "e ", delim2); 11543 ck_assert_ptr_ne(r, null); 11544 s = toStringO(r); 11545 ck_assert_str_eq(s, "[\"thre\"]"); 11546 free(s); 11547 terminateO(r); 11548 // empty delimiter 11549 setValO(self, "AAd"); 11550 setValO(delim2, "Ad"); 11551 r = icExtractSSmallStringO(self, "", delim2); 11552 ck_assert_ptr_eq(r, NULL); 11553 setValO(self, "AAd"); 11554 setValO(delim2, ""); 11555 r = icExtractSSmallStringO(self, "A", delim2); 11556 ck_assert_ptr_eq(r, NULL); 11557 // empty string 11558 setValO(self, ""); 11559 setValO(delim2, "#"); 11560 r = icExtractSSmallStringO(self, "$", delim2); 11561 ck_assert_ptr_eq(r, NULL); 11562 // delim1 = delim2 11563 setValO(self, "$qwe$"); 11564 setValO(delim2, "$"); 11565 r = icExtractSSmallStringO(self, "$", delim2); 11566 ck_assert_ptr_eq(r, NULL); 11567 // non json object 11568 terminateO(delim2); 11569 delim2 = (smallStringt*) allocSmallInt(1); 11570 r = icExtractSSmallStringO(self, ";", delim2); 11571 ck_assert_ptr_eq(r, NULL); 11572 terminateO(delim2); 11573 delim2 = allocSmallString(","); 11574 // NULL string 11575 freeO(self); 11576 ck_assert_ptr_eq(icExtractSSmallStringO(self, ";", delim2), NULL); 11577 // NULL delimiter 11578 setValO(self, "test"); 11579 ck_assert_ptr_eq(icExtractSSmallStringO(self, NULL, delim2), NULL); 11580 ck_assert_ptr_eq(icExtractSSmallStringO(self, ";", NULL), NULL); 11581 terminateO(delim2); 11582 terminateO(self); 11583 11584 } 11585 11586 11587 void icExtractCharSmallJsonSmallStringT(CuTest *tc UNUSED) { 11588 11589 smallArrayt* r; 11590 smallStringt *self = allocG(""); 11591 smallJsont* delim2 = allocSmallJson(); 11592 11593 // string 11594 setValO(self, "one/twos"); 11595 setTopSO(delim2, "S"); 11596 r = icExtractCharSmallJsonO(self, 'E', delim2); 11597 ck_assert_ptr_ne(r, null); 11598 char *s = toStringO(r); 11599 ck_assert_str_eq(s, "[\"/two\"]"); 11600 free(s); 11601 terminateO(r); 11602 // delimiter not found 11603 setValO(self, "one/two"); 11604 freeO(delim2); 11605 setTopSO(delim2, "/"); 11606 r = icExtractCharSmallJsonO(self, '|', delim2); 11607 ck_assert_ptr_eq(r, NULL); 11608 // icExtractCharSmallJsonO with several delimiters after each other 11609 setValO(self, "one/ two /three "); 11610 freeO(delim2); 11611 setTopSO(delim2, " "); 11612 r = icExtractCharSmallJsonO(self, '/', delim2); 11613 ck_assert_ptr_ne(r, null); 11614 s = toStringO(r); 11615 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11616 free(s); 11617 terminateO(r); 11618 // multiple character delimiter 11619 setValO(self, "AAe thre|e icExtract"); 11620 freeO(delim2); 11621 setTopSO(delim2, "|"); 11622 r = icExtractCharSmallJsonO(self, ' ', delim2); 11623 ck_assert_ptr_ne(r, null); 11624 s = toStringO(r); 11625 ck_assert_str_eq(s, "[\"thre\"]"); 11626 free(s); 11627 terminateO(r); 11628 // empty delimiter 11629 setValO(self, "AAd"); 11630 freeO(delim2); 11631 setTopSO(delim2, ""); 11632 r = icExtractCharSmallJsonO(self, 'A', delim2); 11633 ck_assert_ptr_eq(r, NULL); 11634 // empty string 11635 setValO(self, ""); 11636 freeO(delim2); 11637 setTopSO(delim2, "#"); 11638 r = icExtractCharSmallJsonO(self, '$', delim2); 11639 ck_assert_ptr_eq(r, NULL); 11640 // delim1 = delim2 11641 setValO(self, "$qwe$"); 11642 freeO(delim2); 11643 setTopSO(delim2, "$"); 11644 r = icExtractCharSmallJsonO(self, '$', delim2); 11645 ck_assert_ptr_eq(r, NULL); 11646 // non json string 11647 freeO(delim2); 11648 r = icExtractCharSmallJsonO(self, '$', delim2); 11649 ck_assert_ptr_eq(r, NULL); 11650 // non json object 11651 terminateO(delim2); 11652 delim2 = (smallJsont*) allocSmallInt(1); 11653 r = icExtractCharSmallJsonO(self, ';', delim2); 11654 ck_assert_ptr_eq(r, NULL); 11655 terminateO(delim2); 11656 delim2 = allocSmallJson(); 11657 // NULL string 11658 freeO(self); 11659 freeO(delim2); 11660 setTopSO(delim2, ","); 11661 ck_assert_ptr_eq(icExtractCharSmallJsonO(self, ';', delim2), NULL); 11662 // NULL delimiter 11663 setValO(self, "test"); 11664 ck_assert_ptr_eq(icExtractCharSmallJsonO(self, ';', NULL), NULL); 11665 terminateO(delim2); 11666 terminateO(self); 11667 11668 } 11669 11670 11671 void icExtractCharSmallStringSmallStringT(CuTest *tc UNUSED) { 11672 11673 smallArrayt* r; 11674 smallStringt *self = allocG(""); 11675 smallStringt* delim2 = allocSmallString("|"); 11676 11677 // string 11678 setValO(self, "one/twos"); 11679 setValO(delim2, "S"); 11680 r = icExtractCharSmallStringO(self, 'E', delim2); 11681 ck_assert_ptr_ne(r, null); 11682 char *s = toStringO(r); 11683 ck_assert_str_eq(s, "[\"/two\"]"); 11684 free(s); 11685 terminateO(r); 11686 // delimiter not found 11687 setValO(self, "one/two"); 11688 setValO(delim2, "/"); 11689 r = icExtractCharSmallStringO(self, '|', delim2); 11690 ck_assert_ptr_eq(r, NULL); 11691 // icExtractCharSmallStringO with several delimiters after each other 11692 setValO(self, "one/ two /three "); 11693 setValO(delim2, " "); 11694 r = icExtractCharSmallStringO(self, '/', delim2); 11695 ck_assert_ptr_ne(r, null); 11696 s = toStringO(r); 11697 ck_assert_str_eq(s, "[\"\",\"three\"]"); 11698 free(s); 11699 terminateO(r); 11700 // multiple character delimiter 11701 setValO(self, "AAe thre|e icExtract"); 11702 setValO(delim2, "|e"); 11703 r = icExtractCharSmallStringO(self, ' ', delim2); 11704 ck_assert_ptr_ne(r, null); 11705 s = toStringO(r); 11706 ck_assert_str_eq(s, "[\"thre\"]"); 11707 free(s); 11708 terminateO(r); 11709 // empty delimiter 11710 setValO(self, "AAd"); 11711 setValO(delim2, ""); 11712 r = icExtractCharSmallStringO(self, 'A', delim2); 11713 ck_assert_ptr_eq(r, NULL); 11714 // empty string 11715 setValO(self, ""); 11716 setValO(delim2, "#"); 11717 r = icExtractCharSmallStringO(self, '$', delim2); 11718 ck_assert_ptr_eq(r, NULL); 11719 // delim1 = delim2 11720 setValO(self, "$qwe$"); 11721 setValO(delim2, "$"); 11722 r = icExtractCharSmallStringO(self, '$', delim2); 11723 ck_assert_ptr_eq(r, NULL); 11724 // non json object 11725 terminateO(delim2); 11726 delim2 = (smallStringt*) allocSmallInt(1); 11727 r = icExtractCharSmallStringO(self, ';', delim2); 11728 ck_assert_ptr_eq(r, NULL); 11729 terminateO(delim2); 11730 delim2 = allocSmallString(","); 11731 // NULL string 11732 freeO(self); 11733 ck_assert_ptr_eq(icExtractCharSmallStringO(self, ';', delim2), NULL); 11734 // NULL delimiter 11735 setValO(self, "test"); 11736 ck_assert_ptr_eq(icExtractCharSmallStringO(self, ';', NULL), NULL); 11737 terminateO(delim2); 11738 terminateO(self); 11739 11740 } 11741 11742 11743 void colorSmallStringT(CuTest *tc UNUSED) { 11744 11745 smallStringt* r; 11746 smallStringt *self = allocG("qwe"); 11747 11748 r = colorO(self, RED); 11749 ck_assert_ptr_ne(r, null); 11750 char *s = toStringO(r); 11751 ck_assert_str_eq(s, RED"qwe"RST); 11752 free(s); 11753 // null color 11754 r = colorO(self, null); 11755 ck_assert_ptr_eq(r, NULL); 11756 // empty self 11757 freeO(self); 11758 r = colorO(self, RED); 11759 ck_assert_ptr_eq(r, NULL); 11760 terminateO(self); 11761 11762 } 11763 11764 11765 void colordSmallStringT(CuTest *tc UNUSED) { 11766 11767 char* r; 11768 smallStringt *self = allocG("qwe"); 11769 11770 r = colordO(self, RED); 11771 ck_assert_ptr_ne(r, null); 11772 ck_assert_str_eq(r, RED"qwe"RST); 11773 free(r); 11774 // empty string 11775 emptyO(self); 11776 r = colordO(self, RED); 11777 ck_assert_ptr_ne(r, null); 11778 ck_assert_str_eq(r, ""); 11779 free(r); 11780 // null color 11781 r = colordO(self, null); 11782 ck_assert_ptr_eq(r, NULL); 11783 // empty self 11784 freeO(self); 11785 r = colordO(self, RED); 11786 ck_assert_ptr_eq(r, NULL); 11787 terminateO(self); 11788 11789 } 11790 11791 11792 void readFileSmallStringT(CuTest *tc UNUSED) { 11793 11794 smallStringt* r; 11795 smallStringt *self = allocG(""); 11796 11797 // text 11798 r = readFileO(self, "../textTest.null"); 11799 ck_assert_ptr_ne(r, null); 11800 char *s = toStringO(r); 11801 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 11802 free(s); 11803 // empty text 11804 r = readFileO(self, "../chmodTest.null"); 11805 ck_assert_ptr_ne(r, null); 11806 s = toStringO(r); 11807 ck_assert_str_eq(s, ""); 11808 free(s); 11809 fileChmod("../writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH); 11810 ck_assert_ptr_eq(readFileO(self, "../writeOnlyText.null"), NULL); 11811 fileChmod("../writeOnlyText.null", S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH); 11812 // blank path 11813 ck_assert_ptr_eq(readFileO(self, ""), NULL); 11814 // NULL path 11815 ck_assert_ptr_eq(readFileO(self, NULL), NULL); 11816 // non existing path 11817 if (fileExists("nonExistingFile")) 11818 rmAll("nonExistingFile"); 11819 ck_assert_ptr_eq(readFileO(self, "nonExistingFile"), NULL); 11820 terminateO(self); 11821 11822 } 11823 11824 11825 void readFileSmallJsonSmallStringT(CuTest *tc UNUSED) { 11826 11827 smallStringt* r; 11828 smallStringt *self = allocG(""); 11829 smallJsont *filePath = allocSmallJson(); 11830 11831 // text 11832 setTopSO(filePath, "../textTest.null"); 11833 r = self->f->readFileSmallJson(self, filePath); 11834 ck_assert_ptr_ne(r, null); 11835 char *s = toStringO(r); 11836 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 11837 free(s); 11838 // empty text 11839 freeO(filePath); 11840 setTopSO(filePath, "../chmodTest.null"); 11841 r = self->f->readFileSmallJson(self, filePath); 11842 ck_assert_ptr_ne(r, null); 11843 s = toStringO(r); 11844 ck_assert_str_eq(s, ""); 11845 free(s); 11846 freeO(filePath); 11847 fileChmod("../writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH); 11848 setTopSO(filePath, "../writeOnlyText.null"); 11849 ck_assert_ptr_eq(self->f->readFileSmallJson(self, filePath), NULL); 11850 fileChmod("../writeOnlyText.null", S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH); 11851 // blank path 11852 freeO(filePath); 11853 setTopSO(filePath, ""); 11854 ck_assert_ptr_eq(self->f->readFileSmallJson(self, filePath), NULL); 11855 // non json string 11856 freeO(filePath); 11857 ck_assert_ptr_eq(self->f->readFileSmallJson(self, filePath), NULL); 11858 // non json object 11859 terminateO(filePath); 11860 filePath = (smallJsont*) allocSmallInt(1); 11861 ck_assert_ptr_eq(self->f->readFileSmallJson(self, filePath), NULL); 11862 terminateO(filePath); 11863 // NULL path 11864 ck_assert_ptr_eq(self->f->readFileSmallJson(self, NULL), NULL); 11865 // non existing path 11866 if (fileExists("nonExistingFile")) 11867 rmAll("nonExistingFile"); 11868 filePath = allocSmallJson(); 11869 setTopSO(filePath, "nonExistingFile"); 11870 ck_assert_ptr_eq(self->f->readFileSmallJson(self, filePath), NULL); 11871 terminateO(filePath); 11872 terminateO(self); 11873 11874 } 11875 11876 11877 void readFileSmallStringSmallStringT(CuTest *tc UNUSED) { 11878 11879 smallStringt* r; 11880 smallStringt *self = allocG(""); 11881 smallStringt *filePath = allocSmallString(""); 11882 11883 // text 11884 setValO(filePath, "../textTest.null"); 11885 r = self->f->readFileSmallString(self, filePath); 11886 ck_assert_ptr_ne(r, null); 11887 char *s = toStringO(r); 11888 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 11889 free(s); 11890 // empty text 11891 setValO(filePath, "../chmodTest.null"); 11892 r = self->f->readFileSmallString(self, filePath); 11893 ck_assert_ptr_ne(r, null); 11894 s = toStringO(r); 11895 ck_assert_str_eq(s, ""); 11896 free(s); 11897 fileChmod("../writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH); 11898 setValO(filePath, "../writeOnlyText.null"); 11899 ck_assert_ptr_eq(self->f->readFileSmallString(self, filePath), NULL); 11900 fileChmod("../writeOnlyText.null", S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH); 11901 // blank path 11902 setValO(filePath, ""); 11903 ck_assert_ptr_eq(self->f->readFileSmallString(self, filePath), NULL); 11904 // non empty filePath 11905 freeO(filePath); 11906 ck_assert_ptr_eq(self->f->readFileSmallString(self, filePath), NULL); 11907 // non smallString object 11908 terminateO(filePath); 11909 filePath = (smallStringt*) allocSmallInt(1); 11910 ck_assert_ptr_eq(self->f->readFileSmallString(self, filePath), NULL); 11911 terminateO(filePath); 11912 // NULL path 11913 ck_assert_ptr_eq(self->f->readFileSmallString(self, NULL), NULL); 11914 // non existing path 11915 if (fileExists("nonExistingFile")) 11916 rmAll("nonExistingFile"); 11917 filePath = allocSmallString("nonExistingFile"); 11918 ck_assert_ptr_eq(self->f->readFileSmallString(self, filePath), NULL); 11919 terminateO(filePath); 11920 terminateO(self); 11921 11922 } 11923 11924 11925 void readStreamSmallStringT(CuTest *tc UNUSED) { 11926 11927 smallStringt* r; 11928 smallStringt *self = allocG(""); 11929 FILE *f; 11930 11931 // text 11932 f = fopen("../textTest.null", "r"); 11933 r = readStreamO(self, f); 11934 ck_assert_ptr_ne(r, null); 11935 char *s = toStringO(r); 11936 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 11937 free(s); 11938 fclose(f); 11939 // empty text 11940 f = fopen("../chmodTest.null", "r"); 11941 r = readStreamO(self, f); 11942 ck_assert_ptr_ne(r, null); 11943 s = toStringO(r); 11944 ck_assert_str_eq(s, ""); 11945 free(s); 11946 fclose(f); 11947 // null file 11948 ck_assert_ptr_eq(readStreamO(self, null), null); 11949 terminateO(self); 11950 11951 } 11952 11953 11954 void writeFileSmallStringT(CuTest *tc UNUSED) { 11955 11956 int r; 11957 smallStringt *self = allocG(""); 11958 11959 // write textOutTest.null 11960 readFileO(self, "../textTest.null"); 11961 r = writeFileO(self, "textOutTest.null"); 11962 ck_assert(r); 11963 // check textOutTest.null 11964 freeO(self); 11965 readFileO(self, "textOutTest.null"); 11966 ck_assert_uint_eq(lenO(self),20); 11967 char *s = toStringO(self); 11968 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 11969 free(s); 11970 // non existing file 11971 // make sure the file doesnt exist 11972 if (fileExists("nonExistingFile")) 11973 rmAll("nonExistingFile"); 11974 ck_assert(writeFileO(self, "nonExistingFile")); 11975 if (fileExists("nonExistingFile")) 11976 rmAll("nonExistingFile"); 11977 // blank file name 11978 ck_assert(!writeFileO(self, " ")); 11979 // read only path 11980 ck_assert(!writeFileO(self, "/nonExistingFile")); 11981 // NULL path 11982 ck_assert(!writeFileO(self, NULL)); 11983 // NULL string 11984 freeO(self); 11985 ck_assert(!writeFileO(self, "a")); 11986 terminateO(self); 11987 11988 } 11989 11990 11991 void writeFileSmallJsonSmallStringT(CuTest *tc UNUSED) { 11992 11993 int r; 11994 smallStringt *self = allocG(""); 11995 smallJsont *filePath = allocSmallJson(); 11996 11997 // write textOutTest.null 11998 setTopSO(filePath, "textOutTest.null"); 11999 readFileO(self, "../textTest.null"); 12000 r = self->f->writeFileSmallJson(self, filePath); 12001 ck_assert(r); 12002 // check textOutTest.null 12003 freeO(self); 12004 readFileO(self, "textOutTest.null"); 12005 ck_assert_uint_eq(lenO(self),20); 12006 char *s = toStringO(self); 12007 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 12008 free(s); 12009 // non existing file 12010 // make sure the file doesnt exist 12011 if (fileExists("nonExistingFile")) 12012 rmAll("nonExistingFile"); 12013 freeO(filePath); 12014 setTopSO(filePath, "textOutTest.null"); 12015 ck_assert(self->f->writeFileSmallJson(self, filePath)); 12016 if (fileExists("nonExistingFile")) 12017 rmAll("nonExistingFile"); 12018 // blank file name 12019 freeO(filePath); 12020 setTopSO(filePath, " "); 12021 ck_assert(!self->f->writeFileSmallJson(self, filePath)); 12022 // read only path 12023 freeO(filePath); 12024 setTopSO(filePath, "/nonExistingFile"); 12025 ck_assert(!self->f->writeFileSmallJson(self, filePath)); 12026 // non json string 12027 freeO(filePath); 12028 ck_assert(!self->f->writeFileSmallJson(self, filePath)); 12029 // non json object 12030 terminateO(filePath); 12031 filePath = (smallJsont*) allocSmallInt(1); 12032 ck_assert(!self->f->writeFileSmallJson(self, filePath)); 12033 terminateO(filePath); 12034 // NULL path 12035 ck_assert(!self->f->writeFileSmallJson(self, NULL)); 12036 // NULL string 12037 freeO(self); 12038 filePath = allocSmallJson(); 12039 setTopSO(filePath, "a"); 12040 ck_assert(!self->f->writeFileSmallJson(self, filePath)); 12041 terminateO(filePath); 12042 terminateO(self); 12043 12044 } 12045 12046 12047 void writeFileSmallStringSmallStringT(CuTest *tc UNUSED) { 12048 12049 int r; 12050 smallStringt *self = allocG(""); 12051 smallStringt *filePath = allocSmallString(""); 12052 12053 // write textOutTest.null 12054 setValO(filePath, "textOutTest.null"); 12055 readFileO(self, "../textTest.null"); 12056 r = self->f->writeFileSmallString(self, filePath); 12057 ck_assert(r); 12058 // check textOutTest.null 12059 freeO(self); 12060 readFileO(self, "textOutTest.null"); 12061 ck_assert_uint_eq(lenO(self),20); 12062 char *s = toStringO(self); 12063 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 12064 free(s); 12065 // non existing file 12066 // make sure the file doesnt exist 12067 if (fileExists("nonExistingFile")) 12068 rmAll("nonExistingFile"); 12069 setValO(filePath, "textOutTest.null"); 12070 ck_assert(self->f->writeFileSmallString(self, filePath)); 12071 if (fileExists("nonExistingFile")) 12072 rmAll("nonExistingFile"); 12073 // blank file name 12074 setValO(filePath, " "); 12075 ck_assert(!self->f->writeFileSmallString(self, filePath)); 12076 // read only path 12077 setValO(filePath, "/nonExistingFile"); 12078 ck_assert(!self->f->writeFileSmallString(self, filePath)); 12079 // non smallString object 12080 terminateO(filePath); 12081 filePath = (smallStringt*) allocSmallInt(1); 12082 ck_assert(!self->f->writeFileSmallString(self, filePath)); 12083 terminateO(filePath); 12084 // NULL path 12085 ck_assert(!self->f->writeFileSmallString(self, NULL)); 12086 // NULL string 12087 freeO(self); 12088 filePath = allocSmallString("a"); 12089 ck_assert(!self->f->writeFileSmallString(self, filePath)); 12090 terminateO(filePath); 12091 terminateO(self); 12092 12093 } 12094 12095 12096 void writeStreamSmallStringT(CuTest *tc UNUSED) { 12097 12098 int r; 12099 smallStringt *self = allocG(""); 12100 FILE *f; 12101 12102 // write textOutTest.null 12103 readFileO(self, "../textTest.null"); 12104 f = fopen("textOutTest.null", "w"); 12105 r = writeStreamO(self, f); 12106 ck_assert(r); 12107 fclose(f); 12108 // check textOutTest.null 12109 freeO(self); 12110 readFileO(self, "textOutTest.null"); 12111 ck_assert_uint_eq(lenO(self),20); 12112 ck_assert_str_eq(ssGet(self), "LINE 1\nANOTHER line\n"); 12113 // NULL file 12114 setValO(self, "qwe"); 12115 ck_assert(!writeStreamO(self, NULL)); 12116 // NULL string 12117 freeO(self); 12118 ck_assert(!writeStreamO(self, f)); 12119 terminateO(self); 12120 12121 } 12122 12123 12124 void appendFileSmallStringT(CuTest *tc UNUSED) { 12125 12126 int r; 12127 smallStringt *self = allocG(""); 12128 12129 // write textOutTest.null 12130 setValO(self, "appended line\n"); 12131 r = appendFileO(self, "appendTextOutTest.null"); 12132 ck_assert(r); 12133 setValO(self, "appended line 2\n"); 12134 r = appendFileO(self, "appendTextOutTest.null"); 12135 ck_assert(r); 12136 // check textOutTest.null 12137 freeO(self); 12138 readFileO(self, "appendTextOutTest.null"); 12139 ck_assert_uint_eq(lenO(self),30); 12140 ck_assert_str_eq(ssGet(self), "appended line\nappended line 2\n"); 12141 if (fileExists("appendTextOutTest.null")) 12142 rmAll("appendTextOutTest.null"); 12143 // blank file name 12144 ck_assert(!appendFileO(self, " ")); 12145 // read only path 12146 ck_assert(!appendFileO(self, "/nonExistingFile")); 12147 // NULL path 12148 ck_assert(!appendFileO(self, NULL)); 12149 // NULL string 12150 freeO(self); 12151 ck_assert(!appendFileO(self, "a")); 12152 terminateO(self); 12153 12154 } 12155 12156 12157 void appendFileSmallStringSmallStringT(CuTest *tc UNUSED) { 12158 12159 int r; 12160 smallStringt *self = allocG(""); 12161 smallStringt *filePath = allocSmallString(""); 12162 12163 // write textOutTest.null 12164 setValO(self, "appended line\n"); 12165 setValO(filePath, "appendTextOutTest.null"); 12166 r = appendFileSmallStringO(self, filePath); 12167 ck_assert(r); 12168 setValO(self, "appended line 2\n"); 12169 r = appendFileSmallStringO(self, filePath); 12170 ck_assert(r); 12171 // check textOutTest.null 12172 freeO(self); 12173 readFileO(self, "appendTextOutTest.null"); 12174 ck_assert_uint_eq(lenO(self),30); 12175 ck_assert_str_eq(ssGet(self), "appended line\nappended line 2\n"); 12176 if (fileExists("appendTextOutTest.null")) 12177 rmAll("appendTextOutTest.null"); 12178 // blank file name 12179 setValO(filePath, " "); 12180 ck_assert(!appendFileSmallStringO(self, filePath)); 12181 // read only path 12182 setValO(filePath, "/nonExistingFile"); 12183 ck_assert(!appendFileSmallStringO(self, filePath)); 12184 // non smallString path 12185 terminateO(filePath); 12186 filePath = (smallStringt*) allocSmallInt(1); 12187 ck_assert(!appendFileSmallStringO(self, filePath)); 12188 terminateO(filePath); 12189 // NULL path 12190 ck_assert(!appendFileSmallStringO(self, NULL)); 12191 // NULL string 12192 freeO(self); 12193 filePath = allocSmallString("a"); 12194 ck_assert(!appendFileSmallStringO(self, filePath)); 12195 terminateO(filePath); 12196 terminateO(self); 12197 12198 } 12199 12200 12201 void duplicateSmallStringGT(CuTest *tc UNUSED) { 12202 12203 smallStringt* r; 12204 smallStringt *self = allocG("qwe"); 12205 12206 r = duplicateSmallStringG(self); 12207 ck_assert_ptr_ne(r, null); 12208 ck_assert_str_eq(ssGet(r), ssGet(self)); 12209 terminateO(r); 12210 terminateO(self); 12211 12212 } 12213 12214 12215 void freeSmallStringGT(CuTest *tc UNUSED) { 12216 12217 smallStringt *self = allocG(""); 12218 12219 freeSmallStringG(self); 12220 ck_assert_ptr_eq(self->data, null); 12221 terminateO(self); 12222 12223 } 12224 12225 12226 void setBoolSmallStringGT(CuTest *tc UNUSED) { 12227 12228 smallStringt* r; 12229 smallStringt* self = allocG(""); 12230 12231 r = setBoolSmallStringG(self, false); 12232 ck_assert_ptr_ne(r, null); 12233 char *s = toStringO(r); 12234 ck_assert_str_eq(s, "false"); 12235 free(s); 12236 terminateO(self); 12237 12238 } 12239 12240 12241 void setDoubleSmallStringGT(CuTest *tc UNUSED) { 12242 12243 smallStringt* r; 12244 smallStringt* self = allocG(""); 12245 12246 r = setDoubleSmallStringG(self, 2.2); 12247 ck_assert_ptr_ne(r, null); 12248 char *s = toStringO(r); 12249 ck_assert_str_eq(s, "2.200000e+00"); 12250 free(s); 12251 terminateO(self); 12252 12253 } 12254 12255 12256 void setInt64SmallStringGT(CuTest *tc UNUSED) { 12257 12258 smallStringt* r; 12259 smallStringt* self = allocG(""); 12260 12261 r = setInt64SmallStringG(self, 2); 12262 ck_assert_ptr_ne(r, null); 12263 char *s = toStringO(r); 12264 ck_assert_str_eq(s, "2"); 12265 free(s); 12266 terminateO(self); 12267 12268 } 12269 12270 12271 void setInt32SmallStringGT(CuTest *tc UNUSED) { 12272 12273 smallStringt* r; 12274 smallStringt* self = allocG(""); 12275 12276 r = setInt32SmallStringG(self, 2); 12277 ck_assert_ptr_ne(r, null); 12278 char *s = toStringO(r); 12279 ck_assert_str_eq(s, "2"); 12280 free(s); 12281 terminateO(self); 12282 12283 } 12284 12285 12286 void setUint32SmallStringGT(CuTest *tc UNUSED) { 12287 12288 smallStringt* r; 12289 smallStringt* self = allocG(""); 12290 12291 r = setUint32SmallStringG(self, 2); 12292 ck_assert_ptr_ne(r, null); 12293 char *s = toStringO(r); 12294 ck_assert_str_eq(s, "2"); 12295 free(s); 12296 terminateO(self); 12297 12298 } 12299 12300 12301 void setUint64SmallStringGT(CuTest *tc UNUSED) { 12302 12303 smallStringt* r; 12304 smallStringt* self = allocG(""); 12305 12306 r = setUint64SmallStringG(self, 2); 12307 ck_assert_ptr_ne(r, null); 12308 char *s = toStringO(r); 12309 ck_assert_str_eq(s, "2"); 12310 free(s); 12311 terminateO(self); 12312 12313 } 12314 12315 12316 void setSmallStringGT(CuTest *tc UNUSED) { 12317 12318 smallStringt* r; 12319 smallStringt* self = allocG(""); 12320 12321 r = setSmallStringG(self, "qwe"); 12322 ck_assert_ptr_ne(r, null); 12323 char *s = toStringO(r); 12324 ck_assert_str_eq(s, "qwe"); 12325 free(s); 12326 terminateO(self); 12327 12328 } 12329 12330 12331 void setCharSmallStringGT(CuTest *tc UNUSED) { 12332 12333 smallStringt* r; 12334 smallStringt *self = allocG(""); 12335 12336 r = setCharSmallStringG(self, 'q'); 12337 ck_assert_ptr_ne(r, null); 12338 char *s = toStringO(r); 12339 ck_assert_str_eq(s, "q"); 12340 free(s); 12341 terminateO(self); 12342 12343 } 12344 12345 12346 void setSmallArraySmallStringGT(CuTest *tc UNUSED) { 12347 12348 smallStringt* r; 12349 smallStringt* self = allocG(""); 12350 smallArrayt* p2 = allocSmallArray(); 12351 12352 p2->f->pushS(p2, "asd"); 12353 r = setSmallArraySmallStringG(self, p2); 12354 ck_assert_ptr_ne(r, null); 12355 char *s = toStringO(r); 12356 ck_assert_str_eq(s, "[\"asd\"]"); 12357 free(s); 12358 terminateO(p2); 12359 terminateO(self); 12360 12361 } 12362 12363 12364 void setFromSmallDictSmallStringGT(CuTest *tc UNUSED) { 12365 12366 smallStringt* r; 12367 smallStringt* self = allocG(""); 12368 smallDictt* p2 = allocSmallDict(); 12369 12370 p2->f->setS(p2, "1", "asd"); 12371 r = setFromSmallDictSmallStringG(self, p2); 12372 ck_assert_ptr_ne(r, null); 12373 char *s = toStringO(r); 12374 ck_assert_str_eq(s, "{\"1\":\"asd\"}"); 12375 free(s); 12376 terminateO(p2); 12377 terminateO(self); 12378 12379 } 12380 12381 12382 void setFromSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12383 12384 smallStringt* r; 12385 smallStringt* self = allocG(""); 12386 smallJsont* p2 = allocSmallJson(); 12387 12388 p2->f->setS(p2, "1", "asd"); 12389 r = setFromSmallJsonSmallStringG(self, p2); 12390 ck_assert_ptr_ne(r, null); 12391 char *s = toStringO(r); 12392 ck_assert_str_eq(s, "{\"1\":\"asd\"}"); 12393 free(s); 12394 terminateO(p2); 12395 terminateO(self); 12396 12397 } 12398 12399 12400 void setSmallBoolSmallStringGT(CuTest *tc UNUSED) { 12401 12402 smallStringt* r; 12403 smallStringt* self = allocG(""); 12404 smallBoolt* p2 = allocSmallBool(true); 12405 12406 r = setSmallBoolSmallStringG(self, p2); 12407 ck_assert_ptr_ne(r, null); 12408 char *s = toStringO(r); 12409 ck_assert_str_eq(s, "true"); 12410 free(s); 12411 terminateO(p2); 12412 terminateO(self); 12413 12414 } 12415 12416 12417 void setSmallDoubleSmallStringGT(CuTest *tc UNUSED) { 12418 12419 smallStringt* r; 12420 smallStringt* self = allocG(""); 12421 smallDoublet* p2 = allocSmallDouble(2.2); 12422 12423 r = setSmallDoubleSmallStringG(self, p2); 12424 ck_assert_ptr_ne(r, null); 12425 char *s = toStringO(r); 12426 ck_assert_str_eq(s, "2.200000e+00"); 12427 free(s); 12428 terminateO(p2); 12429 terminateO(self); 12430 12431 } 12432 12433 12434 void setSmallIntSmallStringGT(CuTest *tc UNUSED) { 12435 12436 smallStringt* r; 12437 smallStringt* self = allocG(""); 12438 smallIntt* p2 = allocSmallInt(2); 12439 12440 r = setSmallIntSmallStringG(self, p2); 12441 ck_assert_ptr_ne(r, null); 12442 char *s = toStringO(r); 12443 ck_assert_str_eq(s, "2"); 12444 free(s); 12445 terminateO(p2); 12446 terminateO(self); 12447 12448 } 12449 12450 12451 void setSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12452 12453 smallStringt* r; 12454 smallStringt* self = allocG(""); 12455 smallJsont* p2 = allocSmallJson(); 12456 12457 setTopBoolO(p2, true); 12458 r = setSmallJsonSmallStringG(self, p2); 12459 ck_assert_ptr_ne(r, null); 12460 char *s = toStringO(r); 12461 ck_assert_str_eq(s, "true"); 12462 free(s); 12463 terminateO(p2); 12464 terminateO(self); 12465 12466 } 12467 12468 12469 void setSmallStringSmallStringGT(CuTest *tc UNUSED) { 12470 12471 smallStringt* r; 12472 smallStringt* self = allocG(""); 12473 smallStringt* p2 = allocSmallString("qwe"); 12474 12475 r = setSmallStringSmallStringG(self, p2); 12476 ck_assert_ptr_ne(r, null); 12477 char *s = toStringO(r); 12478 ck_assert_str_eq(s, "qwe"); 12479 free(s); 12480 terminateO(p2); 12481 terminateO(self); 12482 12483 } 12484 12485 12486 void getAtSmallStringGT(CuTest *tc UNUSED) { 12487 12488 smallStringt *self = allocG(""); 12489 12490 setValO(self, "sheepy"); 12491 ck_assert_uint_eq(getAtSmallStringG(self, 0, 0), 's'); 12492 terminateO(self); 12493 12494 } 12495 12496 12497 void setAtSmallStringGT(CuTest *tc UNUSED) { 12498 12499 smallStringt* r; 12500 smallStringt *self = allocG("a"); 12501 12502 r = setAtSmallStringG(self, 0, 'S'); 12503 ck_assert_ptr_ne(r, null); 12504 ck_assert_uint_eq(ssGet(self)[0], 'S'); 12505 terminateO(self); 12506 12507 } 12508 12509 12510 void appendSmallStringGT(CuTest *tc UNUSED) { 12511 12512 smallStringt* r; 12513 smallStringt *self = allocG("qwe"); 12514 smallStringt *string = allocSmallString("!@#"); 12515 12516 r = appendSmallStringG(self, string); 12517 ck_assert_ptr_ne(r, null); 12518 char *s = toStringO(r); 12519 ck_assert_str_eq(s, "qwe!@#"); 12520 free(s); 12521 terminateO(string); 12522 terminateO(self); 12523 12524 } 12525 12526 12527 void appendSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12528 12529 smallStringt* r; 12530 smallStringt *self = allocG("qwe"); 12531 smallJsont *string = allocSmallJson(); 12532 12533 setTopSO(string, "!@#"); 12534 r = appendSmallJsonSmallStringG(self, string); 12535 ck_assert_ptr_ne(r, null); 12536 char *s = toStringO(r); 12537 ck_assert_str_eq(s, "qwe!@#"); 12538 free(s); 12539 terminateO(string); 12540 terminateO(self); 12541 12542 } 12543 12544 12545 void appendSSmallStringGT(CuTest *tc UNUSED) { 12546 12547 smallStringt* r; 12548 smallStringt *self = allocG("qwe"); 12549 12550 r = appendSSmallStringG(self, "!@#"); 12551 ck_assert_ptr_ne(r, null); 12552 char *s = toStringO(r); 12553 ck_assert_str_eq(s, "qwe!@#"); 12554 free(s); 12555 terminateO(self); 12556 12557 } 12558 12559 12560 void appendCharSmallStringGT(CuTest *tc UNUSED) { 12561 12562 smallStringt* r; 12563 smallStringt *self = allocG("qwe"); 12564 12565 r = appendCharSmallStringG(self, '!'); 12566 ck_assert_ptr_ne(r, null); 12567 char *s = toStringO(r); 12568 ck_assert_str_eq(s, "qwe!"); 12569 free(s); 12570 terminateO(self); 12571 12572 } 12573 12574 12575 void appendNSmashSmallStringGT(CuTest *tc UNUSED) { 12576 12577 smallStringt* r; 12578 smallStringt *self = allocG("qwe"); 12579 smallStringt *string = allocSmallString("!@#"); 12580 12581 r = appendNSmashSmallStringG(self, string); 12582 ck_assert_ptr_ne(r, null); 12583 char *s = toStringO(r); 12584 ck_assert_str_eq(s, "qwe!@#"); 12585 free(s); 12586 terminateO(self); 12587 12588 } 12589 12590 12591 void appendNSmashSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12592 12593 smallStringt* r; 12594 smallStringt *self = allocG("qwe"); 12595 smallJsont *string = allocSmallJson(); 12596 12597 setTopSO(string, "!@#"); 12598 r = appendNSmashSmallJsonSmallStringG(self, string); 12599 ck_assert_ptr_ne(r, null); 12600 char *s = toStringO(r); 12601 ck_assert_str_eq(s, "qwe!@#"); 12602 free(s); 12603 terminateO(self); 12604 12605 } 12606 12607 12608 void appendNSmashSSmallStringGT(CuTest *tc UNUSED) { 12609 12610 smallStringt* r; 12611 smallStringt *self = allocG("qwe"); 12612 12613 r = appendNSmashSSmallStringG(self, strdup("!@#")); 12614 ck_assert_ptr_ne(r, null); 12615 char *s = toStringO(r); 12616 ck_assert_str_eq(s, "qwe!@#"); 12617 free(s); 12618 terminateO(self); 12619 12620 } 12621 12622 12623 void prependSmallStringGT(CuTest *tc UNUSED) { 12624 12625 smallStringt* r; 12626 smallStringt *self = allocG("qwe"); 12627 smallStringt *string = allocSmallString("!@#"); 12628 12629 r = prependSmallStringG(self, string); 12630 ck_assert_ptr_ne(r, null); 12631 char *s = toStringO(r); 12632 ck_assert_str_eq(s, "!@#qwe"); 12633 free(s); 12634 terminateO(string); 12635 terminateO(self); 12636 12637 } 12638 12639 12640 void prependSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12641 12642 smallStringt* r; 12643 smallStringt *self = allocG("qwe"); 12644 smallJsont *string = allocSmallJson(); 12645 12646 setTopSO(string, "!@#"); 12647 r = prependSmallJsonSmallStringG(self, string); 12648 ck_assert_ptr_ne(r, null); 12649 char *s = toStringO(r); 12650 ck_assert_str_eq(s, "!@#qwe"); 12651 free(s); 12652 terminateO(string); 12653 terminateO(self); 12654 12655 } 12656 12657 12658 void prependSSmallStringGT(CuTest *tc UNUSED) { 12659 12660 smallStringt* r; 12661 smallStringt *self = allocG("qwe"); 12662 12663 r = prependSSmallStringG(self, "!@#"); 12664 ck_assert_ptr_ne(r, null); 12665 char *s = toStringO(r); 12666 ck_assert_str_eq(s, "!@#qwe"); 12667 free(s); 12668 terminateO(self); 12669 12670 } 12671 12672 12673 void prependCharSmallStringGT(CuTest *tc UNUSED) { 12674 12675 smallStringt* r; 12676 smallStringt *self = allocG("qwe"); 12677 12678 r = prependCharSmallStringG(self, '!'); 12679 ck_assert_ptr_ne(r, null); 12680 char *s = toStringO(r); 12681 ck_assert_str_eq(s, "!qwe"); 12682 free(s); 12683 terminateO(self); 12684 12685 } 12686 12687 12688 void prependNSmashSmallStringGT(CuTest *tc UNUSED) { 12689 12690 smallStringt* r; 12691 smallStringt *self = allocG("qwe"); 12692 smallStringt *string = allocSmallString("!@#"); 12693 12694 r = prependNSmashSmallStringG(self, string); 12695 ck_assert_ptr_ne(r, null); 12696 char *s = toStringO(r); 12697 ck_assert_str_eq(s, "!@#qwe"); 12698 free(s); 12699 terminateO(self); 12700 12701 } 12702 12703 12704 void prependNSmashSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12705 12706 smallStringt* r; 12707 smallStringt *self = allocG("qwe"); 12708 smallJsont *string = allocSmallJson(); 12709 12710 setTopSO(string, "!@#"); 12711 r = prependNSmashSmallJsonSmallStringG(self, string); 12712 ck_assert_ptr_ne(r, null); 12713 char *s = toStringO(r); 12714 ck_assert_str_eq(s, "!@#qwe"); 12715 free(s); 12716 terminateO(self); 12717 12718 } 12719 12720 12721 void prependNSmashSSmallStringGT(CuTest *tc UNUSED) { 12722 12723 smallStringt* r; 12724 smallStringt *self = allocG("qwe"); 12725 12726 r = prependNSmashSSmallStringG(self, strdup("!@#")); 12727 ck_assert_ptr_ne(r, null); 12728 char *s = toStringO(r); 12729 ck_assert_str_eq(s, "!@#qwe"); 12730 free(s); 12731 terminateO(self); 12732 12733 } 12734 12735 12736 void replaceSmallStringGT(CuTest *tc UNUSED) { 12737 12738 smallStringt* r; 12739 smallStringt *self = allocG("#ee#ee#ad"); 12740 12741 // replace string, multiple character new delimeter 12742 r = replaceSmallStringG(self, "#","^^", 0); 12743 ck_assert_ptr_ne(r, null); 12744 char *s = toStringO(r); 12745 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12746 free(s); 12747 terminateO(self); 12748 12749 } 12750 12751 12752 void replaceCharSSmallStringGT(CuTest *tc UNUSED) { 12753 12754 smallStringt* r; 12755 smallStringt *self = allocG(""); 12756 12757 // replace string, multiple character new delimeter 12758 setValO(self, "#ee#ee#ad"); 12759 r = replaceCharSSmallStringG(self, '#',"^^", 0); 12760 ck_assert_ptr_ne(r, null); 12761 char *s = toStringO(r); 12762 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12763 free(s); 12764 terminateO(self); 12765 12766 } 12767 12768 12769 void replaceSCharSmallStringGT(CuTest *tc UNUSED) { 12770 12771 smallStringt* r; 12772 smallStringt *self = allocG(""); 12773 12774 // replace string, multiple character new delimeter 12775 setValO(self, "#ee#ee#ad"); 12776 r = replaceSCharSmallStringG(self, "#",'^',0); 12777 ck_assert_ptr_ne(r, null); 12778 char *s = toStringO(r); 12779 ck_assert_str_eq(s, "^ee^ee^ad"); 12780 free(s); 12781 terminateO(self); 12782 12783 } 12784 12785 12786 void replaceCharCharSmallStringGT(CuTest *tc UNUSED) { 12787 12788 smallStringt* r; 12789 smallStringt *self = allocG(""); 12790 12791 // replace string, multiple character new delimeter 12792 setValO(self, "#ee#ee#ad"); 12793 r = replaceCharCharSmallStringG(self, '#','^', 0); 12794 ck_assert_ptr_ne(r, null); 12795 char *s = toStringO(r); 12796 ck_assert_str_eq(s, "^ee^ee^ad"); 12797 free(s); 12798 terminateO(self); 12799 12800 } 12801 12802 12803 void replaceSmallJsonSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12804 12805 smallStringt* r; 12806 smallStringt *self = allocG("#ee#ee#ad"); 12807 smallJsont *olds = allocSmallJson(); 12808 smallJsont *news = allocSmallJson(); 12809 12810 // replace string, multiple character new delimeter 12811 freeO(olds); 12812 freeO(news); 12813 setTopSO(olds, "#"); 12814 setTopSO(news, "^^"); 12815 r = replaceSmallJsonSmallJsonSmallStringG(self, olds, news, 0); 12816 ck_assert_ptr_ne(r, null); 12817 char *s = toStringO(r); 12818 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12819 free(s); 12820 terminateO(olds); 12821 terminateO(news); 12822 terminateO(self); 12823 12824 } 12825 12826 12827 void replaceSmallJsonSmallStringSmallStringGT(CuTest *tc UNUSED) { 12828 12829 smallStringt* r; 12830 smallStringt *self = allocG("#ee#ee#ad"); 12831 smallJsont *olds = allocSmallJson(); 12832 smallStringt *news = allocSmallString(""); 12833 12834 // replace string, multiple character new delimeter 12835 freeO(olds); 12836 setTopSO(olds, "#"); 12837 setValO(news, "^^"); 12838 r = replaceSmallJsonSmallStringSmallStringG(self, olds, news, 0); 12839 ck_assert_ptr_ne(r, null); 12840 char *s = toStringO(r); 12841 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12842 free(s); 12843 terminateO(olds); 12844 terminateO(news); 12845 terminateO(self); 12846 12847 } 12848 12849 12850 void replaceSmallJsonSSmallStringGT(CuTest *tc UNUSED) { 12851 12852 smallStringt* r; 12853 smallStringt *self = allocG("#ee#ee#ad"); 12854 smallJsont *olds = allocSmallJson(); 12855 const char *news; 12856 12857 // replace string, multiple character new delimeter 12858 freeO(olds); 12859 setTopSO(olds, "#"); 12860 news = "^^"; 12861 r = replaceSmallJsonSSmallStringG(self, olds, news, 0); 12862 ck_assert_ptr_ne(r, null); 12863 char *s = toStringO(r); 12864 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12865 free(s); 12866 terminateO(olds); 12867 terminateO(self); 12868 12869 } 12870 12871 12872 void replaceSmallJsonCharSmallStringGT(CuTest *tc UNUSED) { 12873 12874 smallStringt* r; 12875 smallStringt *self = allocG("#ee#ee#ad"); 12876 smallJsont *olds = allocSmallJson(); 12877 char news; 12878 12879 // replace string, multiple character new delimeter 12880 freeO(olds); 12881 setTopSO(olds, "#"); 12882 news = '^'; 12883 r = replaceSmallJsonCharSmallStringG(self, olds, news, 0); 12884 ck_assert_ptr_ne(r, null); 12885 char *s = toStringO(r); 12886 ck_assert_str_eq(s, "^ee^ee^ad"); 12887 free(s); 12888 terminateO(olds); 12889 terminateO(self); 12890 12891 } 12892 12893 12894 void replaceSmallStringSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12895 12896 smallStringt* r; 12897 smallStringt *self = allocG("#ee#ee#ad"); 12898 smallStringt *olds = allocSmallString(""); 12899 smallJsont *news = allocSmallJson(); 12900 12901 // replace string, multiple character new delimeter 12902 freeO(news); 12903 setValO(olds, "#"); 12904 setTopSO(news, "^^"); 12905 r = replaceSmallStringSmallJsonSmallStringG(self, olds, news, 0); 12906 ck_assert_ptr_ne(r, null); 12907 char *s = toStringO(r); 12908 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12909 free(s); 12910 terminateO(olds); 12911 terminateO(news); 12912 terminateO(self); 12913 12914 } 12915 12916 12917 void replaceSmallStringSmallStringSmallStringGT(CuTest *tc UNUSED) { 12918 12919 smallStringt* r; 12920 smallStringt *self = allocG("#ee#ee#ad"); 12921 smallStringt *olds = allocSmallString(""); 12922 smallStringt *news = allocSmallString(""); 12923 12924 // replace string, multiple character new delimeter 12925 setValO(olds, "#"); 12926 setValO(news, "^^"); 12927 r = replaceSmallStringSmallStringSmallStringG(self, olds, news, 0); 12928 ck_assert_ptr_ne(r, null); 12929 char *s = toStringO(r); 12930 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12931 free(s); 12932 terminateO(olds); 12933 terminateO(news); 12934 terminateO(self); 12935 12936 } 12937 12938 12939 void replaceSmallStringSSmallStringGT(CuTest *tc UNUSED) { 12940 12941 smallStringt* r; 12942 smallStringt *self = allocG("#ee#ee#ad"); 12943 smallStringt *olds = allocSmallString(""); 12944 const char *news; 12945 12946 // replace string, multiple character new delimeter 12947 setValO(olds, "#"); 12948 news = "^^"; 12949 r = replaceSmallStringSSmallStringG(self, olds, news, 0); 12950 ck_assert_ptr_ne(r, null); 12951 char *s = toStringO(r); 12952 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12953 free(s); 12954 terminateO(olds); 12955 terminateO(self); 12956 12957 } 12958 12959 12960 void replaceSmallStringCharSmallStringGT(CuTest *tc UNUSED) { 12961 12962 smallStringt* r; 12963 smallStringt *self = allocG("#ee#ee#ad"); 12964 smallStringt *olds = allocSmallString(""); 12965 char news; 12966 12967 // replace string, multiple character new delimeter 12968 setValO(olds, "#"); 12969 news = '^'; 12970 r = replaceSmallStringCharSmallStringG(self, olds, news, 0); 12971 ck_assert_ptr_ne(r, null); 12972 char *s = toStringO(r); 12973 ck_assert_str_eq(s, "^ee^ee^ad"); 12974 free(s); 12975 terminateO(olds); 12976 terminateO(self); 12977 12978 } 12979 12980 12981 void replaceSSmallJsonSmallStringGT(CuTest *tc UNUSED) { 12982 12983 smallStringt* r; 12984 smallStringt *self = allocG("#ee#ee#ad"); 12985 const char *olds; 12986 smallJsont *news = allocSmallJson(); 12987 12988 // replace string, multiple character new delimeter 12989 freeO(news); 12990 olds = "#"; 12991 setTopSO(news, "^^"); 12992 r = replaceSSmallJsonSmallStringG(self, olds, news, 0); 12993 ck_assert_ptr_ne(r, null); 12994 char *s = toStringO(r); 12995 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 12996 free(s); 12997 terminateO(news); 12998 terminateO(self); 12999 13000 } 13001 13002 13003 void replaceSSmallStringSmallStringGT(CuTest *tc UNUSED) { 13004 13005 smallStringt* r; 13006 smallStringt *self = allocG("#ee#ee#ad"); 13007 const char *olds; 13008 smallStringt *news = allocSmallString(""); 13009 13010 // replace string, multiple character new delimeter 13011 olds = "#"; 13012 setValO(news, "^^"); 13013 r = replaceSSmallStringSmallStringG(self, olds, news, 0); 13014 ck_assert_ptr_ne(r, null); 13015 char *s = toStringO(r); 13016 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13017 free(s); 13018 terminateO(news); 13019 terminateO(self); 13020 13021 } 13022 13023 13024 void replaceCharSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13025 13026 smallStringt* r; 13027 smallStringt *self = allocG("#ee#ee#ad"); 13028 char olds; 13029 smallJsont *news = allocSmallJson(); 13030 13031 // replace string, multiple character new delimeter 13032 freeO(news); 13033 olds = '#'; 13034 setTopSO(news, "^^"); 13035 r = replaceCharSmallJsonSmallStringG(self, olds, news, 0); 13036 ck_assert_ptr_ne(r, null); 13037 char *s = toStringO(r); 13038 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13039 free(s); 13040 terminateO(news); 13041 terminateO(self); 13042 13043 } 13044 13045 13046 void replaceCharSmallStringSmallStringGT(CuTest *tc UNUSED) { 13047 13048 smallStringt* r; 13049 smallStringt *self = allocG("#ee#ee#ad"); 13050 char olds; 13051 smallStringt *news = allocSmallString(""); 13052 13053 // replace string, multiple character new delimeter 13054 olds = '#'; 13055 setValO(news, "^^"); 13056 r = replaceCharSmallStringSmallStringG(self, olds, news, 0); 13057 ck_assert_ptr_ne(r, null); 13058 char *s = toStringO(r); 13059 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13060 free(s); 13061 terminateO(news); 13062 terminateO(self); 13063 13064 } 13065 13066 13067 void icReplaceSmallStringGT(CuTest *tc UNUSED) { 13068 13069 smallStringt* r; 13070 smallStringt *self = allocG("BeebeeBad"); 13071 13072 // replace string, multiple character new delimeter 13073 r = icReplaceSmallStringG(self, "b","^^", 0); 13074 ck_assert_ptr_ne(r, null); 13075 char *s = toStringO(r); 13076 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13077 free(s); 13078 terminateO(self); 13079 13080 } 13081 13082 13083 void icReplaceCharSSmallStringGT(CuTest *tc UNUSED) { 13084 13085 smallStringt* r; 13086 smallStringt *self = allocG(""); 13087 13088 // replace string, multiple character new delimeter 13089 setValO(self, "BeebeeBad"); 13090 r = icReplaceCharSSmallStringG(self, 'B',"^^", 0); 13091 ck_assert_ptr_ne(r, null); 13092 char *s = toStringO(r); 13093 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13094 free(s); 13095 terminateO(self); 13096 13097 } 13098 13099 13100 void icReplaceSCharSmallStringGT(CuTest *tc UNUSED) { 13101 13102 smallStringt* r; 13103 smallStringt *self = allocG(""); 13104 13105 // replace string, multiple character new delimeter 13106 setValO(self, "BeebeeBad"); 13107 r = icReplaceSCharSmallStringG(self, "b",'^',0); 13108 ck_assert_ptr_ne(r, null); 13109 char *s = toStringO(r); 13110 ck_assert_str_eq(s, "^ee^ee^ad"); 13111 free(s); 13112 terminateO(self); 13113 13114 } 13115 13116 13117 void icReplaceCharCharSmallStringGT(CuTest *tc UNUSED) { 13118 13119 smallStringt* r; 13120 smallStringt *self = allocG(""); 13121 13122 // replace string, multiple character new delimeter 13123 setValO(self, "beeBeebad"); 13124 r = icReplaceCharCharSmallStringG(self, 'b','^', 0); 13125 ck_assert_ptr_ne(r, null); 13126 char *s = toStringO(r); 13127 ck_assert_str_eq(s, "^ee^ee^ad"); 13128 free(s); 13129 terminateO(self); 13130 13131 } 13132 13133 13134 void icReplaceSmallJsonSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13135 13136 smallStringt* r; 13137 smallStringt *self = allocG("BeebeeBad"); 13138 smallJsont *olds = allocSmallJson(); 13139 smallJsont *news = allocSmallJson(); 13140 13141 // replace string, multiple character new delimeter 13142 freeO(olds); 13143 freeO(news); 13144 setTopSO(olds, "B"); 13145 setTopSO(news, "^^"); 13146 r = icReplaceSmallJsonSmallJsonSmallStringG(self, olds, news, 0); 13147 ck_assert_ptr_ne(r, null); 13148 char *s = toStringO(r); 13149 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13150 free(s); 13151 terminateO(olds); 13152 terminateO(news); 13153 terminateO(self); 13154 13155 } 13156 13157 13158 void icReplaceSmallJsonSmallStringSmallStringGT(CuTest *tc UNUSED) { 13159 13160 smallStringt* r; 13161 smallStringt *self = allocG("BeebeeBad"); 13162 smallJsont *olds = allocSmallJson(); 13163 smallStringt *news = allocSmallString(""); 13164 13165 // replace string, multiple character new delimeter 13166 freeO(olds); 13167 setTopSO(olds, "B"); 13168 setValO(news, "^^"); 13169 r = icReplaceSmallJsonSmallStringSmallStringG(self, olds, news, 0); 13170 ck_assert_ptr_ne(r, null); 13171 char *s = toStringO(r); 13172 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13173 free(s); 13174 terminateO(olds); 13175 terminateO(news); 13176 terminateO(self); 13177 13178 } 13179 13180 13181 void icReplaceSmallJsonSSmallStringGT(CuTest *tc UNUSED) { 13182 13183 smallStringt* r; 13184 smallStringt *self = allocG("BeebeeBad"); 13185 smallJsont *olds = allocSmallJson(); 13186 const char *news; 13187 13188 // replace string, multiple character new delimeter 13189 freeO(olds); 13190 setTopSO(olds, "b"); 13191 news = "^^"; 13192 r = icReplaceSmallJsonSSmallStringG(self, olds, news, 0); 13193 ck_assert_ptr_ne(r, null); 13194 char *s = toStringO(r); 13195 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13196 free(s); 13197 terminateO(olds); 13198 terminateO(self); 13199 13200 } 13201 13202 13203 void icReplaceSmallJsonCharSmallStringGT(CuTest *tc UNUSED) { 13204 13205 smallStringt* r; 13206 smallStringt *self = allocG("beeBeebad"); 13207 smallJsont *olds = allocSmallJson(); 13208 char news; 13209 13210 // replace string, multiple character new delimeter 13211 freeO(olds); 13212 setTopSO(olds, "B"); 13213 news = '^'; 13214 r = icReplaceSmallJsonCharSmallStringG(self, olds, news, 0); 13215 ck_assert_ptr_ne(r, null); 13216 char *s = toStringO(r); 13217 ck_assert_str_eq(s, "^ee^ee^ad"); 13218 free(s); 13219 terminateO(olds); 13220 terminateO(self); 13221 13222 } 13223 13224 13225 void icReplaceSmallStringSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13226 13227 smallStringt* r; 13228 smallStringt *self = allocG("BeeBeeBad"); 13229 smallStringt *olds = allocSmallString(""); 13230 smallJsont *news = allocSmallJson(); 13231 13232 // replace string, multiple character new delimeter 13233 freeO(news); 13234 setValO(olds, "b"); 13235 setTopSO(news, "^^"); 13236 r = icReplaceSmallStringSmallJsonSmallStringG(self, olds, news, 0); 13237 ck_assert_ptr_ne(r, null); 13238 char *s = toStringO(r); 13239 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13240 free(s); 13241 terminateO(olds); 13242 terminateO(news); 13243 terminateO(self); 13244 13245 } 13246 13247 13248 void icReplaceSmallStringSmallStringSmallStringGT(CuTest *tc UNUSED) { 13249 13250 smallStringt* r; 13251 smallStringt *self = allocG("beebeebad"); 13252 smallStringt *olds = allocSmallString(""); 13253 smallStringt *news = allocSmallString(""); 13254 13255 // replace string, multiple character new delimeter 13256 setValO(olds, "B"); 13257 setValO(news, "^^"); 13258 r = icReplaceSmallStringSmallStringSmallStringG(self, olds, news, 0); 13259 ck_assert_ptr_ne(r, null); 13260 char *s = toStringO(r); 13261 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13262 free(s); 13263 terminateO(olds); 13264 terminateO(news); 13265 terminateO(self); 13266 13267 } 13268 13269 13270 void icReplaceSmallStringSSmallStringGT(CuTest *tc UNUSED) { 13271 13272 smallStringt* r; 13273 smallStringt *self = allocG("beebeebad"); 13274 smallStringt *olds = allocSmallString(""); 13275 const char *news; 13276 13277 // replace string, multiple character new delimeter 13278 setValO(olds, "B"); 13279 news = "^^"; 13280 r = icReplaceSmallStringSSmallStringG(self, olds, news, 0); 13281 ck_assert_ptr_ne(r, null); 13282 char *s = toStringO(r); 13283 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13284 free(s); 13285 terminateO(olds); 13286 terminateO(self); 13287 13288 } 13289 13290 13291 void icReplaceSmallStringCharSmallStringGT(CuTest *tc UNUSED) { 13292 13293 smallStringt* r; 13294 smallStringt *self = allocG("beebeebad"); 13295 smallStringt *olds = allocSmallString(""); 13296 char news; 13297 13298 // replace string, multiple character new delimeter 13299 setValO(olds, "B"); 13300 news = '^'; 13301 r = icReplaceSmallStringCharSmallStringG(self, olds, news, 0); 13302 ck_assert_ptr_ne(r, null); 13303 char *s = toStringO(r); 13304 ck_assert_str_eq(s, "^ee^ee^ad"); 13305 free(s); 13306 terminateO(olds); 13307 terminateO(self); 13308 13309 } 13310 13311 13312 void icReplaceSSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13313 13314 smallStringt* r; 13315 smallStringt *self = allocG("beebeebad"); 13316 const char *olds; 13317 smallJsont *news = allocSmallJson(); 13318 13319 // replace string, multiple character new delimeter 13320 freeO(news); 13321 olds = "B"; 13322 setTopSO(news, "^^"); 13323 r = icReplaceSSmallJsonSmallStringG(self, olds, news, 0); 13324 ck_assert_ptr_ne(r, null); 13325 char *s = toStringO(r); 13326 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13327 free(s); 13328 terminateO(news); 13329 terminateO(self); 13330 13331 } 13332 13333 13334 void icReplaceSSmallStringSmallStringGT(CuTest *tc UNUSED) { 13335 13336 smallStringt* r; 13337 smallStringt *self = allocG("beebeebad"); 13338 const char *olds; 13339 smallStringt *news = allocSmallString(""); 13340 13341 // replace string, multiple character new delimeter 13342 olds = "B"; 13343 setValO(news, "^^"); 13344 r = icReplaceSSmallStringSmallStringG(self, olds, news, 0); 13345 ck_assert_ptr_ne(r, null); 13346 char *s = toStringO(r); 13347 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13348 free(s); 13349 terminateO(news); 13350 terminateO(self); 13351 13352 } 13353 13354 13355 void icReplaceCharSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13356 13357 smallStringt* r; 13358 smallStringt *self = allocG("beebeebad"); 13359 char olds; 13360 smallJsont *news = allocSmallJson(); 13361 13362 // replace string, multiple character new delimeter 13363 freeO(news); 13364 olds = 'B'; 13365 setTopSO(news, "^^"); 13366 r = icReplaceCharSmallJsonSmallStringG(self, olds, news, 0); 13367 ck_assert_ptr_ne(r, null); 13368 char *s = toStringO(r); 13369 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13370 free(s); 13371 terminateO(news); 13372 terminateO(self); 13373 13374 } 13375 13376 13377 void icReplaceCharSmallStringSmallStringGT(CuTest *tc UNUSED) { 13378 13379 smallStringt* r; 13380 smallStringt *self = allocG("beebeebad"); 13381 char olds; 13382 smallStringt *news = allocSmallString(""); 13383 13384 // replace string, multiple character new delimeter 13385 olds = 'B'; 13386 setValO(news, "^^"); 13387 r = icReplaceCharSmallStringSmallStringG(self, olds, news, 0); 13388 ck_assert_ptr_ne(r, null); 13389 char *s = toStringO(r); 13390 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 13391 free(s); 13392 terminateO(news); 13393 terminateO(self); 13394 13395 } 13396 13397 13398 void equalSmallStringFGT(CuTest *tc UNUSED) { 13399 13400 bool r; 13401 smallStringt* self = allocG("qwe"); 13402 smallStringt *string = allocSmallString("qwe"); 13403 13404 r = equalSmallStringFG(self,string); 13405 ck_assert(r); 13406 terminateO(string); 13407 terminateO(self); 13408 13409 } 13410 13411 13412 void equalCharSmallStringGT(CuTest *tc UNUSED) { 13413 13414 bool r; 13415 smallStringt *self = allocG("q"); 13416 13417 r = equalCharSmallStringG(self,'q'); 13418 ck_assert(r); 13419 terminateO(self); 13420 13421 } 13422 13423 13424 void equalSSmallStringGT(CuTest *tc UNUSED) { 13425 13426 bool r; 13427 smallStringt *self = allocG("qwe"); 13428 13429 r = equalSSmallStringG(self,"qwe"); 13430 ck_assert(r); 13431 terminateO(self); 13432 13433 } 13434 13435 13436 void equalSmallStringBaseGT(CuTest *tc UNUSED) { 13437 13438 bool r; 13439 smallStringt *self = allocG("12"); 13440 baset* p2 = (baset*) allocSmallInt(12); 13441 13442 r = equalSmallStringBaseG(self, p2); 13443 ck_assert(r); 13444 terminateO(p2); 13445 terminateO(self); 13446 13447 } 13448 13449 13450 void equalSmallStringBoolGT(CuTest *tc UNUSED) { 13451 13452 bool r; 13453 smallStringt* self = allocG("true"); 13454 13455 r = equalSmallStringBoolG(self, true); 13456 ck_assert(r); 13457 terminateO(self); 13458 13459 } 13460 13461 13462 void equalSmallStringDoubleGT(CuTest *tc UNUSED) { 13463 13464 bool r; 13465 smallStringt* self = allocG("2.2"); 13466 13467 r = equalSmallStringDoubleG(self, 2.2); 13468 ck_assert(r); 13469 terminateO(self); 13470 13471 } 13472 13473 13474 void equalSmallStringInt64GT(CuTest *tc UNUSED) { 13475 13476 bool r; 13477 smallStringt* self = allocG("2"); 13478 13479 r = equalSmallStringInt64G(self, 2); 13480 ck_assert(r); 13481 terminateO(self); 13482 13483 } 13484 13485 13486 void equalSmallStringInt32GT(CuTest *tc UNUSED) { 13487 13488 bool r; 13489 smallStringt* self = allocG("2"); 13490 13491 r = equalSmallStringInt32G(self, 2); 13492 ck_assert(r); 13493 terminateO(self); 13494 13495 } 13496 13497 13498 void equalSmallStringUint32GT(CuTest *tc UNUSED) { 13499 13500 bool r; 13501 smallStringt* self = allocG("2"); 13502 13503 r = equalSmallStringUint32G(self, 2); 13504 ck_assert(r); 13505 terminateO(self); 13506 13507 } 13508 13509 13510 void equalSmallStringUint64GT(CuTest *tc UNUSED) { 13511 13512 bool r; 13513 smallStringt* self = allocG("2"); 13514 13515 r = equalSmallStringUint64G(self, 2); 13516 ck_assert(r); 13517 terminateO(self); 13518 13519 } 13520 13521 13522 void equalSmallStringSmallBoolGT(CuTest *tc UNUSED) { 13523 13524 bool r; 13525 smallStringt* self = allocG("TRUE"); 13526 smallBoolt* p2 = allocSmallBool(true); 13527 13528 r = equalSmallStringSmallBoolG(self, p2); 13529 ck_assert(r); 13530 terminateO(p2); 13531 terminateO(self); 13532 13533 } 13534 13535 13536 void equalSmallStringSmallBytesGT(CuTest *tc UNUSED) { 13537 13538 bool r; 13539 smallStringt* self = allocG("qwe"); 13540 smallBytest* p2 = allocSmallBytes("qwe", sizeof("qwe")); 13541 13542 r = equalSmallStringSmallBytesG(self, p2); 13543 ck_assert(r); 13544 terminateO(p2); 13545 terminateO(self); 13546 13547 } 13548 13549 13550 void equalSmallStringSmallDoubleGT(CuTest *tc UNUSED) { 13551 13552 bool r; 13553 smallStringt* self = allocG("2.2"); 13554 smallDoublet* p2 = allocSmallDouble(2.2); 13555 13556 r = equalSmallStringSmallDoubleG(self, p2); 13557 ck_assert(r); 13558 terminateO(p2); 13559 terminateO(self); 13560 13561 } 13562 13563 13564 void equalSmallStringSmallIntGT(CuTest *tc UNUSED) { 13565 13566 bool r; 13567 smallStringt* self = allocG("2"); 13568 smallIntt* p2 = allocSmallInt(2); 13569 13570 r = equalSmallStringSmallIntG(self, p2); 13571 ck_assert(r); 13572 terminateO(p2); 13573 terminateO(self); 13574 13575 } 13576 13577 13578 void equalSmallStringSmallJsonGT(CuTest *tc UNUSED) { 13579 13580 bool r; 13581 smallStringt* self = allocG("qwe"); 13582 smallJsont* p2 = allocSmallJson(); 13583 13584 setTopSO(p2, "qwe"); 13585 r = equalSmallStringSmallJsonG(self, p2); 13586 ck_assert(r); 13587 terminateO(p2); 13588 terminateO(self); 13589 13590 } 13591 13592 13593 void icEqualSmallStringFGT(CuTest *tc UNUSED) { 13594 13595 bool r; 13596 smallStringt *self = allocG("qwe"); 13597 smallStringt *string = allocSmallString("Qwe"); 13598 13599 r = icEqualSmallStringFG(self,string); 13600 ck_assert(r); 13601 terminateO(string); 13602 terminateO(self); 13603 13604 } 13605 13606 13607 void icEqualCharSmallStringGT(CuTest *tc UNUSED) { 13608 13609 bool r; 13610 smallStringt *self = allocG("q"); 13611 13612 r = icEqualCharSmallStringG(self,'Q'); 13613 ck_assert(r); 13614 terminateO(self); 13615 13616 } 13617 13618 13619 void icEqualSSmallStringGT(CuTest *tc UNUSED) { 13620 13621 bool r; 13622 smallStringt *self = allocG("qwe"); 13623 13624 r = icEqualSSmallStringG(self, "Qwe"); 13625 ck_assert(r); 13626 terminateO(self); 13627 13628 } 13629 13630 13631 void icEqualSmallStringBaseGT(CuTest *tc UNUSED) { 13632 13633 bool r; 13634 smallStringt* self = allocG("qwe"); 13635 baset* p2 = (baset*) allocSmallString("QWE"); 13636 13637 r = icEqualSmallStringBaseG(self, p2); 13638 ck_assert(r); 13639 terminateO(p2); 13640 terminateO(self); 13641 13642 } 13643 13644 13645 void icEqualSmallStringSmallJsonGT(CuTest *tc UNUSED) { 13646 13647 bool r; 13648 smallStringt* self = allocG("qwe"); 13649 smallJsont* p2 = allocSmallJson(); 13650 13651 setTopSO(p2, "Qwe"); 13652 r = icEqualSmallStringSmallJsonG(self, p2); 13653 ck_assert(r); 13654 terminateO(p2); 13655 terminateO(self); 13656 13657 } 13658 13659 13660 void equalISSmallStringGT(CuTest *tc UNUSED) { 13661 13662 smallStringt *self = allocG("Ashee|"); 13663 13664 ck_assert(equalISSmallStringG(self, "shee", 1)); 13665 terminateO(self); 13666 13667 } 13668 13669 13670 void equalICharSmallStringGT(CuTest *tc UNUSED) { 13671 13672 smallStringt *self = allocG("Ashee"); 13673 13674 ck_assert(equalICharSmallStringG(self, 's', 1)); 13675 terminateO(self); 13676 13677 } 13678 13679 13680 void equalISmallJsonSmallStringGT(CuTest *tc UNUSED) { 13681 13682 smallStringt *self = allocG("Ashee|"); 13683 smallJsont *string = allocSmallJson(); 13684 13685 setTopSO(string, "shee"); 13686 ck_assert(equalISmallJsonSmallStringG(self, string, 1)); 13687 terminateO(string); 13688 terminateO(self); 13689 13690 } 13691 13692 13693 void equalISmallStringSmallStringGT(CuTest *tc UNUSED) { 13694 13695 smallStringt *self = allocG("Ashee|"); 13696 smallStringt *string = allocSmallString("shee"); 13697 13698 ck_assert(equalISmallStringSmallStringG(self, string, 1)); 13699 terminateO(string); 13700 terminateO(self); 13701 13702 } 13703 13704 13705 void startsWithSSmallStringGT(CuTest *tc UNUSED) { 13706 13707 smallStringt *self = allocG("sheepy"); 13708 13709 ck_assert(startsWithSSmallStringG(self, "shee")); 13710 terminateO(self); 13711 13712 } 13713 13714 13715 void startsWithCharSmallStringGT(CuTest *tc UNUSED) { 13716 13717 smallStringt *self = allocG("shee"); 13718 13719 ck_assert(startsWithCharSmallStringG(self, 's')); 13720 terminateO(self); 13721 13722 } 13723 13724 13725 void startsWithSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13726 13727 smallStringt *self = allocG("sheepy"); 13728 smallJsont *string = allocSmallJson(); 13729 13730 setTopSO(string, "shee"); 13731 ck_assert(startsWithSmallJsonSmallStringG(self, string)); 13732 terminateO(string); 13733 terminateO(self); 13734 13735 } 13736 13737 13738 void startsWithSmallStringSmallStringGT(CuTest *tc UNUSED) { 13739 13740 smallStringt *self = allocG("sheepy"); 13741 smallStringt *string = allocSmallString("shee"); 13742 13743 ck_assert(startsWithSmallStringSmallStringG(self, string)); 13744 terminateO(string); 13745 terminateO(self); 13746 13747 } 13748 13749 13750 void endsWithSSmallStringGT(CuTest *tc UNUSED) { 13751 13752 smallStringt *self = allocG("sheepy"); 13753 13754 ck_assert(endsWithSSmallStringG(self, "eepy")); 13755 terminateO(self); 13756 13757 } 13758 13759 13760 void endsWithCharSmallStringGT(CuTest *tc UNUSED) { 13761 13762 smallStringt *self = allocG("sheepy"); 13763 13764 ck_assert(endsWithCharSmallStringG(self, 'y')); 13765 terminateO(self); 13766 13767 } 13768 13769 13770 void endsWithSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13771 13772 smallStringt *self = allocG("shee"); 13773 smallJsont *string = allocSmallJson(); 13774 13775 setValO(self, "sheepy"); 13776 setTopSO(string, "eepy"); 13777 ck_assert(endsWithSmallJsonSmallStringG(self, string)); 13778 terminateO(string); 13779 terminateO(self); 13780 13781 } 13782 13783 13784 void endsWithSmallStringSmallStringGT(CuTest *tc UNUSED) { 13785 13786 smallStringt *self = allocG("sheepy"); 13787 smallStringt *string = allocSmallString("eepy"); 13788 13789 ck_assert(endsWithSmallStringSmallStringG(self, string)); 13790 terminateO(string); 13791 terminateO(self); 13792 13793 } 13794 13795 13796 void countSSmallStringGT(CuTest *tc UNUSED) { 13797 13798 smallStringt *self = allocG("sheepy"); 13799 13800 // positive count 13801 ck_assert_int_eq(countSSmallStringG(self, "shee"), 1); 13802 terminateO(self); 13803 13804 } 13805 13806 13807 void countCharSmallStringGT(CuTest *tc UNUSED) { 13808 13809 smallStringt *self = allocG("shee"); 13810 13811 // positive count 13812 ck_assert_int_eq(countCharSmallStringG(self, 's'), 1); 13813 terminateO(self); 13814 13815 } 13816 13817 13818 void countSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13819 13820 smallStringt *self = allocG("sheepy"); 13821 smallJsont *string = allocSmallJson(); 13822 13823 // positive count 13824 setTopSO(string, "shee"); 13825 ck_assert_int_eq(countSmallJsonSmallStringG(self, string), 1); 13826 terminateO(string); 13827 terminateO(self); 13828 13829 } 13830 13831 13832 void countSmallStringSmallStringGT(CuTest *tc UNUSED) { 13833 13834 smallStringt *self = allocG("sheepy"); 13835 smallStringt *string = allocSmallString("shee"); 13836 13837 ck_assert_int_eq(countSmallStringSmallStringG(self, string), 1); 13838 terminateO(string); 13839 terminateO(self); 13840 13841 } 13842 13843 13844 void icStartsWithSSmallStringGT(CuTest *tc UNUSED) { 13845 13846 smallStringt *self = allocG("sheepy"); 13847 13848 ck_assert(icStartsWithSSmallStringG(self, "shee")); 13849 terminateO(self); 13850 13851 } 13852 13853 13854 void icStartsWithCharSmallStringGT(CuTest *tc UNUSED) { 13855 13856 smallStringt *self = allocG("shee"); 13857 13858 ck_assert(icStartsWithCharSmallStringG(self, 'S')); 13859 terminateO(self); 13860 13861 } 13862 13863 13864 void icStartsWithSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13865 13866 smallStringt *self = allocG("sheepy"); 13867 smallJsont *string = allocSmallJson(); 13868 13869 setTopSO(string, "shee"); 13870 ck_assert(icStartsWithSmallJsonSmallStringG(self, string)); 13871 terminateO(string); 13872 terminateO(self); 13873 13874 } 13875 13876 13877 void icStartsWithSmallStringSmallStringGT(CuTest *tc UNUSED) { 13878 13879 smallStringt *self = allocG("sheepy"); 13880 smallStringt *string = allocSmallString("shee"); 13881 13882 ck_assert(icStartsWithSmallStringSmallStringG(self, string)); 13883 terminateO(string); 13884 terminateO(self); 13885 13886 } 13887 13888 13889 void icEndsWithSSmallStringGT(CuTest *tc UNUSED) { 13890 13891 smallStringt *self = allocG("sheepy"); 13892 13893 ck_assert(icEndsWithSSmallStringG(self, "EEPY")); 13894 terminateO(self); 13895 13896 } 13897 13898 13899 void icEndsWithCharSmallStringGT(CuTest *tc UNUSED) { 13900 13901 smallStringt *self = allocG("shee"); 13902 13903 ck_assert(icEndsWithCharSmallStringG(self, 'e')); 13904 terminateO(self); 13905 13906 } 13907 13908 13909 void icEndsWithSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13910 13911 smallStringt *self = allocG("sheepy"); 13912 smallJsont *string = allocSmallJson(); 13913 13914 setTopSO(string, "EEPY"); 13915 ck_assert(icEndsWithSmallJsonSmallStringG(self, string)); 13916 terminateO(string); 13917 terminateO(self); 13918 13919 } 13920 13921 13922 void icEndsWithSmallStringSmallStringGT(CuTest *tc UNUSED) { 13923 13924 smallStringt *self = allocG("sheepy"); 13925 smallStringt *string = allocSmallString("EEPY"); 13926 13927 ck_assert(icEndsWithSmallStringSmallStringG(self, string)); 13928 terminateO(string); 13929 terminateO(self); 13930 13931 } 13932 13933 13934 void icCountSSmallStringGT(CuTest *tc UNUSED) { 13935 13936 smallStringt *self = allocG("sheepy"); 13937 13938 // positive count 13939 ck_assert_int_eq(icCountSSmallStringG(self, "Shee"), 1); 13940 terminateO(self); 13941 13942 } 13943 13944 13945 void icCountCharSmallStringGT(CuTest *tc UNUSED) { 13946 13947 smallStringt *self = allocG("shee"); 13948 13949 // positive count 13950 ck_assert_int_eq(icCountCharSmallStringG(self, 'S'), 1); 13951 terminateO(self); 13952 13953 } 13954 13955 13956 void icCountSmallJsonSmallStringGT(CuTest *tc UNUSED) { 13957 13958 smallStringt *self = allocG("sheepy"); 13959 smallJsont *string = allocSmallJson(); 13960 13961 // positive count 13962 setTopSO(string, "Shee"); 13963 ck_assert_int_eq(icCountSmallJsonSmallStringG(self, string), 1); 13964 terminateO(string); 13965 terminateO(self); 13966 13967 } 13968 13969 13970 void icCountSmallStringSmallStringGT(CuTest *tc UNUSED) { 13971 13972 smallStringt *self = allocG("sheepy"); 13973 smallStringt *string = allocSmallString("shee"); 13974 13975 // positive count 13976 ck_assert_int_eq(icCountSmallStringSmallStringG(self, string), 1); 13977 terminateO(string); 13978 terminateO(self); 13979 13980 } 13981 13982 13983 void isNumberSmallStringGT(CuTest *tc UNUSED) { 13984 13985 smallStringt *self = allocG(""); 13986 13987 setValO(self, "-12.3"); 13988 ck_assert(isNumberSmallStringG(self)); 13989 terminateO(self); 13990 13991 } 13992 13993 13994 void isIntSmallStringGT(CuTest *tc UNUSED) { 13995 13996 smallStringt *self = allocG(""); 13997 13998 setValO(self, "-123"); 13999 ck_assert(isIntSmallStringG(self)); 14000 terminateO(self); 14001 14002 } 14003 14004 14005 void parseIntSmallStringGT(CuTest *tc UNUSED) { 14006 14007 smallStringt *self = allocG("123asd"); 14008 14009 ck_assert_int_eq(parseIntSmallStringG(self), 123); 14010 terminateO(self); 14011 14012 } 14013 14014 14015 void intToSmallStringGT(CuTest *tc UNUSED) { 14016 14017 smallStringt* r; 14018 smallStringt *self = allocG(""); 14019 14020 r = intToSmallStringG(self, 123); 14021 ck_assert_ptr_ne(r, null); 14022 char *s = toStringO(r); 14023 ck_assert_str_eq(s, "123"); 14024 free(s); 14025 terminateO(self); 14026 14027 } 14028 14029 14030 void parseDoubleSmallStringGT(CuTest *tc UNUSED) { 14031 14032 smallStringt *self = allocG("123.2sheepy"); 14033 14034 ck_assert(parseDoubleSmallStringG(self) == 123.2); 14035 terminateO(self); 14036 14037 } 14038 14039 14040 void doubleToSmallStringGT(CuTest *tc UNUSED) { 14041 14042 smallStringt* r; 14043 smallStringt *self = allocG(""); 14044 14045 r = doubleToSmallStringG(self, 123.4); 14046 ck_assert_ptr_ne(r, null); 14047 char *s = toStringO(r); 14048 ck_assert_str_eq(s, "1.234000e+02"); 14049 free(s); 14050 terminateO(self); 14051 14052 } 14053 14054 14055 void lenSmallStringGT(CuTest *tc UNUSED) { 14056 14057 size_t r; 14058 smallStringt *self = allocG("123"); 14059 14060 r = lenSmallStringG(self); 14061 ck_assert_int_eq(r, 3); 14062 terminateO(self); 14063 14064 } 14065 14066 14067 void upperSmallStringGT(CuTest *tc UNUSED) { 14068 14069 smallStringt* r; 14070 smallStringt *self = allocG("sheepy"); 14071 14072 r = upperSmallStringG(self); 14073 ck_assert_ptr_ne(r, null); 14074 char *s = toStringO(r); 14075 ck_assert_str_eq(s, "SHEEPY"); 14076 free(s); 14077 terminateO(self); 14078 14079 } 14080 14081 14082 void lowerSmallStringGT(CuTest *tc UNUSED) { 14083 14084 smallStringt* r; 14085 smallStringt *self = allocG("SHeePY"); 14086 14087 r = lowerSmallStringG(self); 14088 ck_assert_ptr_ne(r, null); 14089 char *s = toStringO(r); 14090 ck_assert_str_eq(s, "sheepy"); 14091 free(s); 14092 terminateO(self); 14093 14094 } 14095 14096 14097 void trimSmallStringGT(CuTest *tc UNUSED) { 14098 14099 smallStringt* r; 14100 smallStringt *self = allocG(" SHeePY"); 14101 14102 r = trimSmallStringG(self); 14103 ck_assert_ptr_ne(r, null); 14104 char *s = toStringO(r); 14105 ck_assert_str_eq(s, "SHeePY"); 14106 free(s); 14107 terminateO(self); 14108 14109 } 14110 14111 14112 void lTrimSmallStringGT(CuTest *tc UNUSED) { 14113 14114 smallStringt* r; 14115 smallStringt *self = allocG(" SHeePY "); 14116 14117 r = lTrimSmallStringG(self); 14118 ck_assert_ptr_ne(r, null); 14119 char *s = toStringO(r); 14120 ck_assert_str_eq(s, "SHeePY "); 14121 free(s); 14122 terminateO(self); 14123 14124 } 14125 14126 14127 void rTrimSmallStringGT(CuTest *tc UNUSED) { 14128 14129 smallStringt* r; 14130 smallStringt *self = allocG(" SHeePY "); 14131 14132 r = rTrimSmallStringG(self); 14133 ck_assert_ptr_ne(r, null); 14134 char *s = toStringO(r); 14135 ck_assert_str_eq(s, " SHeePY"); 14136 free(s); 14137 terminateO(self); 14138 14139 } 14140 14141 14142 void uniqSmallStringGT(CuTest *tc UNUSED) { 14143 14144 smallStringt* r; 14145 smallStringt *self = allocG("/qwd///"); 14146 14147 r = uniqSmallStringG(self, '/'); 14148 ck_assert_ptr_ne(r, null); 14149 char *s = toStringO(r); 14150 ck_assert_str_eq(s, "/qwd/"); 14151 free(s); 14152 terminateO(self); 14153 14154 } 14155 14156 14157 void icUniqSmallStringGT(CuTest *tc UNUSED) { 14158 14159 smallStringt* r; 14160 smallStringt *self = allocG("/qQwd///"); 14161 14162 r = icUniqSmallStringG(self, 'q'); 14163 ck_assert_ptr_ne(r, null); 14164 char *s = toStringO(r); 14165 ck_assert_str_eq(s, "/qwd///"); 14166 free(s); 14167 terminateO(self); 14168 14169 } 14170 14171 14172 void sliceSmallStringGT(CuTest *tc UNUSED) { 14173 14174 smallStringt* r; 14175 smallStringt *self = allocG("sheepy"); 14176 14177 r = sliceSmallStringG(self, 0,2); 14178 ck_assert_ptr_ne(r, null); 14179 ck_assert_str_eq(ssGet(self), "sh"); 14180 terminateO(self); 14181 14182 } 14183 14184 14185 void cropSmallStringGT(CuTest *tc UNUSED) { 14186 14187 smallStringt* r; 14188 smallStringt *self = allocG("sheepy"); 14189 14190 r = cropSmallStringG(self, 0,2); 14191 ck_assert_ptr_ne(r, null); 14192 ck_assert_str_eq(ssGet(r), "sh"); 14193 ck_assert_str_eq(ssGet(self), "eepy"); 14194 terminateO(r); 14195 terminateO(self); 14196 14197 } 14198 14199 14200 void cropSSmallStringGT(CuTest *tc UNUSED) { 14201 14202 char* s; 14203 smallStringt *self = allocG("sheepy"); 14204 14205 s = cropSSmallStringG(self, 0,2); 14206 ck_assert_str_eq(s, "sh"); 14207 ck_assert_str_eq(ssGet(self), "eepy"); 14208 free(s); 14209 terminateO(self); 14210 14211 } 14212 14213 14214 void cropSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14215 14216 smallJsont* r; 14217 smallStringt *self = allocG("sheepy"); 14218 14219 r = cropSmallJsonSmallStringG(self, 0,2); 14220 ck_assert_ptr_ne(r, null); 14221 ck_assert_str_eq(sjGet(r), "sh"); 14222 ck_assert_str_eq(ssGet(self), "eepy"); 14223 terminateO(r); 14224 terminateO(self); 14225 14226 } 14227 14228 14229 void cropElemSmallStringGT(CuTest *tc UNUSED) { 14230 14231 char r; 14232 smallStringt *self = allocG("sheepy"); 14233 14234 r = cropElemSmallStringG(self, 0); 14235 ck_assert_int_eq(r, 's'); 14236 ck_assert_str_eq(ssGet(self), "heepy"); 14237 terminateO(self); 14238 14239 } 14240 14241 14242 void copySmallStringGT(CuTest *tc UNUSED) { 14243 14244 smallStringt* r; 14245 smallStringt *self = allocG("sheepy"); 14246 14247 r = copySmallStringG(self, 0,2); 14248 ck_assert_ptr_ne(r, null); 14249 ck_assert_str_eq(ssGet(r), "sh"); 14250 ck_assert_str_eq(ssGet(self), "sheepy"); 14251 terminateO(r); 14252 terminateO(self); 14253 14254 } 14255 14256 14257 void insertSmallStringGT(CuTest *tc UNUSED) { 14258 14259 smallStringt* r; 14260 smallStringt *self = allocG("sheepy"); 14261 smallStringt *toInsert = allocSmallString("lib"); 14262 14263 r = insertSmallStringG(self, 0, toInsert); 14264 ck_assert_ptr_ne(r, null); 14265 char *s = toStringO(r); 14266 ck_assert_str_eq(s, "libsheepy"); 14267 free(s); 14268 terminateO(toInsert); 14269 terminateO(self); 14270 14271 } 14272 14273 14274 void insertSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14275 14276 smallStringt* r; 14277 smallStringt *self = allocG("sheepy"); 14278 smallJsont *toInsert = allocSmallJson(); 14279 14280 setTopSO(toInsert, "lib"); 14281 r = insertSmallJsonSmallStringG(self, 0, toInsert); 14282 ck_assert_ptr_ne(r, null); 14283 char *s = toStringO(r); 14284 ck_assert_str_eq(s, "libsheepy"); 14285 free(s); 14286 terminateO(toInsert); 14287 terminateO(self); 14288 14289 } 14290 14291 14292 void insertSSmallStringGT(CuTest *tc UNUSED) { 14293 14294 smallStringt* r; 14295 smallStringt *self = allocG("sheepy"); 14296 14297 r = insertSSmallStringG(self, 0, "lib"); 14298 ck_assert_ptr_ne(r, null); 14299 char *s = toStringO(r); 14300 ck_assert_str_eq(s, "libsheepy"); 14301 free(s); 14302 terminateO(self); 14303 14304 } 14305 14306 14307 void insertNFreeSmallStringGT(CuTest *tc UNUSED) { 14308 14309 smallStringt* r; 14310 smallStringt *self = allocG(""); 14311 smallStringt *toInsert = allocSmallString(""); 14312 14313 setValO(self, "sheepy"); 14314 setValO(toInsert, "lib"); 14315 r = insertNFreeSmallStringG(self, 0, toInsert); 14316 ck_assert_ptr_ne(r, null); 14317 char *s = toStringO(r); 14318 ck_assert_str_eq(s, "libsheepy"); 14319 free(s); 14320 terminateO(self); 14321 14322 } 14323 14324 14325 void insertNFreeSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14326 14327 smallStringt* r; 14328 smallStringt *self = allocG(""); 14329 smallJsont *toInsert = allocSmallJson(); 14330 14331 setValO(self, "sheepy"); 14332 setTopSO(toInsert, "lib"); 14333 r = insertNFreeSmallJsonSmallStringG(self, 0, toInsert); 14334 ck_assert_ptr_ne(r, null); 14335 char *s = toStringO(r); 14336 ck_assert_str_eq(s, "libsheepy"); 14337 free(s); 14338 terminateO(self); 14339 14340 } 14341 14342 14343 void insertSNFreeSmallStringGT(CuTest *tc UNUSED) { 14344 14345 smallStringt* r; 14346 smallStringt *self = allocG(""); 14347 14348 setValO(self, "sheepy"); 14349 r = insertSNFreeSmallStringG(self, 0, strdup("lib")); 14350 ck_assert_ptr_ne(r, null); 14351 char *s = toStringO(r); 14352 ck_assert_str_eq(s, "libsheepy"); 14353 free(s); 14354 terminateO(self); 14355 14356 } 14357 14358 14359 void injectSmallStringGT(CuTest *tc UNUSED) { 14360 14361 smallStringt* r; 14362 smallStringt *self = allocG(""); 14363 14364 setValO(self, "sheepy"); 14365 r = injectSmallStringG(self, 0, 'L'); 14366 ck_assert_ptr_ne(r, null); 14367 char *s = toStringO(r); 14368 ck_assert_str_eq(s, "Lsheepy"); 14369 free(s); 14370 terminateO(self); 14371 14372 } 14373 14374 14375 void delSmallStringGT(CuTest *tc UNUSED) { 14376 14377 smallStringt* r; 14378 smallStringt *self = allocG(""); 14379 14380 setValO(self, "sheepy"); 14381 r = delSmallStringG(self, 0,2); 14382 ck_assert_ptr_ne(r, null); 14383 char *s = toStringO(r); 14384 ck_assert_str_eq(s, "eepy"); 14385 free(s); 14386 terminateO(self); 14387 14388 } 14389 14390 14391 void delElemSmallStringGT(CuTest *tc UNUSED) { 14392 14393 smallStringt* r; 14394 smallStringt *self = allocG(""); 14395 14396 setValO(self, "sheepy"); 14397 r = delElemSmallStringG(self, 0); 14398 ck_assert_ptr_ne(r, null); 14399 char *s = toStringO(r); 14400 ck_assert_str_eq(s, "heepy"); 14401 free(s); 14402 terminateO(self); 14403 14404 } 14405 14406 14407 void hasSmallStringGT(CuTest *tc UNUSED) { 14408 14409 smallStringt *self = allocG(""); 14410 14411 setValO(self, "sheepy"); 14412 ck_assert_str_eq(hasSmallStringG(self, "ee"), "eepy"); 14413 terminateO(self); 14414 14415 } 14416 14417 14418 void hasCharSmallStringGT(CuTest *tc UNUSED) { 14419 14420 smallStringt *self = allocG(""); 14421 14422 setValO(self, "sheepy"); 14423 ck_assert_str_eq(hasCharSmallStringG(self, 'e'), "eepy"); 14424 terminateO(self); 14425 14426 } 14427 14428 14429 void hasSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14430 14431 smallStringt *self = allocG(""); 14432 smallJsont *needle = allocSmallJson(); 14433 14434 // find string in the middle 14435 setValO(self, "sheepy"); 14436 setTopSO(needle, "ee"); 14437 ck_assert_str_eq(hasSmallJsonSmallStringG(self, needle), "eepy"); 14438 terminateO(needle); 14439 terminateO(self); 14440 14441 } 14442 14443 14444 void hasSmallStringSmallStringGT(CuTest *tc UNUSED) { 14445 14446 smallStringt *self = allocG(""); 14447 smallStringt *needle = allocSmallString("ee"); 14448 14449 // find string in the middle 14450 setValO(self, "sheepy"); 14451 ck_assert_str_eq(hasSmallStringSmallStringG(self, needle), "eepy"); 14452 terminateO(needle); 14453 terminateO(self); 14454 14455 } 14456 14457 14458 void findSmallStringGT(CuTest *tc UNUSED) { 14459 14460 smallStringt* r; 14461 smallStringt *self = allocG(""); 14462 14463 setValO(self, "sheepy"); 14464 r = findSmallStringG(self, "ee"); 14465 ck_assert_ptr_ne(r, null); 14466 ck_assert_str_eq(ssGet(r), "eepy"); 14467 terminateO(r); 14468 terminateO(self); 14469 14470 } 14471 14472 14473 void findCharSmallStringGT(CuTest *tc UNUSED) { 14474 14475 smallStringt* r; 14476 smallStringt *self = allocG(""); 14477 14478 setValO(self, "sheepy"); 14479 r = findCharSmallStringG(self, 'e'); 14480 ck_assert_ptr_ne(r, null); 14481 ck_assert_str_eq(ssGet(r), "eepy"); 14482 terminateO(r); 14483 terminateO(self); 14484 14485 } 14486 14487 14488 void findSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14489 14490 smallStringt* r; 14491 smallStringt *self = allocG(""); 14492 smallJsont *needle = allocSmallJson(); 14493 14494 // find string in the middle 14495 setValO(self, "sheepy"); 14496 setTopSO(needle, "ee"); 14497 r = findSmallJsonSmallStringG(self, needle); 14498 ck_assert_ptr_ne(r, null); 14499 ck_assert_str_eq(ssGet(r), "eepy"); 14500 terminateO(r); 14501 terminateO(needle); 14502 terminateO(self); 14503 14504 } 14505 14506 14507 void findSmallStringSmallStringGT(CuTest *tc UNUSED) { 14508 14509 smallStringt* r; 14510 smallStringt *self = allocG(""); 14511 smallStringt *needle = allocSmallString("ee"); 14512 14513 // find string in the middle 14514 setValO(self, "sheepy"); 14515 r = findSmallStringSmallStringG(self, needle); 14516 ck_assert_ptr_ne(r, null); 14517 ck_assert_str_eq(ssGet(r), "eepy"); 14518 terminateO(r); 14519 terminateO(needle); 14520 terminateO(self); 14521 14522 } 14523 14524 14525 void indexOfSmallStringGT(CuTest *tc UNUSED) { 14526 14527 smallStringt *self = allocG(""); 14528 14529 setValO(self, "sheepy"); 14530 ck_assert_int_eq(indexOfSmallStringG(self, "ee"), 2); 14531 terminateO(self); 14532 14533 } 14534 14535 14536 void indexOfCharSmallStringGT(CuTest *tc UNUSED) { 14537 14538 smallStringt *self = allocG(""); 14539 14540 setValO(self, "sheepy"); 14541 ck_assert_int_eq(indexOfCharSmallStringG(self, 'e'), 2); 14542 terminateO(self); 14543 14544 } 14545 14546 14547 void indexOfSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14548 14549 smallStringt *self = allocG(""); 14550 smallJsont *needle = allocSmallJson(); 14551 14552 // indexOf string in the middle 14553 setValO(self, "sheepy"); 14554 setTopSO(needle, "ee"); 14555 ck_assert_int_eq(indexOfSmallJsonSmallStringG(self, needle), 2); 14556 terminateO(needle); 14557 terminateO(self); 14558 14559 } 14560 14561 14562 void indexOfSmallStringSmallStringGT(CuTest *tc UNUSED) { 14563 14564 smallStringt *self = allocG(""); 14565 smallStringt *needle = allocSmallString("ee"); 14566 14567 // indexOf string in the middle 14568 setValO(self, "sheepy"); 14569 ck_assert_int_eq(indexOfSmallStringSmallStringG(self, needle), 2); 14570 terminateO(needle); 14571 terminateO(self); 14572 14573 } 14574 14575 14576 void icHasSmallStringGT(CuTest *tc UNUSED) { 14577 14578 smallStringt *self = allocG(""); 14579 14580 setValO(self, "sheepy"); 14581 ck_assert_str_eq(icHasSmallStringG(self, "EE"), "eepy"); 14582 terminateO(self); 14583 14584 } 14585 14586 14587 void icHasCharSmallStringGT(CuTest *tc UNUSED) { 14588 14589 smallStringt *self = allocG(""); 14590 14591 setValO(self, "sheepy"); 14592 ck_assert_str_eq(icHasCharSmallStringG(self, 'E'), "eepy"); 14593 terminateO(self); 14594 14595 } 14596 14597 14598 void icHasSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14599 14600 smallStringt *self = allocG(""); 14601 smallJsont *needle = allocSmallJson(); 14602 14603 // find string in the middle 14604 setValO(self, "sheepy"); 14605 setTopSO(needle, "EE"); 14606 ck_assert_str_eq(icHasSmallJsonSmallStringG(self, needle), "eepy"); 14607 terminateO(needle); 14608 terminateO(self); 14609 14610 } 14611 14612 14613 void icHasSmallStringSmallStringGT(CuTest *tc UNUSED) { 14614 14615 smallStringt *self = allocG(""); 14616 smallStringt *needle = allocSmallString("EE"); 14617 14618 // find string in the middle 14619 setValO(self, "sheepy"); 14620 ck_assert_str_eq(icHasSmallStringSmallStringG(self, needle), "eepy"); 14621 terminateO(needle); 14622 terminateO(self); 14623 14624 } 14625 14626 14627 void icFindSmallStringGT(CuTest *tc UNUSED) { 14628 14629 smallStringt* r; 14630 smallStringt *self = allocG(""); 14631 14632 setValO(self, "sheepy"); 14633 r = icFindSmallStringG(self, "EE"); 14634 ck_assert_ptr_ne(r, null); 14635 ck_assert_str_eq(ssGet(r), "eepy"); 14636 terminateO(r); 14637 terminateO(self); 14638 14639 } 14640 14641 14642 void icFindCharSmallStringGT(CuTest *tc UNUSED) { 14643 14644 smallStringt* r; 14645 smallStringt *self = allocG(""); 14646 14647 setValO(self, "sheepy"); 14648 r = icFindCharSmallStringG(self, 'E'); 14649 ck_assert_ptr_ne(r, null); 14650 ck_assert_str_eq(ssGet(r), "eepy"); 14651 terminateO(r); 14652 terminateO(self); 14653 14654 } 14655 14656 14657 void icFindSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14658 14659 smallStringt* r; 14660 smallStringt *self = allocG(""); 14661 smallJsont *needle = allocSmallJson(); 14662 14663 // find string in the middle 14664 setValO(self, "sheepy"); 14665 setTopSO(needle, "EE"); 14666 r = icFindSmallJsonSmallStringG(self, needle); 14667 ck_assert_ptr_ne(r, null); 14668 ck_assert_str_eq(ssGet(r), "eepy"); 14669 terminateO(r); 14670 terminateO(needle); 14671 terminateO(self); 14672 14673 } 14674 14675 14676 void icFindSmallStringSmallStringGT(CuTest *tc UNUSED) { 14677 14678 smallStringt* r; 14679 smallStringt *self = allocG(""); 14680 smallStringt *needle = allocSmallString("EE"); 14681 14682 // find string in the middle 14683 setValO(self, "sheepy"); 14684 r = icFindSmallStringSmallStringG(self, needle); 14685 ck_assert_ptr_ne(r, null); 14686 ck_assert_str_eq(ssGet(r), "eepy"); 14687 terminateO(r); 14688 terminateO(needle); 14689 terminateO(self); 14690 14691 } 14692 14693 14694 void icIndexOfSmallStringGT(CuTest *tc UNUSED) { 14695 14696 smallStringt *self = allocG(""); 14697 14698 setValO(self, "sheepy"); 14699 ck_assert_int_eq(icIndexOfSmallStringG(self, "EE"), 2); 14700 terminateO(self); 14701 14702 } 14703 14704 14705 void icIndexOfCharSmallStringGT(CuTest *tc UNUSED) { 14706 14707 smallStringt *self = allocG(""); 14708 14709 setValO(self, "sheepy"); 14710 ck_assert_int_eq(icIndexOfCharSmallStringG(self, 'E'), 2); 14711 terminateO(self); 14712 14713 } 14714 14715 14716 void icIndexOfSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14717 14718 smallStringt *self = allocG(""); 14719 smallJsont *needle = allocSmallJson(); 14720 14721 // indexOf string in the middle 14722 setValO(self, "sheepy"); 14723 setTopSO(needle, "EE"); 14724 ck_assert_int_eq(icIndexOfSmallJsonSmallStringG(self, needle), 2); 14725 terminateO(needle); 14726 terminateO(self); 14727 14728 } 14729 14730 14731 void icIndexOfSmallStringSmallStringGT(CuTest *tc UNUSED) { 14732 14733 smallStringt *self = allocG(""); 14734 smallStringt *needle = allocSmallString("EE"); 14735 14736 // indexOf string in the middle 14737 setValO(self, "sheepy"); 14738 ck_assert_int_eq(icIndexOfSmallStringSmallStringG(self, needle), 2); 14739 terminateO(needle); 14740 terminateO(self); 14741 14742 } 14743 14744 14745 void emptySmallStringGT(CuTest *tc UNUSED) { 14746 14747 smallStringt* r; 14748 smallStringt *self = allocG("qwe"); 14749 14750 r = emptySmallStringG(self); 14751 ck_assert_ptr_ne(r, null); 14752 char *s = toStringO(r); 14753 ck_assert_str_eq(s, ""); 14754 free(s); 14755 terminateO(self); 14756 14757 } 14758 14759 14760 void isEmptySmallStringGT(CuTest *tc UNUSED) { 14761 14762 smallStringt *self = allocG("qwe"); 14763 14764 ck_assert(!isEmptySmallStringG(self)); 14765 terminateO(self); 14766 14767 } 14768 14769 14770 void isBlankSmallStringGT(CuTest *tc UNUSED) { 14771 14772 smallStringt *self = allocG(""); 14773 14774 setValO(self, " "); 14775 ck_assert(isBlankSmallStringG(self)); 14776 terminateO(self); 14777 14778 } 14779 14780 14781 void splitSmallStringGT(CuTest *tc UNUSED) { 14782 14783 smallArrayt* r; 14784 smallStringt *self = allocG(""); 14785 14786 setValO(self, "one/two"); 14787 r = splitSmallStringG(self, "/"); 14788 ck_assert_ptr_ne(r, null); 14789 char *s = toStringO(r); 14790 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 14791 free(s); 14792 terminateO(r); 14793 terminateO(self); 14794 14795 } 14796 14797 14798 void splitCharSmallStringGT(CuTest *tc UNUSED) { 14799 14800 smallArrayt* r; 14801 smallStringt *self = allocG(""); 14802 14803 setValO(self, "one/two"); 14804 r = splitCharSmallStringG(self, '/'); 14805 ck_assert_ptr_ne(r, null); 14806 char *s = toStringO(r); 14807 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 14808 free(s); 14809 terminateO(r); 14810 terminateO(self); 14811 14812 } 14813 14814 14815 void splitSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14816 14817 smallArrayt* r; 14818 smallStringt *self = allocG(""); 14819 smallJsont *delim = allocSmallJson(); 14820 14821 // string 14822 setValO(self, "one/two"); 14823 setTopSO(delim, "/"); 14824 r = splitSmallJsonSmallStringG(self, delim); 14825 ck_assert_ptr_ne(r, null); 14826 char *s = toStringO(r); 14827 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 14828 free(s); 14829 terminateO(r); 14830 terminateO(delim); 14831 terminateO(self); 14832 14833 } 14834 14835 14836 void splitSmallStringSmallStringGT(CuTest *tc UNUSED) { 14837 14838 smallArrayt* r; 14839 smallStringt *self = allocG(""); 14840 smallStringt *delim = allocSmallString("/"); 14841 14842 // string 14843 setValO(self, "one/two"); 14844 r = splitSmallStringSmallStringG(self, delim); 14845 ck_assert_ptr_ne(r, null); 14846 char *s = toStringO(r); 14847 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 14848 free(s); 14849 terminateO(r); 14850 terminateO(delim); 14851 terminateO(self); 14852 14853 } 14854 14855 14856 void splitCharPSSmallStringGT(CuTest *tc UNUSED) { 14857 14858 char** r; 14859 smallStringt *self = allocG(""); 14860 14861 setValO(self, "one/two"); 14862 r = splitCharPSSmallStringG(self, "/"); 14863 ck_assert_uint_eq(listLengthS(r),2); 14864 ck_assert_str_eq(r[0], "one"); 14865 ck_assert_str_eq(r[1], "two"); 14866 listFreeS(r); 14867 terminateO(self); 14868 14869 } 14870 14871 14872 void splitCharSSmallStringGT(CuTest *tc UNUSED) { 14873 14874 char** r; 14875 smallStringt *self = allocG(""); 14876 14877 setValO(self, "one/two"); 14878 r = splitCharSSmallStringG(self, '/'); 14879 ck_assert_uint_eq(listLengthS(r),2); 14880 ck_assert_str_eq(r[0], "one"); 14881 ck_assert_str_eq(r[1], "two"); 14882 listFreeS(r); 14883 terminateO(self); 14884 14885 } 14886 14887 14888 void splitSmallJsonSSmallStringGT(CuTest *tc UNUSED) { 14889 14890 char** r; 14891 smallStringt *self = allocG(""); 14892 smallJsont *delim = allocSmallJson(); 14893 14894 // string 14895 setValO(self, "one/two"); 14896 setTopSO(delim, "/"); 14897 r = splitSmallJsonSSmallStringG(self, delim); 14898 ck_assert_uint_eq(listLengthS(r),2); 14899 ck_assert_str_eq(r[0], "one"); 14900 ck_assert_str_eq(r[1], "two"); 14901 listFreeS(r); 14902 terminateO(delim); 14903 terminateO(self); 14904 14905 } 14906 14907 14908 void splitSmallStringSSmallStringGT(CuTest *tc UNUSED) { 14909 14910 char** r; 14911 smallStringt *self = allocG(""); 14912 smallStringt *delim = allocSmallString("/"); 14913 14914 // string 14915 setValO(self, "one/two"); 14916 r = splitSmallStringSSmallStringG(self, delim); 14917 ck_assert_uint_eq(listLengthS(r),2); 14918 ck_assert_str_eq(r[0], "one"); 14919 ck_assert_str_eq(r[1], "two"); 14920 listFreeS(r); 14921 terminateO(delim); 14922 terminateO(self); 14923 14924 } 14925 14926 14927 void extractSmallStringGT(CuTest *tc UNUSED) { 14928 14929 smallArrayt* r; 14930 smallStringt *self = allocG(""); 14931 14932 setValO(self, "one/two|"); 14933 r = extractSmallStringG(self, "/", "|"); 14934 ck_assert_ptr_ne(r, null); 14935 char *s = toStringO(r); 14936 ck_assert_str_eq(s, "[\"two\"]"); 14937 free(s); 14938 terminateO(r); 14939 terminateO(self); 14940 14941 } 14942 14943 14944 void extractCharSSmallStringGT(CuTest *tc UNUSED) { 14945 14946 smallArrayt* r; 14947 smallStringt *self = allocG(""); 14948 14949 setValO(self, "one/two|"); 14950 r = extractCharSSmallStringG(self, '/', "|"); 14951 ck_assert_ptr_ne(r, null); 14952 char *s = toStringO(r); 14953 ck_assert_str_eq(s, "[\"two\"]"); 14954 free(s); 14955 terminateO(r); 14956 terminateO(self); 14957 14958 } 14959 14960 14961 void extractSCharSmallStringGT(CuTest *tc UNUSED) { 14962 14963 smallArrayt* r; 14964 smallStringt *self = allocG(""); 14965 14966 setValO(self, "one/two|"); 14967 r = extractSCharSmallStringG(self, "/", '|'); 14968 ck_assert_ptr_ne(r, null); 14969 char *s = toStringO(r); 14970 ck_assert_str_eq(s, "[\"two\"]"); 14971 free(s); 14972 terminateO(r); 14973 terminateO(self); 14974 14975 } 14976 14977 14978 void extractCharCharSmallStringGT(CuTest *tc UNUSED) { 14979 14980 smallArrayt* r; 14981 smallStringt *self = allocG(""); 14982 14983 setValO(self, "one/two|"); 14984 r = extractCharCharSmallStringG(self, '/', '|'); 14985 ck_assert_ptr_ne(r, null); 14986 char *s = toStringO(r); 14987 ck_assert_str_eq(s, "[\"two\"]"); 14988 free(s); 14989 terminateO(r); 14990 terminateO(self); 14991 14992 } 14993 14994 14995 void extractSmallJsonSmallJsonSmallStringGT(CuTest *tc UNUSED) { 14996 14997 smallArrayt* r; 14998 smallStringt *self = allocG(""); 14999 smallJsont* delim1 = allocSmallJson(); 15000 smallJsont* delim2 = allocSmallJson(); 15001 15002 // string 15003 setValO(self, "one/two|"); 15004 setTopSO(delim1, "/"); 15005 setTopSO(delim2, "|"); 15006 r = extractSmallJsonSmallJsonSmallStringG(self, delim1, delim2); 15007 ck_assert_ptr_ne(r, null); 15008 char *s = toStringO(r); 15009 ck_assert_str_eq(s, "[\"two\"]"); 15010 free(s); 15011 terminateO(r); 15012 terminateO(delim1); 15013 terminateO(delim2); 15014 terminateO(self); 15015 15016 } 15017 15018 15019 void extractSmallJsonSmallStringSmallStringGT(CuTest *tc UNUSED) { 15020 15021 smallArrayt* r; 15022 smallStringt *self = allocG(""); 15023 smallJsont* delim1 = allocSmallJson(); 15024 smallStringt* delim2 = allocSmallString("|"); 15025 15026 // string 15027 setValO(self, "one/two|"); 15028 setTopSO(delim1, "/"); 15029 r = extractSmallJsonSmallStringSmallStringG(self, delim1, delim2); 15030 ck_assert_ptr_ne(r, null); 15031 char *s = toStringO(r); 15032 ck_assert_str_eq(s, "[\"two\"]"); 15033 free(s); 15034 terminateO(r); 15035 terminateO(delim1); 15036 terminateO(delim2); 15037 terminateO(self); 15038 15039 } 15040 15041 15042 void extractSmallJsonSSmallStringGT(CuTest *tc UNUSED) { 15043 15044 smallArrayt* r; 15045 smallStringt *self = allocG(""); 15046 smallJsont* delim1 = allocSmallJson(); 15047 15048 // string 15049 setValO(self, "one/two|"); 15050 setTopSO(delim1, "/"); 15051 r = extractSmallJsonSSmallStringG(self, delim1, "|"); 15052 ck_assert_ptr_ne(r, null); 15053 char *s = toStringO(r); 15054 ck_assert_str_eq(s, "[\"two\"]"); 15055 free(s); 15056 terminateO(r); 15057 terminateO(delim1); 15058 terminateO(self); 15059 15060 } 15061 15062 15063 void extractSmallJsonCharSmallStringGT(CuTest *tc UNUSED) { 15064 15065 smallArrayt* r; 15066 smallStringt *self = allocG(""); 15067 smallJsont* delim1 = allocSmallJson(); 15068 15069 // string 15070 setValO(self, "one/two|"); 15071 setTopSO(delim1, "/"); 15072 r = extractSmallJsonCharSmallStringG(self, delim1, '|'); 15073 ck_assert_ptr_ne(r, null); 15074 char *s = toStringO(r); 15075 ck_assert_str_eq(s, "[\"two\"]"); 15076 free(s); 15077 terminateO(r); 15078 terminateO(delim1); 15079 terminateO(self); 15080 15081 } 15082 15083 15084 void extractSmallStringSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15085 15086 smallArrayt* r; 15087 smallStringt *self = allocG(""); 15088 smallStringt* delim1 = allocSmallString("/"); 15089 smallJsont* delim2 = allocSmallJson(); 15090 15091 // string 15092 setValO(self, "one/two|"); 15093 setTopSO(delim2, "|"); 15094 r = extractSmallStringSmallJsonSmallStringG(self, delim1, delim2); 15095 ck_assert_ptr_ne(r, null); 15096 char *s = toStringO(r); 15097 ck_assert_str_eq(s, "[\"two\"]"); 15098 free(s); 15099 terminateO(r); 15100 terminateO(delim1); 15101 terminateO(delim2); 15102 terminateO(self); 15103 15104 } 15105 15106 15107 void extractSmallStringSmallStringSmallStringGT(CuTest *tc UNUSED) { 15108 15109 smallArrayt* r; 15110 smallStringt *self = allocG(""); 15111 smallStringt* delim1 = allocSmallString("/"); 15112 smallStringt* delim2 = allocSmallString("|"); 15113 15114 // string 15115 setValO(self, "one/two|"); 15116 setValO(delim2, "|"); 15117 r = extractSmallStringSmallStringSmallStringG(self, delim1, delim2); 15118 ck_assert_ptr_ne(r, null); 15119 char *s = toStringO(r); 15120 ck_assert_str_eq(s, "[\"two\"]"); 15121 free(s); 15122 terminateO(r); 15123 terminateO(delim1); 15124 terminateO(delim2); 15125 terminateO(self); 15126 15127 } 15128 15129 15130 void extractSmallStringSSmallStringGT(CuTest *tc UNUSED) { 15131 15132 smallArrayt* r; 15133 smallStringt *self = allocG(""); 15134 smallStringt* delim1 = allocSmallString("/"); 15135 15136 // string 15137 setValO(self, "one/two|"); 15138 r = extractSmallStringSSmallStringG(self, delim1, "|"); 15139 ck_assert_ptr_ne(r, null); 15140 char *s = toStringO(r); 15141 ck_assert_str_eq(s, "[\"two\"]"); 15142 free(s); 15143 terminateO(r); 15144 terminateO(delim1); 15145 terminateO(self); 15146 15147 } 15148 15149 15150 void extractSmallStringCharSmallStringGT(CuTest *tc UNUSED) { 15151 15152 smallArrayt* r; 15153 smallStringt *self = allocG(""); 15154 smallStringt* delim1 = allocSmallString("/"); 15155 15156 // string 15157 setValO(self, "one/two|"); 15158 r = extractSmallStringCharSmallStringG(self, delim1, '|'); 15159 ck_assert_ptr_ne(r, null); 15160 char *s = toStringO(r); 15161 ck_assert_str_eq(s, "[\"two\"]"); 15162 free(s); 15163 terminateO(r); 15164 terminateO(delim1); 15165 terminateO(self); 15166 15167 } 15168 15169 15170 void extractSSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15171 15172 smallArrayt* r; 15173 smallStringt *self = allocG(""); 15174 smallJsont* delim2 = allocSmallJson(); 15175 15176 // string 15177 setValO(self, "one/two|"); 15178 setTopSO(delim2, "|"); 15179 r = extractSSmallJsonSmallStringG(self, "/", delim2); 15180 ck_assert_ptr_ne(r, null); 15181 char *s = toStringO(r); 15182 ck_assert_str_eq(s, "[\"two\"]"); 15183 free(s); 15184 terminateO(r); 15185 terminateO(delim2); 15186 terminateO(self); 15187 15188 } 15189 15190 15191 void extractSSmallStringSmallStringGT(CuTest *tc UNUSED) { 15192 15193 smallArrayt* r; 15194 smallStringt *self = allocG(""); 15195 smallStringt* delim2 = allocSmallString("|"); 15196 15197 // string 15198 setValO(self, "one/two|"); 15199 setValO(delim2, "|"); 15200 r = extractSSmallStringSmallStringG(self, "/", delim2); 15201 ck_assert_ptr_ne(r, null); 15202 char *s = toStringO(r); 15203 ck_assert_str_eq(s, "[\"two\"]"); 15204 free(s); 15205 terminateO(r); 15206 terminateO(delim2); 15207 terminateO(self); 15208 15209 } 15210 15211 15212 void extractCharSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15213 15214 smallArrayt* r; 15215 smallStringt *self = allocG(""); 15216 smallJsont* delim2 = allocSmallJson(); 15217 15218 // string 15219 setValO(self, "one/two|"); 15220 setTopSO(delim2, "|"); 15221 r = extractCharSmallJsonSmallStringG(self, '/', delim2); 15222 ck_assert_ptr_ne(r, null); 15223 char *s = toStringO(r); 15224 ck_assert_str_eq(s, "[\"two\"]"); 15225 free(s); 15226 terminateO(r); 15227 terminateO(delim2); 15228 terminateO(self); 15229 15230 } 15231 15232 15233 void extractCharSmallStringSmallStringGT(CuTest *tc UNUSED) { 15234 15235 smallArrayt* r; 15236 smallStringt *self = allocG(""); 15237 smallStringt* delim2 = allocSmallString("|"); 15238 15239 // string 15240 setValO(self, "one/two|"); 15241 setValO(delim2, "|"); 15242 r = extractCharSmallStringSmallStringG(self, '/', delim2); 15243 ck_assert_ptr_ne(r, null); 15244 char *s = toStringO(r); 15245 ck_assert_str_eq(s, "[\"two\"]"); 15246 free(s); 15247 terminateO(r); 15248 terminateO(delim2); 15249 terminateO(self); 15250 15251 } 15252 15253 15254 void icSplitSmallStringGT(CuTest *tc UNUSED) { 15255 15256 smallArrayt* r; 15257 smallStringt *self = allocG(""); 15258 15259 setValO(self, "one/two"); 15260 r = icSplitSmallStringG(self, "/"); 15261 ck_assert_ptr_ne(r, null); 15262 char *s = toStringO(r); 15263 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 15264 free(s); 15265 terminateO(r); 15266 terminateO(self); 15267 15268 } 15269 15270 15271 void icSplitCharSmallStringGT(CuTest *tc UNUSED) { 15272 15273 smallArrayt* r; 15274 smallStringt *self = allocG(""); 15275 15276 setValO(self, "one/two"); 15277 r = icSplitCharSmallStringG(self, 'T'); 15278 ck_assert_ptr_ne(r, null); 15279 char *s = toStringO(r); 15280 ck_assert_str_eq(s, "[\"one/\",\"wo\"]"); 15281 free(s); 15282 terminateO(r); 15283 terminateO(self); 15284 15285 } 15286 15287 15288 void icSplitSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15289 15290 smallArrayt* r; 15291 smallStringt *self = allocG(""); 15292 smallJsont *delim = allocSmallJson(); 15293 15294 // string 15295 setValO(self, "one/two"); 15296 setTopSO(delim, "T"); 15297 r = icSplitSmallJsonSmallStringG(self, delim); 15298 ck_assert_ptr_ne(r, null); 15299 char *s = toStringO(r); 15300 ck_assert_str_eq(s, "[\"one/\",\"wo\"]"); 15301 free(s); 15302 terminateO(r); 15303 terminateO(delim); 15304 terminateO(self); 15305 15306 } 15307 15308 15309 void icSplitSmallStringSmallStringGT(CuTest *tc UNUSED) { 15310 15311 smallArrayt* r; 15312 smallStringt *self = allocG(""); 15313 smallStringt *delim = allocSmallString("T"); 15314 15315 // string 15316 setValO(self, "one/two"); 15317 r = icSplitSmallStringSmallStringG(self, delim); 15318 ck_assert_ptr_ne(r, null); 15319 char *s = toStringO(r); 15320 ck_assert_str_eq(s, "[\"one/\",\"wo\"]"); 15321 free(s); 15322 terminateO(r); 15323 terminateO(delim); 15324 terminateO(self); 15325 15326 } 15327 15328 15329 void icSplitCharPSSmallStringGT(CuTest *tc UNUSED) { 15330 15331 char** r; 15332 smallStringt *self = allocG(""); 15333 15334 setValO(self, "one/two"); 15335 r = icSplitCharPSSmallStringG(self, "T"); 15336 ck_assert_uint_eq(listLengthS(r),2); 15337 ck_assert_str_eq(r[0], "one/"); 15338 ck_assert_str_eq(r[1], "wo"); 15339 listFreeS(r); 15340 terminateO(self); 15341 15342 } 15343 15344 15345 void icSplitCharSSmallStringGT(CuTest *tc UNUSED) { 15346 15347 char** r; 15348 smallStringt *self = allocG(""); 15349 15350 setValO(self, "one/two"); 15351 r = icSplitCharSSmallStringG(self, 'T'); 15352 ck_assert_uint_eq(listLengthS(r),2); 15353 ck_assert_str_eq(r[0], "one/"); 15354 ck_assert_str_eq(r[1], "wo"); 15355 listFreeS(r); 15356 terminateO(self); 15357 15358 } 15359 15360 15361 void icSplitSmallJsonSSmallStringGT(CuTest *tc UNUSED) { 15362 15363 char** r; 15364 smallStringt *self = allocG(""); 15365 smallJsont *delim = allocSmallJson(); 15366 15367 // string 15368 setValO(self, "one/two"); 15369 setTopSO(delim, "T"); 15370 r = icSplitSmallJsonSSmallStringG(self, delim); 15371 ck_assert_uint_eq(listLengthS(r),2); 15372 ck_assert_str_eq(r[0], "one/"); 15373 ck_assert_str_eq(r[1], "wo"); 15374 listFreeS(r); 15375 terminateO(delim); 15376 terminateO(self); 15377 15378 } 15379 15380 15381 void icSplitSmallStringSSmallStringGT(CuTest *tc UNUSED) { 15382 15383 char** r; 15384 smallStringt *self = allocG(""); 15385 smallStringt *delim = allocSmallString("T"); 15386 15387 // string 15388 setValO(self, "one/two"); 15389 r = icSplitSmallStringSSmallStringG(self, delim); 15390 ck_assert_uint_eq(listLengthS(r),2); 15391 ck_assert_str_eq(r[0], "one/"); 15392 ck_assert_str_eq(r[1], "wo"); 15393 listFreeS(r); 15394 terminateO(delim); 15395 terminateO(self); 15396 15397 } 15398 15399 15400 void icExtractSmallStringGT(CuTest *tc UNUSED) { 15401 15402 smallArrayt* r; 15403 smallStringt *self = allocG(""); 15404 15405 setValO(self, "one/twos"); 15406 r = icExtractSmallStringG(self, "E", "S"); 15407 ck_assert_ptr_ne(r, null); 15408 char *s = toStringO(r); 15409 ck_assert_str_eq(s, "[\"/two\"]"); 15410 free(s); 15411 terminateO(r); 15412 terminateO(self); 15413 15414 } 15415 15416 15417 void icExtractCharSSmallStringGT(CuTest *tc UNUSED) { 15418 15419 smallArrayt* r; 15420 smallStringt *self = allocG(""); 15421 15422 setValO(self, "one/twos"); 15423 r = icExtractCharSSmallStringG(self, 'E', "S"); 15424 ck_assert_ptr_ne(r, null); 15425 char *s = toStringO(r); 15426 ck_assert_str_eq(s, "[\"/two\"]"); 15427 free(s); 15428 terminateO(r); 15429 terminateO(self); 15430 15431 } 15432 15433 15434 void icExtractSCharSmallStringGT(CuTest *tc UNUSED) { 15435 15436 smallArrayt* r; 15437 smallStringt *self = allocG(""); 15438 15439 setValO(self, "one/twos"); 15440 r = icExtractSCharSmallStringG(self, "E", 'S'); 15441 ck_assert_ptr_ne(r, null); 15442 char *s = toStringO(r); 15443 ck_assert_str_eq(s, "[\"/two\"]"); 15444 free(s); 15445 terminateO(r); 15446 terminateO(self); 15447 15448 } 15449 15450 15451 void icExtractCharCharSmallStringGT(CuTest *tc UNUSED) { 15452 15453 smallArrayt* r; 15454 smallStringt *self = allocG(""); 15455 15456 setValO(self, "one/twos"); 15457 r = icExtractCharCharSmallStringG(self, 'E', 'S'); 15458 ck_assert_ptr_ne(r, null); 15459 char *s = toStringO(r); 15460 ck_assert_str_eq(s, "[\"/two\"]"); 15461 free(s); 15462 terminateO(r); 15463 terminateO(self); 15464 15465 } 15466 15467 15468 void icExtractSmallJsonSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15469 15470 smallArrayt* r; 15471 smallStringt *self = allocG(""); 15472 smallJsont* delim1 = allocSmallJson(); 15473 smallJsont* delim2 = allocSmallJson(); 15474 15475 // string 15476 setValO(self, "one/twos"); 15477 setTopSO(delim1, "E"); 15478 setTopSO(delim2, "S"); 15479 r = icExtractSmallJsonSmallJsonSmallStringG(self, delim1, delim2); 15480 ck_assert_ptr_ne(r, null); 15481 char *s = toStringO(r); 15482 ck_assert_str_eq(s, "[\"/two\"]"); 15483 free(s); 15484 terminateO(r); 15485 terminateO(delim1); 15486 terminateO(delim2); 15487 terminateO(self); 15488 15489 } 15490 15491 15492 void icExtractSmallJsonSmallStringSmallStringGT(CuTest *tc UNUSED) { 15493 15494 smallArrayt* r; 15495 smallStringt *self = allocG(""); 15496 smallJsont* delim1 = allocSmallJson(); 15497 smallStringt* delim2 = allocSmallString("S"); 15498 15499 // string 15500 setValO(self, "one/twos"); 15501 setTopSO(delim1, "E"); 15502 r = icExtractSmallJsonSmallStringSmallStringG(self, delim1, delim2); 15503 ck_assert_ptr_ne(r, null); 15504 char *s = toStringO(r); 15505 ck_assert_str_eq(s, "[\"/two\"]"); 15506 free(s); 15507 terminateO(r); 15508 terminateO(delim1); 15509 terminateO(delim2); 15510 terminateO(self); 15511 15512 } 15513 15514 15515 void icExtractSmallJsonSSmallStringGT(CuTest *tc UNUSED) { 15516 15517 smallArrayt* r; 15518 smallStringt *self = allocG(""); 15519 smallJsont* delim1 = allocSmallJson(); 15520 15521 // string 15522 setValO(self, "one/twos"); 15523 setTopSO(delim1, "E"); 15524 r = icExtractSmallJsonSSmallStringG(self, delim1, "S"); 15525 ck_assert_ptr_ne(r, null); 15526 char *s = toStringO(r); 15527 ck_assert_str_eq(s, "[\"/two\"]"); 15528 free(s); 15529 terminateO(r); 15530 terminateO(delim1); 15531 terminateO(self); 15532 15533 } 15534 15535 15536 void icExtractSmallJsonCharSmallStringGT(CuTest *tc UNUSED) { 15537 15538 smallArrayt* r; 15539 smallStringt *self = allocG(""); 15540 smallJsont* delim1 = allocSmallJson(); 15541 15542 // string 15543 setValO(self, "one/twos"); 15544 setTopSO(delim1, "E"); 15545 r = icExtractSmallJsonCharSmallStringG(self, delim1, 'S'); 15546 ck_assert_ptr_ne(r, null); 15547 char *s = toStringO(r); 15548 ck_assert_str_eq(s, "[\"/two\"]"); 15549 free(s); 15550 terminateO(r); 15551 terminateO(delim1); 15552 terminateO(self); 15553 15554 } 15555 15556 15557 void icExtractSmallStringSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15558 15559 smallArrayt* r; 15560 smallStringt *self = allocG(""); 15561 smallStringt* delim1 = allocSmallString("E"); 15562 smallJsont* delim2 = allocSmallJson(); 15563 15564 // string 15565 setValO(self, "one/twos"); 15566 setTopSO(delim2, "S"); 15567 r = icExtractSmallStringSmallJsonSmallStringG(self, delim1, delim2); 15568 ck_assert_ptr_ne(r, null); 15569 char *s = toStringO(r); 15570 ck_assert_str_eq(s, "[\"/two\"]"); 15571 free(s); 15572 terminateO(r); 15573 terminateO(delim1); 15574 terminateO(delim2); 15575 terminateO(self); 15576 15577 } 15578 15579 15580 void icExtractSmallStringSmallStringSmallStringGT(CuTest *tc UNUSED) { 15581 15582 smallArrayt* r; 15583 smallStringt *self = allocG(""); 15584 smallStringt* delim1 = allocSmallString("E"); 15585 smallStringt* delim2 = allocSmallString("|"); 15586 15587 // string 15588 setValO(self, "one/twos"); 15589 setValO(delim2, "S"); 15590 r = icExtractSmallStringSmallStringSmallStringG(self, delim1, delim2); 15591 ck_assert_ptr_ne(r, null); 15592 char *s = toStringO(r); 15593 ck_assert_str_eq(s, "[\"/two\"]"); 15594 free(s); 15595 terminateO(r); 15596 terminateO(delim1); 15597 terminateO(delim2); 15598 terminateO(self); 15599 15600 } 15601 15602 15603 void icExtractSmallStringSSmallStringGT(CuTest *tc UNUSED) { 15604 15605 smallArrayt* r; 15606 smallStringt *self = allocG(""); 15607 smallStringt* delim1 = allocSmallString("E"); 15608 15609 // string 15610 setValO(self, "one/twos"); 15611 r = icExtractSmallStringSSmallStringG(self, delim1, "S"); 15612 ck_assert_ptr_ne(r, null); 15613 char *s = toStringO(r); 15614 ck_assert_str_eq(s, "[\"/two\"]"); 15615 free(s); 15616 terminateO(r); 15617 terminateO(delim1); 15618 terminateO(self); 15619 15620 } 15621 15622 15623 void icExtractSmallStringCharSmallStringGT(CuTest *tc UNUSED) { 15624 15625 smallArrayt* r; 15626 smallStringt *self = allocG(""); 15627 smallStringt* delim1 = allocSmallString("E"); 15628 15629 // string 15630 setValO(self, "one/twos"); 15631 r = icExtractSmallStringCharSmallStringG(self, delim1, 'S'); 15632 ck_assert_ptr_ne(r, null); 15633 char *s = toStringO(r); 15634 ck_assert_str_eq(s, "[\"/two\"]"); 15635 free(s); 15636 terminateO(r); 15637 terminateO(delim1); 15638 terminateO(self); 15639 15640 } 15641 15642 15643 void icExtractSSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15644 15645 smallArrayt* r; 15646 smallStringt *self = allocG(""); 15647 smallJsont* delim2 = allocSmallJson(); 15648 15649 // string 15650 setValO(self, "one/twos"); 15651 setTopSO(delim2, "S"); 15652 r = icExtractSSmallJsonSmallStringG(self, "E", delim2); 15653 ck_assert_ptr_ne(r, null); 15654 char *s = toStringO(r); 15655 ck_assert_str_eq(s, "[\"/two\"]"); 15656 free(s); 15657 terminateO(r); 15658 terminateO(delim2); 15659 terminateO(self); 15660 15661 } 15662 15663 15664 void icExtractSSmallStringSmallStringGT(CuTest *tc UNUSED) { 15665 15666 smallArrayt* r; 15667 smallStringt *self = allocG(""); 15668 smallStringt* delim2 = allocSmallString("|"); 15669 15670 // string 15671 setValO(self, "one/twos"); 15672 setValO(delim2, "S"); 15673 r = icExtractSSmallStringSmallStringG(self, "E", delim2); 15674 ck_assert_ptr_ne(r, null); 15675 char *s = toStringO(r); 15676 ck_assert_str_eq(s, "[\"/two\"]"); 15677 free(s); 15678 terminateO(r); 15679 terminateO(delim2); 15680 terminateO(self); 15681 15682 } 15683 15684 15685 void icExtractCharSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15686 15687 smallArrayt* r; 15688 smallStringt *self = allocG(""); 15689 smallJsont* delim2 = allocSmallJson(); 15690 15691 // string 15692 setValO(self, "one/twos"); 15693 setTopSO(delim2, "S"); 15694 r = icExtractCharSmallJsonSmallStringG(self, 'E', delim2); 15695 ck_assert_ptr_ne(r, null); 15696 char *s = toStringO(r); 15697 ck_assert_str_eq(s, "[\"/two\"]"); 15698 free(s); 15699 terminateO(r); 15700 terminateO(delim2); 15701 terminateO(self); 15702 15703 } 15704 15705 15706 void icExtractCharSmallStringSmallStringGT(CuTest *tc UNUSED) { 15707 15708 smallArrayt* r; 15709 smallStringt *self = allocG(""); 15710 smallStringt* delim2 = allocSmallString("|"); 15711 15712 // string 15713 setValO(self, "one/twos"); 15714 setValO(delim2, "S"); 15715 r = icExtractCharSmallStringSmallStringG(self, 'E', delim2); 15716 ck_assert_ptr_ne(r, null); 15717 char *s = toStringO(r); 15718 ck_assert_str_eq(s, "[\"/two\"]"); 15719 free(s); 15720 terminateO(r); 15721 terminateO(delim2); 15722 terminateO(self); 15723 15724 } 15725 15726 15727 void readFileSmallStringGT(CuTest *tc UNUSED) { 15728 15729 smallStringt* r; 15730 smallStringt *self = allocG(""); 15731 15732 r = readFileSmallStringG(self, "../textTest.null"); 15733 ck_assert_ptr_ne(r, null); 15734 char *s = toStringO(r); 15735 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 15736 free(s); 15737 terminateO(self); 15738 15739 } 15740 15741 15742 void readFileSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15743 15744 smallStringt* r; 15745 smallStringt *self = allocG(""); 15746 smallJsont *filePath = allocSmallJson(); 15747 15748 // text 15749 setTopSO(filePath, "../textTest.null"); 15750 r = readFileSmallJsonSmallStringG(self, filePath); 15751 ck_assert_ptr_ne(r, null); 15752 char *s = toStringO(r); 15753 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 15754 free(s); 15755 terminateO(filePath); 15756 terminateO(self); 15757 15758 } 15759 15760 15761 void readFileSmallStringSmallStringGT(CuTest *tc UNUSED) { 15762 15763 smallStringt* r; 15764 smallStringt *self = allocG(""); 15765 smallStringt *filePath = allocSmallString(""); 15766 15767 // text 15768 setValO(filePath, "../textTest.null"); 15769 r = readFileSmallStringSmallStringG(self, filePath); 15770 ck_assert_ptr_ne(r, null); 15771 char *s = toStringO(r); 15772 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 15773 free(s); 15774 terminateO(filePath); 15775 terminateO(self); 15776 15777 } 15778 15779 15780 void readStreamSmallStringGT(CuTest *tc UNUSED) { 15781 15782 smallStringt* r; 15783 smallStringt *self = allocG(""); 15784 FILE *f; 15785 15786 // text 15787 f = fopen("../textTest.null", "r"); 15788 r = readStreamSmallStringG(self, f); 15789 ck_assert_ptr_ne(r, null); 15790 char *s = toStringO(r); 15791 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 15792 free(s); 15793 fclose(f); 15794 terminateO(self); 15795 15796 } 15797 15798 15799 void writeFileSmallStringGT(CuTest *tc UNUSED) { 15800 15801 int r; 15802 smallStringt *self = allocG(""); 15803 15804 readFileO(self, "../textTest.null"); 15805 r = writeFileSmallStringG(self, "textOutTest.null"); 15806 ck_assert(r); 15807 // check textOutTest.null 15808 freeO(self); 15809 readFileO(self, "textOutTest.null"); 15810 ck_assert_uint_eq(lenO(self),20); 15811 char *s = toStringO(self); 15812 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 15813 free(s); 15814 terminateO(self); 15815 15816 } 15817 15818 15819 void writeFileSmallJsonSmallStringGT(CuTest *tc UNUSED) { 15820 15821 int r; 15822 smallStringt *self = allocG(""); 15823 smallJsont *filePath = allocSmallJson(); 15824 15825 // write textOutTest.null 15826 setTopSO(filePath, "textOutTest.null"); 15827 readFileO(self, "../textTest.null"); 15828 r = writeFileSmallJsonSmallStringG(self, filePath); 15829 ck_assert(r); 15830 // check textOutTest.null 15831 freeO(self); 15832 readFileO(self, "textOutTest.null"); 15833 ck_assert_uint_eq(lenO(self),20); 15834 char *s = toStringO(self); 15835 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 15836 free(s); 15837 terminateO(filePath); 15838 terminateO(self); 15839 15840 } 15841 15842 15843 void writeFileSmallStringSmallStringGT(CuTest *tc UNUSED) { 15844 15845 int r; 15846 smallStringt *self = allocG(""); 15847 smallStringt *filePath = allocSmallString(""); 15848 15849 // write textOutTest.null 15850 setValO(filePath, "textOutTest.null"); 15851 readFileO(self, "../textTest.null"); 15852 r = writeFileSmallStringSmallStringG(self, filePath); 15853 ck_assert(r); 15854 // check textOutTest.null 15855 freeO(self); 15856 readFileO(self, "textOutTest.null"); 15857 ck_assert_uint_eq(lenO(self),20); 15858 char *s = toStringO(self); 15859 ck_assert_str_eq(s, "LINE 1\nANOTHER line\n"); 15860 free(s); 15861 terminateO(filePath); 15862 terminateO(self); 15863 15864 } 15865 15866 15867 void writeStreamSmallStringGT(CuTest *tc UNUSED) { 15868 15869 int r; 15870 smallStringt *self = allocG(""); 15871 FILE *f; 15872 15873 // write textOutTest.null 15874 readFileO(self, "../textTest.null"); 15875 f = fopen("textOutTest.null", "w"); 15876 r = writeStreamSmallStringG(self, f); 15877 ck_assert(r); 15878 fclose(f); 15879 // check textOutTest.null 15880 freeO(self); 15881 readFileO(self, "textOutTest.null"); 15882 ck_assert_uint_eq(lenO(self),20); 15883 ck_assert_str_eq(ssGet(self), "LINE 1\nANOTHER line\n"); 15884 terminateO(self); 15885 15886 } 15887 15888 15889 void appendFileSmallStringFGT(CuTest *tc UNUSED) { 15890 15891 int r; 15892 smallStringt *self = allocG(""); 15893 15894 setValO(self, "appended line\n"); 15895 r = appendFileSmallStringFG(self, "appendTextOutTest.null"); 15896 ck_assert(r); 15897 setValO(self, "appended line 2\n"); 15898 r = appendFileSmallStringFG(self, "appendTextOutTest.null"); 15899 ck_assert(r); 15900 // check textOutTest.null 15901 freeO(self); 15902 readFileO(self, "appendTextOutTest.null"); 15903 ck_assert_uint_eq(lenO(self),30); 15904 ck_assert_str_eq(ssGet(self), "appended line\nappended line 2\n"); 15905 if (fileExists("appendTextOutTest.null")) 15906 rmAll("appendTextOutTest.null"); 15907 terminateO(self); 15908 15909 } 15910 15911 15912 void appendFileSmallStringSmallStringGT(CuTest *tc UNUSED) { 15913 15914 int r; 15915 smallStringt *self = allocG(""); 15916 smallStringt *filePath = allocSmallString(""); 15917 15918 // write textOutTest.null 15919 setValO(self, "appended line\n"); 15920 setValO(filePath, "appendTextOutTest.null"); 15921 r = appendFileSmallStringSmallStringG(self, filePath); 15922 ck_assert(r); 15923 setValO(self, "appended line 2\n"); 15924 r = appendFileSmallStringSmallStringG(self, filePath); 15925 ck_assert(r); 15926 // check textOutTest.null 15927 freeO(self); 15928 readFileO(self, "appendTextOutTest.null"); 15929 ck_assert_uint_eq(lenO(self),30); 15930 ck_assert_str_eq(ssGet(self), "appended line\nappended line 2\n"); 15931 if (fileExists("appendTextOutTest.null")) 15932 rmAll("appendTextOutTest.null"); 15933 terminateO(filePath); 15934 terminateO(self); 15935 15936 } 15937 15938 15939 15940 15941 15942 15943 int main(int n UNUSED, char**v UNUSED) { 15944 // disable btrace to make the test run faster 15945 btraceDisable(); 15946 CuString *output = CuStringNew(); 15947 CuSuite *suite = CuSuiteNew(); 15948 15949 SUITE_ADD_TEST(suite, initiateSmallStringT); 15950 SUITE_ADD_TEST(suite, initiateAllocateSmallStringT); 15951 SUITE_ADD_TEST(suite, allocSmallStringT); 15952 SUITE_ADD_TEST(suite, createSFT); 15953 SUITE_ADD_TEST(suite, freeSmallStringT); 15954 SUITE_ADD_TEST(suite, terminateSmallStringT); 15955 SUITE_ADD_TEST(suite, toStringSmallStringT); 15956 SUITE_ADD_TEST(suite, duplicateSmallStringT); 15957 SUITE_ADD_TEST(suite, smashSmallStringT); 15958 SUITE_ADD_TEST(suite, finishSmallStringT); 15959 SUITE_ADD_TEST(suite, getSmallStringT); 15960 SUITE_ADD_TEST(suite, setSmallStringT); 15961 SUITE_ADD_TEST(suite, setCharSmallStringT); 15962 SUITE_ADD_TEST(suite, setBoolSmallStringT); 15963 SUITE_ADD_TEST(suite, setDoubleSmallStringT); 15964 SUITE_ADD_TEST(suite, setInt64SmallStringT); 15965 SUITE_ADD_TEST(suite, setInt32SmallStringT); 15966 SUITE_ADD_TEST(suite, setUint32SmallStringT); 15967 SUITE_ADD_TEST(suite, setUint64SmallStringT); 15968 SUITE_ADD_TEST(suite, setSmallArraySmallStringT); 15969 SUITE_ADD_TEST(suite, setFromSmallDictSmallStringT); 15970 SUITE_ADD_TEST(suite, setFromSmallJsonSmallStringT); 15971 SUITE_ADD_TEST(suite, setSmallBoolSmallStringT); 15972 SUITE_ADD_TEST(suite, setSmallDoubleSmallStringT); 15973 SUITE_ADD_TEST(suite, setSmallIntSmallStringT); 15974 SUITE_ADD_TEST(suite, setSmallJsonSmallStringT); 15975 SUITE_ADD_TEST(suite, setSmallStringSmallStringT); 15976 SUITE_ADD_TEST(suite, setNFreeSmallStringT); 15977 SUITE_ADD_TEST(suite, appendSmallStringT); 15978 SUITE_ADD_TEST(suite, appendSmallJsonSmallStringT); 15979 SUITE_ADD_TEST(suite, appendNSmashSmallStringT); 15980 SUITE_ADD_TEST(suite, appendSSmallStringT); 15981 SUITE_ADD_TEST(suite, appendCharSmallStringT); 15982 SUITE_ADD_TEST(suite, appendNSmashSmallJsonSmallStringT); 15983 SUITE_ADD_TEST(suite, appendNSmashSSmallStringT); 15984 SUITE_ADD_TEST(suite, prependSmallStringT); 15985 SUITE_ADD_TEST(suite, prependSmallJsonSmallStringT); 15986 SUITE_ADD_TEST(suite, prependNSmashSmallStringT); 15987 SUITE_ADD_TEST(suite, prependNSmashSmallJsonSmallStringT); 15988 SUITE_ADD_TEST(suite, prependSSmallStringT); 15989 SUITE_ADD_TEST(suite, prependCharSmallStringT); 15990 SUITE_ADD_TEST(suite, prependNSmashSSmallStringT); 15991 SUITE_ADD_TEST(suite, catSmallStringT); 15992 SUITE_ADD_TEST(suite, catSSmallStringT); 15993 SUITE_ADD_TEST(suite, pushNFreeManySmallStringT); 15994 SUITE_ADD_TEST(suite, pushNFreeManySSmallStringT); 15995 SUITE_ADD_TEST(suite, replaceSmallStringT); 15996 SUITE_ADD_TEST(suite, replaceCharSSmallStringT); 15997 SUITE_ADD_TEST(suite, replaceSCharSmallStringT); 15998 SUITE_ADD_TEST(suite, replaceCharCharSmallStringT); 15999 SUITE_ADD_TEST(suite, replaceSmallJsonSmallJsonSmallStringT); 16000 SUITE_ADD_TEST(suite, replaceSmallJsonSmallStringSmallStringT); 16001 SUITE_ADD_TEST(suite, replaceSmallJsonSSmallStringT); 16002 SUITE_ADD_TEST(suite, replaceSmallJsonCharSmallStringT); 16003 SUITE_ADD_TEST(suite, replaceSmallStringSmallJsonSmallStringT); 16004 SUITE_ADD_TEST(suite, replaceSmallStringSmallStringSmallStringT); 16005 SUITE_ADD_TEST(suite, replaceSmallStringSSmallStringT); 16006 SUITE_ADD_TEST(suite, replaceSmallStringCharSmallStringT); 16007 SUITE_ADD_TEST(suite, replaceSSmallJsonSmallStringT); 16008 SUITE_ADD_TEST(suite, replaceSSmallStringSmallStringT); 16009 SUITE_ADD_TEST(suite, replaceCharSmallJsonSmallStringT); 16010 SUITE_ADD_TEST(suite, replaceCharSmallStringSmallStringT); 16011 SUITE_ADD_TEST(suite, replaceManySmallStringT); 16012 SUITE_ADD_TEST(suite, icReplaceSmallStringT); 16013 SUITE_ADD_TEST(suite, icReplaceCharSSmallStringT); 16014 SUITE_ADD_TEST(suite, icReplaceSCharSmallStringT); 16015 SUITE_ADD_TEST(suite, icReplaceCharCharSmallStringT); 16016 SUITE_ADD_TEST(suite, icReplaceSmallJsonSmallJsonSmallStringT); 16017 SUITE_ADD_TEST(suite, icReplaceSmallJsonSmallStringSmallStringT); 16018 SUITE_ADD_TEST(suite, icReplaceSmallJsonSSmallStringT); 16019 SUITE_ADD_TEST(suite, icReplaceSmallJsonCharSmallStringT); 16020 SUITE_ADD_TEST(suite, icReplaceSmallStringSmallJsonSmallStringT); 16021 SUITE_ADD_TEST(suite, icReplaceSmallStringSmallStringSmallStringT); 16022 SUITE_ADD_TEST(suite, icReplaceSmallStringSSmallStringT); 16023 SUITE_ADD_TEST(suite, icReplaceSmallStringCharSmallStringT); 16024 SUITE_ADD_TEST(suite, icReplaceSSmallJsonSmallStringT); 16025 SUITE_ADD_TEST(suite, icReplaceSSmallStringSmallStringT); 16026 SUITE_ADD_TEST(suite, icReplaceCharSmallJsonSmallStringT); 16027 SUITE_ADD_TEST(suite, icReplaceCharSmallStringSmallStringT); 16028 SUITE_ADD_TEST(suite, icReplaceManySmallStringT); 16029 SUITE_ADD_TEST(suite, equalSmallStringT); 16030 SUITE_ADD_TEST(suite, equalSSmallStringT); 16031 SUITE_ADD_TEST(suite, equalCharSmallStringT); 16032 SUITE_ADD_TEST(suite, equalSmallStringBaseT); 16033 SUITE_ADD_TEST(suite, equalSmallStringBoolT); 16034 SUITE_ADD_TEST(suite, equalSmallStringDoubleT); 16035 SUITE_ADD_TEST(suite, equalSmallStringInt64T); 16036 SUITE_ADD_TEST(suite, equalSmallStringInt32T); 16037 SUITE_ADD_TEST(suite, equalSmallStringUint32T); 16038 SUITE_ADD_TEST(suite, equalSmallStringUint64T); 16039 SUITE_ADD_TEST(suite, equalSmallStringSmallBoolT); 16040 SUITE_ADD_TEST(suite, equalSmallStringSmallBytesT); 16041 SUITE_ADD_TEST(suite, equalSmallStringSmallDoubleT); 16042 SUITE_ADD_TEST(suite, equalSmallStringSmallIntT); 16043 SUITE_ADD_TEST(suite, equalSmallStringSmallJsonT); 16044 SUITE_ADD_TEST(suite, icEqualSmallStringT); 16045 SUITE_ADD_TEST(suite, icEqualSSmallStringT); 16046 SUITE_ADD_TEST(suite, icEqualCharSmallStringT); 16047 SUITE_ADD_TEST(suite, icEqualSmallStringBaseT); 16048 SUITE_ADD_TEST(suite, icEqualSmallStringSmallJsonT); 16049 SUITE_ADD_TEST(suite, equalISSmallStringT); 16050 SUITE_ADD_TEST(suite, equalICharSmallStringT); 16051 SUITE_ADD_TEST(suite, equalISmallJsonSmallStringT); 16052 SUITE_ADD_TEST(suite, equalISmallStringSmallStringT); 16053 SUITE_ADD_TEST(suite, startsWithSSmallStringT); 16054 SUITE_ADD_TEST(suite, startsWithCharSmallStringT); 16055 SUITE_ADD_TEST(suite, startsWithSmallJsonSmallStringT); 16056 SUITE_ADD_TEST(suite, startsWithSmallStringSmallStringT); 16057 SUITE_ADD_TEST(suite, endsWithSSmallStringT); 16058 SUITE_ADD_TEST(suite, endsWithCharSmallStringT); 16059 SUITE_ADD_TEST(suite, endsWithSmallJsonSmallStringT); 16060 SUITE_ADD_TEST(suite, endsWithSmallStringSmallStringT); 16061 SUITE_ADD_TEST(suite, countSSmallStringT); 16062 SUITE_ADD_TEST(suite, countCharSmallStringT); 16063 SUITE_ADD_TEST(suite, countSmallJsonSmallStringT); 16064 SUITE_ADD_TEST(suite, countSmallStringSmallStringT); 16065 SUITE_ADD_TEST(suite, icStartsWithSSmallStringT); 16066 SUITE_ADD_TEST(suite, icStartsWithCharSmallStringT); 16067 SUITE_ADD_TEST(suite, icStartsWithSmallJsonSmallStringT); 16068 SUITE_ADD_TEST(suite, icStartsWithSmallStringSmallStringT); 16069 SUITE_ADD_TEST(suite, icEndsWithSSmallStringT); 16070 SUITE_ADD_TEST(suite, icEndsWithCharSmallStringT); 16071 SUITE_ADD_TEST(suite, icEndsWithSmallJsonSmallStringT); 16072 SUITE_ADD_TEST(suite, icEndsWithSmallStringSmallStringT); 16073 SUITE_ADD_TEST(suite, icCountSSmallStringT); 16074 SUITE_ADD_TEST(suite, icCountCharSmallStringT); 16075 SUITE_ADD_TEST(suite, icCountSmallJsonSmallStringT); 16076 SUITE_ADD_TEST(suite, icCountSmallStringSmallStringT); 16077 SUITE_ADD_TEST(suite, isNumberSmallStringT); 16078 SUITE_ADD_TEST(suite, isIntSmallStringT); 16079 SUITE_ADD_TEST(suite, parseIntSmallStringT); 16080 SUITE_ADD_TEST(suite, parseDoubleSmallStringT); 16081 SUITE_ADD_TEST(suite, intToSmallStringT); 16082 SUITE_ADD_TEST(suite, doubleToSmallStringT); 16083 SUITE_ADD_TEST(suite, lenSmallStringT); 16084 SUITE_ADD_TEST(suite, upperSmallStringT); 16085 SUITE_ADD_TEST(suite, lowerSmallStringT); 16086 SUITE_ADD_TEST(suite, trimSmallStringT); 16087 SUITE_ADD_TEST(suite, lTrimSmallStringT); 16088 SUITE_ADD_TEST(suite, rTrimSmallStringT); 16089 SUITE_ADD_TEST(suite, uniqSmallStringT); 16090 SUITE_ADD_TEST(suite, icUniqSmallStringT); 16091 SUITE_ADD_TEST(suite, getAtSmallStringT); 16092 SUITE_ADD_TEST(suite, setAtSmallStringT); 16093 SUITE_ADD_TEST(suite, sliceSmallStringT); 16094 SUITE_ADD_TEST(suite, cropSmallStringT); 16095 SUITE_ADD_TEST(suite, cropSSmallStringT); 16096 SUITE_ADD_TEST(suite, cropSmallJsonSmallStringT); 16097 SUITE_ADD_TEST(suite, cropElemSmallStringT); 16098 SUITE_ADD_TEST(suite, copySmallStringT); 16099 SUITE_ADD_TEST(suite, insertSmallStringT); 16100 SUITE_ADD_TEST(suite, insertSmallJsonSmallStringT); 16101 SUITE_ADD_TEST(suite, insertSSmallStringT); 16102 SUITE_ADD_TEST(suite, insertNFreeSmallStringT); 16103 SUITE_ADD_TEST(suite, insertNFreeSmallJsonSmallStringT); 16104 SUITE_ADD_TEST(suite, insertSNFreeSmallStringT); 16105 SUITE_ADD_TEST(suite, injectSmallStringT); 16106 SUITE_ADD_TEST(suite, delSmallStringT); 16107 SUITE_ADD_TEST(suite, delElemSmallStringT); 16108 SUITE_ADD_TEST(suite, hasSmallStringT); 16109 SUITE_ADD_TEST(suite, hasCharSmallStringT); 16110 SUITE_ADD_TEST(suite, hasSmallJsonSmallStringT); 16111 SUITE_ADD_TEST(suite, hasSmallStringSmallStringT); 16112 SUITE_ADD_TEST(suite, findSmallStringT); 16113 SUITE_ADD_TEST(suite, findCharSmallStringT); 16114 SUITE_ADD_TEST(suite, findSmallJsonSmallStringT); 16115 SUITE_ADD_TEST(suite, findSmallStringSmallStringT); 16116 SUITE_ADD_TEST(suite, indexOfSmallStringT); 16117 SUITE_ADD_TEST(suite, indexOfCharSmallStringT); 16118 SUITE_ADD_TEST(suite, indexOfSmallJsonSmallStringT); 16119 SUITE_ADD_TEST(suite, indexOfSmallStringSmallStringT); 16120 SUITE_ADD_TEST(suite, icHasSmallStringT); 16121 SUITE_ADD_TEST(suite, icHasCharSmallStringT); 16122 SUITE_ADD_TEST(suite, icHasSmallJsonSmallStringT); 16123 SUITE_ADD_TEST(suite, icHasSmallStringSmallStringT); 16124 SUITE_ADD_TEST(suite, icFindSmallStringT); 16125 SUITE_ADD_TEST(suite, icFindCharSmallStringT); 16126 SUITE_ADD_TEST(suite, icFindSmallJsonSmallStringT); 16127 SUITE_ADD_TEST(suite, icFindSmallStringSmallStringT); 16128 SUITE_ADD_TEST(suite, icIndexOfSmallStringT); 16129 SUITE_ADD_TEST(suite, icIndexOfCharSmallStringT); 16130 SUITE_ADD_TEST(suite, icIndexOfSmallJsonSmallStringT); 16131 SUITE_ADD_TEST(suite, icIndexOfSmallStringSmallStringT); 16132 SUITE_ADD_TEST(suite, emptySmallStringT); 16133 SUITE_ADD_TEST(suite, isEmptySmallStringT); 16134 SUITE_ADD_TEST(suite, isBlankSmallStringT); 16135 SUITE_ADD_TEST(suite, splitSmallStringT); 16136 SUITE_ADD_TEST(suite, splitCharSmallStringT); 16137 SUITE_ADD_TEST(suite, splitSmallJsonSmallStringT); 16138 SUITE_ADD_TEST(suite, splitSmallStringSmallStringT); 16139 SUITE_ADD_TEST(suite, splitSSmallStringT); 16140 SUITE_ADD_TEST(suite, splitCharSSmallStringT); 16141 SUITE_ADD_TEST(suite, splitSmallJsonSSmallStringT); 16142 SUITE_ADD_TEST(suite, splitSmallStringSSmallStringT); 16143 SUITE_ADD_TEST(suite, extractSmallStringT); 16144 SUITE_ADD_TEST(suite, extractCharSSmallStringT); 16145 SUITE_ADD_TEST(suite, extractSCharSmallStringT); 16146 SUITE_ADD_TEST(suite, extractCharCharSmallStringT); 16147 SUITE_ADD_TEST(suite, extractSmallJsonSmallJsonSmallStringT); 16148 SUITE_ADD_TEST(suite, extractSmallJsonSmallStringSmallStringT); 16149 SUITE_ADD_TEST(suite, extractSmallJsonSSmallStringT); 16150 SUITE_ADD_TEST(suite, extractSmallJsonCharSmallStringT); 16151 SUITE_ADD_TEST(suite, extractSmallStringSmallJsonSmallStringT); 16152 SUITE_ADD_TEST(suite, extractSmallStringSmallStringSmallStringT); 16153 SUITE_ADD_TEST(suite, extractSmallStringSSmallStringT); 16154 SUITE_ADD_TEST(suite, extractSmallStringCharSmallStringT); 16155 SUITE_ADD_TEST(suite, extractSSmallJsonSmallStringT); 16156 SUITE_ADD_TEST(suite, extractSSmallStringSmallStringT); 16157 SUITE_ADD_TEST(suite, extractCharSmallJsonSmallStringT); 16158 SUITE_ADD_TEST(suite, extractCharSmallStringSmallStringT); 16159 SUITE_ADD_TEST(suite, icSplitSmallStringT); 16160 SUITE_ADD_TEST(suite, icSplitCharSmallStringT); 16161 SUITE_ADD_TEST(suite, icSplitSmallJsonSmallStringT); 16162 SUITE_ADD_TEST(suite, icSplitSmallStringSmallStringT); 16163 SUITE_ADD_TEST(suite, icSplitSSmallStringT); 16164 SUITE_ADD_TEST(suite, icSplitCharSSmallStringT); 16165 SUITE_ADD_TEST(suite, icSplitSmallJsonSSmallStringT); 16166 SUITE_ADD_TEST(suite, icSplitSmallStringSSmallStringT); 16167 SUITE_ADD_TEST(suite, icExtractSmallStringT); 16168 SUITE_ADD_TEST(suite, icExtractCharSSmallStringT); 16169 SUITE_ADD_TEST(suite, icExtractSCharSmallStringT); 16170 SUITE_ADD_TEST(suite, icExtractCharCharSmallStringT); 16171 SUITE_ADD_TEST(suite, icExtractSmallJsonSmallJsonSmallStringT); 16172 SUITE_ADD_TEST(suite, icExtractSmallJsonSmallStringSmallStringT); 16173 SUITE_ADD_TEST(suite, icExtractSmallJsonSSmallStringT); 16174 SUITE_ADD_TEST(suite, icExtractSmallJsonCharSmallStringT); 16175 SUITE_ADD_TEST(suite, icExtractSmallStringSmallJsonSmallStringT); 16176 SUITE_ADD_TEST(suite, icExtractSmallStringSmallStringSmallStringT); 16177 SUITE_ADD_TEST(suite, icExtractSmallStringSSmallStringT); 16178 SUITE_ADD_TEST(suite, icExtractSmallStringCharSmallStringT); 16179 SUITE_ADD_TEST(suite, icExtractSSmallJsonSmallStringT); 16180 SUITE_ADD_TEST(suite, icExtractSSmallStringSmallStringT); 16181 SUITE_ADD_TEST(suite, icExtractCharSmallJsonSmallStringT); 16182 SUITE_ADD_TEST(suite, icExtractCharSmallStringSmallStringT); 16183 SUITE_ADD_TEST(suite, colorSmallStringT); 16184 SUITE_ADD_TEST(suite, colordSmallStringT); 16185 SUITE_ADD_TEST(suite, readFileSmallStringT); 16186 SUITE_ADD_TEST(suite, readFileSmallJsonSmallStringT); 16187 SUITE_ADD_TEST(suite, readFileSmallStringSmallStringT); 16188 SUITE_ADD_TEST(suite, readStreamSmallStringT); 16189 SUITE_ADD_TEST(suite, writeFileSmallStringT); 16190 SUITE_ADD_TEST(suite, writeFileSmallJsonSmallStringT); 16191 SUITE_ADD_TEST(suite, writeFileSmallStringSmallStringT); 16192 SUITE_ADD_TEST(suite, writeStreamSmallStringT); 16193 SUITE_ADD_TEST(suite, appendFileSmallStringT); 16194 SUITE_ADD_TEST(suite, appendFileSmallStringSmallStringT); 16195 SUITE_ADD_TEST(suite, duplicateSmallStringGT); 16196 SUITE_ADD_TEST(suite, freeSmallStringGT); 16197 SUITE_ADD_TEST(suite, setBoolSmallStringGT); 16198 SUITE_ADD_TEST(suite, setDoubleSmallStringGT); 16199 SUITE_ADD_TEST(suite, setInt64SmallStringGT); 16200 SUITE_ADD_TEST(suite, setInt32SmallStringGT); 16201 SUITE_ADD_TEST(suite, setUint32SmallStringGT); 16202 SUITE_ADD_TEST(suite, setUint64SmallStringGT); 16203 SUITE_ADD_TEST(suite, setSmallStringGT); 16204 SUITE_ADD_TEST(suite, setCharSmallStringGT); 16205 SUITE_ADD_TEST(suite, setSmallArraySmallStringGT); 16206 SUITE_ADD_TEST(suite, setFromSmallDictSmallStringGT); 16207 SUITE_ADD_TEST(suite, setFromSmallJsonSmallStringGT); 16208 SUITE_ADD_TEST(suite, setSmallBoolSmallStringGT); 16209 SUITE_ADD_TEST(suite, setSmallDoubleSmallStringGT); 16210 SUITE_ADD_TEST(suite, setSmallIntSmallStringGT); 16211 SUITE_ADD_TEST(suite, setSmallJsonSmallStringGT); 16212 SUITE_ADD_TEST(suite, setSmallStringSmallStringGT); 16213 SUITE_ADD_TEST(suite, getAtSmallStringGT); 16214 SUITE_ADD_TEST(suite, setAtSmallStringGT); 16215 SUITE_ADD_TEST(suite, appendSmallStringGT); 16216 SUITE_ADD_TEST(suite, appendSmallJsonSmallStringGT); 16217 SUITE_ADD_TEST(suite, appendSSmallStringGT); 16218 SUITE_ADD_TEST(suite, appendCharSmallStringGT); 16219 SUITE_ADD_TEST(suite, appendNSmashSmallStringGT); 16220 SUITE_ADD_TEST(suite, appendNSmashSmallJsonSmallStringGT); 16221 SUITE_ADD_TEST(suite, appendNSmashSSmallStringGT); 16222 SUITE_ADD_TEST(suite, prependSmallStringGT); 16223 SUITE_ADD_TEST(suite, prependSmallJsonSmallStringGT); 16224 SUITE_ADD_TEST(suite, prependSSmallStringGT); 16225 SUITE_ADD_TEST(suite, prependCharSmallStringGT); 16226 SUITE_ADD_TEST(suite, prependNSmashSmallStringGT); 16227 SUITE_ADD_TEST(suite, prependNSmashSmallJsonSmallStringGT); 16228 SUITE_ADD_TEST(suite, prependNSmashSSmallStringGT); 16229 SUITE_ADD_TEST(suite, replaceSmallStringGT); 16230 SUITE_ADD_TEST(suite, replaceCharSSmallStringGT); 16231 SUITE_ADD_TEST(suite, replaceSCharSmallStringGT); 16232 SUITE_ADD_TEST(suite, replaceCharCharSmallStringGT); 16233 SUITE_ADD_TEST(suite, replaceSmallJsonSmallJsonSmallStringGT); 16234 SUITE_ADD_TEST(suite, replaceSmallJsonSmallStringSmallStringGT); 16235 SUITE_ADD_TEST(suite, replaceSmallJsonSSmallStringGT); 16236 SUITE_ADD_TEST(suite, replaceSmallJsonCharSmallStringGT); 16237 SUITE_ADD_TEST(suite, replaceSmallStringSmallJsonSmallStringGT); 16238 SUITE_ADD_TEST(suite, replaceSmallStringSmallStringSmallStringGT); 16239 SUITE_ADD_TEST(suite, replaceSmallStringSSmallStringGT); 16240 SUITE_ADD_TEST(suite, replaceSmallStringCharSmallStringGT); 16241 SUITE_ADD_TEST(suite, replaceSSmallJsonSmallStringGT); 16242 SUITE_ADD_TEST(suite, replaceSSmallStringSmallStringGT); 16243 SUITE_ADD_TEST(suite, replaceCharSmallJsonSmallStringGT); 16244 SUITE_ADD_TEST(suite, replaceCharSmallStringSmallStringGT); 16245 SUITE_ADD_TEST(suite, icReplaceSmallStringGT); 16246 SUITE_ADD_TEST(suite, icReplaceCharSSmallStringGT); 16247 SUITE_ADD_TEST(suite, icReplaceSCharSmallStringGT); 16248 SUITE_ADD_TEST(suite, icReplaceCharCharSmallStringGT); 16249 SUITE_ADD_TEST(suite, icReplaceSmallJsonSmallJsonSmallStringGT); 16250 SUITE_ADD_TEST(suite, icReplaceSmallJsonSmallStringSmallStringGT); 16251 SUITE_ADD_TEST(suite, icReplaceSmallJsonSSmallStringGT); 16252 SUITE_ADD_TEST(suite, icReplaceSmallJsonCharSmallStringGT); 16253 SUITE_ADD_TEST(suite, icReplaceSmallStringSmallJsonSmallStringGT); 16254 SUITE_ADD_TEST(suite, icReplaceSmallStringSmallStringSmallStringGT); 16255 SUITE_ADD_TEST(suite, icReplaceSmallStringSSmallStringGT); 16256 SUITE_ADD_TEST(suite, icReplaceSmallStringCharSmallStringGT); 16257 SUITE_ADD_TEST(suite, icReplaceSSmallJsonSmallStringGT); 16258 SUITE_ADD_TEST(suite, icReplaceSSmallStringSmallStringGT); 16259 SUITE_ADD_TEST(suite, icReplaceCharSmallJsonSmallStringGT); 16260 SUITE_ADD_TEST(suite, icReplaceCharSmallStringSmallStringGT); 16261 SUITE_ADD_TEST(suite, equalSmallStringFGT); 16262 SUITE_ADD_TEST(suite, equalCharSmallStringGT); 16263 SUITE_ADD_TEST(suite, equalSSmallStringGT); 16264 SUITE_ADD_TEST(suite, equalSmallStringBaseGT); 16265 SUITE_ADD_TEST(suite, equalSmallStringBoolGT); 16266 SUITE_ADD_TEST(suite, equalSmallStringDoubleGT); 16267 SUITE_ADD_TEST(suite, equalSmallStringInt64GT); 16268 SUITE_ADD_TEST(suite, equalSmallStringInt32GT); 16269 SUITE_ADD_TEST(suite, equalSmallStringUint32GT); 16270 SUITE_ADD_TEST(suite, equalSmallStringUint64GT); 16271 SUITE_ADD_TEST(suite, equalSmallStringSmallBoolGT); 16272 SUITE_ADD_TEST(suite, equalSmallStringSmallBytesGT); 16273 SUITE_ADD_TEST(suite, equalSmallStringSmallDoubleGT); 16274 SUITE_ADD_TEST(suite, equalSmallStringSmallIntGT); 16275 SUITE_ADD_TEST(suite, equalSmallStringSmallJsonGT); 16276 SUITE_ADD_TEST(suite, icEqualSmallStringFGT); 16277 SUITE_ADD_TEST(suite, icEqualCharSmallStringGT); 16278 SUITE_ADD_TEST(suite, icEqualSSmallStringGT); 16279 SUITE_ADD_TEST(suite, icEqualSmallStringBaseGT); 16280 SUITE_ADD_TEST(suite, icEqualSmallStringSmallJsonGT); 16281 SUITE_ADD_TEST(suite, equalISSmallStringGT); 16282 SUITE_ADD_TEST(suite, equalICharSmallStringGT); 16283 SUITE_ADD_TEST(suite, equalISmallJsonSmallStringGT); 16284 SUITE_ADD_TEST(suite, equalISmallStringSmallStringGT); 16285 SUITE_ADD_TEST(suite, startsWithSSmallStringGT); 16286 SUITE_ADD_TEST(suite, startsWithCharSmallStringGT); 16287 SUITE_ADD_TEST(suite, startsWithSmallJsonSmallStringGT); 16288 SUITE_ADD_TEST(suite, startsWithSmallStringSmallStringGT); 16289 SUITE_ADD_TEST(suite, endsWithSSmallStringGT); 16290 SUITE_ADD_TEST(suite, endsWithCharSmallStringGT); 16291 SUITE_ADD_TEST(suite, endsWithSmallJsonSmallStringGT); 16292 SUITE_ADD_TEST(suite, endsWithSmallStringSmallStringGT); 16293 SUITE_ADD_TEST(suite, countSSmallStringGT); 16294 SUITE_ADD_TEST(suite, countCharSmallStringGT); 16295 SUITE_ADD_TEST(suite, countSmallJsonSmallStringGT); 16296 SUITE_ADD_TEST(suite, countSmallStringSmallStringGT); 16297 SUITE_ADD_TEST(suite, icStartsWithSSmallStringGT); 16298 SUITE_ADD_TEST(suite, icStartsWithCharSmallStringGT); 16299 SUITE_ADD_TEST(suite, icStartsWithSmallJsonSmallStringGT); 16300 SUITE_ADD_TEST(suite, icStartsWithSmallStringSmallStringGT); 16301 SUITE_ADD_TEST(suite, icEndsWithSSmallStringGT); 16302 SUITE_ADD_TEST(suite, icEndsWithCharSmallStringGT); 16303 SUITE_ADD_TEST(suite, icEndsWithSmallJsonSmallStringGT); 16304 SUITE_ADD_TEST(suite, icEndsWithSmallStringSmallStringGT); 16305 SUITE_ADD_TEST(suite, icCountSSmallStringGT); 16306 SUITE_ADD_TEST(suite, icCountCharSmallStringGT); 16307 SUITE_ADD_TEST(suite, icCountSmallJsonSmallStringGT); 16308 SUITE_ADD_TEST(suite, icCountSmallStringSmallStringGT); 16309 SUITE_ADD_TEST(suite, isNumberSmallStringGT); 16310 SUITE_ADD_TEST(suite, isIntSmallStringGT); 16311 SUITE_ADD_TEST(suite, parseIntSmallStringGT); 16312 SUITE_ADD_TEST(suite, intToSmallStringGT); 16313 SUITE_ADD_TEST(suite, parseDoubleSmallStringGT); 16314 SUITE_ADD_TEST(suite, doubleToSmallStringGT); 16315 SUITE_ADD_TEST(suite, lenSmallStringGT); 16316 SUITE_ADD_TEST(suite, upperSmallStringGT); 16317 SUITE_ADD_TEST(suite, lowerSmallStringGT); 16318 SUITE_ADD_TEST(suite, trimSmallStringGT); 16319 SUITE_ADD_TEST(suite, lTrimSmallStringGT); 16320 SUITE_ADD_TEST(suite, rTrimSmallStringGT); 16321 SUITE_ADD_TEST(suite, uniqSmallStringGT); 16322 SUITE_ADD_TEST(suite, icUniqSmallStringGT); 16323 SUITE_ADD_TEST(suite, sliceSmallStringGT); 16324 SUITE_ADD_TEST(suite, cropSmallStringGT); 16325 SUITE_ADD_TEST(suite, cropSSmallStringGT); 16326 SUITE_ADD_TEST(suite, cropSmallJsonSmallStringGT); 16327 SUITE_ADD_TEST(suite, cropElemSmallStringGT); 16328 SUITE_ADD_TEST(suite, copySmallStringGT); 16329 SUITE_ADD_TEST(suite, insertSmallStringGT); 16330 SUITE_ADD_TEST(suite, insertSmallJsonSmallStringGT); 16331 SUITE_ADD_TEST(suite, insertSSmallStringGT); 16332 SUITE_ADD_TEST(suite, insertNFreeSmallStringGT); 16333 SUITE_ADD_TEST(suite, insertNFreeSmallJsonSmallStringGT); 16334 SUITE_ADD_TEST(suite, insertSNFreeSmallStringGT); 16335 SUITE_ADD_TEST(suite, injectSmallStringGT); 16336 SUITE_ADD_TEST(suite, delSmallStringGT); 16337 SUITE_ADD_TEST(suite, delElemSmallStringGT); 16338 SUITE_ADD_TEST(suite, hasSmallStringGT); 16339 SUITE_ADD_TEST(suite, hasCharSmallStringGT); 16340 SUITE_ADD_TEST(suite, hasSmallJsonSmallStringGT); 16341 SUITE_ADD_TEST(suite, hasSmallStringSmallStringGT); 16342 SUITE_ADD_TEST(suite, findSmallStringGT); 16343 SUITE_ADD_TEST(suite, findCharSmallStringGT); 16344 SUITE_ADD_TEST(suite, findSmallJsonSmallStringGT); 16345 SUITE_ADD_TEST(suite, findSmallStringSmallStringGT); 16346 SUITE_ADD_TEST(suite, indexOfSmallStringGT); 16347 SUITE_ADD_TEST(suite, indexOfCharSmallStringGT); 16348 SUITE_ADD_TEST(suite, indexOfSmallJsonSmallStringGT); 16349 SUITE_ADD_TEST(suite, indexOfSmallStringSmallStringGT); 16350 SUITE_ADD_TEST(suite, icHasSmallStringGT); 16351 SUITE_ADD_TEST(suite, icHasCharSmallStringGT); 16352 SUITE_ADD_TEST(suite, icHasSmallJsonSmallStringGT); 16353 SUITE_ADD_TEST(suite, icHasSmallStringSmallStringGT); 16354 SUITE_ADD_TEST(suite, icFindSmallStringGT); 16355 SUITE_ADD_TEST(suite, icFindCharSmallStringGT); 16356 SUITE_ADD_TEST(suite, icFindSmallJsonSmallStringGT); 16357 SUITE_ADD_TEST(suite, icFindSmallStringSmallStringGT); 16358 SUITE_ADD_TEST(suite, icIndexOfSmallStringGT); 16359 SUITE_ADD_TEST(suite, icIndexOfCharSmallStringGT); 16360 SUITE_ADD_TEST(suite, icIndexOfSmallJsonSmallStringGT); 16361 SUITE_ADD_TEST(suite, icIndexOfSmallStringSmallStringGT); 16362 SUITE_ADD_TEST(suite, emptySmallStringGT); 16363 SUITE_ADD_TEST(suite, isEmptySmallStringGT); 16364 SUITE_ADD_TEST(suite, isBlankSmallStringGT); 16365 SUITE_ADD_TEST(suite, splitSmallStringGT); 16366 SUITE_ADD_TEST(suite, splitCharSmallStringGT); 16367 SUITE_ADD_TEST(suite, splitSmallJsonSmallStringGT); 16368 SUITE_ADD_TEST(suite, splitSmallStringSmallStringGT); 16369 SUITE_ADD_TEST(suite, splitCharPSSmallStringGT); 16370 SUITE_ADD_TEST(suite, splitCharSSmallStringGT); 16371 SUITE_ADD_TEST(suite, splitSmallJsonSSmallStringGT); 16372 SUITE_ADD_TEST(suite, splitSmallStringSSmallStringGT); 16373 SUITE_ADD_TEST(suite, extractSmallStringGT); 16374 SUITE_ADD_TEST(suite, extractCharSSmallStringGT); 16375 SUITE_ADD_TEST(suite, extractSCharSmallStringGT); 16376 SUITE_ADD_TEST(suite, extractCharCharSmallStringGT); 16377 SUITE_ADD_TEST(suite, extractSmallJsonSmallJsonSmallStringGT); 16378 SUITE_ADD_TEST(suite, extractSmallJsonSmallStringSmallStringGT); 16379 SUITE_ADD_TEST(suite, extractSmallJsonSSmallStringGT); 16380 SUITE_ADD_TEST(suite, extractSmallJsonCharSmallStringGT); 16381 SUITE_ADD_TEST(suite, extractSmallStringSmallJsonSmallStringGT); 16382 SUITE_ADD_TEST(suite, extractSmallStringSmallStringSmallStringGT); 16383 SUITE_ADD_TEST(suite, extractSmallStringSSmallStringGT); 16384 SUITE_ADD_TEST(suite, extractSmallStringCharSmallStringGT); 16385 SUITE_ADD_TEST(suite, extractSSmallJsonSmallStringGT); 16386 SUITE_ADD_TEST(suite, extractSSmallStringSmallStringGT); 16387 SUITE_ADD_TEST(suite, extractCharSmallJsonSmallStringGT); 16388 SUITE_ADD_TEST(suite, extractCharSmallStringSmallStringGT); 16389 SUITE_ADD_TEST(suite, icSplitSmallStringGT); 16390 SUITE_ADD_TEST(suite, icSplitCharSmallStringGT); 16391 SUITE_ADD_TEST(suite, icSplitSmallJsonSmallStringGT); 16392 SUITE_ADD_TEST(suite, icSplitSmallStringSmallStringGT); 16393 SUITE_ADD_TEST(suite, icSplitCharPSSmallStringGT); 16394 SUITE_ADD_TEST(suite, icSplitCharSSmallStringGT); 16395 SUITE_ADD_TEST(suite, icSplitSmallJsonSSmallStringGT); 16396 SUITE_ADD_TEST(suite, icSplitSmallStringSSmallStringGT); 16397 SUITE_ADD_TEST(suite, icExtractSmallStringGT); 16398 SUITE_ADD_TEST(suite, icExtractCharSSmallStringGT); 16399 SUITE_ADD_TEST(suite, icExtractSCharSmallStringGT); 16400 SUITE_ADD_TEST(suite, icExtractCharCharSmallStringGT); 16401 SUITE_ADD_TEST(suite, icExtractSmallJsonSmallJsonSmallStringGT); 16402 SUITE_ADD_TEST(suite, icExtractSmallJsonSmallStringSmallStringGT); 16403 SUITE_ADD_TEST(suite, icExtractSmallJsonSSmallStringGT); 16404 SUITE_ADD_TEST(suite, icExtractSmallJsonCharSmallStringGT); 16405 SUITE_ADD_TEST(suite, icExtractSmallStringSmallJsonSmallStringGT); 16406 SUITE_ADD_TEST(suite, icExtractSmallStringSmallStringSmallStringGT); 16407 SUITE_ADD_TEST(suite, icExtractSmallStringSSmallStringGT); 16408 SUITE_ADD_TEST(suite, icExtractSmallStringCharSmallStringGT); 16409 SUITE_ADD_TEST(suite, icExtractSSmallJsonSmallStringGT); 16410 SUITE_ADD_TEST(suite, icExtractSSmallStringSmallStringGT); 16411 SUITE_ADD_TEST(suite, icExtractCharSmallJsonSmallStringGT); 16412 SUITE_ADD_TEST(suite, icExtractCharSmallStringSmallStringGT); 16413 SUITE_ADD_TEST(suite, readFileSmallStringGT); 16414 SUITE_ADD_TEST(suite, readFileSmallJsonSmallStringGT); 16415 SUITE_ADD_TEST(suite, readFileSmallStringSmallStringGT); 16416 SUITE_ADD_TEST(suite, readStreamSmallStringGT); 16417 SUITE_ADD_TEST(suite, writeFileSmallStringGT); 16418 SUITE_ADD_TEST(suite, writeFileSmallJsonSmallStringGT); 16419 SUITE_ADD_TEST(suite, writeFileSmallStringSmallStringGT); 16420 SUITE_ADD_TEST(suite, writeStreamSmallStringGT); 16421 SUITE_ADD_TEST(suite, appendFileSmallStringFGT); 16422 SUITE_ADD_TEST(suite, appendFileSmallStringSmallStringGT); 16423 16424 16425 CuSuiteRun(suite); 16426 CuSuiteDetails(suite, output); 16427 printf ("%s\n", output->buffer); 16428 return suite->failCount; 16429 }