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