libsheepyObjectFuncTestMem.c (150418B)
1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <string.h> 4 5 #define ck_assert_str_eq(a,b) a;b; 6 #define ck_assert_str_ne(a,b) a;b; 7 #define ck_assert_ptr_eq(a,b) a;b; 8 #define ck_assert_ptr_ne(a,b) a;b; 9 #define ck_assert_uint_eq(a,b) a;b; 10 #define ck_assert_uint_ne(a,b) a;b; 11 #define ck_assert_int_eq(a,b) a;b; 12 #define ck_assert_int_ne(a,b) a;b; 13 #define ck_assert(a) a; 14 15 16 #include "../libsheepy.h" 17 #include "../libsheepyObject.h" 18 19 #ifdef __GNUC__ 20 #define UNUSED __attribute__ ((unused)) 21 #else 22 #define UNUSED 23 #endif 24 25 // TODO redirect stderr 26 27 28 void shSysinfoT(void) { 29 30 smallDictt *r; 31 32 r = shSysinfo(); 33 ck_assert_ptr_ne(r, null); 34 terminateO(r); 35 36 } 37 38 39 void duplicateBaseGT(void) { 40 41 baset *r; 42 baset *self = (baset*) allocSmallInt(1); 43 44 r = duplicateBaseG(self); 45 terminateO(self); 46 char *s = toStringO(r); 47 ck_assert_str_eq(s, "1"); 48 free(s); 49 terminateO(r); 50 51 } 52 53 54 void freeManyOFT(void) { 55 56 smallIntt *i0 = allocSmallInt(1); 57 smallIntt *i1 = allocSmallInt(2); 58 smallIntt *i2 = allocSmallInt(3); 59 60 freeManyOF(i0, i1, i2, null); 61 char *s = toStringO(i0); 62 ck_assert_ptr_eq(s, null); 63 s = toStringO(i1); 64 ck_assert_ptr_eq(s, null); 65 s = toStringO(i2); 66 ck_assert_ptr_eq(s, null); 67 terminateO(i0); 68 terminateO(i1); 69 terminateO(i2); 70 71 } 72 73 74 void terminateManyOFT(void) { 75 76 smallIntt *i0 = allocSmallInt(1); 77 smallIntt *i1 = allocSmallInt(2); 78 smallIntt *i2 = allocSmallInt(3); 79 80 terminateManyOF(i0, i1, i2, null); 81 82 } 83 84 85 void smashManyOFT(void) { 86 87 createAllocateSmallInt(i0); 88 createAllocateSmallInt(i1); 89 createAllocateSmallInt(i2); 90 91 smashManyOF(i0, i1, i2, null); 92 93 } 94 95 96 void finishManyOFT(void) { 97 98 createAllocateSmallInt(i0); 99 createAllocateSmallInt(i1); 100 createAllocateSmallInt(i2); 101 102 finishManyOF(i0, i1, i2, null); 103 104 } 105 106 107 void getProgPathJOT(void) { 108 109 smallJsont *r; 110 111 r = getProgPathJO(); 112 ck_assert_ptr_ne(r, null); 113 terminateO(r); 114 115 } 116 117 118 void getProgPathOT(void) { 119 120 smallStringt *r; 121 122 r = getProgPathO(); 123 ck_assert_ptr_ne(r, null); 124 terminateO(r); 125 126 } 127 128 129 void getRealProgPathJOT(void) { 130 131 smallJsont *r; 132 133 r = getRealProgPathJO(); 134 ck_assert_ptr_ne(r, null); 135 terminateO(r); 136 137 } 138 139 140 void getRealProgPathOT(void) { 141 142 smallStringt *r; 143 144 r = getRealProgPathO(); 145 ck_assert_ptr_ne(r, null); 146 terminateO(r); 147 freeRealProgPath(); 148 149 } 150 151 152 void systemJOT(void) { 153 154 int r; 155 smallJsont *command = allocSmallJson(); 156 setTopStringO(command, "echo TEST"); 157 158 r = systemJO(command); 159 ck_assert_int_eq(r, 0); 160 // non json string 161 freeO(command); 162 r = systemJO(command); 163 ck_assert_int_eq(r, -1); 164 // null command 165 r = systemJO(null); 166 ck_assert_int_eq(r, -1); 167 terminateO(command); 168 169 } 170 171 172 void systemOT(void) { 173 174 int r; 175 smallStringt *command = allocSmallString("echo TEST"); 176 177 r = systemO(command); 178 ck_assert_int_eq(r, 0); 179 // null command 180 r = systemO(null); 181 ck_assert_int_eq(r, -1); 182 terminateO(command); 183 184 } 185 186 187 void systemNFreeJOFT(void) { 188 189 int r; 190 smallJsont *command = allocSmallJson(); 191 setTopStringO(command, "echo TEST"); 192 193 r = systemNFreeOJ(command); 194 ck_assert_int_eq(r, 0); 195 // unknown command 196 command = allocSmallJson(); 197 setTopStringO(command, "randomCommand"); 198 r = systemNFreeOJ(command); 199 ck_assert_int_ne(r, 0); 200 // non json string 201 command = allocSmallJson(); 202 r = systemNFreeOJ(command); 203 ck_assert_int_eq(r, -1); 204 terminateO(command); 205 // null command 206 r = systemNFreeOJ(null); 207 ck_assert_int_eq(r, -1); 208 209 } 210 211 212 void systemNFreeOFT(void) { 213 214 int r; 215 smallStringt *command = allocSmallString("echo TEST"); 216 217 r = systemNFreeO(command); 218 ck_assert_int_eq(r, 0); 219 // unknown command 220 command = allocSmallString("randomCommand"); 221 r = systemNFreeO(command); 222 ck_assert_int_ne(r, 0); 223 // null command 224 r = systemNFreeO(null); 225 ck_assert_int_eq(r, -1); 226 227 } 228 229 230 void print_mT(void) { 231 232 // TODO 233 /* int r; */ 234 /* FILE *stream; */ 235 /* const struct printf_info *info; */ 236 /* const void *const *args; */ 237 238 //r = print_m(); 239 240 } 241 242 243 void print_m_arginfoT(void) { 244 245 // TODO 246 /* int r; */ 247 /* const struct printf_info *info UNUSED; */ 248 /* size_t n; */ 249 /* int *argtypes; */ 250 /* int* size; */ 251 252 //r = print_m_arginfo(); 253 254 } 255 256 257 void putsUndefinedGFT(void) { 258 259 undefinedt* object = allocUndefined(); 260 261 putsUndefinedGF(object); 262 ck_assert_ptr_ne(object, null); 263 terminateO(object); 264 putsUndefinedGF(null); 265 266 } 267 268 269 void putsBoolGFT(void) { 270 271 putsBoolGF(true); 272 273 } 274 275 276 void putsBoolPGFT(void) { 277 278 bool v = true; 279 280 putsBoolPGF(&v); 281 putsBoolPGF(null); 282 283 } 284 285 286 void putsDoubleGFT(void) { 287 288 putsDoubleGF(1.5); 289 290 } 291 292 293 void putsDoublePGFT(void) { 294 295 double object = 1.5; 296 297 putsDoublePGF(&object); 298 putsDoublePGF(null); 299 300 } 301 302 303 void putsIntGFT(void) { 304 305 putsIntGF(2); 306 307 } 308 309 310 void putsIntPGFT(void) { 311 312 int64_t object = 2; 313 314 putsIntPGF(&object); 315 putsIntPGF(null); 316 317 } 318 319 320 void putsInt32GFT(void) { 321 322 putsInt32GF(2); 323 324 } 325 326 327 void putsInt32PGFT(void) { 328 329 int32_t object = 2; 330 331 putsInt32PGF(&object); 332 putsInt32PGF(null); 333 334 } 335 336 337 void putsUintGFT(void) { 338 339 putsUintGF(2); 340 341 } 342 343 344 void putsUintPGFT(void) { 345 346 uint64_t object = 2; 347 348 putsUintPGF(&object); 349 putsUintPGF(null); 350 351 } 352 353 354 void putsUint32GFT(void) { 355 356 putsUint32GF(2); 357 358 } 359 360 361 void putsUint32PGFT(void) { 362 363 uint32_t object = 2; 364 365 putsUint32PGF(&object); 366 putsUint32PGF(null); 367 368 } 369 370 371 void putsSGFT(void) { 372 373 putsSGF("puts"); 374 putsSGF(null); 375 376 } 377 378 379 void putsListSGFT(void) { 380 381 char** object = listCreateS("a", "bb"); 382 383 putsListSGF(object); 384 listFreeS(object); 385 putsListSGF(null); 386 387 } 388 389 390 void putsListCSGFT(void) { 391 392 const char* object[] = {"a", "bb", null}; 393 394 putsListCSGF(object); 395 putsListCSGF(null); 396 397 } 398 399 400 void putsDictGFT(void) { 401 402 smallDictt* object = allocSmallDict(); 403 404 putsDictGF(object); 405 terminateO(object); 406 putsDictGF(null); 407 408 } 409 410 411 void putsJsonGFT(void) { 412 413 smallJsont* object = allocSmallJson(); 414 415 putsJsonGF(object); 416 terminateO(object); 417 putsJsonGF(null); 418 419 } 420 421 422 void putsArrayGFT(void) { 423 424 smallArrayt* object = allocSmallArray(); 425 426 putsArrayGF(object); 427 terminateO(object); 428 putsArrayGF(null); 429 430 } 431 432 433 void putsSmallBoolGFT(void) { 434 435 smallBoolt* object = allocSmallBool(true); 436 437 putsSmallBoolGF(object); 438 freeO(object); 439 putsSmallBoolGF(object); 440 terminateO(object); 441 putsSmallBoolGF(null); 442 443 } 444 445 446 void putsSmallBytesGFT(void) { 447 448 smallBytest* object = allocSmallBytes("qwe", sizeof("qwe")); 449 450 putsSmallBytesGF(object); 451 freeO(object); 452 putsSmallBytesGF(object); 453 terminateO(object); 454 putsSmallBytesGF(null); 455 456 } 457 458 459 void putsSmallDoubleGFT(void) { 460 461 smallDoublet* object = allocSmallDouble(1.5); 462 463 putsSmallDoubleGF(object); 464 freeO(object); 465 putsSmallDoubleGF(object); 466 terminateO(object); 467 putsSmallDoubleGF(null); 468 469 } 470 471 472 void putsSmallIntGFT(void) { 473 474 smallIntt* object = allocSmallInt(3); 475 476 putsSmallIntGF(object); 477 freeO(object); 478 putsSmallIntGF(object); 479 terminateO(object); 480 putsSmallIntGF(null); 481 482 } 483 484 485 void putsSmallStringGFT(void) { 486 487 smallStringt* object = allocSmallString("str"); 488 489 putsSmallStringGF(object); 490 freeO(object); 491 putsSmallStringGF(object); 492 terminateO(object); 493 putsSmallStringGF(null); 494 495 } 496 497 498 void putsVoidGFT(void) { 499 500 void* object = null; 501 502 putsVoidGF(&object); 503 putsVoidGF(null); 504 505 } 506 507 508 void putsSmallContainerGFT(void) { 509 510 smallContainert* object = allocSmallContainer(null); 511 512 putsSmallContainerGF(object); 513 freeO(object); 514 putsSmallContainerGF(object); 515 terminateO(object); 516 putsSmallContainerGF(null); 517 518 } 519 520 521 void toStringOFT(void) { 522 523 char *r; 524 baset* object = (baset*) allocSmallInt(22); 525 526 r = toStringOF(object); 527 ck_assert_str_eq(r, "22"); 528 free(r); 529 // empty object 530 freeO(object); 531 r = toStringOF(object); 532 ck_assert_ptr_eq(r, null); 533 terminateO(object); 534 // null object 535 r = toStringOF(null); 536 ck_assert_ptr_eq(r, null); 537 538 } 539 540 541 void toStringUndefinedGFT(void) { 542 543 char *r; 544 undefinedt* object = allocUndefined(); 545 546 r = toStringUndefinedGF(object); 547 ck_assert_str_eq(r, "null"); 548 free(r); 549 terminateO(object); 550 // null object 551 r = toStringUndefinedGF(null); 552 ck_assert_ptr_eq(r, null); 553 554 } 555 556 557 void toStringBoolGFT(void) { 558 559 char *r; 560 561 r = toStringBoolGF(true); 562 ck_assert_str_eq(r, "true"); 563 free(r); 564 r = toStringBoolGF(false); 565 ck_assert_str_eq(r, "false"); 566 free(r); 567 568 } 569 570 571 void toStringBoolPGFT(void) { 572 573 char *r; 574 bool object = true; 575 576 r = toStringBoolPGF(&object); 577 ck_assert_str_eq(r, "true"); 578 free(r); 579 object = false; 580 r = toStringBoolPGF(&object); 581 ck_assert_str_eq(r, "false"); 582 free(r); 583 // null object 584 r = toStringBoolPGF(null); 585 ck_assert_ptr_eq(r, null); 586 587 } 588 589 590 void toStringFloatGFT(void) { 591 592 char *r; 593 594 r = toStringFloatGF(2.5); 595 ck_assert_str_eq(r, "2.500000"); 596 free(r); 597 598 } 599 600 601 void toStringFloatPGFT(void) { 602 603 char *r; 604 float object = 2.5; 605 606 r = toStringFloatPGF(&object); 607 ck_assert_str_eq(r, "2.500000"); 608 free(r); 609 r = toStringFloatPGF(null); 610 ck_assert_ptr_eq(r, null); 611 612 } 613 614 615 void toStringDoubleGFT(void) { 616 617 char *r; 618 619 r = toStringDoubleGF(2.5); 620 ck_assert_str_eq(r, "2.500000e+00"); 621 free(r); 622 623 } 624 625 626 void toStringDoublePGFT(void) { 627 628 char *r; 629 double object = 2.5; 630 631 r = toStringDoublePGF(&object); 632 ck_assert_str_eq(r, "2.500000e+00"); 633 free(r); 634 r = toStringDoublePGF(null); 635 ck_assert_ptr_eq(r, null); 636 637 } 638 639 640 void toStringIntGFT(void) { 641 642 char *r; 643 644 r = toStringIntGF(2); 645 ck_assert_str_eq(r, "2"); 646 free(r); 647 648 } 649 650 651 void toStringIntPGFT(void) { 652 653 char *r; 654 int64_t object = 2; 655 656 r = toStringIntPGF(&object); 657 ck_assert_str_eq(r, "2"); 658 free(r); 659 r = toStringIntPGF(null); 660 ck_assert_ptr_eq(r, null); 661 662 } 663 664 665 void toStringInt32GFT(void) { 666 667 char *r; 668 669 r = toStringInt32GF(2); 670 ck_assert_str_eq(r, "2"); 671 free(r); 672 673 } 674 675 676 void toStringInt32PGFT(void) { 677 678 char *r; 679 int32_t object = 2; 680 681 r = toStringInt32PGF(&object); 682 ck_assert_str_eq(r, "2"); 683 free(r); 684 r = toStringInt32PGF(null); 685 ck_assert_ptr_eq(r, null); 686 687 } 688 689 690 void toStringInt16GFT(void) { 691 692 char *r; 693 694 r = toStringInt16GF(2); 695 ck_assert_str_eq(r, "2"); 696 free(r); 697 698 } 699 700 701 void toStringInt16PGFT(void) { 702 703 char *r; 704 int16_t object = 2; 705 706 r = toStringInt16PGF(&object); 707 ck_assert_str_eq(r, "2"); 708 free(r); 709 r = toStringInt16PGF(null); 710 ck_assert_ptr_eq(r, null); 711 712 } 713 714 715 void toStringUintGFT(void) { 716 717 char *r; 718 719 r = toStringUintGF(2); 720 ck_assert_str_eq(r, "2"); 721 free(r); 722 723 } 724 725 726 void toStringUintPGFT(void) { 727 728 char *r; 729 uint64_t object = 2; 730 731 r = toStringUintPGF(&object); 732 ck_assert_str_eq(r, "2"); 733 free(r); 734 r = toStringUintPGF(null); 735 ck_assert_ptr_eq(r, null); 736 737 } 738 739 740 void toStringUint32GFT(void) { 741 742 char *r; 743 744 r = toStringUint32GF(2); 745 ck_assert_str_eq(r, "2"); 746 free(r); 747 748 } 749 750 751 void toStringUint32PGFT(void) { 752 753 char *r; 754 uint32_t object = 2; 755 756 r = toStringUint32PGF(&object); 757 ck_assert_str_eq(r, "2"); 758 free(r); 759 r = toStringUintPGF(null); 760 ck_assert_ptr_eq(r, null); 761 762 } 763 764 765 void toStringUint16GFT(void) { 766 767 char *r; 768 769 r = toStringUint16GF(2); 770 ck_assert_str_eq(r, "2"); 771 free(r); 772 773 } 774 775 776 void toStringUint16PGFT(void) { 777 778 char *r; 779 uint16_t object = 2; 780 781 r = toStringUint16PGF(&object); 782 ck_assert_str_eq(r, "2"); 783 free(r); 784 r = toStringUint16PGF(null); 785 ck_assert_ptr_eq(r, null); 786 787 } 788 789 790 void toStringUint8GFT(void) { 791 792 char *r; 793 794 r = toStringUint8GF(2); 795 ck_assert_str_eq(r, "2"); 796 free(r); 797 798 } 799 800 801 void toStringUint8PGFT(void) { 802 803 char *r; 804 uint8_t object = 2; 805 806 r = toStringUint8PGF(&object); 807 ck_assert_str_eq(r, "2"); 808 free(r); 809 r = toStringUint8PGF(null); 810 ck_assert_ptr_eq(r, null); 811 812 } 813 814 815 void toStringCharGFT(void) { 816 817 char *r; 818 819 r = toStringCharGF('2'); 820 ck_assert_str_eq(r, "2"); 821 free(r); 822 823 } 824 825 826 void toStringSGFT(void) { 827 828 char *r; 829 830 r = toStringSGF("2"); 831 ck_assert_str_eq(r, "2"); 832 free(r); 833 834 } 835 836 837 void toStringListSGFT(void) { 838 839 char *r; 840 char** object = listCreateS("a", "bb"); 841 842 r = toStringListSGF(object); 843 ck_assert_str_eq(r, "[\"a\",\"bb\"]"); 844 free(r); 845 listFreeS(object); 846 r = toStringListSGF(null); 847 ck_assert_ptr_eq(r, null); 848 849 } 850 851 852 void toStringListCSGFT(void) { 853 854 char *r; 855 const char* object[] = {"a", "bb", null}; 856 857 r = toStringListCSGF(object); 858 ck_assert_str_eq(r, "[\"a\",\"bb\"]"); 859 free(r); 860 r = toStringListSGF(null); 861 ck_assert_ptr_eq(r, null); 862 863 } 864 865 866 void toStringDictGFT(void) { 867 868 char *r; 869 smallDictt* object = allocSmallDict(); 870 871 r = toStringDictGF(object); 872 ck_assert_str_eq(r, "{}"); 873 free(r); 874 terminateO(object); 875 r = toStringDictGF(null); 876 ck_assert_ptr_eq(r, null); 877 878 } 879 880 881 void toStringArrayGFT(void) { 882 883 char *r; 884 smallArrayt* object = allocSmallArray(); 885 886 r = toStringArrayGF(object); 887 ck_assert_str_eq(r, "[]"); 888 free(r); 889 terminateO(object); 890 r = toStringArrayGF(null); 891 ck_assert_ptr_eq(r, null); 892 893 } 894 895 896 void toStringSmallBoolGFT(void) { 897 898 char *r; 899 smallBoolt* object = allocSmallBool(true); 900 901 r = toStringSmallBoolGF(object); 902 ck_assert_str_eq(r, "true"); 903 free(r); 904 terminateO(object); 905 r = toStringSmallBoolGF(null); 906 ck_assert_ptr_eq(r, null); 907 908 } 909 910 911 void toStringSmallBytesGFT(void) { 912 913 char *r; 914 smallBytest* object = allocSmallBytes("qwe", sizeof("qwe")); 915 916 r = toStringSmallBytesGF(object); 917 ck_assert_str_eq(r, "[0x71,0x77,0x65,0x00]"); 918 free(r); 919 terminateO(object); 920 r = toStringSmallBytesGF(null); 921 ck_assert_ptr_eq(r, null); 922 923 } 924 925 926 void toStringSmallDoubleGFT(void) { 927 928 char *r; 929 smallDoublet* object = allocSmallDouble(2.5); 930 931 r = toStringSmallDoubleGF(object); 932 ck_assert_str_eq(r, "2.500000e+00"); 933 free(r); 934 terminateO(object); 935 r = toStringSmallDoubleGF(null); 936 ck_assert_ptr_eq(r, null); 937 938 } 939 940 941 void toStringSmallIntGFT(void) { 942 943 char *r; 944 smallIntt* object = allocSmallInt(2); 945 946 r = toStringSmallIntGF(object); 947 ck_assert_str_eq(r, "2"); 948 free(r); 949 terminateO(object); 950 r = toStringSmallIntGF(null); 951 ck_assert_ptr_eq(r, null); 952 953 } 954 955 956 void toStringSmallStringGFT(void) { 957 958 char *r; 959 smallStringt* object = allocSmallString("qwe"); 960 961 r = toStringSmallStringGF(object); 962 ck_assert_str_eq(r, "qwe"); 963 free(r); 964 terminateO(object); 965 r = toStringSmallStringGF(null); 966 ck_assert_ptr_eq(r, null); 967 968 } 969 970 971 void toStringVoidGFT(void) { 972 973 char *r; 974 void* object = null; 975 976 r = toStringVoidGF(&object); 977 ck_assert_str_eq(r, "Unsupported toStringG type or void pointer"); 978 free(r); 979 r = toStringVoidGF(null); 980 ck_assert_ptr_eq(r, null); 981 982 } 983 984 985 void toStringSmallContainerGFT(void) { 986 987 char *r; 988 smallContainert* object = allocSmallContainer(null); 989 990 r = toStringSmallContainerGF(object); 991 ck_assert_str_eq(r, "<data smallContainer>"); 992 free(r); 993 terminateO(object); 994 r = toStringSmallContainerGF(null); 995 ck_assert_ptr_eq(r, null); 996 997 } 998 999 1000 void toStringSmallJsonGFT(void) { 1001 1002 char *r; 1003 smallJsont* object = allocSmallJson(); 1004 1005 r = toStringSmallJsonGF(object); 1006 ck_assert_str_eq(r, "{}"); 1007 free(r); 1008 terminateO(object); 1009 r = toStringSmallJsonGF(null); 1010 ck_assert_ptr_eq(r, null); 1011 1012 } 1013 1014 1015 void otosT(void) { 1016 1017 char *r; 1018 smallIntt *i = allocSmallInt(2); 1019 void *basetObj = i; 1020 1021 r = otos(basetObj); 1022 ck_assert_str_eq(r, "2"); 1023 free(r); 1024 terminateO(i); 1025 1026 } 1027 1028 1029 void formatOT(void) { 1030 1031 smallStringt *r; 1032 1033 r = formatO("%d", 2); 1034 char *s = toStringO(r); 1035 terminateO(r); 1036 ck_assert_str_eq(s, "2"); 1037 free(s); 1038 r = formatO(null, 2); 1039 ck_assert_ptr_eq(r, null); 1040 1041 } 1042 1043 1044 void execSmallJsonOT(void) { 1045 1046 int r; 1047 smallJsont *cmd = allocSmallJson(); 1048 createAllocateSmallArray(l); 1049 1050 // command 1051 setTopStringO(cmd, "ls libsheepyObjectTest.c"); 1052 r = execSmallJsonO(cmd, l, NULL); 1053 ck_assert_int_eq(r, 1); 1054 ck_assert_uint_eq(l->f->len(l),1); 1055 ck_assert_str_eq(l->f->getAtS(l, 0), "libsheepyObjectTest.c"); 1056 freeO(l); 1057 // invalid command 1058 freeO(cmd); 1059 setTopStringO(cmd, "randomCommand"); 1060 r = execSmallJsonO(cmd, l, NULL); 1061 ck_assert_int_eq(r, 1); 1062 ck_assert_uint_eq(l->f->len(l),0); 1063 // NULL out array 1064 freeO(cmd); 1065 setTopStringO(cmd, "ls libsheepyObjectTest.c"); 1066 r = execSmallJsonO(cmd, NULL, NULL); 1067 ck_assert_int_eq(r, 0); 1068 ck_assert_uint_eq(l->f->len(l),0); 1069 // non json string 1070 freeO(cmd); 1071 setTopIntO(cmd, 2); 1072 r = execSmallJsonO(cmd, l, NULL); 1073 ck_assert_int_eq(r, 0); 1074 terminateO(cmd); 1075 ck_assert_uint_eq(l->f->len(l),0); 1076 terminateO(l); 1077 // NULL command 1078 ck_assert_int_eq(execSmallJsonO(NULL, NULL, NULL), 0); 1079 1080 } 1081 1082 1083 void execSmallStringOT(void) { 1084 1085 int r; 1086 smallStringt *cmd = allocSmallString(""); 1087 createAllocateSmallArray(l); 1088 1089 // command 1090 setValO(cmd, "ls libsheepyObjectTest.c"); 1091 r = execSmallStringO(cmd, l, NULL); 1092 ck_assert_int_eq(r, 1); 1093 ck_assert_uint_eq(l->f->len(l),1); 1094 ck_assert_str_eq(l->f->getAtS(l, 0), "libsheepyObjectTest.c"); 1095 freeO(l); 1096 // invalid command 1097 setValO(cmd, "randomCommand"); 1098 r = execSmallStringO(cmd, l, NULL); 1099 ck_assert_int_eq(r, 1); 1100 ck_assert_uint_eq(l->f->len(l),0); 1101 // NULL out array 1102 setValO(cmd, "ls libsheepyObjectTest.c"); 1103 r = execSmallStringO(cmd, NULL, NULL); 1104 ck_assert_int_eq(r, 0); 1105 terminateO(cmd); 1106 ck_assert_uint_eq(l->f->len(l),0); 1107 terminateO(cmd); 1108 terminateO(l); 1109 // NULL command 1110 ck_assert_int_eq(execSmallStringO(NULL, NULL, NULL), 0); 1111 1112 } 1113 1114 1115 void walkDirSmallJsonOT(void) { 1116 1117 smallArrayt *r; 1118 smallJsont* dirPath = allocSmallJson(); 1119 1120 // existing directory 1121 setTopStringO(dirPath, "../dirTest.null"); 1122 r = walkDirSmallJsonO(dirPath); 1123 char *s = toStringO(r); 1124 ck_assert_str_eq(s, "[\"../dirTest.null/one\",\"../dirTest.null/two/four\",\"../dirTest.null/two/three\"]"); 1125 free(s); 1126 terminateO(r); 1127 // empty path 1128 freeO(dirPath); 1129 setTopStringO(dirPath, ""); 1130 ck_assert_ptr_eq(walkDirSmallJsonO(dirPath), NULL); 1131 // non existing directory 1132 freeO(dirPath); 1133 setTopStringO(dirPath, "nonExisting.null"); 1134 r = walkDirSmallJsonO(dirPath); 1135 ck_assert(isEmptyO(r)); 1136 terminateO(r); 1137 // non json string 1138 freeO(dirPath); 1139 setTopIntO(dirPath, 2); 1140 ck_assert_ptr_eq(walkDirSmallJsonO(dirPath), NULL); 1141 // NULL path 1142 ck_assert_ptr_eq(walkDirSmallJsonO(NULL), NULL); 1143 terminateO(dirPath); 1144 1145 } 1146 1147 1148 void walkDirSmallStringOT(void) { 1149 1150 smallArrayt *r; 1151 smallStringt* dirPath = allocSmallString(""); 1152 1153 // existing directory 1154 setValO(dirPath, "../dirTest.null"); 1155 r = walkDirSmallStringO(dirPath); 1156 ck_assert_ptr_ne(r, null); 1157 char *s = toStringO(r); 1158 ck_assert_str_eq(s, "[\"../dirTest.null/one\",\"../dirTest.null/two/four\",\"../dirTest.null/two/three\"]"); 1159 free(s); 1160 terminateO(r); 1161 // empty path 1162 freeO(dirPath); 1163 setValO(dirPath, ""); 1164 ck_assert_ptr_eq(walkDirSmallStringO(dirPath), NULL); 1165 // non existing directory 1166 freeO(dirPath); 1167 setValO(dirPath, "nonExisting.null"); 1168 r = walkDirSmallStringO(dirPath); 1169 ck_assert_ptr_ne(r, null); 1170 ck_assert(isEmptyO(r)); 1171 terminateO(r); 1172 // NULL path 1173 ck_assert_ptr_eq(walkDirSmallStringO(NULL), NULL); 1174 terminateO(dirPath); 1175 1176 } 1177 1178 1179 void walkDirDirOT(void) { 1180 1181 smallArrayt* r; 1182 1183 // existing directory 1184 r = walkDirDirO("../dirTest.null"); 1185 ck_assert_ptr_ne(r, null); 1186 char *s = toStringO(r); 1187 ck_assert_str_eq(s, "[\"../dirTest.null/symlinkLoop\",\"../dirTest.null/two\"]"); 1188 free(s); 1189 terminateO(r); 1190 // empty path 1191 ck_assert_ptr_eq(walkDirDirO(""), NULL); 1192 // non existing directory 1193 r = walkDirDirO("nonExisting.null"); 1194 ck_assert_ptr_ne(r, null); 1195 ck_assert(isEmptyO(r)); 1196 terminateO(r); 1197 // NULL path 1198 ck_assert_ptr_eq(walkDirDirO(NULL), NULL); 1199 1200 } 1201 1202 1203 void walkDirDirSmallJsonOT(void) { 1204 1205 smallArrayt *r; 1206 smallJsont* dirPath = allocSmallJson(); 1207 1208 // existing directory 1209 setTopStringO(dirPath, "../dirTest.null"); 1210 r = walkDirDirSmallJsonO(dirPath); 1211 ck_assert_ptr_ne(r, null); 1212 char *s = toStringO(r); 1213 ck_assert_str_eq(s, "[\"../dirTest.null/symlinkLoop\",\"../dirTest.null/two\"]"); 1214 free(s); 1215 terminateO(r); 1216 // empty path 1217 freeO(dirPath); 1218 setTopStringO(dirPath, ""); 1219 ck_assert_ptr_eq(walkDirDirSmallJsonO(dirPath), NULL); 1220 // non existing directory 1221 freeO(dirPath); 1222 setTopStringO(dirPath, "nonExisting.null"); 1223 r = walkDirDirSmallJsonO(dirPath); 1224 ck_assert_ptr_ne(r, null); 1225 ck_assert(isEmptyO(r)); 1226 terminateO(r); 1227 // non json string 1228 freeO(dirPath); 1229 setTopIntO(dirPath, 2); 1230 ck_assert_ptr_eq(walkDirDirSmallJsonO(dirPath), NULL); 1231 // NULL path 1232 ck_assert_ptr_eq(walkDirDirSmallJsonO(NULL), NULL); 1233 terminateO(dirPath); 1234 1235 } 1236 1237 1238 void walkDirDirSmallStringOT(void) { 1239 1240 smallArrayt *r; 1241 smallStringt* dirPath = allocSmallString(""); 1242 1243 // existing directory 1244 setValO(dirPath, "../dirTest.null"); 1245 r = walkDirDirSmallStringO(dirPath); 1246 ck_assert_ptr_ne(r, null); 1247 char *s = toStringO(r); 1248 ck_assert_str_eq(s, "[\"../dirTest.null/symlinkLoop\",\"../dirTest.null/two\"]"); 1249 free(s); 1250 terminateO(r); 1251 // empty path 1252 setValO(dirPath, ""); 1253 ck_assert_ptr_eq(walkDirDirSmallStringO(dirPath), NULL); 1254 // non existing directory 1255 setValO(dirPath, "nonExisting.null"); 1256 r = walkDirDirSmallStringO(dirPath); 1257 ck_assert_ptr_ne(r, null); 1258 ck_assert(isEmptyO(r)); 1259 terminateO(r); 1260 // NULL path 1261 ck_assert_ptr_eq(walkDirDirSmallStringO(NULL), NULL); 1262 terminateO(dirPath); 1263 1264 } 1265 1266 1267 void readDirOT(void) { 1268 1269 smallArrayt *r; 1270 1271 // existing directory 1272 r = readDirO("../dirTest.null"); 1273 ck_assert_ptr_ne(r, null); 1274 char *s = toStringO(r); 1275 ck_assert_str_eq(s, "[\"one\"]"); 1276 free(s); 1277 terminateO(r); 1278 // empty path 1279 ck_assert_ptr_eq(readDirO(""), NULL); 1280 // non existing directory 1281 r = readDirO("nonExisting.null"); 1282 ck_assert_ptr_ne(r, null); 1283 ck_assert(isEmptyO(r)); 1284 terminateO(r); 1285 // NULL path 1286 ck_assert_ptr_eq(readDirO(NULL), NULL); 1287 1288 } 1289 1290 1291 void readDirSmallJsonOT(void) { 1292 1293 smallArrayt *r; 1294 smallJsont *dirPath = allocSmallJson(); 1295 1296 // existing directory 1297 setTopStringO(dirPath, "../dirTest.null"); 1298 r = readDirSmallJsonO(dirPath); 1299 ck_assert_ptr_ne(r, null); 1300 char *s = toStringO(r); 1301 ck_assert_str_eq(s, "[\"one\"]"); 1302 free(s); 1303 terminateO(r); 1304 // empty path 1305 freeO(dirPath); 1306 setTopStringO(dirPath, ""); 1307 ck_assert_ptr_eq(readDirSmallJsonO(dirPath), NULL); 1308 // non existing directory 1309 freeO(dirPath); 1310 setTopStringO(dirPath, "nonExisting.null"); 1311 r = readDirSmallJsonO(dirPath); 1312 ck_assert_ptr_ne(r, null); 1313 ck_assert(isEmptyO(r)); 1314 terminateO(r); 1315 // non json string 1316 freeO(dirPath); 1317 setTopIntO(dirPath, 2); 1318 ck_assert_ptr_eq(readDirSmallJsonO(dirPath), NULL); 1319 // NULL path 1320 ck_assert_ptr_eq(readDirSmallJsonO(NULL), NULL); 1321 terminateO(dirPath); 1322 1323 } 1324 1325 1326 void readDirSmallStringOT(void) { 1327 1328 smallArrayt *r; 1329 smallStringt *dirPath = allocSmallString(""); 1330 1331 //r = readDirSmallStringO(); 1332 // existing directory 1333 setValO(dirPath, "../dirTest.null"); 1334 r = readDirSmallStringO(dirPath); 1335 ck_assert_ptr_ne(r, null); 1336 char *s = toStringO(r); 1337 ck_assert_str_eq(s, "[\"one\"]"); 1338 free(s); 1339 terminateO(r); 1340 // empty path 1341 setValO(dirPath, ""); 1342 ck_assert_ptr_eq(readDirSmallStringO(dirPath), NULL); 1343 // non existing directory 1344 setValO(dirPath, "nonExisting.null"); 1345 r = readDirSmallStringO(dirPath); 1346 ck_assert_ptr_ne(r, null); 1347 ck_assert(isEmptyO(r)); 1348 terminateO(r); 1349 // NULL path 1350 ck_assert_ptr_eq(readDirSmallStringO(NULL), NULL); 1351 terminateO(dirPath); 1352 1353 } 1354 1355 1356 void readDirDirOT(void) { 1357 1358 smallArrayt *r; 1359 1360 // existing directory 1361 r = readDirDirO("../dirTest.null"); 1362 ck_assert_ptr_ne(r, null); 1363 char *s = toStringO(r); 1364 ck_assert_str_eq(s, "[\"symlinkLoop\",\"two\"]"); 1365 free(s); 1366 terminateO(r); 1367 // empty path 1368 ck_assert_ptr_eq(readDirDirO(""), NULL); 1369 // non existing directory 1370 r = readDirDirO("nonExisting.null"); 1371 ck_assert_ptr_ne(r, null); 1372 ck_assert(isEmptyO(r)); 1373 terminateO(r); 1374 // NULL path 1375 ck_assert_ptr_eq(readDirDirO(NULL), NULL); 1376 1377 } 1378 1379 1380 void readDirDirSmallJsonOT(void) { 1381 1382 smallArrayt *r; 1383 smallJsont *dirPath = allocSmallJson(); 1384 1385 // existing directory 1386 setTopStringO(dirPath, "../dirTest.null"); 1387 r = readDirDirSmallJsonO(dirPath); 1388 ck_assert_ptr_ne(r, null); 1389 char *s = toStringO(r); 1390 ck_assert_str_eq(s, "[\"symlinkLoop\",\"two\"]"); 1391 free(s); 1392 terminateO(r); 1393 // empty path 1394 freeO(dirPath); 1395 setTopStringO(dirPath, ""); 1396 ck_assert_ptr_eq(readDirDirSmallJsonO(dirPath), NULL); 1397 // non existing directory 1398 freeO(dirPath); 1399 setTopStringO(dirPath, "nonExisting.null"); 1400 r = readDirDirSmallJsonO(dirPath); 1401 ck_assert_ptr_ne(r, null); 1402 ck_assert(isEmptyO(r)); 1403 terminateO(r); 1404 // non json string 1405 freeO(dirPath); 1406 setTopIntO(dirPath, 2); 1407 ck_assert_ptr_eq(readDirDirSmallJsonO(dirPath), NULL); 1408 // NULL path 1409 ck_assert_ptr_eq(readDirDirSmallJsonO(NULL), NULL); 1410 terminateO(dirPath); 1411 1412 } 1413 1414 1415 void readDirDirSmallStringOT(void) { 1416 1417 smallArrayt *r; 1418 smallStringt *dirPath = allocSmallString(""); 1419 1420 // existing directory 1421 setValO(dirPath, "../dirTest.null"); 1422 r = readDirDirSmallStringO(dirPath); 1423 ck_assert_ptr_ne(r, null); 1424 char *s = toStringO(r); 1425 ck_assert_str_eq(s, "[\"symlinkLoop\",\"two\"]"); 1426 free(s); 1427 terminateO(r); 1428 // empty path 1429 setValO(dirPath, ""); 1430 ck_assert_ptr_eq(readDirDirSmallStringO(dirPath), NULL); 1431 // non existing directory 1432 setValO(dirPath, "nonExisting.null"); 1433 r = readDirDirSmallStringO(dirPath); 1434 ck_assert_ptr_ne(r, null); 1435 ck_assert(isEmptyO(r)); 1436 terminateO(r); 1437 // NULL path 1438 ck_assert_ptr_eq(readDirDirSmallStringO(NULL), NULL); 1439 terminateO(dirPath); 1440 1441 } 1442 1443 1444 void walkDirAllOT(void) { 1445 1446 smallArrayt *r; 1447 1448 // existing directory 1449 r = walkDirAllO("../dirTest.null"); 1450 ck_assert_ptr_ne(r, null); 1451 char *s = toStringO(r); 1452 ck_assert_str_eq(s, "[\"../dirTest.null/one\",\"../dirTest.null/symlinkLoop\",\"../dirTest.null/two\",\"../dirTest.null/two/four\",\"../dirTest.null/two/three\"]"); 1453 free(s); 1454 terminateO(r); 1455 // empty path 1456 ck_assert_ptr_eq(walkDirAllO(""), NULL); 1457 // non existing directory 1458 r = walkDirAllO("nonExisting.null"); 1459 ck_assert_ptr_ne(r, null); 1460 ck_assert(isEmptyO(r)); 1461 terminateO(r); 1462 // NULL path 1463 ck_assert_ptr_eq(walkDirAllO(NULL), NULL); 1464 1465 } 1466 1467 1468 void walkDirAllSmallJsonOT(void) { 1469 1470 smallArrayt *r; 1471 smallJsont* dirPath = allocSmallJson(); 1472 1473 // existing directory 1474 setTopStringO(dirPath, "../dirTest.null"); 1475 r = walkDirAllSmallJsonO(dirPath); 1476 ck_assert_ptr_ne(r, null); 1477 char *s = toStringO(r); 1478 ck_assert_str_eq(s, "[\"../dirTest.null/one\",\"../dirTest.null/symlinkLoop\",\"../dirTest.null/two\",\"../dirTest.null/two/four\",\"../dirTest.null/two/three\"]"); 1479 free(s); 1480 terminateO(r); 1481 // empty path 1482 freeO(dirPath); 1483 setTopStringO(dirPath, ""); 1484 ck_assert_ptr_eq(walkDirAllSmallJsonO(dirPath), NULL); 1485 // non existing directory 1486 freeO(dirPath); 1487 setTopStringO(dirPath, "nonExisting.null"); 1488 r = walkDirAllSmallJsonO(dirPath); 1489 ck_assert_ptr_ne(r, null); 1490 ck_assert(isEmptyO(r)); 1491 terminateO(r); 1492 // non json string 1493 freeO(dirPath); 1494 setTopIntO(dirPath, 2); 1495 ck_assert_ptr_eq(walkDirAllSmallJsonO(dirPath), NULL); 1496 // NULL path 1497 ck_assert_ptr_eq(walkDirAllSmallJsonO(NULL), NULL); 1498 terminateO(dirPath); 1499 1500 } 1501 1502 1503 void walkDirAllSmallStringOT(void) { 1504 1505 smallArrayt *r; 1506 smallStringt* dirPath = allocSmallString(""); 1507 1508 // existing directory 1509 setValO(dirPath, "../dirTest.null"); 1510 r = walkDirAllSmallStringO(dirPath); 1511 ck_assert_ptr_ne(r, null); 1512 char *s = toStringO(r); 1513 ck_assert_str_eq(s, "[\"../dirTest.null/one\",\"../dirTest.null/symlinkLoop\",\"../dirTest.null/two\",\"../dirTest.null/two/four\",\"../dirTest.null/two/three\"]"); 1514 free(s); 1515 terminateO(r); 1516 // empty path 1517 setValO(dirPath, ""); 1518 ck_assert_ptr_eq(walkDirAllSmallStringO(dirPath), NULL); 1519 // non existing directory 1520 setValO(dirPath, "nonExisting.null"); 1521 r = walkDirAllSmallStringO(dirPath); 1522 ck_assert_ptr_ne(r, null); 1523 ck_assert(isEmptyO(r)); 1524 terminateO(r); 1525 // NULL path 1526 ck_assert_ptr_eq(walkDirAllSmallStringO(NULL), NULL); 1527 terminateO(dirPath); 1528 1529 } 1530 1531 1532 void readDirAllOT(void) { 1533 1534 smallArrayt *r; 1535 1536 // existing directory 1537 r = readDirAllO("../dirTest.null"); 1538 ck_assert_ptr_ne(r, null); 1539 char *s = toStringO(r); 1540 ck_assert_str_eq(s, "[\"one\",\"symlinkLoop\",\"two\"]"); 1541 free(s); 1542 terminateO(r); 1543 // empty path 1544 ck_assert_ptr_eq(readDirAllO(""), NULL); 1545 // non existing directory 1546 r = readDirAllO("nonExisting.null"); 1547 ck_assert_ptr_ne(r, null); 1548 ck_assert(isEmptyO(r)); 1549 terminateO(r); 1550 // NULL path 1551 ck_assert_ptr_eq(readDirAllO(NULL), NULL); 1552 1553 } 1554 1555 1556 void readDirAllSmallJsonOT(void) { 1557 1558 smallArrayt *r; 1559 smallJsont *dirPath = allocSmallJson(); 1560 1561 // existing directory 1562 setTopStringO(dirPath, "../dirTest.null"); 1563 r = readDirAllSmallJsonO(dirPath); 1564 ck_assert_ptr_ne(r, null); 1565 char *s = toStringO(r); 1566 ck_assert_str_eq(s, "[\"one\",\"symlinkLoop\",\"two\"]"); 1567 free(s); 1568 terminateO(r); 1569 // empty path 1570 freeO(dirPath); 1571 setTopStringO(dirPath, ""); 1572 ck_assert_ptr_eq(readDirAllSmallJsonO(dirPath), NULL); 1573 // non existing directory 1574 freeO(dirPath); 1575 setTopStringO(dirPath, "nonExisting.null"); 1576 r = readDirAllSmallJsonO(dirPath); 1577 ck_assert_ptr_ne(r, null); 1578 ck_assert(isEmptyO(r)); 1579 terminateO(r); 1580 // non json string 1581 freeO(dirPath); 1582 setTopIntO(dirPath, 2); 1583 ck_assert_ptr_eq(readDirAllSmallJsonO(dirPath), NULL); 1584 // NULL path 1585 ck_assert_ptr_eq(readDirAllSmallJsonO(NULL), NULL); 1586 terminateO(dirPath); 1587 1588 } 1589 1590 1591 void readDirAllSmallStringOT(void) { 1592 1593 smallArrayt *r; 1594 smallStringt *dirPath = allocSmallString(""); 1595 1596 // existing directory 1597 setValO(dirPath, "../dirTest.null"); 1598 r = readDirAllSmallStringO(dirPath); 1599 ck_assert_ptr_ne(r, null); 1600 char *s = toStringO(r); 1601 ck_assert_str_eq(s, "[\"one\",\"symlinkLoop\",\"two\"]"); 1602 free(s); 1603 terminateO(r); 1604 // empty path 1605 setValO(dirPath, ""); 1606 ck_assert_ptr_eq(readDirAllSmallStringO(dirPath), NULL); 1607 // non existing directory 1608 setValO(dirPath, "nonExisting.null"); 1609 r = readDirAllSmallStringO(dirPath); 1610 ck_assert_ptr_ne(r, null); 1611 ck_assert(isEmptyO(r)); 1612 terminateO(r); 1613 // NULL path 1614 ck_assert_ptr_eq(readDirAllSmallStringO(NULL), NULL); 1615 terminateO(dirPath); 1616 1617 } 1618 1619 1620 void getModificationTimeJOT(void) { 1621 1622 smallJsont *path = allocSmallJson(); 1623 1624 // get time 1625 setTopStringO(path, "libsheepyObject.c"); 1626 ck_assert_int_ne(getModificationTimeJO(path), 0); 1627 // missing file 1628 freeO(path); 1629 setTopStringO(path, "nonExisting.null"); 1630 ck_assert_int_eq(getModificationTimeJO(path), 0); 1631 // non json string 1632 freeO(path); 1633 setTopIntO(path, 2); 1634 ck_assert_int_eq(getModificationTimeJO(path), 0); 1635 // NULL 1636 ck_assert_int_eq(getModificationTimeJO(NULL), 0); 1637 terminateO(path); 1638 1639 } 1640 1641 1642 void getModificationTimeOT(void) { 1643 1644 smallStringt *path = allocSmallString(""); 1645 1646 // get time 1647 setValO(path, "libsheepyObject.c"); 1648 ck_assert_int_ne(getModificationTimeO(path), 0); 1649 // missing file 1650 setValO(path, "nonExisting.null"); 1651 ck_assert_int_eq(getModificationTimeO(path), 0); 1652 // NULL 1653 ck_assert_int_eq(getModificationTimeO(NULL), 0); 1654 terminateO(path); 1655 1656 } 1657 1658 1659 void setModificationTimeJOT(void) { 1660 1661 smallJsont *path = allocSmallJson(); 1662 time_t t; 1663 1664 // set time 1665 setTopStringO(path, "../chmodTest.null"); 1666 t = getModificationTimeJO(path); 1667 ck_assert_int_eq(setModificationTimeJO(path, t), 1); 1668 // non existing file 1669 freeO(path); 1670 setTopStringO(path, "/chmodTest.null"); 1671 ck_assert_int_eq(setModificationTimeJO(path, t), 0); 1672 // non json string 1673 freeO(path); 1674 setTopIntO(path, 2); 1675 ck_assert_int_eq(setModificationTimeJO(path, t), 0); 1676 // NULL 1677 ck_assert_int_eq(setModificationTimeJO(NULL, t), 0); 1678 terminateO(path); 1679 1680 } 1681 1682 1683 void setModificationTimeOT(void) { 1684 1685 smallStringt *path = allocSmallString(""); 1686 time_t t; 1687 1688 // set time 1689 setValO(path, "../chmodTest.null"); 1690 t = getModificationTimeO(path); 1691 ck_assert_int_eq(setModificationTimeO(path, t), 1); 1692 // non existing file 1693 setValO(path, "/chmodTest.null"); 1694 ck_assert_int_eq(setModificationTimeO(path, t), 0); 1695 // NULL 1696 ck_assert_int_eq(setModificationTimeO(NULL, t), 0); 1697 terminateO(path); 1698 1699 } 1700 1701 1702 void equalModificationTimesJOT(void) { 1703 1704 smallJsont *path1 = allocSmallJson(); 1705 smallJsont *path2 = allocSmallJson(); 1706 1707 // equal time 1708 setTopStringO(path1, "../chmodTest.null"); 1709 setTopStringO(path2, "../chmodTest.null"); 1710 ck_assert(equalModificationTimesJO(path1, path2)); 1711 // not equal 1712 freeO(path2); 1713 setTopStringO(path2, "libsheepyObject.c"); 1714 ck_assert(!equalModificationTimesJO(path1, path2)); 1715 // non existing 1716 freeO(path1); 1717 setTopStringO(path1, "/chmodTest.null"); 1718 ck_assert(!equalModificationTimesJO(path1, path2)); 1719 freeO(path1); 1720 setTopStringO(path1, "../chmodTest.null"); 1721 freeO(path2); 1722 setTopStringO(path2, "/libsheepyObject.c"); 1723 ck_assert(!equalModificationTimesJO(path1, path2)); 1724 // non json string 1725 freeO(path1); 1726 setTopIntO(path1, 2); 1727 freeO(path2); 1728 setTopStringO(path2, "libsheepyObject.c"); 1729 ck_assert(!equalModificationTimesJO(path1, path2)); 1730 freeO(path1); 1731 setTopStringO(path1, "../chmodTest.null"); 1732 freeO(path2); 1733 setTopIntO(path2, 2); 1734 ck_assert(!equalModificationTimesJO(path1, path2)); 1735 // NULL 1736 freeO(path2); 1737 setTopStringO(path2, "libsheepyObject.c"); 1738 ck_assert(!equalModificationTimesJO(NULL, path2)); 1739 ck_assert(!equalModificationTimesJO(path1, NULL)); 1740 terminateO(path1); 1741 terminateO(path2); 1742 1743 } 1744 1745 1746 void equalModificationTimesSJOT(void) { 1747 1748 smallJsont *path2 = allocSmallJson(); 1749 1750 // equal time 1751 setTopStringO(path2, "../chmodTest.null"); 1752 ck_assert(equalModificationTimesSJO("../chmodTest.null", path2)); 1753 // not equal 1754 freeO(path2); 1755 setTopStringO(path2, "libsheepyObject.c"); 1756 ck_assert(!equalModificationTimesSJO("../chmodTest.null", path2)); 1757 // non existing 1758 ck_assert(!equalModificationTimesSJO("/chmodTest.null", path2)); 1759 freeO(path2); 1760 setTopStringO(path2, "/libsheepyObject.c"); 1761 ck_assert(!equalModificationTimesSJO("../chmodTest.null", path2)); 1762 // non json string 1763 freeO(path2); 1764 setTopIntO(path2, 2); 1765 ck_assert(!equalModificationTimesSJO("../chmodTest.null", path2)); 1766 // NULL 1767 freeO(path2); 1768 setTopStringO(path2, "libsheepyObject.c"); 1769 ck_assert(!equalModificationTimesSJO(NULL, path2)); 1770 ck_assert(!equalModificationTimesSJO("../chmodTest.null", NULL)); 1771 terminateO(path2); 1772 1773 } 1774 1775 1776 void equalModificationTimesJOST(void) { 1777 1778 smallJsont *path1 = allocSmallJson(); 1779 1780 // equal time 1781 setTopStringO(path1, "../chmodTest.null"); 1782 ck_assert(equalModificationTimesJOS(path1, "../chmodTest.null")); 1783 // not equal 1784 ck_assert(!equalModificationTimesJOS(path1, "libsheepyObject.c")); 1785 // non existing 1786 freeO(path1); 1787 setTopStringO(path1, "/chmodTest.null"); 1788 ck_assert(!equalModificationTimesJOS(path1, "libsheepyObject.c")); 1789 freeO(path1); 1790 setTopStringO(path1, "../chmodTest.null"); 1791 ck_assert(!equalModificationTimesJOS(path1, "/libsheepyObject.c")); 1792 // non json string 1793 freeO(path1); 1794 setTopIntO(path1, 2); 1795 ck_assert(!equalModificationTimesJOS(path1, "libsheepyObject.c")); 1796 // NULL 1797 freeO(path1); 1798 setTopStringO(path1, "../chmodTest.null"); 1799 ck_assert(!equalModificationTimesJOS(NULL, "libsheepyObject.c")); 1800 ck_assert(!equalModificationTimesJOS(path1, NULL)); 1801 terminateO(path1); 1802 1803 } 1804 1805 1806 void equalModificationTimesJOOT(void) { 1807 1808 smallJsont *path1 = allocSmallJson(); 1809 smallStringt *path2 = allocSmallString(""); 1810 1811 // equal time 1812 setTopStringO(path1, "../chmodTest.null"); 1813 setValO(path2, "../chmodTest.null"); 1814 ck_assert(equalModificationTimesJOO(path1, path2)); 1815 // not equal 1816 setValO(path2, "libsheepyObject.c"); 1817 ck_assert(!equalModificationTimesJOO(path1, path2)); 1818 // non existing 1819 freeO(path1); 1820 setTopStringO(path1, "/chmodTest.null"); 1821 ck_assert(!equalModificationTimesJOO(path1, path2)); 1822 freeO(path1); 1823 setTopStringO(path1, "../chmodTest.null"); 1824 setValO(path2, "/libsheepyObject.c"); 1825 ck_assert(!equalModificationTimesJOO(path1, path2)); 1826 // non json string 1827 freeO(path1); 1828 setTopIntO(path1, 2); 1829 setValO(path2, "libsheepyObject.c"); 1830 ck_assert(!equalModificationTimesJOO(path1, path2)); 1831 // NULL 1832 freeO(path1); 1833 setTopStringO(path1, "../chmodTest.null"); 1834 setValO(path2, "libsheepyObject.c"); 1835 ck_assert(!equalModificationTimesJOO(NULL, path2)); 1836 ck_assert(!equalModificationTimesJOO(path1, NULL)); 1837 terminateO(path1); 1838 terminateO(path2); 1839 1840 } 1841 1842 1843 void equalModificationTimesOJOT(void) { 1844 1845 smallStringt *path1 = allocSmallString(""); 1846 smallJsont *path2 = allocSmallJson(); 1847 1848 // equal time 1849 setValO(path1, "../chmodTest.null"); 1850 setTopStringO(path2, "../chmodTest.null"); 1851 ck_assert(equalModificationTimesOJO(path1, path2)); 1852 // not equal 1853 freeO(path2); 1854 setTopStringO(path2, "libsheepyObject.c"); 1855 ck_assert(!equalModificationTimesOJO(path1, path2)); 1856 // non existing 1857 setValO(path1, "/chmodTest.null"); 1858 ck_assert(!equalModificationTimesOJO(path1, path2)); 1859 setValO(path1, "../chmodTest.null"); 1860 freeO(path2); 1861 setTopStringO(path2, "/libsheepyObject.c"); 1862 ck_assert(!equalModificationTimesOJO(path1, path2)); 1863 // non json string 1864 freeO(path2); 1865 setTopIntO(path2, 2); 1866 ck_assert(!equalModificationTimesOJO(path1, path2)); 1867 // NULL 1868 freeO(path2); 1869 setTopStringO(path2, "libsheepyObject.c"); 1870 ck_assert(!equalModificationTimesOJO(NULL, path2)); 1871 ck_assert(!equalModificationTimesOJO(path1, NULL)); 1872 terminateO(path1); 1873 terminateO(path2); 1874 1875 } 1876 1877 1878 void equalModificationTimesOT(void) { 1879 1880 smallStringt *path1 = allocSmallString(""); 1881 smallStringt *path2 = allocSmallString(""); 1882 1883 // equal time 1884 setValO(path1, "../chmodTest.null"); 1885 setValO(path2, "../chmodTest.null"); 1886 ck_assert(equalModificationTimesO(path1, path2)); 1887 // not equal 1888 setValO(path2, "libsheepyObject.c"); 1889 ck_assert(!equalModificationTimesO(path1, path2)); 1890 // non existing 1891 setValO(path1, "/chmodTest.null"); 1892 ck_assert(!equalModificationTimesO(path1, path2)); 1893 setValO(path1, "../chmodTest.null"); 1894 setValO(path2, "/libsheepyObject.c"); 1895 ck_assert(!equalModificationTimesO(path1, path2)); 1896 // NULL 1897 setValO(path2, "libsheepyObject.c"); 1898 ck_assert(!equalModificationTimesO(NULL, path2)); 1899 ck_assert(!equalModificationTimesO(path1, NULL)); 1900 terminateO(path1); 1901 terminateO(path2); 1902 1903 } 1904 1905 1906 void equalModificationTimesSOT(void) { 1907 1908 smallStringt *path2 = allocSmallString(""); 1909 1910 // equal time 1911 setValO(path2, "../chmodTest.null"); 1912 ck_assert(equalModificationTimesSO("../chmodTest.null", path2)); 1913 // not equal 1914 setValO(path2, "libsheepyObject.c"); 1915 ck_assert(!equalModificationTimesSO("../chmodTest.null", path2)); 1916 // non existing 1917 ck_assert(!equalModificationTimesSO("/chmodTest.null", path2)); 1918 setValO(path2, "/libsheepyObject.c"); 1919 ck_assert(!equalModificationTimesSO("../chmodTest.null", path2)); 1920 // NULL 1921 setValO(path2, "libsheepyObject.c"); 1922 ck_assert(!equalModificationTimesSO(NULL, path2)); 1923 ck_assert(!equalModificationTimesSO("../chmodTest.null", NULL)); 1924 terminateO(path2); 1925 1926 } 1927 1928 1929 void equalModificationTimesOST(void) { 1930 1931 smallStringt *path1 = allocSmallString(""); 1932 1933 // equal time 1934 setValO(path1, "../chmodTest.null"); 1935 ck_assert(equalModificationTimesOS(path1, "../chmodTest.null")); 1936 // not equal 1937 ck_assert(!equalModificationTimesOS(path1, "libsheepyObject.c")); 1938 // non existing 1939 setValO(path1, "/chmodTest.null"); 1940 ck_assert(!equalModificationTimesOS(path1, "libsheepyObject.c")); 1941 setValO(path1, "../chmodTest.null"); 1942 ck_assert(!equalModificationTimesOS(path1, "/libsheepyObject.c")); 1943 // NULL 1944 ck_assert(!equalModificationTimesOS(NULL, "libsheepyObject.c")); 1945 ck_assert(!equalModificationTimesOS(path1, NULL)); 1946 terminateO(path1); 1947 1948 } 1949 1950 1951 void timeToJOT(void) { 1952 1953 smallJsont *r; 1954 1955 r = timeToJO(0); 1956 ck_assert_ptr_ne(r, null); 1957 ck_assert_str_eq(sjGet(r), "Thu Jan 1 01:00:00 1970"); 1958 terminateO(r); 1959 1960 } 1961 1962 1963 void timeToSOT(void) { 1964 1965 smallStringt *r; 1966 1967 r = timeToSO(0); 1968 ck_assert_ptr_ne(r, null); 1969 ck_assert_str_eq(ssGet(r), "Thu Jan 1 01:00:00 1970"); 1970 terminateO(r); 1971 1972 } 1973 1974 1975 void shDirnameJOT(void) { 1976 1977 smallJsont *r; 1978 smallJsont *path = allocSmallJson(); 1979 1980 setTopStringO(path, "release/libsheepy.a"); 1981 r = shDirnameJO(path); 1982 ck_assert_ptr_ne(r, null); 1983 ck_assert_str_eq(sjGet(r), "release"); 1984 terminateO(r); 1985 // non json string 1986 freeO(path); 1987 setTopIntO(path, 2); 1988 r = shDirnameJO(path); 1989 ck_assert_ptr_eq(r, null); 1990 terminateO(path); 1991 // NULL path 1992 r = shDirnameJO(null); 1993 ck_assert_ptr_eq(r, null); 1994 1995 } 1996 1997 1998 void shDirnameOT(void) { 1999 2000 smallStringt *r; 2001 smallStringt *path = allocSmallString("release/libsheepy.a"); 2002 2003 r = shDirnameO(path); 2004 ck_assert_ptr_ne(r, null); 2005 ck_assert_str_eq(ssGet(r), "release"); 2006 terminateO(r); 2007 // one item path 2008 setValO(path, "sheepy.lib"); 2009 r = shDirnameO(path); 2010 ck_assert_ptr_ne(r, null); 2011 ck_assert_str_eq(ssGet(r), "./"); 2012 terminateO(r); 2013 // blank path 2014 setValO(path, ""); 2015 r = shDirnameO(path); 2016 ck_assert_ptr_ne(r, null); 2017 ck_assert_str_eq(ssGet(r), "./"); 2018 terminateO(r); 2019 terminateO(path); 2020 // NULL path 2021 r = shDirnameO(null); 2022 ck_assert_ptr_eq(r, null); 2023 2024 } 2025 2026 2027 void expandHomeJOT(void) { 2028 2029 smallJsont *r; 2030 smallJsont *path = allocSmallJson(); 2031 2032 // no ~/ 2033 setTopStringO(path, "sheepy"); 2034 r = expandHomeJO(path); 2035 ck_assert_ptr_ne(r, null); 2036 ck_assert_str_eq(sjGet(r), "sheepy"); 2037 // non json string 2038 freeO(path); 2039 setTopIntO(path, 2); 2040 ck_assert_ptr_eq(expandHomeJO(path), NULL); 2041 // NULL path 2042 ck_assert_ptr_eq(expandHomeJO(NULL), NULL); 2043 terminateO(path); 2044 2045 } 2046 2047 2048 void normalizePathJOT(void) { 2049 2050 smallJsont *r; 2051 smallJsont *path = allocSmallJson(); 2052 2053 setTopStringO(path, "test/.././file.txt"); 2054 r = normalizePathJO(path); 2055 ck_assert_ptr_ne(r, null); 2056 ck_assert_str_eq(sjGet(r), "file.txt"); 2057 // empty json object 2058 freeO(path); 2059 r = normalizePathJO(path); 2060 ck_assert_ptr_eq(r, null); 2061 // non json string 2062 freeO(path); 2063 setTopIntO(path, 2); 2064 ck_assert_ptr_eq(normalizePathJO(path), NULL); 2065 // NULL path 2066 ck_assert_ptr_eq(normalizePathJO(NULL), NULL); 2067 terminateO(path); 2068 2069 } 2070 2071 2072 void normalizePathOT(void) { 2073 2074 smallStringt *r; 2075 smallStringt *path = allocSmallString("test/.././file.txt"); 2076 2077 r = normalizePathO(path); 2078 ck_assert_ptr_ne(r, null); 2079 ck_assert_str_eq(ssGet(r), "file.txt"); 2080 // blank string 2081 setValO(path, " "); 2082 r = normalizePathO(path); 2083 ck_assert_ptr_ne(r, null); 2084 ck_assert_str_eq(ssGet(r), "/"); 2085 // remove end / 2086 setValO(path, "/home/"); 2087 r = normalizePathO(path); 2088 ck_assert_ptr_ne(r, null); 2089 ck_assert_str_eq(ssGet(r), "/home"); 2090 // cancel path and keep leading / 2091 setValO(path, "/home/../"); 2092 r = normalizePathO(path); 2093 ck_assert_ptr_ne(r, null); 2094 ck_assert_str_eq(ssGet(r), "/"); 2095 // cancel path 2096 setValO(path, "home/../"); 2097 r = normalizePathO(path); 2098 ck_assert_ptr_ne(r, null); 2099 ck_assert_str_eq(ssGet(r), ""); 2100 // multiple / 2101 setValO(path, "/home///stuff"); 2102 r = normalizePathO(path); 2103 ck_assert_ptr_ne(r, null); 2104 ck_assert_str_eq(ssGet(r), "/home/stuff"); 2105 // remove . and .. and keep leading / 2106 setValO(path, "/a/./b/../../c/"); 2107 r = normalizePathO(path); 2108 ck_assert_ptr_ne(r, null); 2109 ck_assert_str_eq(ssGet(r), "/c"); 2110 // keep leading / 2111 setValO(path, "/../"); 2112 r = normalizePathO(path); 2113 ck_assert_str_eq(ssGet(r), "/"); 2114 // keep leading .. 2115 setValO(path, ".././/"); 2116 r = normalizePathO(path); 2117 ck_assert_str_eq(ssGet(r), ".."); 2118 // remove . 2119 setValO(path, "./"); 2120 r = normalizePathO(path); 2121 ck_assert_str_eq(ssGet(r), ""); 2122 // keep / before . 2123 setValO(path, "/."); 2124 r = normalizePathO(path); 2125 ck_assert_str_eq(ssGet(r), "/"); 2126 // remove . 2127 setValO(path, "."); 2128 r = normalizePathO(path); 2129 ck_assert_str_eq(ssGet(r), ""); 2130 // / not changed 2131 setValO(path, "/"); 2132 r = normalizePathO(path); 2133 ck_assert_str_eq(ssGet(r), "/"); 2134 // // becomes / 2135 setValO(path, "//"); 2136 r = normalizePathO(path); 2137 ck_assert_str_eq(ssGet(r), "/"); 2138 // remove leading . 2139 setValO(path, "/./werwer"); 2140 r = normalizePathO(path); 2141 ck_assert_str_eq(ssGet(r), "/werwer"); 2142 // keep leading .. and remove .. in path 2143 setValO(path, ".././test/../test/file"); 2144 r = normalizePathO(path); 2145 ck_assert_str_eq(ssGet(r), "../test/file"); 2146 setValO(path, "../d1/./d2/../f1"); 2147 r = normalizePathO(path); 2148 ck_assert_str_eq(ssGet(r), "../d1/f1"); 2149 setValO(path, "a/b/c/../d/../e"); 2150 r = normalizePathO(path); 2151 ck_assert_str_eq(ssGet(r), "a/b/e"); 2152 // dont remove .. when there are only .. in front 2153 setValO(path, "../../test/test/file"); 2154 r = normalizePathO(path); 2155 ck_assert_str_eq(ssGet(r), "../../test/test/file"); 2156 // empty path 2157 setValO(path, ""); 2158 r = normalizePathO(path); 2159 ck_assert_str_eq(ssGet(r), ""); 2160 // empty smallString 2161 freeO(path); 2162 r = normalizePathO(path); 2163 ck_assert_ptr_eq(r, null); 2164 // NULL path 2165 ck_assert_ptr_eq(normalizePathO(NULL), NULL); 2166 terminateO(path); 2167 2168 } 2169 2170 2171 void getCwdJOT(void) { 2172 2173 smallJsont *r; 2174 2175 r = getCwdJO(); 2176 ck_assert_ptr_ne(r, null); 2177 terminateO(r); 2178 2179 } 2180 2181 2182 void chDirJOT(void) { 2183 2184 int r; 2185 smallJsont *path = allocSmallJson(); 2186 2187 // change directory 2188 char *c = getCwd(); 2189 setTopStringO(path, "../dirTest.null"); 2190 r = chDirJO(path); 2191 ck_assert_int_ne(r, 0); 2192 char *s = getCwd(); 2193 ck_assert((size_t)findS(s, "dirTest.null")); 2194 chDir(c); 2195 freeManyS(c,s); 2196 // non json string 2197 freeO(path); 2198 setTopIntO(path, 2); 2199 ck_assert(!chDirJO(path)); 2200 // NULL path 2201 ck_assert(!chDirJO(NULL)); 2202 terminateO(path); 2203 2204 } 2205 2206 2207 void isDirJOT(void) { 2208 2209 smallJsont *path = allocSmallJson(); 2210 2211 // dir 2212 setTopStringO(path, "../dirTest.null"); 2213 ck_assert(isDirJO(path)); 2214 // non json string 2215 freeO(path); 2216 setTopIntO(path, 2); 2217 ck_assert(!isDirJO(path)); 2218 // NULL path 2219 ck_assert(!isDirJO(NULL)); 2220 terminateO(path); 2221 2222 } 2223 2224 2225 void isDirOT(void) { 2226 2227 smallStringt *path = allocSmallString("../dirTest.null"); 2228 2229 // dir 2230 ck_assert(isDirO(path)); 2231 // not a dir 2232 setValO(path, "libsheepyObject.c"); 2233 ck_assert(!isDirO(path)); 2234 // non existing dir 2235 setValO(path, "RandomNonExistingDir"); 2236 ck_assert(!isDirO(path)); 2237 // NULL path 2238 ck_assert(!isDirO(NULL)); 2239 terminateO(path); 2240 2241 } 2242 2243 2244 void isLinkJOT(void) { 2245 2246 smallJsont *path = allocSmallJson(); 2247 2248 // link 2249 setTopStringO(path, "../linkTest.null"); 2250 ck_assert(isLinkJO(path)); 2251 // non json string 2252 freeO(path); 2253 setTopIntO(path, 2); 2254 ck_assert(!isLinkJO(path)); 2255 // NULL path 2256 ck_assert(!isLinkJO(NULL)); 2257 terminateO(path); 2258 2259 } 2260 2261 2262 void isLinkOT(void) { 2263 2264 smallStringt *path = allocSmallString("../linkTest.null"); 2265 2266 // link 2267 ck_assert(isLinkO(path)); 2268 // not a link 2269 setValO(path, "libsheepyObject.c"); 2270 ck_assert(!isLinkO(path)); 2271 // non existing file 2272 setValO(path, "RandomNonExistingDir"); 2273 ck_assert(!isLinkO(path)); 2274 // NULL path 2275 ck_assert(!isLinkO(NULL)); 2276 terminateO(path); 2277 2278 } 2279 2280 2281 void fileExistsJOT(void) { 2282 2283 smallJsont *path = allocSmallJson(); 2284 2285 // detect existing file 2286 setTopStringO(path, "libsheepyObject.c"); 2287 ck_assert(fileExistsJO(path)); 2288 // non json string 2289 freeO(path); 2290 setTopIntO(path, 2); 2291 ck_assert(!fileExistsJO(path)); 2292 // NULL path 2293 ck_assert(!fileExistsJO(NULL)); 2294 terminateO(path); 2295 2296 } 2297 2298 2299 void fileChmodJOT(void) { 2300 2301 smallJsont *path = allocSmallJson(); 2302 2303 // existing file 2304 setTopStringO(path, "../chmodTest.null"); 2305 ck_assert(fileChmodJO(path, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)); 2306 ck_assert(fileChmodJO(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); 2307 // non json string 2308 freeO(path); 2309 setTopIntO(path, 2); 2310 ck_assert(!fileChmodJO(path, 0)); 2311 // NULL path 2312 ck_assert(!fileChmodJO(NULL, 0)); 2313 terminateO(path); 2314 2315 } 2316 2317 2318 void fileSizeJOT(void) { 2319 2320 smallJsont *path = allocSmallJson(); 2321 2322 // existing file 2323 setTopStringO(path, "../sizeTest.null"); 2324 ck_assert_int_eq(fileSizeJO(path), 743); 2325 // non json string 2326 freeO(path); 2327 setTopIntO(path, 2); 2328 ck_assert_int_eq(fileSizeJO(path), -1); 2329 // NULL path 2330 ck_assert_int_eq(fileSizeJO(NULL), -1); 2331 terminateO(path); 2332 2333 } 2334 2335 2336 void readFileToNewGT(void) { 2337 2338 char *r = readFileToNewG(null, "../textTest.null"); 2339 ck_assert_str_eq(r, "LINE 1\nANOTHER line\n"); 2340 free(r); 2341 2342 } 2343 2344 2345 void readStreamToNewGT(void) { 2346 2347 FILE *f; 2348 2349 f = fopen("../textTest.null", "r"); 2350 char *r = readStreamToNewG(null, f); 2351 ck_assert_str_eq(r, "LINE 1\nANOTHER line\n"); 2352 free(r); 2353 fclose(f); 2354 2355 } 2356 2357 2358 void readFileToGT(void) { 2359 2360 char *r; 2361 char *string; 2362 2363 r = readFileToG(&string, "../textTest.null"); 2364 ck_assert_ptr_ne(r, null); 2365 ck_assert_ptr_eq(r, string); 2366 ck_assert_str_eq(r, "LINE 1\nANOTHER line\n"); 2367 free(r); 2368 // NULL string 2369 ck_assert_ptr_eq(readFileToG(null, "../textTest.null"), null); 2370 2371 } 2372 2373 2374 void readStreamToGT(void) { 2375 2376 char *r; 2377 char *string; 2378 FILE *f; 2379 2380 f = fopen("../textTest.null", "r"); 2381 r = readStreamToG(&string, f); 2382 ck_assert_ptr_ne(r, null); 2383 ck_assert_ptr_eq(r, string); 2384 ck_assert_str_eq(r, "LINE 1\nANOTHER line\n"); 2385 free(r); 2386 // NULL string 2387 ck_assert_ptr_eq(readStreamToG(null, f), null); 2388 fclose(f); 2389 2390 } 2391 2392 2393 void readTextSmallJsonNotSupportedT(void) { 2394 2395 readTextSmallJsonNotSupported(null, null); 2396 2397 } 2398 2399 2400 void readTextSmallStringNotSupportedT(void) { 2401 2402 readTextSmallStringNotSupported(null, null); 2403 2404 } 2405 2406 2407 void readToFileSmallJsonNotSupportedT(void) { 2408 2409 readToFileSmallJsonNotSupported(null, null); 2410 2411 } 2412 2413 2414 void readToFileSmallStringNotSupportedT(void) { 2415 2416 readToFileSmallStringNotSupported(null, null); 2417 2418 } 2419 2420 2421 void writeFileFromGT(void) { 2422 2423 int r; 2424 char *l; 2425 2426 // write textOutTest.null 2427 l = readFileToS("../textTest.null"); 2428 r = writeFileFromG(l, "textOutTest.null"); 2429 ck_assert(r); 2430 free(l); 2431 // check textOutTest.null 2432 l = readFileToS("textOutTest.null"); 2433 ck_assert_uint_eq(strlen(l),20); 2434 ck_assert_str_eq(l, "LINE 1\nANOTHER line\n"); 2435 free(l); 2436 2437 } 2438 2439 2440 void writeStreamFromGT(void) { 2441 2442 int r; 2443 char *l; 2444 FILE *f; 2445 2446 // write textOutTest.null 2447 l = readFileToS("../textTest.null"); 2448 f = fopen("textOutTest.null", "w"); 2449 r = writeStreamFromG(l, f); 2450 ck_assert(r); 2451 fclose(f); 2452 free(l); 2453 // check textOutTest.null 2454 l = readFileToS("textOutTest.null"); 2455 ck_assert_uint_eq(strlen(l),20); 2456 ck_assert_str_eq(l, "LINE 1\nANOTHER line\n"); 2457 free(l); 2458 2459 } 2460 2461 2462 void writeTextSmallJsonNotSupportedT(void) { 2463 2464 ck_assert_int_eq(writeTextSmallJsonNotSupported(null, null), 0); 2465 2466 } 2467 2468 2469 void writeTextSmallStringNotSupportedT(void) { 2470 2471 ck_assert_int_eq(writeTextSmallStringNotSupported(null, null), 0); 2472 2473 } 2474 2475 2476 void writeTextCCSmallJsonNotSupportedT(void) { 2477 2478 ck_assert_int_eq(writeTextCCSmallJsonNotSupported(null, null), 0); 2479 2480 } 2481 2482 2483 void writeTextCCSmallStringNotSupportedT(void) { 2484 2485 ck_assert_int_eq(writeTextCCSmallStringNotSupported(null, null), 0); 2486 2487 } 2488 2489 2490 void readTextSGT(void) { 2491 2492 char **r; 2493 char **list; 2494 2495 // text 2496 r = readTextSG(&list, "../textTest.null"); 2497 ck_assert_ptr_ne(r, null); 2498 ck_assert_uint_eq(listLengthS(r),2); 2499 ck_assert_str_eq(r[0], "LINE 1"); 2500 ck_assert_str_eq(r[1], "ANOTHER line"); 2501 listFreeS(r); 2502 // NULL list 2503 r = readTextSG(null, "../textTest.null"); 2504 ck_assert_ptr_eq(r, null); 2505 2506 } 2507 2508 2509 void readTextStreamGT(void) { 2510 2511 char **r; 2512 char **list; 2513 FILE *fp; 2514 2515 // stream 2516 fp = fopen("../textTest.null", "r"); 2517 r = readTextStreamG(&list, fp); 2518 ck_assert_ptr_ne(r, null); 2519 ck_assert_uint_eq(listLengthS(r),2); 2520 ck_assert_str_eq(r[0], "LINE 1"); 2521 ck_assert_str_eq(r[1], "ANOTHER line"); 2522 listFreeS(r); 2523 // NULL list 2524 r = readTextStreamG(null, fp); 2525 ck_assert_ptr_eq(r, null); 2526 fclose(fp); 2527 2528 } 2529 2530 2531 void writeTextSGT(void) { 2532 2533 bool r; 2534 char **l; 2535 2536 // write textOutTest.null 2537 l = readText("../textTest.null"); 2538 r = writeTextSG(l, "textOutTest.null"); 2539 ck_assert(r); 2540 listFreeS(l); 2541 // check textOutTest.null 2542 l = readText("textOutTest.null"); 2543 ck_assert_uint_eq(listLengthS(l),2); 2544 ck_assert_str_eq(l[0], "LINE 1"); 2545 ck_assert_str_eq(l[1], "ANOTHER line"); 2546 listFreeS(l); 2547 rmAll("textOutTest.null"); 2548 2549 } 2550 2551 2552 void writeTextStreamGT(void) { 2553 2554 bool r; 2555 char **l; 2556 FILE *fp; 2557 2558 // write textOutTest.null 2559 l = readText("../textTest.null"); 2560 fp = fopen("textOutTest.null", "w"); 2561 r = writeTextStreamG(l, fp); 2562 ck_assert(r); 2563 fclose(fp); 2564 listFreeS(l); 2565 // check textOutTest.null 2566 l = readText("textOutTest.null"); 2567 ck_assert_uint_eq(listLengthS(l),2); 2568 ck_assert_str_eq(l[0], "LINE 1"); 2569 ck_assert_str_eq(l[1], "ANOTHER line"); 2570 listFreeS(l); 2571 rmAll("textOutTest.null"); 2572 2573 } 2574 2575 2576 void writeTextCGT(void) { 2577 2578 bool r; 2579 const char *list[] = {"LINE 1", "ANOTHER line", null}; 2580 char **l; 2581 2582 r = writeTextCG(list, "textOutTest.null"); 2583 ck_assert(r); 2584 // check textOutTest.null 2585 l = readText("textOutTest.null"); 2586 ck_assert_uint_eq(listLengthS(l),2); 2587 ck_assert_str_eq(l[0], "LINE 1"); 2588 ck_assert_str_eq(l[1], "ANOTHER line"); 2589 listFreeS(l); 2590 rmAll("textOutTest.null"); 2591 2592 } 2593 2594 2595 void writeTextStreamCGT(void) { 2596 2597 bool r; 2598 const char *list[] = {"LINE 1", "ANOTHER line", null}; 2599 char **l; 2600 FILE *fp; 2601 2602 fp = fopen("textOutTest.null", "w"); 2603 r = writeTextStreamCG(list, fp); 2604 fclose(fp); 2605 ck_assert(r); 2606 // check textOutTest.null 2607 l = readText("textOutTest.null"); 2608 ck_assert_uint_eq(listLengthS(l),2); 2609 ck_assert_str_eq(l[0], "LINE 1"); 2610 ck_assert_str_eq(l[1], "ANOTHER line"); 2611 listFreeS(l); 2612 rmAll("textOutTest.null"); 2613 2614 } 2615 2616 2617 void appendFileSGT(void) { 2618 2619 bool r; 2620 char *l; 2621 2622 r = appendFileSG("appended line\n", "appendTextOutTest.null"); 2623 ck_assert(r); 2624 r = appendFileSG("appended line 2\n", "appendTextOutTest.null"); 2625 ck_assert(r); 2626 // check textOutTest.null 2627 l = readFileToS("appendTextOutTest.null"); 2628 ck_assert_uint_eq(strlen(l),30); 2629 ck_assert_str_eq(l, "appended line\nappended line 2\n"); 2630 free(l); 2631 if (fileExists("appendTextOutTest.null")) 2632 rmAll("appendTextOutTest.null"); 2633 2634 } 2635 2636 2637 void appendTextSGT(void) { 2638 2639 bool r; 2640 char **l; 2641 2642 // append to textOutTest.null 2643 l = readText("../textTest.null"); 2644 r = writeText("textOutTest.null", l); 2645 ck_assert(r); 2646 char **c = listCreateS("A","B"); 2647 r = appendTextSG(c, "textOutTest.null"); 2648 listFreeManyS(l,c); 2649 // check textOutTest.null 2650 l = readText("textOutTest.null"); 2651 ck_assert_uint_eq(listLengthS(l),4); 2652 ck_assert_str_eq(l[0], "LINE 1"); 2653 ck_assert_str_eq(l[1], "ANOTHER line"); 2654 ck_assert_str_eq(l[2], "A"); 2655 ck_assert_str_eq(l[3], "B"); 2656 listFreeS(l); 2657 rmAll("textOutTest.null"); 2658 2659 } 2660 2661 2662 void appendTextCGT(void) { 2663 2664 bool r; 2665 const char *list[] = {"A", "B", null}; 2666 char **l; 2667 2668 // append to textOutTest.null 2669 l = readText("../textTest.null"); 2670 r = writeText("textOutTest.null", l); 2671 ck_assert(r); 2672 r = appendTextCG(list, "textOutTest.null"); 2673 listFreeS(l); 2674 // check textOutTest.null 2675 l = readText("textOutTest.null"); 2676 ck_assert_uint_eq(listLengthS(l),4); 2677 ck_assert_str_eq(l[0], "LINE 1"); 2678 ck_assert_str_eq(l[1], "ANOTHER line"); 2679 ck_assert_str_eq(l[2], "A"); 2680 ck_assert_str_eq(l[3], "B"); 2681 listFreeS(l); 2682 rmAll("textOutTest.null"); 2683 2684 } 2685 2686 2687 void mkdirParentsSmallJsonOT(void) { 2688 2689 smallJsont* path = allocSmallJson(); 2690 2691 // directory 2692 rmAll("mkdirTest.null"); 2693 setTopStringO(path, "mkdirTest.null/null"); 2694 ck_assert_int_eq(mkdirParentsSmallJsonO(path),1); 2695 // non json string 2696 freeO(path); 2697 setTopIntO(path, 2); 2698 ck_assert_int_eq(mkdirParentsSmallJsonO(path),0); 2699 terminateO(path); 2700 // null path 2701 ck_assert_int_eq(mkdirParentsSmallJsonO(null),0); 2702 rmAll("mkdirTest.null"); 2703 2704 } 2705 2706 2707 void rmAllSmallJsonOT(void) { 2708 2709 smallJsont* path = allocSmallJson(); 2710 2711 // directory 2712 mkdirParents("rmAllTest.null/null"); 2713 setTopStringO(path, "rmAllTest.null"); 2714 ck_assert_int_eq(rmAllSmallJsonO(path), 1); 2715 // non json string 2716 freeO(path); 2717 setTopIntO(path, 2); 2718 ck_assert_int_eq(rmAllSmallJsonO(path),0); 2719 terminateO(path); 2720 // null path 2721 ck_assert_int_eq(rmAllSmallJsonO(null),0); 2722 2723 } 2724 2725 2726 void copySSmallJsonOT(void) { 2727 2728 smallJsont* dst = allocSmallJson(); 2729 2730 // file 2731 rmAll("copyTest.null"); 2732 setTopStringO(dst, "copyTest.null"); 2733 ck_assert_int_eq(copySSmallJsonO("../chmodTest.null", dst),1); 2734 ck_assert(fileExists("copyTest.null")); 2735 rmAll("copyTest.null"); 2736 // non json string 2737 freeO(dst); 2738 setTopIntO(dst, 2); 2739 ck_assert_int_eq(copySSmallJsonO("../chmodTest.null", dst),0); 2740 terminateO(dst); 2741 // non json object 2742 dst = (smallJsont*) allocSmallInt(2); 2743 ck_assert_int_eq(copySSmallJsonO("../chmodTest.null", dst),0); 2744 terminateO(dst); 2745 // blank src 2746 dst = allocSmallJson(); 2747 setTopStringO(dst, ""); 2748 ck_assert_int_eq(copySSmallJsonO("", dst),0); 2749 // blank dst 2750 ck_assert_int_eq(copySSmallJsonO("../chmodTest.null", dst),0); 2751 // null src 2752 ck_assert_int_eq(copySSmallJsonO(null, dst),0); 2753 // null dst 2754 ck_assert_int_eq(copySSmallJsonO("../chmodTest.null", null),0); 2755 terminateO(dst); 2756 2757 } 2758 2759 2760 void copySOT(void) { 2761 2762 smallStringt* dst = allocSmallString("copyTest.null"); 2763 2764 // file 2765 rmAll("copyTest.null"); 2766 ck_assert_int_eq(copySO("../chmodTest.null", dst),1); 2767 ck_assert(fileExists("copyTest.null")); 2768 rmAll("copyTest.null"); 2769 // blank src 2770 setValO(dst, ""); 2771 ck_assert_int_eq(copySO("", dst),0); 2772 // blank dst 2773 ck_assert_int_eq(copySO("../chmodTest.null", dst),0); 2774 // null src 2775 ck_assert_int_eq(copySO(null, dst),0); 2776 // null dst 2777 ck_assert_int_eq(copySO("../chmodTest.null", null),0); 2778 terminateO(dst); 2779 2780 } 2781 2782 2783 void copySmallJsonOST(void) { 2784 2785 smallJsont* src = allocSmallJson(); 2786 2787 // file 2788 rmAll("copyTest.null"); 2789 setTopStringO(src, "../chmodTest.null"); 2790 ck_assert_int_eq(copySmallJsonOS(src, "copyTest.null"),1); 2791 ck_assert(fileExists("copyTest.null")); 2792 rmAll("copyTest.null"); 2793 // non json string 2794 freeO(src); 2795 setTopIntO(src, 2); 2796 ck_assert_int_eq(copySmallJsonOS(src, "copyTest.null"),0); 2797 terminateO(src); 2798 // non json object 2799 src = (smallJsont*) allocSmallInt(2); 2800 ck_assert_int_eq(copySmallJsonOS(src, "copyTest.null"),0); 2801 terminateO(src); 2802 // blank src 2803 src = allocSmallJson(); 2804 setTopStringO(src, ""); 2805 ck_assert_int_eq(copySmallJsonOS(src, "asd"),0); 2806 // blank dst 2807 freeO(src); 2808 setTopStringO(src, "../chmodTest.null"); 2809 ck_assert_int_eq(copySmallJsonOS(src, ""),0); 2810 // null src 2811 ck_assert_int_eq(copySmallJsonOS(null, "qwe"),0); 2812 // null dst 2813 ck_assert_int_eq(copySmallJsonOS(src, null),0); 2814 terminateO(src); 2815 2816 } 2817 2818 2819 void copySmallJsonSmallJsonT(void) { 2820 2821 smallJsont* src = allocSmallJson(); 2822 smallJsont* dst = allocSmallJson(); 2823 2824 // file 2825 rmAll("copyTest.null"); 2826 setTopStringO(src, "../chmodTest.null"); 2827 setTopStringO(dst, "copyTest.null"); 2828 ck_assert_int_eq(copySmallJsonSmallJson(src, dst),1); 2829 ck_assert(fileExists("copyTest.null")); 2830 rmAll("copyTest.null"); 2831 // non json string 2832 freeO(src); 2833 setTopIntO(src, 2); 2834 ck_assert_int_eq(copySmallJsonSmallJson(src, dst),0); 2835 terminateO(src); 2836 src = allocSmallJson(); 2837 setTopStringO(src, "../chmodTest.null"); 2838 freeO(dst); 2839 setTopIntO(dst, 2); 2840 ck_assert_int_eq(copySmallJsonSmallJson(src, dst),0); 2841 terminateO(src); 2842 terminateO(dst); 2843 // non json object 2844 dst = allocSmallJson(); 2845 setTopStringO(dst, "copyTest.null"); 2846 src = (smallJsont*) allocSmallInt(2); 2847 ck_assert_int_eq(copySmallJsonSmallJson(src, dst),0); 2848 terminateO(src); 2849 terminateO(dst); 2850 src = allocSmallJson(); 2851 setTopStringO(src, "../chmodTest.null"); 2852 dst = (smallJsont*) allocSmallInt(2); 2853 ck_assert_int_eq(copySmallJsonSmallJson(src, dst),0); 2854 terminateO(dst); 2855 // blank src 2856 dst = allocSmallJson(); 2857 setTopStringO(dst, "copyTest.null"); 2858 freeO(src); 2859 setTopStringO(src, ""); 2860 ck_assert_int_eq(copySmallJsonSmallJson(src, dst),0); 2861 // blank dst 2862 freeO(src); 2863 setTopStringO(src, "../chmodTest.null"); 2864 freeO(dst); 2865 setTopStringO(dst, ""); 2866 ck_assert_int_eq(copySmallJsonSmallJson(src, dst),0); 2867 // null src 2868 ck_assert_int_eq(copySmallJsonSmallJson(null, dst),0); 2869 // null dst 2870 ck_assert_int_eq(copySmallJsonSmallJson(src, null),0); 2871 terminateO(src); 2872 terminateO(dst); 2873 2874 } 2875 2876 2877 void copySmallJsonOT(void) { 2878 2879 smallJsont* src = allocSmallJson(); 2880 smallStringt* dst = allocSmallString(""); 2881 2882 // file 2883 rmAll("copyTest.null"); 2884 setTopStringO(src, "../chmodTest.null"); 2885 setValO(dst, "copyTest.null"); 2886 ck_assert_int_eq(copySmallJsonO(src, dst),1); 2887 ck_assert(fileExists("copyTest.null")); 2888 rmAll("copyTest.null"); 2889 // non json string 2890 freeO(src); 2891 setTopIntO(src, 2); 2892 ck_assert_int_eq(copySmallJsonO(src, dst),0); 2893 terminateO(src); 2894 // non json object 2895 src = (smallJsont*) allocSmallInt(2); 2896 ck_assert_int_eq(copySmallJsonO(src, dst),0); 2897 terminateO(src); 2898 src = allocSmallJson(); 2899 setTopStringO(src, "qwe"); 2900 terminateO(dst); 2901 dst = (smallStringt*) allocSmallInt(2); 2902 ck_assert_int_eq(copySmallJsonO(src, dst),0); 2903 terminateO(dst); 2904 // blank src 2905 dst = allocSmallString("copyTest.null"); 2906 freeO(src); 2907 setTopStringO(src, ""); 2908 ck_assert_int_eq(copySmallJsonO(src, dst),0); 2909 // blank dst 2910 freeO(src); 2911 setTopStringO(src, "../chmodTest.null"); 2912 setValO(dst, ""); 2913 ck_assert_int_eq(copySmallJsonO(src, dst),0); 2914 // null src 2915 ck_assert_int_eq(copySmallJsonO(null, dst),0); 2916 // null dst 2917 ck_assert_int_eq(copySmallJsonO(src, null),0); 2918 terminateO(src); 2919 terminateO(dst); 2920 2921 } 2922 2923 2924 void copyOST(void) { 2925 2926 smallStringt* src = allocSmallString(""); 2927 2928 // file 2929 rmAll("copyTest.null"); 2930 setValO(src, "../chmodTest.null"); 2931 ck_assert_int_eq(copyOS(src, "copyTest.null"),1); 2932 ck_assert(fileExists("copyTest.null")); 2933 rmAll("copyTest.null"); 2934 // blank src 2935 setValO(src, ""); 2936 ck_assert_int_eq(copyOS(src, "asd"),0); 2937 // blank dst 2938 setValO(src, "../chmodTest.null"); 2939 ck_assert_int_eq(copyOS(src, ""),0); 2940 // null src 2941 ck_assert_int_eq(copyOS(null, "qwe"),0); 2942 // null dst 2943 ck_assert_int_eq(copyOS(src, null),0); 2944 terminateO(src); 2945 2946 } 2947 2948 2949 void copyOSmallJsonT(void) { 2950 2951 smallStringt* src = allocSmallString(""); 2952 smallJsont* dst = allocSmallJson(); 2953 2954 // file 2955 rmAll("copyTest.null"); 2956 setValO(src, "../chmodTest.null"); 2957 setTopStringO(dst, "copyTest.null"); 2958 ck_assert_int_eq(copyOSmallJson(src, dst),1); 2959 ck_assert(fileExists("copyTest.null")); 2960 rmAll("copyTest.null"); 2961 // non json string 2962 freeO(dst); 2963 setTopIntO(dst, 2); 2964 ck_assert_int_eq(copyOSmallJson(src, dst),0); 2965 terminateO(dst); 2966 // non json object 2967 dst = (smallJsont*) allocSmallInt(2); 2968 ck_assert_int_eq(copyOSmallJson(src, dst),0); 2969 terminateO(src); 2970 terminateO(dst); 2971 dst = allocSmallJson(); 2972 setTopStringO(dst, "copyTest.null"); 2973 src = (smallStringt*) allocSmallInt(2); 2974 ck_assert_int_eq(copyOSmallJson(src, dst),0); 2975 terminateO(src); 2976 // blank src 2977 src = allocSmallString(""); 2978 ck_assert_int_eq(copyOSmallJson(src, dst),0); 2979 // blank dst 2980 setValO(src, "../chmodTest.null"); 2981 freeO(dst); 2982 setTopStringO(dst, ""); 2983 ck_assert_int_eq(copyOSmallJson(src, dst),0); 2984 // null src 2985 ck_assert_int_eq(copyOSmallJson(null, dst),0); 2986 // null dst 2987 ck_assert_int_eq(copyOSmallJson(src, null),0); 2988 terminateO(src); 2989 terminateO(dst); 2990 2991 } 2992 2993 2994 void renameSmallJsonOT(void) { 2995 2996 smallJsont* src = allocSmallJson(); 2997 smallStringt* dst = allocSmallString("rename2Test.null"); 2998 2999 // regualar file 3000 setTopStringO(src, "renameTest.null"); 3001 ck_assert_int_eq(renameSmallJsonO(src, dst), 1); 3002 freeO(src); 3003 setTopStringO(src, "rename2Test.null"); 3004 setValO(dst, "renameTest.null"); 3005 ck_assert_int_eq(renameSmallJsonO(src, dst), 1); 3006 // blank src 3007 freeO(src); 3008 setTopStringO(src, ""); 3009 ck_assert_int_eq(renameSmallJsonO(src, dst), 0); 3010 // blank dst 3011 freeO(src); 3012 setTopStringO(src, "renameTest.null"); 3013 setValO(dst, ""); 3014 ck_assert_int_eq(renameSmallJsonO(src, dst), 0); 3015 // non json string 3016 freeO(src); 3017 setTopIntO(src, 2); 3018 ck_assert_int_eq(renameSmallJsonO(src, dst), 0); 3019 // non smallJson/smallString objects 3020 terminateO(src); 3021 src = (smallJsont*) allocSmallInt(2); 3022 ck_assert_int_eq(renameSmallJsonO(src, dst), 0); 3023 terminateO(src); 3024 terminateO(dst); 3025 src = allocSmallJson(); 3026 dst = (smallStringt*) allocSmallInt(2); 3027 ck_assert_int_eq(renameSmallJsonO(src, dst), 0); 3028 terminateO(dst); 3029 dst = allocSmallString("qwe"); 3030 // null paths 3031 ck_assert_int_eq(renameSmallJsonO(null, dst), 0); 3032 ck_assert_int_eq(renameSmallJsonO(src, null), 0); 3033 terminateO(src); 3034 terminateO(dst); 3035 3036 } 3037 3038 3039 void renameSmallJsonSmallJsonT(void) { 3040 3041 smallJsont* src = allocSmallJson(); 3042 smallJsont* dst = allocSmallJson(); 3043 3044 // regualar file 3045 setTopStringO(src, "renameTest.null"); 3046 setTopStringO(dst, "rename2Test.null"); 3047 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 1); 3048 freeO(src); 3049 setTopStringO(src, "rename2Test.null"); 3050 freeO(dst); 3051 setTopStringO(dst, "renameTest.null"); 3052 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 1); 3053 // blank src 3054 freeO(src); 3055 setTopStringO(src, ""); 3056 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 0); 3057 // blank dst 3058 freeO(src); 3059 setTopStringO(src, "renameTest.null"); 3060 freeO(dst); 3061 setTopStringO(dst, ""); 3062 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 0); 3063 // non json string 3064 freeO(src); 3065 setTopIntO(src, 2); 3066 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 0); 3067 freeO(src); 3068 setTopStringO(src, "renameTest.null"); 3069 freeO(dst); 3070 setTopIntO(dst, 2); 3071 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 0); 3072 freeO(dst); 3073 setTopStringO(dst, "rename2Test.null"); 3074 // non smallJson/smallString objects 3075 terminateO(src); 3076 src = (smallJsont*) allocSmallInt(2); 3077 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 0); 3078 terminateO(src); 3079 terminateO(dst); 3080 src = allocSmallJson(); 3081 dst = (smallJsont*) allocSmallInt(2); 3082 ck_assert_int_eq(renameSmallJsonSmallJson(src, dst), 0); 3083 terminateO(dst); 3084 dst = allocSmallJson(); 3085 // null paths 3086 ck_assert_int_eq(renameSmallJsonSmallJson(null, dst), 0); 3087 ck_assert_int_eq(renameSmallJsonSmallJson(src, null), 0); 3088 terminateO(src); 3089 terminateO(dst); 3090 3091 } 3092 3093 3094 void renameSmallJsonOST(void) { 3095 3096 smallJsont* src = allocSmallJson(); 3097 const char* dst = "rename2Test.null"; 3098 3099 // regualar file 3100 setTopStringO(src, "renameTest.null"); 3101 ck_assert_int_eq(renameSmallJsonOS(src, dst), 1); 3102 freeO(src); 3103 setTopStringO(src, "rename2Test.null"); 3104 dst = "renameTest.null"; 3105 ck_assert_int_eq(renameSmallJsonOS(src, dst), 1); 3106 // blank src 3107 freeO(src); 3108 setTopStringO(src, ""); 3109 ck_assert_int_eq(renameSmallJsonOS(src, dst), 0); 3110 // blank dst 3111 freeO(src); 3112 setTopStringO(src, "renameTest.null"); 3113 dst = ""; 3114 ck_assert_int_eq(renameSmallJsonOS(src, dst), 0); 3115 // non json string 3116 dst = "qwe"; 3117 freeO(src); 3118 setTopIntO(src, 2); 3119 ck_assert_int_eq(renameSmallJsonOS(src, dst), 0); 3120 // non smallJson object 3121 terminateO(src); 3122 src = (smallJsont*) allocSmallInt(2); 3123 ck_assert_int_eq(renameSmallJsonOS(src, dst), 0); 3124 terminateO(src); 3125 // null paths 3126 ck_assert_int_eq(renameSmallJsonOS(null, dst), 0); 3127 ck_assert_int_eq(renameSmallJsonOS(src, null), 0); 3128 terminateO(src); 3129 3130 } 3131 3132 3133 void renameOT(void) { 3134 3135 smallStringt* src = allocSmallString("renameTest.null"); 3136 smallStringt* dst = allocSmallString("rename2Test.null"); 3137 3138 // regualar file 3139 ck_assert_int_eq(renameO(src, dst), 1); 3140 ck_assert_int_eq(renameO(dst, src), 1); 3141 // blank src 3142 setValO(src, ""); 3143 ck_assert_int_eq(renameO(src, dst), 0); 3144 // blank dst 3145 setValO(src, "renameTest.null"); 3146 setValO(dst, ""); 3147 ck_assert_int_eq(renameO(src, dst), 0); 3148 // null paths 3149 setValO(dst, "qwe"); 3150 ck_assert_int_eq(renameO(null, dst), 0); 3151 ck_assert_int_eq(renameO(src, null), 0); 3152 terminateO(src); 3153 terminateO(dst); 3154 3155 } 3156 3157 3158 void renameOSmallJsonT(void) { 3159 3160 smallStringt* src = allocSmallString(""); 3161 smallJsont* dst = allocSmallJson(); 3162 3163 // regualar file 3164 setValO(src, "renameTest.null"); 3165 setTopStringO(dst, "rename2Test.null"); 3166 ck_assert_int_eq(renameOSmallJson(src, dst), 1); 3167 setValO(src, "rename2Test.null"); 3168 freeO(dst); 3169 setTopStringO(dst, "renameTest.null"); 3170 ck_assert_int_eq(renameOSmallJson(src, dst), 1); 3171 // blank src 3172 setValO(src, ""); 3173 ck_assert_int_eq(renameOSmallJson(src, dst), 0); 3174 // blank dst 3175 setValO(src, "renameTest.null"); 3176 freeO(dst); 3177 setTopStringO(dst, ""); 3178 ck_assert_int_eq(renameOSmallJson(src, dst), 0); 3179 // non json string 3180 freeO(dst); 3181 setTopIntO(dst, 2); 3182 ck_assert_int_eq(renameOSmallJson(src, dst), 0); 3183 freeO(dst); 3184 setTopStringO(dst, "rename2Test.null"); 3185 // non smallJson/smallString objects 3186 terminateO(src); 3187 src = (smallStringt*) allocSmallInt(2); 3188 ck_assert_int_eq(renameOSmallJson(src, dst), 0); 3189 terminateO(src); 3190 terminateO(dst); 3191 src = allocSmallString("qwe"); 3192 dst = (smallJsont*) allocSmallInt(2); 3193 ck_assert_int_eq(renameOSmallJson(src, dst), 0); 3194 terminateO(dst); 3195 dst = allocSmallJson(); 3196 // null paths 3197 ck_assert_int_eq(renameOSmallJson(null, dst), 0); 3198 ck_assert_int_eq(renameOSmallJson(src, null), 0); 3199 terminateO(src); 3200 terminateO(dst); 3201 3202 } 3203 3204 3205 void renameSSmallJsonOT(void) { 3206 3207 const char* src = "renameTest.null"; 3208 smallJsont* dst = allocSmallJson(); 3209 3210 // regualar file 3211 setTopStringO(dst, "rename2Test.null"); 3212 ck_assert_int_eq(renameSSmallJsonO(src, dst), 1); 3213 src = "rename2Test.null"; 3214 freeO(dst); 3215 setTopStringO(dst, "renameTest.null"); 3216 ck_assert_int_eq(renameSSmallJsonO(src, dst), 1); 3217 // blank src 3218 src = ""; 3219 ck_assert_int_eq(renameSSmallJsonO(src, dst), 0); 3220 // blank dst 3221 src = "renameTest.null"; 3222 freeO(dst); 3223 setTopStringO(dst, ""); 3224 ck_assert_int_eq(renameSSmallJsonO(src, dst), 0); 3225 // non json string 3226 freeO(dst); 3227 setTopIntO(dst, 2); 3228 ck_assert_int_eq(renameSSmallJsonO(src, dst), 0); 3229 freeO(dst); 3230 setTopStringO(dst, "rename2Test.null"); 3231 // non smallJson/smallString objects 3232 terminateO(dst); 3233 src = "qwe"; 3234 dst = (smallJsont*) allocSmallInt(2); 3235 ck_assert_int_eq(renameSSmallJsonO(src, dst), 0); 3236 terminateO(dst); 3237 dst = allocSmallJson(); 3238 // null paths 3239 ck_assert_int_eq(renameSSmallJsonO(null, dst), 0); 3240 ck_assert_int_eq(renameSSmallJsonO(src, null), 0); 3241 terminateO(dst); 3242 3243 } 3244 3245 3246 void renameSOT(void) { 3247 3248 const char* src = "renameTest.null"; 3249 smallStringt* dst = allocSmallString("rename2Test.null"); 3250 3251 // regualar file 3252 ck_assert_int_eq(renameSO(src, dst), 1); 3253 src = "rename2Test.null"; 3254 setValO(dst, "renameTest.null"); 3255 ck_assert_int_eq(renameSO(src, dst), 1); 3256 // null paths 3257 ck_assert_int_eq(renameSO(null, dst), 0); 3258 ck_assert_int_eq(renameSO(src, null), 0); 3259 terminateO(dst); 3260 3261 } 3262 3263 3264 void renameOST(void) { 3265 3266 smallStringt* src = allocSmallString("renameTest.null"); 3267 const char* dst = "rename2Test.null"; 3268 3269 // regualar file 3270 ck_assert_int_eq(renameOS(src, dst), 1); 3271 setValO(src, "rename2Test.null"); 3272 dst = "renameTest.null"; 3273 ck_assert_int_eq(renameOS(src, dst), 1); 3274 // null paths 3275 ck_assert_int_eq(renameOS(null, dst), 0); 3276 ck_assert_int_eq(renameOS(src, null), 0); 3277 terminateO(src); 3278 3279 } 3280 3281 3282 void moveSmallJsonOT(void) { 3283 3284 smallJsont* src = allocSmallJson(); 3285 smallStringt* dst = allocSmallString("../../rename2Test.null"); 3286 3287 // regualar file 3288 setTopStringO(src, "renameTest.null"); 3289 ck_assert_int_eq(moveSmallJsonO(src, dst), 1); 3290 freeO(src); 3291 setTopStringO(src, "../../rename2Test.null"); 3292 setValO(dst, "renameTest.null"); 3293 ck_assert_int_eq(moveSmallJsonO(src, dst), 1); 3294 // blank src 3295 freeO(src); 3296 setTopStringO(src, ""); 3297 ck_assert_int_eq(moveSmallJsonO(src, dst), 0); 3298 // blank dst 3299 freeO(src); 3300 setTopStringO(src, "renameTest.null"); 3301 setValO(dst, ""); 3302 ck_assert_int_eq(moveSmallJsonO(src, dst), 0); 3303 // non json string 3304 freeO(src); 3305 setTopIntO(src, 2); 3306 ck_assert_int_eq(moveSmallJsonO(src, dst), 0); 3307 // non smallJson/smallString objects 3308 terminateO(src); 3309 src = (smallJsont*) allocSmallInt(2); 3310 ck_assert_int_eq(moveSmallJsonO(src, dst), 0); 3311 terminateO(src); 3312 terminateO(dst); 3313 src = allocSmallJson(); 3314 dst = (smallStringt*) allocSmallInt(2); 3315 ck_assert_int_eq(moveSmallJsonO(src, dst), 0); 3316 terminateO(dst); 3317 dst = allocSmallString("qwe"); 3318 // null paths 3319 ck_assert_int_eq(moveSmallJsonO(null, dst), 0); 3320 ck_assert_int_eq(moveSmallJsonO(src, null), 0); 3321 terminateO(src); 3322 terminateO(dst); 3323 3324 } 3325 3326 3327 void moveSmallJsonSmallJsonT(void) { 3328 3329 smallJsont* src = allocSmallJson(); 3330 smallJsont* dst = allocSmallJson(); 3331 3332 // regualar file 3333 setTopStringO(src, "renameTest.null"); 3334 setTopStringO(dst, "../../rename2Test.null"); 3335 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 1); 3336 freeO(src); 3337 setTopStringO(src, "../../rename2Test.null"); 3338 freeO(dst); 3339 setTopStringO(dst, "renameTest.null"); 3340 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 1); 3341 // blank src 3342 freeO(src); 3343 setTopStringO(src, ""); 3344 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 0); 3345 // blank dst 3346 freeO(src); 3347 setTopStringO(src, "renameTest.null"); 3348 freeO(dst); 3349 setTopStringO(dst, ""); 3350 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 0); 3351 // non json string 3352 freeO(src); 3353 setTopIntO(src, 2); 3354 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 0); 3355 freeO(src); 3356 setTopStringO(src, "renameTest.null"); 3357 freeO(dst); 3358 setTopIntO(dst, 2); 3359 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 0); 3360 freeO(dst); 3361 setTopStringO(dst, "rename2Test.null"); 3362 // non smallJson/smallString objects 3363 terminateO(src); 3364 src = (smallJsont*) allocSmallInt(2); 3365 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 0); 3366 terminateO(src); 3367 terminateO(dst); 3368 src = allocSmallJson(); 3369 dst = (smallJsont*) allocSmallInt(2); 3370 ck_assert_int_eq(moveSmallJsonSmallJson(src, dst), 0); 3371 terminateO(dst); 3372 dst = allocSmallJson(); 3373 // null paths 3374 ck_assert_int_eq(moveSmallJsonSmallJson(null, dst), 0); 3375 ck_assert_int_eq(moveSmallJsonSmallJson(src, null), 0); 3376 terminateO(src); 3377 terminateO(dst); 3378 3379 } 3380 3381 3382 void moveSmallJsonOST(void) { 3383 3384 smallJsont* src = allocSmallJson(); 3385 const char* dst = "../../rename2Test.null"; 3386 3387 // regualar file 3388 setTopStringO(src, "renameTest.null"); 3389 ck_assert_int_eq(moveSmallJsonOS(src, dst), 1); 3390 freeO(src); 3391 setTopStringO(src, "../../rename2Test.null"); 3392 dst = "renameTest.null"; 3393 ck_assert_int_eq(moveSmallJsonOS(src, dst), 1); 3394 // blank src 3395 freeO(src); 3396 setTopStringO(src, ""); 3397 ck_assert_int_eq(moveSmallJsonOS(src, dst), 0); 3398 // blank dst 3399 freeO(src); 3400 setTopStringO(src, "renameTest.null"); 3401 dst = ""; 3402 ck_assert_int_eq(moveSmallJsonOS(src, dst), 0); 3403 // non json string 3404 dst = "qwe"; 3405 freeO(src); 3406 setTopIntO(src, 2); 3407 ck_assert_int_eq(moveSmallJsonOS(src, dst), 0); 3408 // non smallJson object 3409 terminateO(src); 3410 src = (smallJsont*) allocSmallInt(2); 3411 ck_assert_int_eq(moveSmallJsonOS(src, dst), 0); 3412 terminateO(src); 3413 // null paths 3414 ck_assert_int_eq(moveSmallJsonOS(null, dst), 0); 3415 ck_assert_int_eq(moveSmallJsonOS(src, null), 0); 3416 terminateO(src); 3417 3418 } 3419 3420 3421 void moveOT(void) { 3422 3423 smallStringt* src = allocSmallString("renameTest.null"); 3424 smallStringt* dst = allocSmallString("../../rename2Test.null"); 3425 3426 // regualar file 3427 ck_assert_int_eq(moveO(src, dst), 1); 3428 ck_assert_int_eq(moveO(dst, src), 1); 3429 // blank src 3430 setValO(src, ""); 3431 ck_assert_int_eq(moveO(src, dst), 0); 3432 // blank dst 3433 setValO(src, "renameTest.null"); 3434 setValO(dst, ""); 3435 ck_assert_int_eq(moveO(src, dst), 0); 3436 // null paths 3437 setValO(dst, "qwe"); 3438 ck_assert_int_eq(moveO(null, dst), 0); 3439 ck_assert_int_eq(moveO(src, null), 0); 3440 terminateO(src); 3441 terminateO(dst); 3442 3443 } 3444 3445 3446 void moveOSmallJsonT(void) { 3447 3448 smallStringt* src = allocSmallString(""); 3449 smallJsont* dst = allocSmallJson(); 3450 3451 // regualar file 3452 setValO(src, "renameTest.null"); 3453 setTopStringO(dst, "../../rename2Test.null"); 3454 ck_assert_int_eq(moveOSmallJson(src, dst), 1); 3455 setValO(src, "../../rename2Test.null"); 3456 freeO(dst); 3457 setTopStringO(dst, "renameTest.null"); 3458 ck_assert_int_eq(moveOSmallJson(src, dst), 1); 3459 // blank src 3460 setValO(src, ""); 3461 ck_assert_int_eq(moveOSmallJson(src, dst), 0); 3462 // blank dst 3463 setValO(src, "renameTest.null"); 3464 freeO(dst); 3465 setTopStringO(dst, ""); 3466 ck_assert_int_eq(moveOSmallJson(src, dst), 0); 3467 // non json string 3468 freeO(dst); 3469 setTopIntO(dst, 2); 3470 ck_assert_int_eq(moveOSmallJson(src, dst), 0); 3471 freeO(dst); 3472 setTopStringO(dst, "rename2Test.null"); 3473 // non smallJson/smallString objects 3474 terminateO(src); 3475 src = (smallStringt*) allocSmallInt(2); 3476 ck_assert_int_eq(moveOSmallJson(src, dst), 0); 3477 terminateO(src); 3478 terminateO(dst); 3479 src = allocSmallString("qwe"); 3480 dst = (smallJsont*) allocSmallInt(2); 3481 ck_assert_int_eq(moveOSmallJson(src, dst), 0); 3482 terminateO(dst); 3483 dst = allocSmallJson(); 3484 // null paths 3485 ck_assert_int_eq(moveOSmallJson(null, dst), 0); 3486 ck_assert_int_eq(moveOSmallJson(src, null), 0); 3487 terminateO(src); 3488 terminateO(dst); 3489 3490 } 3491 3492 3493 void moveSSmallJsonOT(void) { 3494 3495 const char* src = "renameTest.null"; 3496 smallJsont* dst = allocSmallJson(); 3497 3498 // regualar file 3499 setTopStringO(dst, "../../rename2Test.null"); 3500 ck_assert_int_eq(moveSSmallJsonO(src, dst), 1); 3501 src = "../../rename2Test.null"; 3502 freeO(dst); 3503 setTopStringO(dst, "renameTest.null"); 3504 ck_assert_int_eq(moveSSmallJsonO(src, dst), 1); 3505 // blank src 3506 src = ""; 3507 ck_assert_int_eq(moveSSmallJsonO(src, dst), 0); 3508 // blank dst 3509 src = "renameTest.null"; 3510 freeO(dst); 3511 setTopStringO(dst, ""); 3512 ck_assert_int_eq(moveSSmallJsonO(src, dst), 0); 3513 // non json string 3514 freeO(dst); 3515 setTopIntO(dst, 2); 3516 ck_assert_int_eq(moveSSmallJsonO(src, dst), 0); 3517 freeO(dst); 3518 setTopStringO(dst, "rename2Test.null"); 3519 // non smallJson/smallString objects 3520 terminateO(dst); 3521 src = "qwe"; 3522 dst = (smallJsont*) allocSmallInt(2); 3523 ck_assert_int_eq(moveSSmallJsonO(src, dst), 0); 3524 terminateO(dst); 3525 dst = allocSmallJson(); 3526 // null paths 3527 ck_assert_int_eq(moveSSmallJsonO(null, dst), 0); 3528 ck_assert_int_eq(moveSSmallJsonO(src, null), 0); 3529 terminateO(dst); 3530 3531 } 3532 3533 3534 void moveSOT(void) { 3535 3536 const char* src = "renameTest.null"; 3537 smallStringt* dst = allocSmallString("../../rename2Test.null"); 3538 3539 // regualar file 3540 ck_assert_int_eq(moveSO(src, dst), 1); 3541 src = "../../rename2Test.null"; 3542 setValO(dst, "renameTest.null"); 3543 ck_assert_int_eq(moveSO(src, dst), 1); 3544 // null paths 3545 ck_assert_int_eq(moveSO(null, dst), 0); 3546 ck_assert_int_eq(moveSO(src, null), 0); 3547 terminateO(dst); 3548 3549 } 3550 3551 3552 void moveOST(void) { 3553 3554 smallStringt* src = allocSmallString("renameTest.null"); 3555 const char* dst = "../../rename2Test.null"; 3556 3557 // regualar file 3558 ck_assert_int_eq(moveOS(src, dst), 1); 3559 setValO(src, "../../rename2Test.null"); 3560 dst = "renameTest.null"; 3561 ck_assert_int_eq(moveOS(src, dst), 1); 3562 // null paths 3563 ck_assert_int_eq(moveOS(null, dst), 0); 3564 ck_assert_int_eq(moveOS(src, null), 0); 3565 terminateO(src); 3566 3567 } 3568 3569 3570 void randomSmallJsonOT(void) { 3571 3572 smallJsont *r; 3573 uint64_t length = 20; 3574 3575 r = randomSmallJsonO(length); 3576 ck_assert_ptr_ne(r, null); 3577 ck_assert_int_eq(lenO(r), length); 3578 terminateO(r); 3579 // invalid length (0) 3580 ck_assert_ptr_eq(randomSmallJsonO(0), null); 3581 3582 } 3583 3584 3585 void randomAlphaNumSmallJsonOT(void) { 3586 3587 smallJsont *r; 3588 uint64_t length = 20; 3589 3590 r = randomAlphaNumSmallJsonO(length); 3591 ck_assert_ptr_ne(r, null); 3592 ck_assert_int_eq(lenO(r), length); 3593 terminateO(r); 3594 // invalid length (0) 3595 ck_assert_ptr_eq(randomAlphaNumSmallJsonO(0), null); 3596 3597 } 3598 3599 3600 void readSmallJsonOT(void) { 3601 3602 smallJsont *r; 3603 3604 r = readSmallJsonO(); 3605 char *s = toStringO(r); 3606 terminateO(r); 3607 ck_assert_str_eq(s, "aaaaaaaaaaaaaaaaaaaa"); 3608 free(s); 3609 3610 } 3611 3612 3613 void readOT(void) { 3614 3615 smallStringt *r; 3616 3617 r = readO(); 3618 char *s = toStringO(r); 3619 terminateO(r); 3620 ck_assert_str_eq(s, "aaaaaaaaaaaaaaaaaaaa"); 3621 free(s); 3622 3623 } 3624 3625 3626 void readLineSmallJsonOT(void) { 3627 3628 smallJsont *r; 3629 FILE *fp; 3630 3631 // file with data 3632 fp = fopen("../textTest.null", "r"); 3633 r = readLineSmallJsonO(fp); 3634 fclose(fp); 3635 char *s = toStringO(r); 3636 terminateO(r); 3637 ck_assert_str_eq(s, "LINE 1"); 3638 free(s); 3639 3640 } 3641 3642 3643 void intToSGT(void) { 3644 3645 char *s; 3646 3647 s = intToSG(null, 123); 3648 ck_assert_str_eq(s, "123"); 3649 free(s); 3650 s = intToSG(null, -465464123); 3651 ck_assert_str_eq(s, "-465464123"); 3652 free(s); 3653 3654 } 3655 3656 3657 void doubleToSGT(void) { 3658 3659 char *s; 3660 3661 s = doubleToSG(null, 123.4); 3662 ck_assert_str_eq(s, "1.234000e+02"); 3663 free(s); 3664 s = doubleToSG(null, -4652445e5); 3665 ck_assert_str_eq(s, "-4.652445e+11"); 3666 free(s); 3667 3668 } 3669 3670 3671 void iListUniqGT(void) { 3672 3673 char **l = NULL; 3674 char **l2; 3675 3676 // list with unique elements 3677 listPushS(&l, "1"); 3678 listPushS(&l, "22"); 3679 listPushS(&l, "333"); 3680 listPushS(&l, "4444"); 3681 l2 = listDupS(l); 3682 iListUniqG(&l2, 0); 3683 ck_assert(listEqS(l,l2)); 3684 // list with identical elements 3685 l[2][0] = '2'; 3686 l[2][1] = '2'; 3687 l[2][2] = 0; 3688 listFreeS(l2); 3689 l2 = listDupS(l); 3690 iListUniqG(&l2, 0); 3691 ck_assert_uint_eq(listLengthS(l2),3); 3692 ck_assert_str_eq(l2[2], "4444"); 3693 listFreeS(l); 3694 listFreeS(l2); 3695 3696 } 3697 3698 3699 void iicListUniqGT(void) { 3700 3701 char **l = NULL; 3702 char **l2; 3703 3704 // list with unique elements 3705 listPushS(&l, "1"); 3706 listPushS(&l, "BB"); 3707 listPushS(&l, "333"); 3708 listPushS(&l, "4444"); 3709 l2 = listDupS(l); 3710 iicListUniqG(&l2, 0); 3711 ck_assert(listEqS(l,l2)); 3712 // list with identical elements 3713 l[2][0] = 'b'; 3714 l[2][1] = 'b'; 3715 l[2][2] = 0; 3716 listFreeS(l2); 3717 l2 = listDupS(l); 3718 iicListUniqG(&l2, 0); 3719 ck_assert_uint_eq(listLengthS(l2),3); 3720 ck_assert_str_eq(l2[2], "4444"); 3721 listFreeS(l); 3722 listFreeS(l2); 3723 3724 } 3725 3726 3727 void listFromArrayGT(void) { 3728 3729 char **l = NULL; 3730 char *array[] = {"1", "22", "333"}; 3731 3732 // copy array to list 3733 l = listFromArrayG(null, array, 3); 3734 ck_assert_uint_eq(listLengthS(l),3); 3735 ck_assert_str_eq(l[0], "1"); 3736 ck_assert_str_eq(l[1], "22"); 3737 ck_assert_str_eq(l[2], "333"); 3738 listFreeS(l); 3739 3740 } 3741 3742 3743 void listFromCArrayGT(void) { 3744 3745 char **l = NULL; 3746 const char *array[] = {"1", "22", "333"}; 3747 3748 // copy array to list 3749 l = listFromCArrayG(null, array, 3); 3750 ck_assert_uint_eq(listLengthS(l),3); 3751 ck_assert_str_eq(l[0], "1"); 3752 ck_assert_str_eq(l[1], "22"); 3753 ck_assert_str_eq(l[2], "333"); 3754 listFreeS(l); 3755 3756 } 3757 3758 3759 void getSGT(void) { 3760 3761 // get char 3762 ck_assert_uint_eq(getSG("sheepy", 0/*type unused*/, 1), 'h'); 3763 3764 } 3765 3766 3767 void listGetGT(void) { 3768 3769 char **l = NULL; 3770 3771 // get string 3772 listPushS(&l, "1"); 3773 listPushS(&l, "22"); 3774 listPushS(&l, "333"); 3775 listPushS(&l, "4444"); 3776 char *s = listGetG(l, 0/*type unused*/, 1); 3777 ck_assert_str_eq(s, "22"); 3778 free(s); 3779 listFreeS(l); 3780 3781 } 3782 3783 3784 void listGetCGT(void) { 3785 3786 const char *array[] = {"1", "22", "333", null}; 3787 3788 char *s = listGetCG(array, 0/*type unused*/, 1); 3789 ck_assert_str_eq(s, "22"); 3790 free(s); 3791 3792 } 3793 3794 3795 void iListGetGT(void) { 3796 3797 char **l = NULL; 3798 3799 // get string 3800 listPushS(&l, "1"); 3801 listPushS(&l, "22"); 3802 listPushS(&l, "333"); 3803 listPushS(&l, "4444"); 3804 ck_assert_str_eq(iListGetG(l, 0/*type unused*/, 1), "22"); 3805 listFreeS(l); 3806 3807 } 3808 3809 3810 void iListGetCGT(void) { 3811 3812 const char *array[] = {"1", "22", "333", null}; 3813 3814 ck_assert_str_eq(iListGetCG(array, 0/*type unused*/, 1), "22"); 3815 3816 } 3817 3818 3819 void listPopGT(void) { 3820 3821 char **l = NULL; 3822 char *s; 3823 3824 // pop string 3825 listPushS(&l, "sheepy"); 3826 listPushS(&l, "SHEEPY"); 3827 s = listPopG(&l, 0/*unused*/); 3828 ck_assert_str_eq(s, "SHEEPY"); 3829 ck_assert_uint_eq(listLengthS(l),1); 3830 free(s); 3831 listFreeS(l); 3832 3833 } 3834 3835 3836 void listDequeueGT(void) { 3837 3838 char **l = NULL; 3839 char *s; 3840 3841 // dequeue string 3842 listPushS(&l, "sheepy"); 3843 listPushS(&l, "SHEEPY"); 3844 s = listDequeueG(&l, 0/*unused*/); 3845 ck_assert_str_eq(s, "sheepy"); 3846 ck_assert_uint_eq(listLengthS(l),1); 3847 free(s); 3848 listFreeS(l); 3849 3850 } 3851 3852 3853 void listDupCGT(void) { 3854 3855 const char *l[] = {"1", "22", "333", "4444", null}; 3856 char **l2; 3857 3858 // list 3859 l2 = listDupCG(l); 3860 ck_assert_uint_eq(listLengthS(l2),4); 3861 ck_assert_str_eq(l2[0], "1"); 3862 ck_assert_str_eq(l2[3], "4444"); 3863 listFreeS(l2); 3864 3865 } 3866 3867 3868 void listEqCGT(void) { 3869 3870 char **l = null; 3871 const char *l2[] = {"1", "22", "333", "4444", null}; 3872 3873 // identical lists 3874 listPushS(&l, "1"); 3875 listPushS(&l, "22"); 3876 listPushS(&l, "333"); 3877 listPushS(&l, "4444"); 3878 ck_assert(listEqCG(l,l2)); 3879 listFreeS(l); 3880 3881 } 3882 3883 3884 void listEqC1GT(void) { 3885 3886 char **l = null; 3887 const char *l2[] = {"1", "22", "333", "4444", null}; 3888 3889 // identical lists 3890 listPushS(&l, "1"); 3891 listPushS(&l, "22"); 3892 listPushS(&l, "333"); 3893 listPushS(&l, "4444"); 3894 ck_assert(listEqC1G(l2,l)); 3895 listFreeS(l); 3896 3897 } 3898 3899 3900 void listEqCCGT(void) { 3901 3902 const char *l[] = {"1", "22", "333", "4444", null}; 3903 const char *l2[] = {"1", "22", "333", "4444", null}; 3904 ck_assert(listEqCCG(l,l2)); 3905 3906 } 3907 3908 3909 void icListEqCGT(void) { 3910 3911 char **l = null; 3912 const char *l2[] = {"a", "22", "333", "4444", null}; 3913 3914 listPushS(&l, "A"); 3915 listPushS(&l, "22"); 3916 listPushS(&l, "333"); 3917 listPushS(&l, "4444"); 3918 ck_assert(icListEqCG(l,l2)); 3919 listFreeS(l); 3920 3921 } 3922 3923 3924 void icListEqC1GT(void) { 3925 3926 char **l = null; 3927 const char *l2[] = {"a", "22", "333", "4444", null}; 3928 3929 listPushS(&l, "A"); 3930 listPushS(&l, "22"); 3931 listPushS(&l, "333"); 3932 listPushS(&l, "4444"); 3933 ck_assert(icListEqC1G(l2,l)); 3934 listFreeS(l); 3935 3936 } 3937 3938 3939 void icListEqCCGT(void) { 3940 3941 const char *l[] = {"a", "22", "333", "4444", null}; 3942 const char *l2[] = {"A", "22", "333", "4444", null}; 3943 ck_assert(icListEqCCG(l,l2)); 3944 3945 } 3946 3947 3948 void listLengthCGT(void) { 3949 3950 const char *l[] = {"a", "22", "333", "4444", null}; 3951 3952 ck_assert_int_eq(listLengthCG(l), 4); 3953 3954 } 3955 3956 3957 void listIndexOfCGT(void) { 3958 3959 const char *l[] = {"a", "22", "333", "4444", null}; 3960 3961 ck_assert_int_eq(listIndexOfCG(l, "333"), 2); 3962 3963 } 3964 3965 3966 void listIndexOfCharCGT(void) { 3967 3968 const char *l[] = {"a", "22", "333", "4444", null}; 3969 3970 ck_assert_int_eq(listIndexOfCharCG(l, 'a'), 0); 3971 3972 } 3973 3974 3975 void icListIndexOfCGT(void) { 3976 3977 const char *l[] = {"a", "22", "333", "4444", null}; 3978 3979 ck_assert_int_eq(icListIndexOfCG(l, "A"), 0); 3980 3981 } 3982 3983 3984 void icListIndexOfCharCGT(void) { 3985 3986 const char *l[] = {"a", "22", "333", "4444", null}; 3987 3988 ck_assert_int_eq(icListIndexOfCharCG(l, 'A'), 0); 3989 3990 } 3991 3992 3993 void listHasCharCGT(void) { 3994 3995 const char *l[] = {"a", "22", "333", "4444", null}; 3996 3997 ck_assert(listHasCharCG(l, 'a')); 3998 3999 } 4000 4001 4002 void listHasCGT(void) { 4003 4004 const char *l[] = {"a", "22", "333", "4444", null}; 4005 4006 ck_assert(listHasCG(l, "333")); 4007 4008 } 4009 4010 4011 void icListHasCGT(void) { 4012 4013 const char *l[] = {"a", "22", "333", "4444", null}; 4014 4015 ck_assert(icListHasCG(l, "A")); 4016 4017 } 4018 4019 4020 void icListHasCharCGT(void) { 4021 4022 const char *l[] = {"a", "22", "333", "4444", null}; 4023 4024 ck_assert(icListHasCharCG(l, 'A')); 4025 4026 } 4027 4028 4029 void joinCGT(void) { 4030 4031 char *r; 4032 const char *list[] = {"one", "two", null}; 4033 4034 r = joinCG(list, "/"); 4035 ck_assert_ptr_ne(r, null); 4036 ck_assert_str_eq(r, "one/two"); 4037 free(r); 4038 4039 } 4040 4041 4042 void joinCharCGT(void) { 4043 4044 char *r; 4045 const char *list[] = {"one", "two", null}; 4046 4047 r = joinCharCG(list, '/'); 4048 ck_assert_ptr_ne(r, null); 4049 ck_assert_str_eq(r, "one/two"); 4050 free(r); 4051 4052 } 4053 4054 4055 void listAddCGT(void) { 4056 4057 char **r; 4058 char **l = null; 4059 const char *l2[] = {"A", "BB", "CCC", "DDDD", null}; 4060 4061 // lists 4062 listPushS(&l, "1"); 4063 listPushS(&l, "22"); 4064 listPushS(&l, "333"); 4065 listPushS(&l, "4444"); 4066 r = listAddCG(l, l2); 4067 ck_assert_uint_eq(listLengthS(r),8); 4068 ck_assert_str_eq(r[0], "1"); 4069 ck_assert_str_eq(r[3], "4444"); 4070 ck_assert_str_eq(r[4],"A"); 4071 ck_assert_str_eq(r[7],"DDDD"); 4072 listFreeS(r); 4073 listFreeS(l); 4074 4075 } 4076 4077 4078 void listPrintCGT(void) { 4079 4080 const char *list[] = {"1", "22", null}; 4081 4082 listPrintCG(list); 4083 4084 } 4085 4086 4087 void eqCharCharT(void) { 4088 4089 ck_assert(eqCharChar('a', 'a')); 4090 4091 } 4092 4093 4094 void equalChaOGT(void) { 4095 4096 baset* value = (baset*) allocSmallString("a"); 4097 4098 ck_assert(equalChaOG('a', value)); 4099 terminateO(value); 4100 4101 } 4102 4103 4104 void equalChaBoolGT(void) { 4105 4106 ck_assert(!equalChaBoolG('a', false)); 4107 4108 } 4109 4110 4111 void equalChaDoubleGT(void) { 4112 4113 ck_assert(!equalChaDoubleG('1', 1)); 4114 4115 } 4116 4117 4118 void equalChaInt64GT(void) { 4119 4120 ck_assert(equalChaInt64G('2', 2)); 4121 4122 } 4123 4124 4125 void equalChaInt32GT(void) { 4126 4127 ck_assert(equalChaInt32G('2', 2)); 4128 4129 } 4130 4131 4132 void equalChaUint32GT(void) { 4133 4134 ck_assert(equalChaUint32G('2', 2)); 4135 4136 } 4137 4138 4139 void equalChaUint64GT(void) { 4140 4141 ck_assert(equalChaUint64G('2', 2)); 4142 4143 } 4144 4145 4146 void equalChaSmallBytesGT(void) { 4147 4148 smallBytest* value = allocSmallBytes("a", sizeof("a")); 4149 4150 ck_assert(equalChaSmallBytesG('a', value)); 4151 freeO(value); 4152 ck_assert(!equalChaSmallBytesG('a', value)); 4153 terminateO(value); 4154 ck_assert(!equalChaSmallBytesG('a', value)); 4155 4156 } 4157 4158 4159 void equalChaSmallDoubleGT(void) { 4160 4161 smallDoublet* value = allocSmallDouble(0); 4162 4163 ck_assert(!equalChaSmallDoubleG('0', value)); 4164 freeO(value); 4165 ck_assert(!equalChaSmallDoubleG('0', value)); 4166 terminateO(value); 4167 ck_assert(!equalChaSmallDoubleG('0', value)); 4168 4169 } 4170 4171 4172 void equalChaSmallIntGT(void) { 4173 4174 smallIntt* value = allocSmallInt(2); 4175 4176 ck_assert(equalChaSmallIntG('2', value)); 4177 freeO(value); 4178 ck_assert(!equalChaSmallIntG('2', value)); 4179 terminateO(value); 4180 ck_assert(!equalChaSmallIntG('2', value)); 4181 4182 } 4183 4184 4185 void equalChaSmallJsonGT(void) { 4186 4187 smallJsont* value = allocSmallJson(); 4188 4189 setTopStringO(value, "a"); 4190 ck_assert(equalChaSmallJsonG('a', value)); 4191 // non json string 4192 freeO(value); 4193 setTopIntO(value, 2); 4194 ck_assert(!equalChaSmallJsonG('a', value)); 4195 // non json object 4196 terminateO(value); 4197 value = (smallJsont*) allocSmallInt(0); 4198 ck_assert(!equalChaSmallJsonG('a', value)); 4199 terminateO(value); 4200 ck_assert(!equalChaSmallJsonG('a', value)); 4201 4202 } 4203 4204 4205 void equalChaSmallStringGT(void) { 4206 4207 smallStringt* value = allocSmallString("a"); 4208 4209 ck_assert(equalChaSmallStringG('a', value)); 4210 freeO(value); 4211 ck_assert(!equalChaSmallStringG('a', value)); 4212 terminateO(value); 4213 ck_assert(!equalChaSmallStringG('a', value)); 4214 4215 } 4216 4217 4218 void equalCharOGT(void) { 4219 4220 baset* value = (baset*) allocSmallInt(2); 4221 4222 ck_assert(equalCharOG("2", value)); 4223 ck_assert(!equalCharOG(null, value)); 4224 terminateO(value); 4225 ck_assert(!equalCharOG("2", value)); 4226 4227 } 4228 4229 4230 void equalCharBoolGT(void) { 4231 4232 ck_assert(equalCharBoolG("true", true)); 4233 4234 } 4235 4236 4237 void equalCharDoubleGT(void) { 4238 4239 ck_assert(equalCharDoubleG("1.0", 1)); 4240 4241 } 4242 4243 4244 void equalCharInt64GT(void) { 4245 4246 ck_assert(equalCharInt64G("2", 2)); 4247 4248 } 4249 4250 4251 void equalCharInt32GT(void) { 4252 4253 ck_assert(equalCharInt32G("2", 2)); 4254 4255 } 4256 4257 4258 void equalCharUint32GT(void) { 4259 4260 ck_assert(equalCharUint32G("2", 2)); 4261 4262 } 4263 4264 4265 void equalCharUint64GT(void) { 4266 4267 ck_assert(equalCharUint64G("2", 2)); 4268 4269 } 4270 4271 4272 void equalCharSmallBoolGT(void) { 4273 4274 smallBoolt* value = allocSmallBool(true); 4275 4276 ck_assert(equalCharSmallBoolG("true", value)); 4277 terminateO(value); 4278 ck_assert(!equalCharSmallBoolG("false", value)); 4279 4280 } 4281 4282 4283 void equalCharSmallBytesGT(void) { 4284 4285 smallBytest* value = allocSmallBytes("qwe", sizeof("qwe")); 4286 4287 ck_assert(equalCharSmallBytesG("qwe", value)); 4288 terminateO(value); 4289 ck_assert(!equalCharSmallBytesG("qwe", value)); 4290 4291 } 4292 4293 4294 void equalCharSmallDoubleGT(void) { 4295 4296 smallDoublet* value = allocSmallDouble(1); 4297 4298 ck_assert(equalCharSmallDoubleG("1.0", value)); 4299 terminateO(value); 4300 ck_assert(!equalCharSmallDoubleG("1.0", value)); 4301 4302 } 4303 4304 4305 void equalCharSmallIntGT(void) { 4306 4307 smallIntt* value = allocSmallInt(2); 4308 4309 ck_assert(equalCharSmallIntG("2", value)); 4310 terminateO(value); 4311 ck_assert(!equalCharSmallIntG("2", value)); 4312 4313 } 4314 4315 4316 void equalCharPSmallJsonGT(void) { 4317 4318 smallJsont* value = allocSmallJson(); 4319 4320 setTopStringO(value, "qwe"); 4321 ck_assert(equalCharPSmallJsonG("qwe", value)); 4322 // non json string 4323 freeO(value); 4324 setTopIntO(value, 2); 4325 ck_assert(!equalCharPSmallJsonG("2", value)); 4326 // non json object 4327 terminateO(value); 4328 value = (smallJsont*) allocSmallInt(2); 4329 ck_assert(!equalCharPSmallJsonG("2", value)); 4330 terminateO(value); 4331 ck_assert(!equalCharPSmallJsonG("qwe", value)); 4332 4333 } 4334 4335 4336 void equalCharPSmallStringGT(void) { 4337 4338 smallStringt* value = allocSmallString("qwe"); 4339 4340 ck_assert(equalCharPSmallStringG("qwe", value)); 4341 terminateO(value); 4342 ck_assert(!equalCharPSmallStringG("qwe", value)); 4343 4344 } 4345 4346 4347 void equalArrayOGT(void) { 4348 4349 char ** p1 = listCreateS("A", "bb"); 4350 smallArrayt* a = createSA("A", "BB"); 4351 baset* p2 = (baset*)a; 4352 4353 ck_assert(!equalArrayOG(p1, p2)); 4354 iUpperS(&p1[1]); 4355 ck_assert(equalArrayOG(p1, p2)); 4356 // array with deleted elements 4357 a->f->pushS(a, "BB"); 4358 delElemO(a, 1); 4359 ck_assert(!equalArrayOG(p1, p2)); 4360 trimO(a); 4361 // p1 empty 4362 forEachS(p1, e) free(e); 4363 p1[0] = null; 4364 ck_assert(!equalArrayOG(p1, p2)); 4365 // p2 empty 4366 listPushS(&p1, "A"); 4367 listPushS(&p1, "BB"); 4368 emptyO(a); 4369 ck_assert(!equalArrayOG(p1, p2)); 4370 // non smallArray object 4371 terminateO(p2); 4372 p2 = (baset*) allocSmallInt(2); 4373 ck_assert(!equalArrayOG(p1, p2)); 4374 // null parameters 4375 ck_assert(!equalArrayOG(null, p2)); 4376 ck_assert(!equalArrayOG(p1, null)); 4377 terminateO(p2); 4378 listFreeS(p1); 4379 4380 4381 } 4382 4383 4384 void equalCArrayOGT(void) { 4385 4386 const char *p1[] = {"A", "bb", null}; 4387 smallArrayt* a = createSA("A", "BB"); 4388 baset* p2 = (baset*)a; 4389 4390 ck_assert(!equalCArrayOG(p1, p2)); 4391 p1[1] = "BB"; 4392 ck_assert(equalCArrayOG(p1, p2)); 4393 terminateO(p2); 4394 4395 } 4396 4397 4398 void equalArraySmallJsonGT(void) { 4399 4400 char ** p1 = listCreateS("A", "bb"); 4401 smallJsont* p2 = createSJ("A", "BB"); 4402 4403 ck_assert(!equalArraySmallJsonG(p1, p2)); 4404 iUpperS(&p1[1]); 4405 ck_assert(equalArraySmallJsonG(p1, p2)); 4406 // array with deleted elements 4407 p2->f->pushS(p2, "BB"); 4408 delElemIndexO(p2, 1); 4409 ck_assert(!equalArraySmallJsonG(p1, p2)); 4410 trimO(p2); 4411 // p1 empty 4412 forEachS(p1, e) free(e); 4413 p1[0] = null; 4414 ck_assert(!equalArraySmallJsonG(p1, p2)); 4415 // p2 empty 4416 listPushS(&p1, "A"); 4417 listPushS(&p1, "BB"); 4418 emptyO(p2); 4419 ck_assert(!equalArraySmallJsonG(p1, p2)); 4420 // non json array 4421 freeO(p2); 4422 setTopIntO(p2, 2); 4423 ck_assert(!equalArraySmallJsonG(p1, p2)); 4424 // non smallJson object 4425 terminateO(p2); 4426 p2 = (smallJsont*) allocSmallInt(2); 4427 ck_assert(!equalArraySmallJsonG(p1, p2)); 4428 // null parameters 4429 ck_assert(!equalArraySmallJsonG(null, p2)); 4430 ck_assert(!equalArraySmallJsonG(p1, null)); 4431 terminateO(p2); 4432 listFreeS(p1); 4433 4434 } 4435 4436 4437 void equalArraySmallArrayGT(void) { 4438 4439 char ** p1 = listCreateS("A", "bb"); 4440 smallArrayt* p2 = createSA("A", "BB"); 4441 4442 ck_assert(!equalArraySmallArrayG(p1, p2)); 4443 iUpperS(&p1[1]); 4444 ck_assert(equalArraySmallArrayG(p1, p2)); 4445 // array with deleted elements 4446 p2->f->pushS(p2, "BB"); 4447 delElemO(p2, 1); 4448 ck_assert(!equalArraySmallArrayG(p1, p2)); 4449 trimO(p2); 4450 // p1 empty 4451 forEachS(p1, e) free(e); 4452 p1[0] = null; 4453 ck_assert(!equalArraySmallArrayG(p1, p2)); 4454 // p2 empty 4455 listPushS(&p1, "A"); 4456 listPushS(&p1, "BB"); 4457 emptyO(p2); 4458 ck_assert(!equalArraySmallArrayG(p1, p2)); 4459 // non smallArray object 4460 terminateO(p2); 4461 p2 = (smallArrayt*) allocSmallInt(2); 4462 ck_assert(!equalArraySmallArrayG(p1, p2)); 4463 // null parameters 4464 ck_assert(!equalArraySmallArrayG(null, p2)); 4465 ck_assert(!equalArraySmallArrayG(p1, null)); 4466 terminateO(p2); 4467 listFreeS(p1); 4468 4469 } 4470 4471 4472 void equalCArraySmallJsonGT(void) { 4473 4474 const char * p1[] = {"a", null}; 4475 smallJsont* p2 = allocSmallJson(); 4476 4477 ck_assert(!equalCArraySmallJsonG(p1, p2)); 4478 terminateO(p2); 4479 4480 } 4481 4482 4483 void equalCArraySmallArrayGT(void) { 4484 4485 const char * p1[] = {"a", null}; 4486 smallArrayt* p2 = allocSmallArray(); 4487 4488 ck_assert(!equalCArraySmallArrayG(p1, p2)); 4489 terminateO(p2); 4490 4491 } 4492 4493 4494 void equalOCharGT(void) { 4495 4496 baset* p1 = (baset*) allocSmallString("asd"); 4497 const char * p2 = "asd"; 4498 4499 ck_assert(equalOCharG(p1, p2)); 4500 terminateO(p1); 4501 4502 } 4503 4504 4505 void equalOChaGT(void) { 4506 4507 baset* p1 = (baset*) allocSmallString("a"); 4508 4509 ck_assert(equalOChaG(p1, 'a')); 4510 terminateO(p1); 4511 4512 } 4513 4514 4515 void equalOArrayGT(void) { 4516 4517 baset* p1 = (baset*) createSA("A", "BB"); 4518 char ** p2 = listCreateS("A", "BB"); 4519 4520 ck_assert(equalOArrayG(p1, p2)); 4521 terminateO(p1); 4522 listFreeS(p2); 4523 4524 } 4525 4526 4527 void equalOCArrayGT(void) { 4528 4529 baset* p1 = (baset*) createSA("A", "BB"); 4530 const char * p2[] = {"A", "BB", null}; 4531 4532 ck_assert(equalOCArrayG(p1, p2)); 4533 terminateO(p1); 4534 4535 } 4536 4537 4538 void equalOOGT(void) { 4539 4540 baset* p1 = (baset*) allocSmallString("2"); 4541 smallJsont* P2 = allocSmallJson(); 4542 baset* p2 = (baset*)P2; 4543 4544 setTopIntO(P2, 2); 4545 ck_assert(equalOOG(p1, p2)); 4546 freeO(P2); 4547 setTopIntO(P2, 0); 4548 ck_assert(!equalOOG(p1, p2)); 4549 freeO(P2); 4550 setTopIntO(P2, 2); 4551 // null parameters 4552 ck_assert(!equalOOG(null, p2)); 4553 ck_assert(!equalOOG(p1, null)); 4554 terminateO(p1); 4555 terminateO(p2); 4556 4557 } 4558 4559 4560 void equalOBoolGT(void) { 4561 4562 baset* p1 = (baset*)allocSmallString("TRUE"); 4563 4564 ck_assert(equalOBoolG(p1, true)); 4565 terminateO(p1); 4566 4567 } 4568 4569 4570 void equalODoubleGT(void) { 4571 4572 baset* p1 = (baset*) allocSmallDouble(2.2); 4573 4574 ck_assert(equalODoubleG(p1, 2.2)); 4575 terminateO(p1); 4576 4577 } 4578 4579 4580 void equalOInt64GT(void) { 4581 4582 baset* p1 = (baset*) allocSmallString("2"); 4583 4584 ck_assert(equalOInt64G(p1, 2)); 4585 terminateO(p1); 4586 4587 } 4588 4589 4590 void equalOInt32GT(void) { 4591 4592 baset* p1 = (baset*) allocSmallString("2"); 4593 4594 ck_assert(equalOInt32G(p1, 2)); 4595 terminateO(p1); 4596 4597 } 4598 4599 4600 void equalOUint32GT(void) { 4601 4602 baset* p1 = (baset*) allocSmallString("2"); 4603 4604 ck_assert(equalOUint32G(p1, 2)); 4605 terminateO(p1); 4606 4607 } 4608 4609 4610 void equalOUint64GT(void) { 4611 4612 baset* p1 = (baset*) allocSmallString("2"); 4613 4614 ck_assert(equalOUint64G(p1, 2)); 4615 terminateO(p1); 4616 4617 } 4618 4619 4620 void equalOSmallArrayGT(void) { 4621 4622 baset* p1 = (baset*) createSA("A"); 4623 smallArrayt* p2 = createSA("A"); 4624 4625 ck_assert(equalOSmallArrayG(p1, p2)); 4626 terminateO(p2); 4627 // non smallArray object 4628 p2 = (smallArrayt*) allocSmallInt(2); 4629 ck_assert(!equalOSmallArrayG(p1, p2)); 4630 // null p2 4631 terminateO(p2); 4632 ck_assert(!equalOSmallArrayG(p1, p2)); 4633 terminateO(p1); 4634 4635 } 4636 4637 4638 void equalOSmallBoolGT(void) { 4639 4640 baset* p1 = (baset*) allocSmallBool(true); 4641 smallBoolt* p2 = allocSmallBool(true); 4642 4643 ck_assert(equalOSmallBoolG(p1, p2)); 4644 // non smallBool p2 4645 terminateO(p2); 4646 p2 = (smallBoolt*) allocSmallInt(2); 4647 ck_assert(!equalOSmallBoolG(p1, p2)); 4648 // null p2 4649 ck_assert(!equalOSmallBoolG(p1, null)); 4650 terminateO(p1); 4651 terminateO(p2); 4652 4653 } 4654 4655 4656 void equalOSmallBytesGT(void) { 4657 4658 baset* p1 = (baset*) allocSmallString("qwe"); 4659 smallBytest* p2 = allocSmallBytes("qwe", sizeof("qwe")); 4660 4661 ck_assert(equalOSmallBytesG(p1, p2)); 4662 // non smallBytes p2 4663 terminateO(p2); 4664 p2 = (smallBytest*) allocSmallInt(2); 4665 ck_assert(!equalOSmallBytesG(p1, p2)); 4666 // null p2 4667 ck_assert(!equalOSmallBytesG(p1, null)); 4668 terminateO(p1); 4669 terminateO(p2); 4670 4671 } 4672 4673 4674 void equalOSmallDoubleGT(void) { 4675 4676 baset* p1 = (baset*) allocSmallDouble(2.2); 4677 smallDoublet* p2 = allocSmallDouble(2.2); 4678 4679 ck_assert(equalOSmallDoubleG(p1, p2)); 4680 // non smallDouble p2 4681 terminateO(p2); 4682 p2 = (smallDoublet*) allocSmallInt(2); 4683 ck_assert(!equalOSmallDoubleG(p1, p2)); 4684 // null p2 4685 ck_assert(!equalOSmallDoubleG(p1, null)); 4686 terminateO(p1); 4687 terminateO(p2); 4688 4689 } 4690 4691 4692 void equalOSmallDictGT(void) { 4693 4694 smallDictt* P1 = allocSmallDict(); 4695 baset* p1 = (baset*) P1; 4696 smallDictt* p2 = allocSmallDict(); 4697 4698 P1->f->setS(P1, "qwe", "qwe"); 4699 p2->f->setS(p2, "qwe", "qwe"); 4700 ck_assert(equalOSmallDictG(p1, p2)); 4701 // non smallDict p2 4702 terminateO(p2); 4703 p2 = (smallDictt*) allocSmallInt(2); 4704 ck_assert(!equalOSmallDictG(p1, p2)); 4705 // null p2 4706 ck_assert(!equalOSmallDictG(p1, null)); 4707 terminateO(p1); 4708 terminateO(p2); 4709 4710 } 4711 4712 4713 void equalOSmallIntGT(void) { 4714 4715 baset* p1 = (baset*) allocSmallInt(2); 4716 smallIntt* p2 = allocSmallInt(2); 4717 4718 ck_assert(equalOSmallIntG(p1, p2)); 4719 // non smallInt p2 4720 terminateO(p2); 4721 p2 = (smallIntt*) allocSmallBool(true); 4722 ck_assert(!equalOSmallIntG(p1, p2)); 4723 // null p2 4724 ck_assert(!equalOSmallIntG(p1, null)); 4725 terminateO(p1); 4726 terminateO(p2); 4727 4728 } 4729 4730 4731 void equalOSmallJsonGT(void) { 4732 4733 baset* p1 = (baset*) allocSmallInt(2); 4734 smallJsont* p2 = allocSmallJson(); 4735 4736 setTopIntO(p2, 2); 4737 ck_assert(equalOSmallJsonG(p1, p2)); 4738 // non smallJson p2 4739 terminateO(p2); 4740 p2 = (smallJsont*) allocSmallInt(2); 4741 ck_assert(!equalOSmallJsonG(p1, p2)); 4742 // null p2 4743 ck_assert(!equalOSmallJsonG(p1, null)); 4744 terminateO(p1); 4745 terminateO(p2); 4746 4747 } 4748 4749 4750 void equalOSmallStringGT(void) { 4751 4752 baset* p1 = (baset*) allocSmallString("qwe"); 4753 smallStringt* p2 = allocSmallString("qwe"); 4754 4755 ck_assert(equalOSmallStringG(p1, p2)); 4756 // non smallString p2 4757 terminateO(p2); 4758 p2 = (smallStringt*) allocSmallInt(2); 4759 ck_assert(!equalOSmallStringG(p1, p2)); 4760 // null p2 4761 ck_assert(!equalOSmallStringG(p1, null)); 4762 terminateO(p1); 4763 terminateO(p2); 4764 4765 } 4766 4767 4768 void equalBoolChaGT(void) { 4769 4770 ck_assert(!equalBoolChaG(false, '0')); 4771 4772 } 4773 4774 4775 void equalBoolCharGT(void) { 4776 4777 bool p1 = true; 4778 const char * p2 = "TRUE"; 4779 4780 ck_assert(equalBoolCharG(p1, p2)); 4781 p1 = false; 4782 p2 = "false"; 4783 ck_assert(equalBoolCharG(p1, p2)); 4784 // p2 is anything 4785 p2 = "qwe"; 4786 ck_assert(!equalBoolCharG(p1, p2)); 4787 // null p2 4788 ck_assert(!equalBoolCharG(p1, null)); 4789 4790 } 4791 4792 4793 void equalBoolOGT(void) { 4794 4795 bool p1 = true; 4796 smallBoolt* P2 = allocSmallBool(true); 4797 baset* p2 = (baset*) P2; 4798 4799 ck_assert(equalBoolOG(p1, p2)); 4800 p1 = false; 4801 setValO(P2, false); 4802 ck_assert(equalBoolOG(p1, p2)); 4803 // p2 is anything 4804 terminateO(p2); 4805 p2 = (baset*) allocSmallString("qwe"); 4806 ck_assert(!equalBoolOG(p1, p2)); 4807 // null p2 4808 ck_assert(!equalBoolOG(p1, null)); 4809 terminateO(p2); 4810 4811 } 4812 4813 4814 void equalBoolFGT(void) { 4815 4816 bool p1 = true; 4817 bool p2 = true; 4818 4819 ck_assert(equalBoolFG(p1, p2)); 4820 4821 } 4822 4823 4824 void equalBoolDoubleGT(void) { 4825 4826 bool p1 = true; 4827 double p2 = 1; 4828 4829 ck_assert(equalBoolDoubleG(p1, p2)); 4830 4831 } 4832 4833 4834 void equalBoolInt64GT(void) { 4835 4836 bool p1 = true; 4837 int64_t p2 = 1; 4838 4839 ck_assert(equalBoolInt64G(p1, p2)); 4840 4841 } 4842 4843 4844 void equalBoolInt32GT(void) { 4845 4846 bool p1 = true; 4847 int32_t p2 = 1; 4848 4849 ck_assert(equalBoolInt32G(p1, p2)); 4850 4851 } 4852 4853 4854 void equalBoolUint32GT(void) { 4855 4856 bool p1 = true; 4857 uint32_t p2 = 1; 4858 4859 ck_assert(equalBoolUint32G(p1, p2)); 4860 4861 } 4862 4863 4864 void equalBoolUint64GT(void) { 4865 4866 bool p1 = true; 4867 uint64_t p2 = 1; 4868 4869 ck_assert(equalBoolUint64G(p1, p2)); 4870 4871 } 4872 4873 4874 void equalBoolSmallBoolGT(void) { 4875 4876 bool p1 = true; 4877 smallBoolt* p2 = allocSmallBool(true); 4878 4879 ck_assert(equalBoolSmallBoolG(p1, p2)); 4880 // empty smallBool 4881 freeO(p2); 4882 ck_assert(!equalBoolSmallBoolG(p1, p2)); 4883 // null p2 4884 ck_assert(!equalBoolSmallBoolG(p1, null)); 4885 terminateO(p2); 4886 4887 } 4888 4889 4890 void equalBoolSmallBytesGT(void) { 4891 4892 bool p1 = true; 4893 smallBytest* p2 = allocSmallBytes("TRUE", sizeof("true")); 4894 4895 ck_assert(equalBoolSmallBytesG(p1, p2)); 4896 p1 = false; 4897 terminateO(p2); 4898 p2 = allocSmallBytes("false", sizeof("false")); 4899 ck_assert(equalBoolSmallBytesG(p1, p2)); 4900 // p2 is anything 4901 terminateO(p2); 4902 p2 = allocSmallBytes("qwe", strlen("qwe")); 4903 ck_assert(!equalBoolSmallBytesG(p1, p2)); 4904 // null p2 4905 ck_assert(!equalBoolSmallBytesG(p1, null)); 4906 terminateO(p2); 4907 4908 } 4909 4910 4911 void equalBoolSmallDoubleGT(void) { 4912 4913 bool p1 = true; 4914 smallDoublet* p2 = allocSmallDouble(1); 4915 4916 ck_assert(equalBoolSmallDoubleG(p1, p2)); 4917 // empty object 4918 freeO(p2); 4919 ck_assert(!equalBoolSmallDoubleG(p1, p2)); 4920 terminateO(p2); 4921 // null object 4922 ck_assert(!equalBoolSmallDoubleG(p1, p2)); 4923 4924 } 4925 4926 4927 void equalBoolSmallIntGT(void) { 4928 4929 bool p1 = true; 4930 smallIntt* p2 = allocSmallInt(1); 4931 4932 ck_assert(equalBoolSmallIntG(p1, p2)); 4933 // empty object 4934 freeO(p2); 4935 ck_assert(!equalBoolSmallIntG(p1, p2)); 4936 terminateO(p2); 4937 // null object 4938 ck_assert(!equalBoolSmallIntG(p1, p2)); 4939 4940 } 4941 4942 4943 void equalBoolSmallJsonGT(void) { 4944 4945 bool p1 = true; 4946 smallJsont* p2 = allocSmallJson(); 4947 4948 setTopBoolO(p2, true); 4949 ck_assert(equalBoolSmallJsonG(p1, p2)); 4950 // empty object 4951 freeO(p2); 4952 ck_assert(!equalBoolSmallJsonG(p1, p2)); 4953 terminateO(p2); 4954 // non json object 4955 p2 = (smallJsont*) allocSmallInt(2); 4956 ck_assert(!equalBoolSmallJsonG(p1, p2)); 4957 terminateO(p2); 4958 // null object 4959 ck_assert(!equalBoolSmallJsonG(p1, p2)); 4960 4961 } 4962 4963 4964 void equalBoolSmallStringGT(void) { 4965 4966 bool p1 = true; 4967 smallStringt* p2 = allocSmallString("true"); 4968 4969 ck_assert(equalBoolSmallStringG(p1, p2)); 4970 p1 = false; 4971 setValO(p2, "false"); 4972 ck_assert(equalBoolSmallStringG(p1, p2)); 4973 // p2 is anything 4974 setValO(p2, "qwe"); 4975 ck_assert(!equalBoolSmallStringG(p1, p2)); 4976 // empty object 4977 freeO(p2); 4978 ck_assert(!equalBoolSmallStringG(p1, p2)); 4979 terminateO(p2); 4980 // null object 4981 ck_assert(!equalBoolSmallStringG(p1, p2)); 4982 4983 } 4984 4985 4986 void equalDoubleChaGT(void) { 4987 4988 ck_assert(!equalDoubleChaG(1, '1')); 4989 4990 } 4991 4992 4993 void equalDoubleCharGT(void) { 4994 4995 double p1 = 2.2; 4996 const char * p2 = "2.2"; 4997 4998 ck_assert(equalDoubleCharG(p1, p2)); 4999 p1 = 2; 5000 p2 = "2.2"; 5001 ck_assert(!equalDoubleCharG(p1, p2)); 5002 // p2 is not double 5003 p2 = "2"; 5004 ck_assert(!equalDoubleCharG(p1, p2)); 5005 // null p2 5006 ck_assert(!equalDoubleCharG(p1, null)); 5007 5008 } 5009 5010 5011 void equalDoubleBaseGT(void) { 5012 5013 double p1 = 2.2; 5014 smallStringt* P2 = allocSmallString("2.2"); 5015 baset* p2 = (baset*) P2; 5016 5017 ck_assert(equalDoubleBaseG(p1, p2)); 5018 p1 = 2; 5019 setValO(P2, "2.2"); 5020 ck_assert(!equalDoubleBaseG(p1, p2)); 5021 // p2 is not double 5022 setValO(P2, "2"); 5023 ck_assert(!equalDoubleBaseG(p1, p2)); 5024 // null p2 5025 ck_assert(!equalDoubleBaseG(p1, null)); 5026 terminateO(p2); 5027 5028 } 5029 5030 5031 void equalDoubleBoolGT(void) { 5032 5033 ck_assert(equalDoubleBoolG(1,true)); 5034 5035 } 5036 5037 5038 void equalDoubleFGT(void) { 5039 5040 ck_assert(equalDoubleFG(2,2)); 5041 5042 } 5043 5044 5045 void equalDoubleInt64GT(void) { 5046 5047 ck_assert(equalDoubleInt64G(2,2)); 5048 5049 } 5050 5051 5052 void equalDoubleInt32GT(void) { 5053 5054 ck_assert(equalDoubleInt32G(2,2)); 5055 5056 } 5057 5058 5059 void equalDoubleUint32GT(void) { 5060 5061 ck_assert(equalDoubleUint32G(2,2)); 5062 5063 } 5064 5065 5066 void equalDoubleUint64GT(void) { 5067 5068 ck_assert(equalDoubleUint64G(2,2)); 5069 5070 } 5071 5072 5073 void equalDoubleSmallBoolGT(void) { 5074 5075 double p1 = 1; 5076 smallBoolt* p2 = allocSmallBool(true); 5077 5078 ck_assert(equalDoubleSmallBoolG(p1, p2)); 5079 // empty smallBool 5080 freeO(p2); 5081 ck_assert(!equalDoubleSmallBoolG(p1, p2)); 5082 // null p2 5083 ck_assert(!equalDoubleSmallBoolG(p1, null)); 5084 terminateO(p2); 5085 5086 } 5087 5088 5089 void equalDoubleSmallBytesGT(void) { 5090 5091 double p1 = 2.2; 5092 smallBytest* p2 = allocSmallBytes("2.2", sizeof("2.2")); 5093 5094 ck_assert(equalDoubleSmallBytesG(p1, p2)); 5095 // p2 not double 5096 p1 = 2; 5097 terminateO(p2); 5098 p2 = allocSmallBytes("2", sizeof("2")); 5099 ck_assert(!equalDoubleSmallBytesG(p1, p2)); 5100 // p2 is anything 5101 terminateO(p2); 5102 p2 = allocSmallBytes("qwe", strlen("qwe")); 5103 ck_assert(!equalDoubleSmallBytesG(p1, p2)); 5104 // empty p2 5105 freeO(p2); 5106 ck_assert(!equalDoubleSmallBytesG(p1, p2)); 5107 // null p2 5108 ck_assert(!equalDoubleSmallBytesG(p1, null)); 5109 terminateO(p2); 5110 5111 } 5112 5113 5114 void equalDoubleSmallDoubleGT(void) { 5115 5116 double p1 = 2.2; 5117 smallDoublet* p2 = allocSmallDouble(2.2); 5118 5119 ck_assert(equalDoubleSmallDoubleG(p1, p2)); 5120 // empty object 5121 freeO(p2); 5122 ck_assert(!equalDoubleSmallDoubleG(p1, p2)); 5123 terminateO(p2); 5124 // null object 5125 ck_assert(!equalDoubleSmallDoubleG(p1, p2)); 5126 5127 } 5128 5129 5130 void equalDoubleSmallIntGT(void) { 5131 5132 double p1 = 2; 5133 smallIntt* p2 = allocSmallInt(2); 5134 5135 ck_assert(equalDoubleSmallIntG(p1, p2)); 5136 // empty object 5137 freeO(p2); 5138 ck_assert(!equalDoubleSmallIntG(p1, p2)); 5139 terminateO(p2); 5140 // null object 5141 ck_assert(!equalDoubleSmallIntG(p1, p2)); 5142 5143 } 5144 5145 5146 void equalDoubleSmallJsonGT(void) { 5147 5148 double p1 = 2.2; 5149 smallJsont* p2 = allocSmallJson(); 5150 5151 setTopDoubleO(p2, 2.2); 5152 ck_assert(equalDoubleSmallJsonG(p1, p2)); 5153 // empty object 5154 freeO(p2); 5155 ck_assert(!equalDoubleSmallJsonG(p1, p2)); 5156 terminateO(p2); 5157 // non json object 5158 p2 = (smallJsont*) allocSmallInt(2); 5159 ck_assert(!equalDoubleSmallJsonG(p1, p2)); 5160 terminateO(p2); 5161 // null object 5162 ck_assert(!equalDoubleSmallJsonG(p1, p2)); 5163 5164 } 5165 5166 5167 void equalDoubleSmallStringGT(void) { 5168 5169 double p1 = 2.2; 5170 smallStringt* p2 = allocSmallString("2.2"); 5171 5172 ck_assert(equalDoubleSmallStringG(p1, p2)); 5173 // p2 is anything 5174 setValO(p2, "qwe"); 5175 ck_assert(!equalDoubleSmallStringG(p1, p2)); 5176 // empty object 5177 freeO(p2); 5178 ck_assert(!equalDoubleSmallStringG(p1, p2)); 5179 terminateO(p2); 5180 // null object 5181 ck_assert(!equalDoubleSmallStringG(p1, p2)); 5182 5183 } 5184 5185 5186 void equalInt64ChaGT(void) { 5187 5188 ck_assert(equalInt64ChaG(2,'2')); 5189 5190 } 5191 5192 5193 void equalInt64CharGT(void) { 5194 5195 ck_assert(equalInt64CharG(2, "2")); 5196 ck_assert(!equalInt64CharG(2, "qwe")); 5197 ck_assert(!equalInt64CharG(2, null)); 5198 5199 } 5200 5201 5202 void equalInt64BaseGT(void) { 5203 5204 smallStringt* P2 = allocSmallString("2"); 5205 baset* p2 = (baset*) P2; 5206 5207 ck_assert(equalInt64BaseG(2, p2)); 5208 ck_assert(!equalInt64BaseG(1, p2)); 5209 setValO(P2, "qwe"); 5210 ck_assert(!equalInt64BaseG(2, p2)); 5211 ck_assert(!equalInt64BaseG(2, null)); 5212 terminateO(p2); 5213 5214 } 5215 5216 5217 void equalInt64BoolGT(void) { 5218 5219 ck_assert(equalInt64BoolG(1, true)); 5220 5221 } 5222 5223 5224 void equalInt64DoubleGT(void) { 5225 5226 ck_assert(equalInt64DoubleG(2, 2)); 5227 5228 } 5229 5230 5231 void equalInt64FGT(void) { 5232 5233 ck_assert(equalInt64FG(2,2)); 5234 5235 } 5236 5237 5238 void equalInt64Int32GT(void) { 5239 5240 ck_assert(equalInt64Int32G(2,2)); 5241 5242 } 5243 5244 5245 void equalInt64Uint32GT(void) { 5246 5247 ck_assert(equalInt64Uint32G(2,2)); 5248 5249 } 5250 5251 5252 void equalInt64Uint64GT(void) { 5253 5254 ck_assert(equalInt64Uint64G(2,2)); 5255 5256 } 5257 5258 5259 void equalInt64SmallBoolGT(void) { 5260 5261 int64_t p1 = 1; 5262 smallBoolt* p2 = allocSmallBool(true); 5263 5264 ck_assert(equalInt64SmallBoolG(p1, p2)); 5265 // empty smallBool 5266 freeO(p2); 5267 ck_assert(!equalInt64SmallBoolG(p1, p2)); 5268 // null p2 5269 ck_assert(!equalInt64SmallBoolG(p1, null)); 5270 terminateO(p2); 5271 5272 } 5273 5274 5275 void equalInt64SmallBytesGT(void) { 5276 5277 int64_t p1 = 2; 5278 smallBytest* p2 = allocSmallBytes("2", sizeof("2")); 5279 5280 ck_assert(equalInt64SmallBytesG(p1, p2)); 5281 // p2 not int 5282 terminateO(p2); 5283 p2 = allocSmallBytes("qwe", sizeof("qwe")); 5284 ck_assert(!equalInt64SmallBytesG(p1, p2)); 5285 // p2 is anything without 0 ending 5286 terminateO(p2); 5287 p2 = allocSmallBytes("qwe", strlen("qwe")); 5288 ck_assert(!equalInt64SmallBytesG(p1, p2)); 5289 // empty p2 5290 freeO(p2); 5291 ck_assert(!equalInt64SmallBytesG(p1, p2)); 5292 // null p2 5293 ck_assert(!equalInt64SmallBytesG(p1, null)); 5294 terminateO(p2); 5295 5296 } 5297 5298 5299 void equalInt64SmallDoubleGT(void) { 5300 5301 int64_t p1 = 2; 5302 smallDoublet* p2 = allocSmallDouble(2); 5303 5304 ck_assert(equalInt64SmallDoubleG(p1, p2)); 5305 // empty object 5306 freeO(p2); 5307 ck_assert(!equalInt64SmallDoubleG(p1, p2)); 5308 terminateO(p2); 5309 // null object 5310 ck_assert(!equalInt64SmallDoubleG(p1, p2)); 5311 5312 } 5313 5314 5315 void equalInt64SmallIntGT(void) { 5316 5317 int64_t p1 = 2; 5318 smallIntt* p2 = allocSmallInt(2); 5319 5320 ck_assert(equalInt64SmallIntG(p1, p2)); 5321 // empty object 5322 freeO(p2); 5323 ck_assert(!equalInt64SmallIntG(p1, p2)); 5324 terminateO(p2); 5325 // null object 5326 ck_assert(!equalInt64SmallIntG(p1, p2)); 5327 5328 } 5329 5330 5331 void equalInt64SmallJsonGT(void) { 5332 5333 int64_t p1 = 2; 5334 smallJsont* p2 = allocSmallJson(); 5335 5336 setTopIntO(p2, 2); 5337 ck_assert(equalInt64SmallJsonG(p1, p2)); 5338 // empty object 5339 freeO(p2); 5340 ck_assert(!equalInt64SmallJsonG(p1, p2)); 5341 terminateO(p2); 5342 // non json object 5343 p2 = (smallJsont*) allocSmallInt(2); 5344 ck_assert(!equalInt64SmallJsonG(p1, p2)); 5345 terminateO(p2); 5346 // null object 5347 ck_assert(!equalInt64SmallJsonG(p1, p2)); 5348 5349 } 5350 5351 5352 void equalInt64SmallStringGT(void) { 5353 5354 int64_t p1 = 2; 5355 smallStringt* p2 = allocSmallString("2"); 5356 5357 ck_assert(equalInt64SmallStringG(p1, p2)); 5358 // p2 is anything 5359 setValO(p2, "qwe"); 5360 ck_assert(!equalInt64SmallStringG(p1, p2)); 5361 // empty object 5362 freeO(p2); 5363 ck_assert(!equalInt64SmallStringG(p1, p2)); 5364 terminateO(p2); 5365 // null object 5366 ck_assert(!equalInt64SmallStringG(p1, p2)); 5367 5368 } 5369 5370 5371 void equalInt32ChaGT(void) { 5372 5373 ck_assert(equalInt32ChaG(2,'2')); 5374 5375 } 5376 5377 5378 void equalInt32CharGT(void) { 5379 5380 ck_assert(equalInt32CharG(2, "2")); 5381 ck_assert(!equalInt32CharG(2, "qwe")); 5382 ck_assert(!equalInt32CharG(2, null)); 5383 5384 } 5385 5386 5387 void equalInt32BaseGT(void) { 5388 5389 smallStringt* P2 = allocSmallString("2"); 5390 baset* p2 = (baset*) P2; 5391 5392 ck_assert(equalInt32BaseG(2, p2)); 5393 ck_assert(!equalInt32BaseG(1, p2)); 5394 setValO(P2, "qwe"); 5395 ck_assert(!equalInt32BaseG(2, p2)); 5396 ck_assert(!equalInt32BaseG(2, null)); 5397 terminateO(p2); 5398 5399 } 5400 5401 5402 void equalInt32BoolGT(void) { 5403 5404 ck_assert(equalInt32BoolG(1, true)); 5405 5406 } 5407 5408 5409 void equalInt32DoubleGT(void) { 5410 5411 ck_assert(equalInt32DoubleG(2, 2)); 5412 5413 } 5414 5415 5416 void equalInt32Int64GT(void) { 5417 5418 ck_assert(equalInt32Int64G(2,2)); 5419 5420 } 5421 5422 5423 void equalInt32FGT(void) { 5424 5425 ck_assert(equalInt32FG(2,2)); 5426 5427 } 5428 5429 5430 void equalInt32Uint32GT(void) { 5431 5432 ck_assert(equalInt32Uint32G(2,2)); 5433 5434 } 5435 5436 5437 void equalInt32Uint64GT(void) { 5438 5439 ck_assert(equalInt32Uint64G(2,2)); 5440 5441 } 5442 5443 5444 void equalInt32SmallBoolGT(void) { 5445 5446 int32_t p1 = 1; 5447 smallBoolt* p2 = allocSmallBool(true); 5448 5449 ck_assert(equalInt32SmallBoolG(p1, p2)); 5450 // empty smallBool 5451 freeO(p2); 5452 ck_assert(!equalInt32SmallBoolG(p1, p2)); 5453 // null p2 5454 ck_assert(!equalInt32SmallBoolG(p1, null)); 5455 terminateO(p2); 5456 5457 } 5458 5459 5460 void equalInt32SmallBytesGT(void) { 5461 5462 int32_t p1 = 2; 5463 smallBytest* p2 = allocSmallBytes("2", sizeof("2")); 5464 5465 ck_assert(equalInt32SmallBytesG(p1, p2)); 5466 // p2 not int 5467 terminateO(p2); 5468 p2 = allocSmallBytes("qwe", sizeof("qwe")); 5469 ck_assert(!equalInt32SmallBytesG(p1, p2)); 5470 // p2 is anything without 0 ending 5471 terminateO(p2); 5472 p2 = allocSmallBytes("qwe", strlen("qwe")); 5473 ck_assert(!equalInt32SmallBytesG(p1, p2)); 5474 // empty p2 5475 freeO(p2); 5476 ck_assert(!equalInt32SmallBytesG(p1, p2)); 5477 // null p2 5478 ck_assert(!equalInt32SmallBytesG(p1, null)); 5479 terminateO(p2); 5480 5481 } 5482 5483 5484 void equalInt32SmallDoubleGT(void) { 5485 5486 int32_t p1 = 2; 5487 smallDoublet* p2 = allocSmallDouble(2); 5488 5489 ck_assert(equalInt32SmallDoubleG(p1, p2)); 5490 // empty object 5491 freeO(p2); 5492 ck_assert(!equalInt32SmallDoubleG(p1, p2)); 5493 terminateO(p2); 5494 // null object 5495 ck_assert(!equalInt32SmallDoubleG(p1, p2)); 5496 5497 } 5498 5499 5500 void equalInt32SmallIntGT(void) { 5501 5502 int32_t p1 = 2; 5503 smallIntt* p2 = allocSmallInt(2); 5504 5505 ck_assert(equalInt32SmallIntG(p1, p2)); 5506 // empty object 5507 freeO(p2); 5508 ck_assert(!equalInt32SmallIntG(p1, p2)); 5509 terminateO(p2); 5510 // null object 5511 ck_assert(!equalInt32SmallIntG(p1, p2)); 5512 5513 } 5514 5515 5516 void equalInt32SmallJsonGT(void) { 5517 5518 int32_t p1 = 2; 5519 smallJsont* p2 = allocSmallJson(); 5520 5521 setTopIntO(p2, 2); 5522 ck_assert(equalInt32SmallJsonG(p1, p2)); 5523 // empty object 5524 freeO(p2); 5525 ck_assert(!equalInt32SmallJsonG(p1, p2)); 5526 terminateO(p2); 5527 // non json object 5528 p2 = (smallJsont*) allocSmallInt(2); 5529 ck_assert(!equalInt32SmallJsonG(p1, p2)); 5530 terminateO(p2); 5531 // null object 5532 ck_assert(!equalInt32SmallJsonG(p1, p2)); 5533 5534 } 5535 5536 5537 void equalInt32SmallStringGT(void) { 5538 5539 int32_t p1 = 2; 5540 smallStringt* p2 = allocSmallString("2"); 5541 5542 ck_assert(equalInt32SmallStringG(p1, p2)); 5543 // p2 is anything 5544 setValO(p2, "qwe"); 5545 ck_assert(!equalInt32SmallStringG(p1, p2)); 5546 // empty object 5547 freeO(p2); 5548 ck_assert(!equalInt32SmallStringG(p1, p2)); 5549 terminateO(p2); 5550 // null object 5551 ck_assert(!equalInt32SmallStringG(p1, p2)); 5552 5553 } 5554 5555 5556 void equalUint32ChaGT(void) { 5557 5558 ck_assert(equalUint32ChaG(2,'2')); 5559 5560 } 5561 5562 5563 void equalUint32CharGT(void) { 5564 5565 ck_assert(equalUint32CharG(2, "2")); 5566 ck_assert(!equalUint32CharG(2, "qwe")); 5567 ck_assert(!equalUint32CharG(2, null)); 5568 5569 } 5570 5571 5572 void equalUint32BaseGT(void) { 5573 5574 smallStringt* P2 = allocSmallString("2"); 5575 baset* p2 = (baset*) P2; 5576 5577 ck_assert(equalUint32BaseG(2, p2)); 5578 ck_assert(!equalUint32BaseG(1, p2)); 5579 setValO(P2, "qwe"); 5580 ck_assert(!equalUint32BaseG(2, p2)); 5581 ck_assert(!equalUint32BaseG(2, null)); 5582 terminateO(p2); 5583 5584 } 5585 5586 5587 void equalUint32BoolGT(void) { 5588 5589 ck_assert(equalUint32BoolG(1, true)); 5590 5591 } 5592 5593 5594 void equalUint32DoubleGT(void) { 5595 5596 ck_assert(equalUint32DoubleG(2, 2)); 5597 5598 } 5599 5600 5601 void equalUint32Int64GT(void) { 5602 5603 ck_assert(equalUint32Int64G(2,2)); 5604 5605 } 5606 5607 5608 void equalUint32Int32GT(void) { 5609 5610 ck_assert(equalUint32Int32G(2,2)); 5611 5612 } 5613 5614 5615 void equalUint32FGT(void) { 5616 5617 ck_assert(equalUint32FG(2,2)); 5618 5619 } 5620 5621 5622 void equalUint32Uint64GT(void) { 5623 5624 ck_assert(equalUint32Uint64G(2,2)); 5625 5626 } 5627 5628 5629 void equalUint32SmallBoolGT(void) { 5630 5631 uint32_t p1 = 1; 5632 smallBoolt* p2 = allocSmallBool(true); 5633 5634 ck_assert(equalUint32SmallBoolG(p1, p2)); 5635 // empty smallBool 5636 freeO(p2); 5637 ck_assert(!equalUint32SmallBoolG(p1, p2)); 5638 // null p2 5639 ck_assert(!equalUint32SmallBoolG(p1, null)); 5640 terminateO(p2); 5641 5642 } 5643 5644 5645 void equalUint32SmallBytesGT(void) { 5646 5647 uint32_t p1 = 2; 5648 smallBytest* p2 = allocSmallBytes("2", sizeof("2")); 5649 5650 ck_assert(equalUint32SmallBytesG(p1, p2)); 5651 // p2 not int 5652 terminateO(p2); 5653 p2 = allocSmallBytes("qwe", sizeof("qwe")); 5654 ck_assert(!equalUint32SmallBytesG(p1, p2)); 5655 // p2 is anything without 0 ending 5656 terminateO(p2); 5657 p2 = allocSmallBytes("qwe", strlen("qwe")); 5658 ck_assert(!equalUint32SmallBytesG(p1, p2)); 5659 // empty p2 5660 freeO(p2); 5661 ck_assert(!equalUint32SmallBytesG(p1, p2)); 5662 // null p2 5663 ck_assert(!equalUint32SmallBytesG(p1, null)); 5664 terminateO(p2); 5665 5666 } 5667 5668 5669 void equalUint32SmallDoubleGT(void) { 5670 5671 uint32_t p1 = 2; 5672 smallDoublet* p2 = allocSmallDouble(2); 5673 5674 ck_assert(equalUint32SmallDoubleG(p1, p2)); 5675 // empty object 5676 freeO(p2); 5677 ck_assert(!equalUint32SmallDoubleG(p1, p2)); 5678 terminateO(p2); 5679 // null object 5680 ck_assert(!equalUint32SmallDoubleG(p1, p2)); 5681 5682 } 5683 5684 5685 void equalUint32SmallIntGT(void) { 5686 5687 uint32_t p1 = 2; 5688 smallIntt* p2 = allocSmallInt(2); 5689 5690 ck_assert(equalUint32SmallIntG(p1, p2)); 5691 // empty object 5692 freeO(p2); 5693 ck_assert(!equalUint32SmallIntG(p1, p2)); 5694 terminateO(p2); 5695 // null object 5696 ck_assert(!equalUint32SmallIntG(p1, p2)); 5697 5698 } 5699 5700 5701 void equalUint32SmallJsonGT(void) { 5702 5703 uint32_t p1 = 2; 5704 smallJsont* p2 = allocSmallJson(); 5705 5706 setTopIntO(p2, 2); 5707 ck_assert(equalUint32SmallJsonG(p1, p2)); 5708 // empty object 5709 freeO(p2); 5710 ck_assert(!equalUint32SmallJsonG(p1, p2)); 5711 terminateO(p2); 5712 // non json object 5713 p2 = (smallJsont*) allocSmallInt(2); 5714 ck_assert(!equalUint32SmallJsonG(p1, p2)); 5715 terminateO(p2); 5716 // null object 5717 ck_assert(!equalUint32SmallJsonG(p1, p2)); 5718 5719 } 5720 5721 5722 void equalUint32SmallStringGT(void) { 5723 5724 uint32_t p1 = 2; 5725 smallStringt* p2 = allocSmallString("2"); 5726 5727 ck_assert(equalUint32SmallStringG(p1, p2)); 5728 // p2 is anything 5729 setValO(p2, "qwe"); 5730 ck_assert(!equalUint32SmallStringG(p1, p2)); 5731 // empty object 5732 freeO(p2); 5733 ck_assert(!equalUint32SmallStringG(p1, p2)); 5734 terminateO(p2); 5735 // null object 5736 ck_assert(!equalUint32SmallStringG(p1, p2)); 5737 5738 } 5739 5740 5741 void equalUint64ChaGT(void) { 5742 5743 ck_assert(equalUint64ChaG(2,'2')); 5744 5745 } 5746 5747 5748 void equalUint64CharGT(void) { 5749 5750 ck_assert(equalUint64CharG(2, "2")); 5751 ck_assert(!equalUint64CharG(2, "qwe")); 5752 ck_assert(!equalUint64CharG(2, null)); 5753 5754 } 5755 5756 5757 void equalUint64BaseGT(void) { 5758 5759 smallStringt* P2 = allocSmallString("2"); 5760 baset* p2 = (baset*) P2; 5761 5762 ck_assert(equalUint64BaseG(2, p2)); 5763 ck_assert(!equalUint64BaseG(1, p2)); 5764 setValO(P2, "qwe"); 5765 ck_assert(!equalUint64BaseG(2, p2)); 5766 ck_assert(!equalUint64BaseG(2, null)); 5767 terminateO(p2); 5768 5769 } 5770 5771 5772 void equalUint64BoolGT(void) { 5773 5774 ck_assert(equalUint64BoolG(1, true)); 5775 5776 } 5777 5778 5779 void equalUint64DoubleGT(void) { 5780 5781 ck_assert(equalUint64DoubleG(2, 2)); 5782 5783 } 5784 5785 5786 void equalUint64Int64GT(void) { 5787 5788 ck_assert(equalUint64Int64G(2,2)); 5789 5790 } 5791 5792 5793 void equalUint64Int32GT(void) { 5794 5795 ck_assert(equalUint64Int32G(2,2)); 5796 5797 } 5798 5799 5800 void equalUint64Uint32GT(void) { 5801 5802 ck_assert(equalUint64Uint32G(2,2)); 5803 5804 } 5805 5806 5807 void equalUint64FGT(void) { 5808 5809 ck_assert(equalUint64FG(2,2)); 5810 5811 } 5812 5813 5814 void equalUint64SmallBoolGT(void) { 5815 5816 uint64_t p1 = 1; 5817 smallBoolt* p2 = allocSmallBool(true); 5818 5819 ck_assert(equalUint64SmallBoolG(p1, p2)); 5820 // empty smallBool 5821 freeO(p2); 5822 ck_assert(!equalUint64SmallBoolG(p1, p2)); 5823 // null p2 5824 ck_assert(!equalUint64SmallBoolG(p1, null)); 5825 terminateO(p2); 5826 5827 } 5828 5829 5830 void equalUint64SmallBytesGT(void) { 5831 5832 uint64_t p1 = 2; 5833 smallBytest* p2 = allocSmallBytes("2", sizeof("2")); 5834 5835 ck_assert(equalUint64SmallBytesG(p1, p2)); 5836 // p2 not int 5837 terminateO(p2); 5838 p2 = allocSmallBytes("qwe", sizeof("qwe")); 5839 ck_assert(!equalUint64SmallBytesG(p1, p2)); 5840 // p2 is anything without 0 ending 5841 terminateO(p2); 5842 p2 = allocSmallBytes("qwe", strlen("qwe")); 5843 ck_assert(!equalUint64SmallBytesG(p1, p2)); 5844 // empty p2 5845 freeO(p2); 5846 ck_assert(!equalUint64SmallBytesG(p1, p2)); 5847 // null p2 5848 ck_assert(!equalUint64SmallBytesG(p1, null)); 5849 terminateO(p2); 5850 5851 } 5852 5853 5854 void equalUint64SmallDoubleGT(void) { 5855 5856 uint64_t p1 = 2; 5857 smallDoublet* p2 = allocSmallDouble(2); 5858 5859 ck_assert(equalUint64SmallDoubleG(p1, p2)); 5860 // empty object 5861 freeO(p2); 5862 ck_assert(!equalUint64SmallDoubleG(p1, p2)); 5863 terminateO(p2); 5864 // null object 5865 ck_assert(!equalUint64SmallDoubleG(p1, p2)); 5866 5867 } 5868 5869 5870 void equalUint64SmallIntGT(void) { 5871 5872 uint64_t p1 = 2; 5873 smallIntt* p2 = allocSmallInt(2); 5874 5875 ck_assert(equalUint64SmallIntG(p1, p2)); 5876 // empty object 5877 freeO(p2); 5878 ck_assert(!equalUint64SmallIntG(p1, p2)); 5879 terminateO(p2); 5880 // null object 5881 ck_assert(!equalUint64SmallIntG(p1, p2)); 5882 5883 } 5884 5885 5886 void equalUint64SmallJsonGT(void) { 5887 5888 uint64_t p1 = 2; 5889 smallJsont* p2 = allocSmallJson(); 5890 5891 setTopIntO(p2, 2); 5892 ck_assert(equalUint64SmallJsonG(p1, p2)); 5893 // empty object 5894 freeO(p2); 5895 ck_assert(!equalUint64SmallJsonG(p1, p2)); 5896 terminateO(p2); 5897 // non json object 5898 p2 = (smallJsont*) allocSmallInt(2); 5899 ck_assert(!equalUint64SmallJsonG(p1, p2)); 5900 terminateO(p2); 5901 // null object 5902 ck_assert(!equalUint64SmallJsonG(p1, p2)); 5903 5904 } 5905 5906 5907 void equalUint64SmallStringGT(void) { 5908 5909 uint64_t p1 = 2; 5910 smallStringt* p2 = allocSmallString("2"); 5911 5912 ck_assert(equalUint64SmallStringG(p1, p2)); 5913 // p2 is anything 5914 setValO(p2, "qwe"); 5915 ck_assert(!equalUint64SmallStringG(p1, p2)); 5916 // empty object 5917 freeO(p2); 5918 ck_assert(!equalUint64SmallStringG(p1, p2)); 5919 terminateO(p2); 5920 // null object 5921 ck_assert(!equalUint64SmallStringG(p1, p2)); 5922 5923 } 5924 5925 5926 void notEqualCharGT(void) { 5927 5928 ck_assert(!notEqualCharG('0', null)); 5929 5930 } 5931 5932 5933 void notEqualOCharGT(void) { 5934 5935 ck_assert(!notEqualOCharG(null, '1')); 5936 5937 } 5938 5939 5940 void notEqualOGT(void) { 5941 5942 ck_assert(!notEqualOG(null, null)); 5943 5944 } 5945 5946 5947 void notEqualCCOGT(void) { 5948 5949 ck_assert(!notEqualCCOG("","")); 5950 5951 } 5952 5953 5954 void notEqualBoolOGT(void) { 5955 5956 ck_assert(!notEqualBoolOG(true,"")); 5957 5958 } 5959 5960 5961 void notEqualDoubleOGT(void) { 5962 5963 ck_assert(!notEqualDoubleOG(2.2,"")); 5964 5965 } 5966 5967 5968 void notEqualInt64OGT(void) { 5969 5970 ck_assert(!notEqualInt64OG(2,"2")); 5971 5972 } 5973 5974 5975 void notEqualInt32OGT(void) { 5976 5977 ck_assert(!notEqualInt32OG(2,"")); 5978 5979 } 5980 5981 5982 void notEqualUint32OGT(void) { 5983 5984 ck_assert(!notEqualUint32OG(2,"2")); 5985 5986 } 5987 5988 5989 void notEqualUint64OGT(void) { 5990 5991 ck_assert(!notEqualUint64OG(2,null)); 5992 5993 } 5994 5995 5996 void notEqualOBoolGT(void) { 5997 5998 ck_assert(!notEqualOBoolG("",true)); 5999 6000 } 6001 6002 6003 void notEqualDoubleGT(void) { 6004 6005 ck_assert(!notEqualDoubleG("",1.1)); 6006 6007 } 6008 6009 6010 void notEqualOInt64GT(void) { 6011 6012 ck_assert(!notEqualOInt64G("",0)); 6013 6014 } 6015 6016 6017 void notEqualOInt32GT(void) { 6018 6019 ck_assert(!notEqualOInt32G(null,0)); 6020 6021 } 6022 6023 6024 void notEqualOUint32GT(void) { 6025 6026 ck_assert(!notEqualOUint32G("",0)); 6027 6028 } 6029 6030 6031 void notEqualOUint64GT(void) { 6032 6033 ck_assert(!notEqualOUint64G("",0)); 6034 6035 } 6036 6037 6038 void icEqCharCharT(void) { 6039 6040 ck_assert(icEqCharChar('a', 'A')); 6041 6042 } 6043 6044 6045 void icEqualChaOGT(void) { 6046 6047 baset* value = (baset*) allocSmallString("A"); 6048 6049 ck_assert(icEqualChaOG('a', value)); 6050 terminateO(value); 6051 6052 } 6053 6054 6055 void icEqualChaSmallJsonGT(void) { 6056 6057 smallJsont* value = allocSmallJson(); 6058 6059 setTopStringO(value, "A"); 6060 ck_assert(icEqualChaSmallJsonG('a', value)); 6061 // non json string 6062 freeO(value); 6063 setTopIntO(value, 2); 6064 ck_assert(!icEqualChaSmallJsonG('a', value)); 6065 // non json object 6066 terminateO(value); 6067 value = (smallJsont*) allocSmallInt(0); 6068 ck_assert(!icEqualChaSmallJsonG('a', value)); 6069 terminateO(value); 6070 ck_assert(!icEqualChaSmallJsonG('a', value)); 6071 6072 } 6073 6074 6075 void icEqualChaSmallStringGT(void) { 6076 6077 smallStringt* value = allocSmallString("A"); 6078 6079 ck_assert(icEqualChaSmallStringG('a', value)); 6080 freeO(value); 6081 ck_assert(!icEqualChaSmallStringG('a', value)); 6082 terminateO(value); 6083 ck_assert(!icEqualChaSmallStringG('a', value)); 6084 6085 } 6086 6087 6088 void icEqualCharOGT(void) { 6089 6090 baset* value = (baset*) allocSmallString("A"); 6091 6092 ck_assert(icEqualCharOG("a", value)); 6093 ck_assert(!icEqualCharOG(null, value)); 6094 terminateO(value); 6095 ck_assert(!icEqualCharOG("a", value)); 6096 6097 } 6098 6099 6100 void icEqualCharPSmallJsonGT(void) { 6101 6102 smallJsont* value = allocSmallJson(); 6103 6104 setTopStringO(value, "QWE"); 6105 ck_assert(icEqualCharPSmallJsonG("qwe", value)); 6106 // non json string 6107 freeO(value); 6108 setTopIntO(value, 2); 6109 ck_assert(!icEqualCharPSmallJsonG("2", value)); 6110 // non json object 6111 terminateO(value); 6112 value = (smallJsont*) allocSmallInt(2); 6113 ck_assert(!icEqualCharPSmallJsonG("2", value)); 6114 terminateO(value); 6115 ck_assert(!icEqualCharPSmallJsonG("qwe", value)); 6116 6117 } 6118 6119 6120 void icEqualCharPSmallStringGT(void) { 6121 6122 smallStringt* value = allocSmallString("QWE"); 6123 6124 ck_assert(icEqualCharPSmallStringG("qwe", value)); 6125 terminateO(value); 6126 ck_assert(!icEqualCharPSmallStringG("qwe", value)); 6127 6128 } 6129 6130 6131 void icEqualArrayOGT(void) { 6132 6133 char ** p1 = listCreateS("A", "bb"); 6134 smallArrayt* a = createSA("A", "BB"); 6135 baset* p2 = (baset*)a; 6136 6137 ck_assert(icEqualArrayOG(p1, p2)); 6138 free(p1[1]); 6139 p1[1] = strdup("qwe"); 6140 ck_assert(!icEqualArrayOG(p1, p2)); 6141 // array with deleted elements 6142 a->f->pushS(a, "BB"); 6143 delElemO(a, 1); 6144 ck_assert(!icEqualArrayOG(p1, p2)); 6145 trimO(a); 6146 // p1 empty 6147 forEachS(p1, e) free(e); 6148 p1[0] = null; 6149 ck_assert(!icEqualArrayOG(p1, p2)); 6150 // p2 empty 6151 listPushS(&p1, "A"); 6152 listPushS(&p1, "BB"); 6153 emptyO(a); 6154 ck_assert(!icEqualArrayOG(p1, p2)); 6155 // non smallArray object 6156 terminateO(p2); 6157 p2 = (baset*) allocSmallInt(2); 6158 ck_assert(!icEqualArrayOG(p1, p2)); 6159 // null parameters 6160 ck_assert(!icEqualArrayOG(null, p2)); 6161 ck_assert(!icEqualArrayOG(p1, null)); 6162 terminateO(p2); 6163 listFreeS(p1); 6164 6165 } 6166 6167 6168 void icEqualCArrayOGT(void) { 6169 6170 const char *p1[] = {"A", "qwe", null}; 6171 smallArrayt* a = createSA("A", "BB"); 6172 baset* p2 = (baset*)a; 6173 6174 ck_assert(!icEqualCArrayOG(p1, p2)); 6175 p1[1] = "bb"; 6176 ck_assert(icEqualCArrayOG(p1, p2)); 6177 terminateO(p2); 6178 6179 } 6180 6181 6182 void icEqualArraySmallJsonGT(void) { 6183 6184 char ** p1 = listCreateS("A", "qwe"); 6185 smallJsont* p2 = createSJ("A", "BB"); 6186 6187 ck_assert(!icEqualArraySmallJsonG(p1, p2)); 6188 listSetS(p1, 1, "bb"); 6189 ck_assert(icEqualArraySmallJsonG(p1, p2)); 6190 // array with deleted elements 6191 p2->f->pushS(p2, "BB"); 6192 delElemIndexO(p2, 1); 6193 ck_assert(!icEqualArraySmallJsonG(p1, p2)); 6194 trimO(p2); 6195 // p1 empty 6196 forEachS(p1, e) free(e); 6197 p1[0] = null; 6198 ck_assert(!icEqualArraySmallJsonG(p1, p2)); 6199 // p2 empty 6200 listPushS(&p1, "A"); 6201 listPushS(&p1, "BB"); 6202 emptyO(p2); 6203 ck_assert(!icEqualArraySmallJsonG(p1, p2)); 6204 // non json array 6205 freeO(p2); 6206 setTopIntO(p2, 2); 6207 ck_assert(!icEqualArraySmallJsonG(p1, p2)); 6208 // non smallJson object 6209 terminateO(p2); 6210 p2 = (smallJsont*) allocSmallInt(2); 6211 ck_assert(!icEqualArraySmallJsonG(p1, p2)); 6212 // null parameters 6213 ck_assert(!icEqualArraySmallJsonG(null, p2)); 6214 ck_assert(!icEqualArraySmallJsonG(p1, null)); 6215 terminateO(p2); 6216 listFreeS(p1); 6217 6218 } 6219 6220 6221 void icEqualArraySmallArrayGT(void) { 6222 6223 char ** p1 = listCreateS("A", "qwe"); 6224 smallArrayt* p2 = createSA("A", "BB"); 6225 6226 ck_assert(!icEqualArraySmallArrayG(p1, p2)); 6227 listSetS(p1, 1, "bb"); 6228 ck_assert(icEqualArraySmallArrayG(p1, p2)); 6229 // array with deleted elements 6230 p2->f->pushS(p2, "BB"); 6231 delElemO(p2, 1); 6232 ck_assert(!icEqualArraySmallArrayG(p1, p2)); 6233 trimO(p2); 6234 // p1 empty 6235 forEachS(p1, e) free(e); 6236 p1[0] = null; 6237 ck_assert(!icEqualArraySmallArrayG(p1, p2)); 6238 // p2 empty 6239 listPushS(&p1, "A"); 6240 listPushS(&p1, "BB"); 6241 emptyO(p2); 6242 ck_assert(!icEqualArraySmallArrayG(p1, p2)); 6243 /* // non smallArray object */ 6244 terminateO(p2); 6245 p2 = (smallArrayt*) allocSmallInt(2); 6246 ck_assert(!icEqualArraySmallArrayG(p1, p2)); 6247 /* // null parameters */ 6248 ck_assert(!icEqualArraySmallArrayG(null, p2)); 6249 ck_assert(!icEqualArraySmallArrayG(p1, null)); 6250 terminateO(p2); 6251 listFreeS(p1); 6252 6253 } 6254 6255 6256 void icEqualCArraySmallJsonGT(void) { 6257 6258 const char * p1[] = {"a", null}; 6259 smallJsont* p2 = allocSmallJson(); 6260 6261 ck_assert(!icEqualCArraySmallJsonG(p1, p2)); 6262 terminateO(p2); 6263 6264 } 6265 6266 6267 void icEqualCArraySmallArrayGT(void) { 6268 6269 const char * p1[] = {"a", null}; 6270 smallArrayt* p2 = allocSmallArray(); 6271 6272 ck_assert(!icEqualCArraySmallArrayG(p1, p2)); 6273 terminateO(p2); 6274 6275 } 6276 6277 6278 void icEqualOCharGT(void) { 6279 6280 baset* p1 = (baset*) allocSmallString("ASD"); 6281 const char * p2 = "asd"; 6282 6283 ck_assert(icEqualOCharG(p1, p2)); 6284 terminateO(p1); 6285 6286 } 6287 6288 6289 void icEqualOChaGT(void) { 6290 6291 baset* p1 = (baset*) allocSmallString("A"); 6292 6293 ck_assert(icEqualOChaG(p1, 'a')); 6294 terminateO(p1); 6295 6296 } 6297 6298 6299 void icEqualOArrayGT(void) { 6300 6301 baset* p1 = (baset*) createSA("a", "bb"); 6302 char ** p2 = listCreateS("A", "BB"); 6303 6304 ck_assert(icEqualOArrayG(p1, p2)); 6305 terminateO(p1); 6306 listFreeS(p2); 6307 6308 } 6309 6310 6311 void icEqualOCArrayGT(void) { 6312 6313 baset* p1 = (baset*) createSA("A", "bb"); 6314 const char * p2[] = {"A", "BB", null}; 6315 6316 ck_assert(icEqualOCArrayG(p1, p2)); 6317 terminateO(p1); 6318 6319 } 6320 6321 6322 void icEqualOOGT(void) { 6323 6324 baset* p1 = (baset*) allocSmallString("a"); 6325 smallJsont* P2 = allocSmallJson(); 6326 baset* p2 = (baset*)P2; 6327 6328 setTopStringO(P2, "A"); 6329 ck_assert(icEqualOOG(p1, p2)); 6330 freeO(P2); 6331 setTopIntO(P2, 0); 6332 ck_assert(!icEqualOOG(p1, p2)); 6333 freeO(P2); 6334 setTopIntO(P2, 2); 6335 // null parameters 6336 ck_assert(!icEqualOOG(null, p2)); 6337 ck_assert(!icEqualOOG(p1, null)); 6338 terminateO(p1); 6339 terminateO(p2); 6340 6341 } 6342 6343 6344 void icEqualOSmallArrayGT(void) { 6345 6346 baset* p1 = (baset*) createSA("a"); 6347 smallArrayt* p2 = createSA("A"); 6348 6349 ck_assert(icEqualOSmallArrayG(p1, p2)); 6350 terminateO(p2); 6351 // non smallArray object 6352 p2 = (smallArrayt*) allocSmallInt(2); 6353 ck_assert(!icEqualOSmallArrayG(p1, p2)); 6354 // null p2 6355 terminateO(p2); 6356 ck_assert(!icEqualOSmallArrayG(p1, p2)); 6357 terminateO(p1); 6358 6359 } 6360 6361 6362 void icEqualOSmallDictGT(void) { 6363 6364 smallDictt* P1 = allocSmallDict(); 6365 baset* p1 = (baset*) P1; 6366 smallDictt* p2 = allocSmallDict(); 6367 6368 P1->f->setS(P1, "qwe", "QWE"); 6369 p2->f->setS(p2, "qwe", "qwe"); 6370 ck_assert(icEqualOSmallDictG(p1, p2)); 6371 // non smallDict p2 6372 terminateO(p2); 6373 p2 = (smallDictt*) allocSmallInt(2); 6374 ck_assert(!icEqualOSmallDictG(p1, p2)); 6375 // null p2 6376 ck_assert(!icEqualOSmallDictG(p1, null)); 6377 terminateO(p1); 6378 terminateO(p2); 6379 6380 } 6381 6382 6383 void icEqualOSmallJsonGT(void) { 6384 6385 baset* p1 = (baset*) allocSmallString("A"); 6386 smallJsont* p2 = allocSmallJson(); 6387 6388 setTopStringO(p2, "a"); 6389 ck_assert(icEqualOSmallJsonG(p1, p2)); 6390 // non smallJson p2 6391 terminateO(p2); 6392 p2 = (smallJsont*) allocSmallInt(2); 6393 ck_assert(!icEqualOSmallJsonG(p1, p2)); 6394 // null p2 6395 ck_assert(!icEqualOSmallJsonG(p1, null)); 6396 terminateO(p1); 6397 terminateO(p2); 6398 6399 } 6400 6401 6402 void icEqualOSmallStringGT(void) { 6403 6404 baset* p1 = (baset*) allocSmallString("QWE"); 6405 smallStringt* p2 = allocSmallString("qwe"); 6406 6407 ck_assert(icEqualOSmallStringG(p1, p2)); 6408 // non smallString p2 6409 terminateO(p2); 6410 p2 = (smallStringt*) allocSmallInt(2); 6411 ck_assert(!icEqualOSmallStringG(p1, p2)); 6412 // null p2 6413 ck_assert(!icEqualOSmallStringG(p1, null)); 6414 terminateO(p1); 6415 terminateO(p2); 6416 6417 } 6418 6419 6420 void cpuCountT(void) { 6421 6422 ck_assert_int_ne(cpuCount(), 0); 6423 6424 } 6425 6426 6427 void registerFinalizeRecycleContainersInThreadPoolT(void) { 6428 6429 //TODO r = registerFinalizeRecycleContainersInThreadPool(); 6430 6431 } 6432 6433 6434 void initLibsheepyObjectT(void) { 6435 6436 //TODO r = initLibsheepyObject(); 6437 6438 } 6439 6440 6441 void putsOT(void) { 6442 6443 createAllocateSmallArray(l); 6444 6445 // object 6446 putsO(l); 6447 // NULL 6448 putsO(NULL); 6449 6450 terminateO(l); 6451 6452 } 6453 6454 6455 void execOT(void) { 6456 6457 int r; 6458 6459 createAllocateSmallArray(l); 6460 6461 // command 6462 r = execO("ls libsheepyObjectTest.c", l, NULL); 6463 ck_assert_int_eq(r, 1); 6464 ck_assert_uint_eq(l->f->len(l),1); 6465 ck_assert_str_eq(l->f->getAtS(l, 0), "libsheepyObjectTest.c"); 6466 freeO(l); 6467 // invalid command 6468 r = execO("randomCommand", l, NULL); 6469 ck_assert_int_eq(r, 1); 6470 ck_assert_uint_eq(l->f->len(l),0); 6471 // NULL out array 6472 r = execO("ls libsheepyObjectTest.c", NULL, NULL); 6473 ck_assert_int_eq(r, 0); 6474 ck_assert_uint_eq(l->f->len(l),0); 6475 terminateO(l); 6476 // NULL command 6477 ck_assert_int_eq(execO(NULL, NULL, NULL), 0); 6478 6479 } 6480 6481 6482 void walkDirOT(void) { 6483 6484 smallArrayt *l; 6485 6486 // existing directory 6487 l = walkDirO("../dirTest.null"); 6488 ck_assert_uint_eq(l->f->len(l),3); 6489 ck_assert_str_eq(l->f->getAtS(l, 0), "../dirTest.null/one"); 6490 ck_assert_str_eq(l->f->getAtS(l, 1), "../dirTest.null/two/four"); 6491 ck_assert_str_eq(l->f->getAtS(l, 2), "../dirTest.null/two/three"); 6492 terminateO(l); 6493 // empty path 6494 ck_assert_ptr_eq(walkDirO(""), NULL); 6495 // non existing directory 6496 l = walkDirO("nonExisting.null"); 6497 ck_assert(l->f->isEmpty(l)); 6498 terminateO(l); 6499 // NULL path 6500 ck_assert_ptr_eq(walkDirO(NULL), NULL); 6501 6502 } 6503 6504 6505 void expandHomeOT(void) { 6506 6507 // no ~/ 6508 createAllocateSmallString(v); 6509 v->f->set(v, "sheepy"); 6510 expandHomeO(v); 6511 ck_assert(v->f->equalS(v, "sheepy")); 6512 terminateO(v); 6513 // NULL var 6514 expandHomeO(NULL); 6515 6516 } 6517 6518 6519 void chDirOT(void) { 6520 6521 // change directory 6522 smallStringt *c; 6523 c = getCwdO(); 6524 createAllocateSmallString(v); 6525 v->f->set(v, "../dirTest.null"); 6526 ck_assert(chDirO(v)); 6527 char *s = getCwd(); 6528 ck_assert((size_t)findS(s, "dirTest.null")); 6529 chDirO(c); 6530 free(s); 6531 terminateO(c); 6532 // non existing dir 6533 createAllocateSmallString(n); 6534 n->f->set(n, "RandomNonExistingDir"); 6535 ck_assert(!chDirO(n)); 6536 // NULL path 6537 ck_assert(!chDirO(NULL)); 6538 terminateO(v); 6539 terminateO(n); 6540 6541 } 6542 6543 6544 void fileExistsOT(void) { 6545 6546 createAllocateSmallArray(sA); 6547 char **l = listCreateS("../libsheepyTest.c", "wefwepfk34.c", "../../src", ""); 6548 sA->f->fromArrayNFree(sA, l, 0); 6549 // detect existing file 6550 smallStringt *S = sA->f->getAtSmallString(sA, 0); 6551 ck_assert(fileExistsO(S)); 6552 finishO(S); 6553 // non existing file 6554 S = sA->f->getAtSmallString(sA, 1); 6555 ck_assert(!fileExistsO(S)); 6556 finishO(S); 6557 // folder 6558 S = sA->f->getAtSmallString(sA, 2); 6559 ck_assert(fileExistsO(S)); 6560 finishO(S); 6561 // empty path 6562 S = sA->f->getAtSmallString(sA, 3); 6563 ck_assert(!fileExistsO(S)); 6564 finishO(S); 6565 // NULL path 6566 ck_assert(!fileExistsO(NULL)); 6567 terminateO(sA); 6568 6569 } 6570 6571 6572 void fileChmodOT(void) { 6573 6574 // existing file 6575 createAllocateSmallString(v); 6576 v->f->set(v, "../chmodTest.null"); 6577 ck_assert(fileChmodO(v, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)); 6578 ck_assert(fileChmodO(v, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); 6579 // non existing file 6580 createAllocateSmallString(n); 6581 n->f->set(n, "qweqwe_null"); 6582 ck_assert(!fileChmodO(n, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); 6583 // empty path 6584 createAllocateSmallString(e); 6585 e->f->set(e, ""); 6586 ck_assert(!fileChmodO(e,0)); 6587 // NULL path 6588 ck_assert(!fileChmodO(NULL,0)); 6589 terminateO(v); 6590 terminateO(n); 6591 terminateO(e); 6592 6593 } 6594 6595 6596 void fileSizeOT(void) { 6597 6598 // existing file 6599 createAllocateSmallString(s); 6600 s->f->set(s, "../sizeTest.null"); 6601 ck_assert_uint_eq(fileSizeO(s), 743); 6602 // empty file 6603 createAllocateSmallString(v); 6604 v->f->set(v, "../chmodTest.null"); 6605 ck_assert_uint_eq(fileSizeO(v), 0); 6606 // non existing file 6607 createAllocateSmallString(n); 6608 n->f->set(n, "qweqwe_null"); 6609 ck_assert_int_eq(fileSizeO(n), -1); 6610 // empty path 6611 createAllocateSmallString(e); 6612 e->f->set(e, ""); 6613 ck_assert_int_eq(fileSizeO(e), -1); 6614 // NULL path 6615 ck_assert_int_eq(fileSizeO(NULL), -1); 6616 terminateO(s); 6617 terminateO(v); 6618 terminateO(n); 6619 terminateO(e); 6620 6621 } 6622 6623 6624 void mkdirParentsOT(void) { 6625 6626 // directory 6627 rmAll("mkdirTest.null/null"); 6628 createAllocateSmallString(s); 6629 s->f->set(s, "mkdirTest.null/null"); 6630 ck_assert_int_eq(mkdirParentsO(s),1); 6631 // not allowed 6632 createAllocateSmallString(v); 6633 v->f->set(v, "/usr/null"); 6634 ck_assert_int_eq(mkdirParentsO(v),0); 6635 // empty path 6636 createAllocateSmallString(e); 6637 e->f->set(e, ""); 6638 ck_assert_int_eq(mkdirParentsO(e),0); 6639 // NULL path 6640 ck_assert_int_eq(mkdirParentsO(NULL),0); 6641 terminateO(s); 6642 terminateO(e); 6643 terminateO(v); 6644 6645 } 6646 6647 6648 void rmAllOT(void) { 6649 6650 // directory 6651 createAllocateSmallString(s); 6652 s->f->set(s, "rmAllTest.null/null"); 6653 mkdirParents("rmAllTest.null/null"); 6654 ck_assert_int_eq(rmAllO(s),1); 6655 // empty path 6656 createAllocateSmallString(e); 6657 e->f->set(e,""); 6658 ck_assert_int_eq(rmAllO(e),0); 6659 // too little permissions 6660 createAllocateSmallString(v); 6661 v->f->set(v,"/var/lock"); 6662 ck_assert_int_eq(rmAllO(v),0); 6663 // NULL path 6664 ck_assert_int_eq(rmAllO(NULL),0); 6665 terminateO(s); 6666 terminateO(e); 6667 terminateO(v); 6668 6669 6670 } 6671 6672 6673 void copyOT(void) { 6674 6675 // file 6676 createAllocateSmallString(s); 6677 createAllocateSmallString(d); 6678 s->f->set(s, "../chmodTest.null"); 6679 d->f->set(d, "../copyTest.null"); 6680 ck_assert_int_eq(copyO(s, d),1); 6681 ck_assert(fileExists("../copyTest.null")); 6682 // too little permissions 6683 fileChmod("../copyTest.null", 1); 6684 ck_assert_int_eq(copyO(d, d),0); 6685 fileChmod("../copyTest.null", 777); 6686 rmAll("../copyTest.null"); 6687 // empty path 6688 createAllocateSmallString(e); 6689 e->f->set(e, ""); 6690 ck_assert_int_eq(copyO(e, d),0); 6691 ck_assert(!fileExists("copyTest.null")); 6692 ck_assert_int_eq(copyO(s, e),0); 6693 ck_assert(!fileExists("copyTest.null")); 6694 // NULL path 6695 ck_assert_int_eq(copyO(NULL, d),0); 6696 ck_assert_int_eq(copyO(s, NULL),0); 6697 ck_assert_int_eq(copyO(NULL, NULL),0); 6698 terminateO(s); 6699 terminateO(d); 6700 terminateO(e); 6701 6702 } 6703 6704 6705 void randomSOT(void) { 6706 6707 // get random string 6708 smallStringt *s = randomSO(10); 6709 ck_assert_ptr_ne(s, NULL); 6710 terminateO(s); 6711 // invalid length (0) 6712 ck_assert_ptr_eq(randomSO(0), NULL); 6713 6714 randomUrandomClose(); 6715 6716 } 6717 6718 6719 void randomAlphaNumSOT(void) { 6720 6721 // get random string 6722 smallStringt *s = randomAlphaNumSO(10); 6723 ck_assert_ptr_ne(s, NULL); 6724 terminateO(s); 6725 // invalid length (0) 6726 ck_assert_ptr_eq(randomAlphaNumSO(0), NULL); 6727 6728 randomUrandomClose(); 6729 6730 } 6731 6732 6733 void readLineOT(void) { 6734 6735 FILE *fp; 6736 smallStringt *s; 6737 6738 // file with data 6739 fp = fopen("../textTest.null", "r"); 6740 s = readLineO(fp); 6741 fclose(fp); 6742 ck_assert_str_eq(s->f->get(s), "LINE 1"); 6743 terminateO(s); 6744 // empty file or end of stream 6745 fp = fopen("../chmodTest.null", "r"); 6746 s = readLineO(fp); 6747 fclose(fp); 6748 ck_assert_str_eq(ssGet(s), ""); 6749 terminateO(s); 6750 // NULL stream 6751 ck_assert_ptr_eq(readLineO(NULL), NULL); 6752 6753 6754 } 6755 6756 6757 void toSmalltT(void) { 6758 6759 smallStringt *s; 6760 smallIntt *i; 6761 6762 // undefined 6763 createAllocateUndefined(u); 6764 sUndefinedt *su = (sUndefinedt *) toSmallt((baset *)u); 6765 finishO(u); 6766 ck_assert(isSType(su, UNDEFINED)); 6767 sFree((smallt *) su); 6768 // smallArray 6769 createAllocateSmallArray(a); 6770 initiateAllocateSmallString(&s); 6771 s->f->set(s, "sheepy"); 6772 a->f->push(a, (baset *) s); 6773 finishO(s); 6774 initiateAllocateSmallInt(&i); 6775 i->f->set(i, 20); 6776 a->f->push(a, (baset *) i); 6777 finishO(i); 6778 sArrayt *sa = (sArrayt *) toSmallt((baset *)a); 6779 ck_assert_uint_eq(sa->count, 2); 6780 char *S = sToString((smallt *) sa); 6781 ck_assert_str_eq(S, "[\"sheepy\",20]"); 6782 free(S); 6783 freeO(a); 6784 sa = (sArrayt *) toSmallt((baset *)a); 6785 ck_assert_uint_eq(sa->count, 0); 6786 S = sToString((smallt *) sa); 6787 ck_assert_str_eq(S, "[]"); 6788 free(S); 6789 sFree((smallt *) sa); 6790 finishO(a); 6791 // smallDict 6792 createAllocateSmallDict(d); 6793 initiateAllocateSmallString(&s); 6794 s->f->set(s, "sheepy"); 6795 d->f->set(d, "s", (baset *) s); 6796 finishO(s); 6797 initiateAllocateSmallInt(&i); 6798 i->f->set(i, 20); 6799 d->f->set(d, "i", (baset *) i); 6800 finishO(i); 6801 sDictt *sd = (sDictt *) toSmallt((baset *)d); 6802 ck_assert_uint_eq(sd->count, 2); 6803 S = sToString((smallt *) sd); 6804 ck_assert_str_eq(S, "{\"s\":\"sheepy\",\"i\":20}"); 6805 free(S); 6806 freeO(d); 6807 sd = (sDictt *) toSmallt((baset *)d); 6808 ck_assert_uint_eq(sd->count, 0); 6809 S = sToString((smallt *) sd); 6810 ck_assert_str_eq(S, "{}"); 6811 free(S); 6812 sFree((smallt *) sd); 6813 finishO(d); 6814 // smallJson 6815 createAllocateSmallJson(j); 6816 smallt *so = toSmallt((baset *)j); 6817 ck_assert_ptr_ne(so, NULL); 6818 ck_assert_int_eq(so->type, CONTAINER); 6819 ck_assert_ptr_eq(((sContainert*)so)->data, j); 6820 sFree(so); // sFree does terminateO(j); because smallJson is stored in a container 6821 // smallBool 6822 smallBoolt *b = allocSmallBool(true); 6823 sBoolt *sb = (sBoolt*) toSmallt((baset*)b); 6824 S = sToString((smallt *) sb); 6825 ck_assert_str_eq(S, "true"); 6826 free(S); 6827 freeO(b); 6828 sb = (sBoolt*) toSmallt((baset*)b); 6829 S = sToString((smallt *) sb); 6830 ck_assert_str_eq(S, "false"); 6831 free(S); 6832 sFree((smallt*) sb); 6833 finishO(b); 6834 // smallBytes 6835 smallBytest *B = allocSmallBytes("qwe", sizeof("qwe")); 6836 sBytest *sB = (sBytest*) toSmallt((baset*)B); 6837 S = sToString((smallt *) sB); 6838 ck_assert_str_eq(S, "[0x71,0x77,0x65,0x00]"); 6839 free(S); 6840 freeO(B); 6841 sB = (sBytest*) toSmallt((baset*)B); 6842 S = sToString((smallt *) sB); 6843 ck_assert_str_eq(S, "[]"); 6844 free(S); 6845 sFree((smallt*) sB); 6846 finishO(B); 6847 // smallContainer 6848 smallContainert *c = allocSmallContainer("qwe"); 6849 sContainert *sc = (sContainert*) toSmallt((baset*)c); 6850 S = sToString((smallt *) sc); 6851 ck_assert_str_eq(S, "<data container>"); 6852 free(S); 6853 freeO(c); 6854 sc = (sContainert*) toSmallt((baset*)c); 6855 S = sToString((smallt *) sc); 6856 ck_assert_str_eq(S, "<data container>"); 6857 free(S); 6858 sFree((smallt*) sc); 6859 finishO(c); 6860 // smallDouble 6861 smallDoublet *D = allocSmallDouble(1); 6862 sDoublet *sD = (sDoublet*) toSmallt((baset*)D); 6863 S = sToString((smallt *) sD); 6864 ck_assert_str_eq(S, "1.000000e+00"); 6865 free(S); 6866 freeO(D); 6867 sD = (sDoublet*) toSmallt((baset*)D); 6868 S = sToString((smallt *) sD); 6869 ck_assert_str_eq(S, "0.000000e+00"); 6870 free(S); 6871 sFree((smallt*) sD); 6872 finishO(D); 6873 // smallInt 6874 i = allocSmallInt(2); 6875 sIntt *si = (sIntt*) toSmallt((baset*)i); 6876 S = sToString((smallt *) si); 6877 ck_assert_str_eq(S, "2"); 6878 free(S); 6879 freeO(i); 6880 si = (sIntt*) toSmallt((baset*)i); 6881 S = sToString((smallt *) si); 6882 ck_assert_str_eq(S, "0"); 6883 free(S); 6884 sFree((smallt*) si); 6885 finishO(i); 6886 // smallString 6887 s = allocSmallString("qwe"); 6888 sStringt *ss = (sStringt*) toSmallt((baset*)s); 6889 S = sToString((smallt *) ss); 6890 ck_assert_str_eq(S, "qwe"); 6891 free(S); 6892 freeO(s); 6893 ss = (sStringt*) toSmallt((baset*)s); 6894 S = sToString((smallt *) ss); 6895 ck_assert_str_eq(S, ""); 6896 free(S); 6897 sFree((smallt*) ss); 6898 finishO(s); 6899 // any class 6900 i = allocSmallInt(2); 6901 i->type = "randomClass"; 6902 sc = (sContainert*) toSmallt((baset*)i); 6903 S = sToString((smallt *) sc); 6904 ck_assert_str_eq(S, "<data container>"); 6905 free(S); 6906 sFree((smallt*) sc); 6907 // NULL 6908 ck_assert_ptr_eq(toSmallt(NULL), NULL); 6909 6910 } 6911 6912 6913 void toBasetT(void) { 6914 6915 // bool 6916 sBoolt *sb = allocSBool(true); 6917 smallBoolt *b = (smallBoolt *) toBaset((smallt *)sb); 6918 ck_assert(b->value->value); 6919 terminateO(b); 6920 // smallBytes 6921 sBytest *sB = allocSBytes(); 6922 smallBytest *B = (smallBytest *) toBaset((smallt *)sB); 6923 ck_assert_ptr_eq(B->B, sB); 6924 terminateO(B); 6925 // container 6926 sContainert *sc = allocSContainer(strdup("sheepy")); 6927 smallContainert *c = (smallContainert *) toBaset((smallt *)sc); 6928 ck_assert_str_eq(c->data->data, "sheepy"); 6929 free(c->data->data); 6930 terminateO(c); 6931 // any class 6932 smallIntt *n = allocSmallInt(2); 6933 n->type = "randomClass"; 6934 sc = (sContainert*) toSmallt((baset*)n); 6935 smallIntt *x = (smallIntt *) toBaset((smallt *)sc); 6936 ck_assert_str_eq(x->type, "randomClass"); 6937 sFree((smallt*) sc); 6938 // double 6939 sDoublet *sD = allocSDouble(10); 6940 smallDoublet *D = (smallDoublet *) toBaset((smallt *)sD); 6941 ck_assert_uint_eq((uint)D->value->value, 10); 6942 terminateO(D); 6943 // int 6944 sIntt *si = allocSInt(10); 6945 smallIntt *i = (smallIntt *) toBaset((smallt *)si); 6946 ck_assert_uint_eq(i->value->value, 10); 6947 terminateO(i); 6948 // string 6949 sStringt *ss = allocSStringTiny("sheepy"); 6950 smallStringt *s = (smallStringt *) toBaset((smallt *)ss); 6951 ck_assert_str_eq(sStringGetTiny(ss), "sheepy"); 6952 terminateO(s); 6953 // undefined 6954 sUndefinedt *su = allocSUndefined(); 6955 undefinedt *u = (undefinedt *) toBaset((smallt *)su); 6956 ck_assert(isOType(u, "undefined")); 6957 sFree((smallt *) su); 6958 terminateO(u); 6959 // smallArray 6960 sArrayt *sa = allocSArray(); 6961 ss = allocSStringTiny("sheepy"); 6962 sArrayPushTiny(&sa, (smallt *) ss); 6963 si = allocSInt(20); 6964 sArrayPushTiny(&sa, (smallt *) si); 6965 smallArrayt *a = (smallArrayt *) toBaset((smallt *)sa); 6966 ck_assert_uint_eq(a->a->count, 2); 6967 char *S = toStringO(a); 6968 ck_assert_str_eq(S, "[\"sheepy\",20]"); 6969 free(S); 6970 terminateO(a); 6971 // smallDict 6972 sDictt *sd = allocSDict(); 6973 ss = allocSStringTiny("sheepy"); 6974 sDictPushTiny(&sd, "s", (smallt *) ss); 6975 si = allocSInt(20); 6976 sDictPushTiny(&sd, "i", (smallt *) si); 6977 smallDictt *d = (smallDictt *) toBaset((smallt *)sd); 6978 ck_assert_uint_eq(d->d->count, 2); 6979 S = toStringO(d); 6980 ck_assert_str_eq(S, "{\"s\":\"sheepy\",\"i\":20}"); 6981 free(S); 6982 terminateO(d); 6983 // NULL 6984 ck_assert_ptr_eq(toBaset(NULL), NULL); 6985 6986 } 6987 6988 6989 6990 6991 int main(int n UNUSED, char**v UNUSED) { 6992 // disable btrace to make the test run faster 6993 btraceDisable(); 6994 shSysinfoT(); 6995 duplicateBaseGT(); 6996 freeManyOFT(); 6997 terminateManyOFT(); 6998 smashManyOFT(); 6999 finishManyOFT(); 7000 getProgPathJOT(); 7001 getProgPathOT(); 7002 getRealProgPathJOT(); 7003 getRealProgPathOT(); 7004 systemJOT(); 7005 systemOT(); 7006 systemNFreeJOFT(); 7007 systemNFreeOFT(); 7008 print_mT(); 7009 print_m_arginfoT(); 7010 putsUndefinedGFT(); 7011 putsBoolGFT(); 7012 putsBoolPGFT(); 7013 putsDoubleGFT(); 7014 putsDoublePGFT(); 7015 putsIntGFT(); 7016 putsIntPGFT(); 7017 putsInt32GFT(); 7018 putsInt32PGFT(); 7019 putsUintGFT(); 7020 putsUintPGFT(); 7021 putsUint32GFT(); 7022 putsUint32PGFT(); 7023 putsSGFT(); 7024 putsListSGFT(); 7025 putsListCSGFT(); 7026 putsDictGFT(); 7027 putsJsonGFT(); 7028 putsArrayGFT(); 7029 putsSmallBoolGFT(); 7030 putsSmallBytesGFT(); 7031 putsSmallDoubleGFT(); 7032 putsSmallIntGFT(); 7033 putsSmallStringGFT(); 7034 putsVoidGFT(); 7035 putsSmallContainerGFT(); 7036 toStringOFT(); 7037 toStringUndefinedGFT(); 7038 toStringBoolGFT(); 7039 toStringBoolPGFT(); 7040 toStringFloatGFT(); 7041 toStringFloatPGFT(); 7042 toStringDoubleGFT(); 7043 toStringDoublePGFT(); 7044 toStringIntGFT(); 7045 toStringIntPGFT(); 7046 toStringInt32GFT(); 7047 toStringInt32PGFT(); 7048 toStringInt16GFT(); 7049 toStringInt16PGFT(); 7050 toStringUintGFT(); 7051 toStringUintPGFT(); 7052 toStringUint32GFT(); 7053 toStringUint32PGFT(); 7054 toStringUint16GFT(); 7055 toStringUint16PGFT(); 7056 toStringUint8GFT(); 7057 toStringUint8PGFT(); 7058 toStringCharGFT(); 7059 toStringSGFT(); 7060 toStringListSGFT(); 7061 toStringListCSGFT(); 7062 toStringDictGFT(); 7063 toStringArrayGFT(); 7064 toStringSmallBoolGFT(); 7065 toStringSmallBytesGFT(); 7066 toStringSmallDoubleGFT(); 7067 toStringSmallIntGFT(); 7068 toStringSmallStringGFT(); 7069 toStringVoidGFT(); 7070 toStringSmallContainerGFT(); 7071 toStringSmallJsonGFT(); 7072 otosT(); 7073 formatOT(); 7074 execSmallJsonOT(); 7075 execSmallStringOT(); 7076 walkDirSmallJsonOT(); 7077 walkDirSmallStringOT(); 7078 walkDirDirOT(); 7079 walkDirDirSmallJsonOT(); 7080 walkDirDirSmallStringOT(); 7081 readDirOT(); 7082 readDirSmallJsonOT(); 7083 readDirSmallStringOT(); 7084 readDirDirOT(); 7085 readDirDirSmallJsonOT(); 7086 readDirDirSmallStringOT(); 7087 walkDirAllOT(); 7088 walkDirAllSmallJsonOT(); 7089 walkDirAllSmallStringOT(); 7090 readDirAllOT(); 7091 readDirAllSmallJsonOT(); 7092 readDirAllSmallStringOT(); 7093 getModificationTimeJOT(); 7094 getModificationTimeOT(); 7095 setModificationTimeJOT(); 7096 setModificationTimeOT(); 7097 equalModificationTimesJOT(); 7098 equalModificationTimesSJOT(); 7099 equalModificationTimesJOST(); 7100 equalModificationTimesJOOT(); 7101 equalModificationTimesOJOT(); 7102 equalModificationTimesOT(); 7103 equalModificationTimesSOT(); 7104 equalModificationTimesOST(); 7105 timeToJOT(); 7106 timeToSOT(); 7107 shDirnameJOT(); 7108 shDirnameOT(); 7109 expandHomeJOT(); 7110 normalizePathJOT(); 7111 normalizePathOT(); 7112 getCwdJOT(); 7113 chDirJOT(); 7114 isDirJOT(); 7115 isDirOT(); 7116 isLinkJOT(); 7117 isLinkOT(); 7118 fileExistsJOT(); 7119 fileChmodJOT(); 7120 fileSizeJOT(); 7121 readFileToNewGT(); 7122 readStreamToNewGT(); 7123 readFileToGT(); 7124 readStreamToGT(); 7125 readTextSmallJsonNotSupportedT(); 7126 readTextSmallStringNotSupportedT(); 7127 readToFileSmallJsonNotSupportedT(); 7128 readToFileSmallStringNotSupportedT(); 7129 writeFileFromGT(); 7130 writeStreamFromGT(); 7131 writeTextSmallJsonNotSupportedT(); 7132 writeTextSmallStringNotSupportedT(); 7133 writeTextCCSmallJsonNotSupportedT(); 7134 writeTextCCSmallStringNotSupportedT(); 7135 readTextSGT(); 7136 readTextStreamGT(); 7137 writeTextSGT(); 7138 writeTextStreamGT(); 7139 writeTextCGT(); 7140 writeTextStreamCGT(); 7141 appendFileSGT(); 7142 appendTextSGT(); 7143 appendTextCGT(); 7144 mkdirParentsSmallJsonOT(); 7145 rmAllSmallJsonOT(); 7146 copySSmallJsonOT(); 7147 copySOT(); 7148 copySmallJsonOST(); 7149 copySmallJsonSmallJsonT(); 7150 copySmallJsonOT(); 7151 copyOST(); 7152 copyOSmallJsonT(); 7153 renameSmallJsonOT(); 7154 renameSmallJsonSmallJsonT(); 7155 renameSmallJsonOST(); 7156 renameOT(); 7157 renameOSmallJsonT(); 7158 renameSSmallJsonOT(); 7159 renameSOT(); 7160 renameOST(); 7161 moveSmallJsonOT(); 7162 moveSmallJsonSmallJsonT(); 7163 moveSmallJsonOST(); 7164 moveOT(); 7165 moveOSmallJsonT(); 7166 moveSSmallJsonOT(); 7167 moveSOT(); 7168 moveOST(); 7169 randomSmallJsonOT(); 7170 randomAlphaNumSmallJsonOT(); 7171 readSmallJsonOT(); 7172 readOT(); 7173 readLineSmallJsonOT(); 7174 intToSGT(); 7175 doubleToSGT(); 7176 iListUniqGT(); 7177 iicListUniqGT(); 7178 listFromArrayGT(); 7179 listFromCArrayGT(); 7180 getSGT(); 7181 listGetGT(); 7182 listGetCGT(); 7183 iListGetGT(); 7184 iListGetCGT(); 7185 listPopGT(); 7186 listDequeueGT(); 7187 listDupCGT(); 7188 listEqCGT(); 7189 listEqC1GT(); 7190 listEqCCGT(); 7191 icListEqCGT(); 7192 icListEqC1GT(); 7193 icListEqCCGT(); 7194 listLengthCGT(); 7195 listIndexOfCGT(); 7196 listIndexOfCharCGT(); 7197 icListIndexOfCGT(); 7198 icListIndexOfCharCGT(); 7199 listHasCharCGT(); 7200 listHasCGT(); 7201 icListHasCGT(); 7202 icListHasCharCGT(); 7203 joinCGT(); 7204 joinCharCGT(); 7205 listAddCGT(); 7206 listPrintCGT(); 7207 eqCharCharT(); 7208 equalChaOGT(); 7209 equalChaBoolGT(); 7210 equalChaDoubleGT(); 7211 equalChaInt64GT(); 7212 equalChaInt32GT(); 7213 equalChaUint32GT(); 7214 equalChaUint64GT(); 7215 equalChaSmallBytesGT(); 7216 equalChaSmallDoubleGT(); 7217 equalChaSmallIntGT(); 7218 equalChaSmallJsonGT(); 7219 equalChaSmallStringGT(); 7220 equalCharOGT(); 7221 equalCharBoolGT(); 7222 equalCharDoubleGT(); 7223 equalCharInt64GT(); 7224 equalCharInt32GT(); 7225 equalCharUint32GT(); 7226 equalCharUint64GT(); 7227 equalCharSmallBoolGT(); 7228 equalCharSmallBytesGT(); 7229 equalCharSmallDoubleGT(); 7230 equalCharSmallIntGT(); 7231 equalCharPSmallJsonGT(); 7232 equalCharPSmallStringGT(); 7233 equalArrayOGT(); 7234 equalCArrayOGT(); 7235 equalArraySmallJsonGT(); 7236 equalArraySmallArrayGT(); 7237 equalCArraySmallJsonGT(); 7238 equalCArraySmallArrayGT(); 7239 equalOCharGT(); 7240 equalOChaGT(); 7241 equalOArrayGT(); 7242 equalOCArrayGT(); 7243 equalOOGT(); 7244 equalOBoolGT(); 7245 equalODoubleGT(); 7246 equalOInt64GT(); 7247 equalOInt32GT(); 7248 equalOUint32GT(); 7249 equalOUint64GT(); 7250 equalOSmallArrayGT(); 7251 equalOSmallBoolGT(); 7252 equalOSmallBytesGT(); 7253 equalOSmallDoubleGT(); 7254 equalOSmallDictGT(); 7255 equalOSmallIntGT(); 7256 equalOSmallJsonGT(); 7257 equalOSmallStringGT(); 7258 equalBoolChaGT(); 7259 equalBoolCharGT(); 7260 equalBoolOGT(); 7261 equalBoolFGT(); 7262 equalBoolDoubleGT(); 7263 equalBoolInt64GT(); 7264 equalBoolInt32GT(); 7265 equalBoolUint32GT(); 7266 equalBoolUint64GT(); 7267 equalBoolSmallBoolGT(); 7268 equalBoolSmallBytesGT(); 7269 equalBoolSmallDoubleGT(); 7270 equalBoolSmallIntGT(); 7271 equalBoolSmallJsonGT(); 7272 equalBoolSmallStringGT(); 7273 equalDoubleChaGT(); 7274 equalDoubleCharGT(); 7275 equalDoubleBaseGT(); 7276 equalDoubleBoolGT(); 7277 equalDoubleFGT(); 7278 equalDoubleInt64GT(); 7279 equalDoubleInt32GT(); 7280 equalDoubleUint32GT(); 7281 equalDoubleUint64GT(); 7282 equalDoubleSmallBoolGT(); 7283 equalDoubleSmallBytesGT(); 7284 equalDoubleSmallDoubleGT(); 7285 equalDoubleSmallIntGT(); 7286 equalDoubleSmallJsonGT(); 7287 equalDoubleSmallStringGT(); 7288 equalInt64ChaGT(); 7289 equalInt64CharGT(); 7290 equalInt64BaseGT(); 7291 equalInt64BoolGT(); 7292 equalInt64DoubleGT(); 7293 equalInt64FGT(); 7294 equalInt64Int32GT(); 7295 equalInt64Uint32GT(); 7296 equalInt64Uint64GT(); 7297 equalInt64SmallBoolGT(); 7298 equalInt64SmallBytesGT(); 7299 equalInt64SmallDoubleGT(); 7300 equalInt64SmallIntGT(); 7301 equalInt64SmallJsonGT(); 7302 equalInt64SmallStringGT(); 7303 equalInt32ChaGT(); 7304 equalInt32CharGT(); 7305 equalInt32BaseGT(); 7306 equalInt32BoolGT(); 7307 equalInt32DoubleGT(); 7308 equalInt32Int64GT(); 7309 equalInt32FGT(); 7310 equalInt32Uint32GT(); 7311 equalInt32Uint64GT(); 7312 equalInt32SmallBoolGT(); 7313 equalInt32SmallBytesGT(); 7314 equalInt32SmallDoubleGT(); 7315 equalInt32SmallIntGT(); 7316 equalInt32SmallJsonGT(); 7317 equalInt32SmallStringGT(); 7318 equalUint32ChaGT(); 7319 equalUint32CharGT(); 7320 equalUint32BaseGT(); 7321 equalUint32BoolGT(); 7322 equalUint32DoubleGT(); 7323 equalUint32Int64GT(); 7324 equalUint32Int32GT(); 7325 equalUint32FGT(); 7326 equalUint32Uint64GT(); 7327 equalUint32SmallBoolGT(); 7328 equalUint32SmallBytesGT(); 7329 equalUint32SmallDoubleGT(); 7330 equalUint32SmallIntGT(); 7331 equalUint32SmallJsonGT(); 7332 equalUint32SmallStringGT(); 7333 equalUint64ChaGT(); 7334 equalUint64CharGT(); 7335 equalUint64BaseGT(); 7336 equalUint64BoolGT(); 7337 equalUint64DoubleGT(); 7338 equalUint64Int64GT(); 7339 equalUint64Int32GT(); 7340 equalUint64Uint32GT(); 7341 equalUint64FGT(); 7342 equalUint64SmallBoolGT(); 7343 equalUint64SmallBytesGT(); 7344 equalUint64SmallDoubleGT(); 7345 equalUint64SmallIntGT(); 7346 equalUint64SmallJsonGT(); 7347 equalUint64SmallStringGT(); 7348 notEqualCharGT(); 7349 notEqualOCharGT(); 7350 notEqualOGT(); 7351 notEqualCCOGT(); 7352 notEqualBoolOGT(); 7353 notEqualDoubleOGT(); 7354 notEqualInt64OGT(); 7355 notEqualInt32OGT(); 7356 notEqualUint32OGT(); 7357 notEqualUint64OGT(); 7358 notEqualOBoolGT(); 7359 notEqualDoubleGT(); 7360 notEqualOInt64GT(); 7361 notEqualOInt32GT(); 7362 notEqualOUint32GT(); 7363 notEqualOUint64GT(); 7364 icEqCharCharT(); 7365 icEqualChaOGT(); 7366 icEqualChaSmallJsonGT(); 7367 icEqualChaSmallStringGT(); 7368 icEqualCharOGT(); 7369 icEqualCharPSmallJsonGT(); 7370 icEqualCharPSmallStringGT(); 7371 icEqualArrayOGT(); 7372 icEqualCArrayOGT(); 7373 icEqualArraySmallJsonGT(); 7374 icEqualArraySmallArrayGT(); 7375 icEqualCArraySmallJsonGT(); 7376 icEqualCArraySmallArrayGT(); 7377 icEqualOCharGT(); 7378 icEqualOChaGT(); 7379 icEqualOArrayGT(); 7380 icEqualOCArrayGT(); 7381 icEqualOOGT(); 7382 icEqualOSmallArrayGT(); 7383 icEqualOSmallDictGT(); 7384 icEqualOSmallJsonGT(); 7385 icEqualOSmallStringGT(); 7386 cpuCountT(); 7387 registerFinalizeRecycleContainersInThreadPoolT(); 7388 initLibsheepyObjectT(); 7389 putsOT(); 7390 execOT(); 7391 walkDirOT(); 7392 expandHomeOT(); 7393 chDirOT(); 7394 fileExistsOT(); 7395 fileChmodOT(); 7396 fileSizeOT(); 7397 mkdirParentsOT(); 7398 rmAllOT(); 7399 copyOT(); 7400 randomSOT(); 7401 randomAlphaNumSOT(); 7402 readLineOT(); 7403 toSmalltT(); 7404 toBasetT(); 7405 7406 finalizeSmallDict(); 7407 finalizeSmallArray(); 7408 finalizeSmallJson(); 7409 finalizeUndefined(); 7410 finalizeSmallBytes(); 7411 finalizeSmallBool(); 7412 finalizeSmallContainer(); 7413 finalizeSmallDouble(); 7414 finalizeSmallInt(); 7415 finalizeSmallString(); 7416 }