libsheepyCSmallIntTestMem.c (41603B)
1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <string.h> 4 5 #define ck_assert_str_eq(a,b) a;b; 6 #define ck_assert_str_ne(a,b) a;b; 7 #define ck_assert_ptr_eq(a,b) a;b; 8 #define ck_assert_ptr_ne(a,b) a;b; 9 #define ck_assert_uint_eq(a,b) a;b; 10 #define ck_assert_uint_ne(a,b) a;b; 11 #define ck_assert_int_eq(a,b) a;b; 12 #define ck_assert_int_ne(a,b) a;b; 13 #define ck_assert(a) a; 14 15 16 #include "../libsheepy.h" 17 #include "../libsheepyObject.h" 18 19 #ifdef __GNUC__ 20 #define UNUSED __attribute__ ((unused)) 21 #else 22 #define UNUSED 23 #endif 24 25 // TODO redirect stderr 26 27 28 void initiateSmallIntT(void) { 29 30 smallIntt self; 31 32 initiateSmallInt(&self); 33 char *s = toStringO(&self); 34 ck_assert_ptr_eq(s, null); 35 36 } 37 38 39 void initiateAllocateSmallIntT(void) { 40 41 smallIntt *self; 42 43 initiateAllocateSmallInt(&self); 44 char *s = toStringO(self); 45 ck_assert_ptr_eq(s, null); 46 terminateO(self); 47 48 } 49 50 51 void allocSmallIntT(void) { 52 53 smallIntt* r; 54 55 r = allocSmallInt(1); 56 char *s = toStringO(r); 57 ck_assert_str_eq(s, "1"); 58 free(s); 59 terminateO(r); 60 61 } 62 63 64 void freeSmallIntT(void) { 65 66 smallIntt *self = allocSmallInt(1); 67 68 freeO(self); 69 char *s = toStringO(self); 70 ck_assert_ptr_eq(s, null); 71 terminateO(self); 72 73 } 74 75 76 void terminateSmallIntT(void) { 77 78 smallIntt *self = allocSmallInt(1); 79 80 terminateO(self); 81 ck_assert_ptr_eq(self, null); 82 83 } 84 85 86 void toStringSmallIntT(void) { 87 88 char* r; 89 smallIntt *self = allocSmallInt(1); 90 91 r = toStringO(self); 92 ck_assert_str_eq(r, "1"); 93 free(r); 94 // empty smallInt 95 freeO(self); 96 r = toStringO(self); 97 ck_assert_ptr_eq(r, null); 98 terminateO(self); 99 100 } 101 102 103 void duplicateSmallIntT(void) { 104 105 smallIntt* r; 106 smallIntt *self = allocSmallInt(1); 107 108 r = duplicateO(self); 109 ck_assert_ptr_ne(r, null); 110 char *s = toStringO(r); 111 ck_assert_str_eq(s, "1"); 112 free(s); 113 terminateO(r); 114 // empty smallInt 115 freeO(self); 116 r = duplicateO(self); 117 ck_assert_ptr_ne(r, null); 118 s = toStringO(r); 119 ck_assert_ptr_eq(s, null); 120 terminateO(r); 121 terminateO(self); 122 123 } 124 125 126 void smashSmallIntT(void) { 127 128 smallIntt *self = allocSmallInt(1); 129 130 freeO(self); 131 smashO(self); 132 ck_assert_ptr_eq(self, null); 133 134 } 135 136 137 void finishSmallIntT(void) { 138 139 smallIntt *self = allocSmallInt(1); 140 141 freeO(self); 142 finishO(self); 143 ck_assert_ptr_eq(self, null); 144 145 } 146 147 148 void getSmallIntT(void) { 149 150 int64_t r; 151 smallIntt *self = allocSmallInt(1); 152 153 r = getValO(self); 154 ck_assert(r == 1); 155 // empty smallInt 156 freeO(self); 157 r = getValO(self); 158 ck_assert(r == 0); 159 terminateO(self); 160 161 } 162 163 164 void setSmallIntT(void) { 165 166 smallIntt* r; 167 smallIntt *self = allocSmallInt(1); 168 169 r = setValO(self, 1); 170 ck_assert_ptr_ne(r, null); 171 char *s = toStringO(r); 172 ck_assert_str_eq(s, "1"); 173 free(s); 174 // empty smallInt 175 freeO(self); 176 r = setValO(self, 1); 177 ck_assert_ptr_ne(r, null); 178 s = toStringO(r); 179 ck_assert_str_eq(s, "1"); 180 free(s); 181 terminateO(self); 182 183 } 184 185 186 void setBoolSmallIntT(void) { 187 188 smallIntt* r; 189 smallIntt* self = allocSmallInt(0); 190 191 r = self->f->setBool(self, true); 192 ck_assert_ptr_ne(r, null); 193 char *s = toStringO(r); 194 ck_assert_str_eq(s, "1"); 195 free(s); 196 // empty smallInt 197 freeO(self); 198 r = self->f->setBool(self, true); 199 ck_assert_ptr_ne(r, null); 200 s = toStringO(r); 201 ck_assert_str_eq(s, "1"); 202 free(s); 203 terminateO(self); 204 205 } 206 207 208 void setDoubleSmallIntT(void) { 209 210 smallIntt* r; 211 smallIntt* self = allocSmallInt(1); 212 213 r = self->f->setDouble(self, 1.5); 214 ck_assert_ptr_ne(r, null); 215 char *s = toStringO(r); 216 ck_assert_str_eq(s, "1"); 217 free(s); 218 // empty smallInt 219 freeO(self); 220 r = self->f->setDouble(self, 1); 221 ck_assert_ptr_ne(r, null); 222 s = toStringO(r); 223 ck_assert_str_eq(s, "1"); 224 free(s); 225 terminateO(self); 226 227 } 228 229 230 void setInt32SmallIntT(void) { 231 232 smallIntt* r; 233 smallIntt* self = allocSmallInt(1); 234 235 r = self->f->setInt32(self, 2); 236 ck_assert_ptr_ne(r, null); 237 char *s = toStringO(r); 238 ck_assert_str_eq(s, "2"); 239 free(s); 240 // empty smallInt 241 freeO(self); 242 r = self->f->setInt32(self, 2); 243 ck_assert_ptr_ne(r, null); 244 s = toStringO(r); 245 ck_assert_str_eq(s, "2"); 246 free(s); 247 terminateO(self); 248 249 } 250 251 252 void setUint32SmallIntT(void) { 253 254 smallIntt* r; 255 smallIntt* self = allocSmallInt(1); 256 257 r = self->f->setUint32(self, 2); 258 ck_assert_ptr_ne(r, null); 259 char *s = toStringO(r); 260 ck_assert_str_eq(s, "2"); 261 free(s); 262 // empty smallInt 263 freeO(self); 264 r = self->f->setUint32(self, 2); 265 ck_assert_ptr_ne(r, null); 266 s = toStringO(r); 267 ck_assert_str_eq(s, "2"); 268 free(s); 269 terminateO(self); 270 271 } 272 273 274 void setUint64SmallIntT(void) { 275 276 smallIntt* r; 277 smallIntt* self = allocSmallInt(1); 278 279 r = self->f->setUint64(self, 2); 280 ck_assert_ptr_ne(r, null); 281 char *s = toStringO(r); 282 ck_assert_str_eq(s, "2"); 283 free(s); 284 // empty smallInt 285 freeO(self); 286 r = self->f->setUint64(self, 2); 287 ck_assert_ptr_ne(r, null); 288 s = toStringO(r); 289 ck_assert_str_eq(s, "2"); 290 free(s); 291 terminateO(self); 292 293 } 294 295 296 void setSSmallIntT(void) { 297 298 smallIntt* r; 299 smallIntt* self = allocSmallInt(1); 300 301 r = self->f->setS(self, "2"); 302 ck_assert_ptr_ne(r, null); 303 char *s = toStringO(r); 304 ck_assert_str_eq(s, "2"); 305 free(s); 306 r = self->f->setS(self, "3.5"); 307 ck_assert_ptr_ne(r, null); 308 s = toStringO(r); 309 ck_assert_str_eq(s, "3"); 310 free(s); 311 // empty smallInt 312 freeO(self); 313 r = self->f->setS(self, "5"); 314 ck_assert_ptr_ne(r, null); 315 s = toStringO(r); 316 ck_assert_str_eq(s, "5"); 317 free(s); 318 // NULL parameter 319 r = self->f->setS(self, null); 320 ck_assert_ptr_eq(r, null); 321 terminateO(self); 322 323 } 324 325 326 void setSmallBoolSmallIntT(void) { 327 328 smallIntt* r; 329 smallIntt* self = allocSmallInt(1); 330 smallBoolt* p2 = allocSmallBool(true); 331 332 r = self->f->setSmallBool(self, p2); 333 ck_assert_ptr_ne(r, null); 334 char *s = toStringO(r); 335 ck_assert_str_eq(s, "1"); 336 free(s); 337 // empty smallInt 338 freeO(self); 339 r = self->f->setSmallBool(self, p2); 340 terminateO(p2); 341 ck_assert_ptr_ne(r, null); 342 s = toStringO(r); 343 ck_assert_str_eq(s, "1"); 344 free(s); 345 // NULL parameter 346 r = self->f->setSmallBool(self, null); 347 ck_assert_ptr_eq(r, null); 348 terminateO(self); 349 350 } 351 352 353 void setSmallDoubleSmallIntT(void) { 354 355 smallIntt* r; 356 smallIntt* self = allocSmallInt(1); 357 smallDoublet* p2 = allocSmallDouble(2); 358 359 r = self->f->setSmallDouble(self, p2); 360 ck_assert_ptr_ne(r, null); 361 char *s = toStringO(r); 362 ck_assert_str_eq(s, "2"); 363 free(s); 364 // empty smallInt 365 freeO(self); 366 r = self->f->setSmallDouble(self, p2); 367 terminateO(p2); 368 ck_assert_ptr_ne(r, null); 369 s = toStringO(r); 370 ck_assert_str_eq(s, "2"); 371 free(s); 372 // NULL parameter 373 r = self->f->setSmallDouble(self, null); 374 ck_assert_ptr_eq(r, null); 375 terminateO(self); 376 377 } 378 379 380 void setSmallIntSmallIntT(void) { 381 382 smallIntt* r; 383 smallIntt* self = allocSmallInt(1); 384 smallIntt* p2 = allocSmallInt(2); 385 386 r = self->f->setSmallInt(self, p2); 387 ck_assert_ptr_ne(r, null); 388 char *s = toStringO(r); 389 ck_assert_str_eq(s, "2"); 390 free(s); 391 // empty smallInt 392 freeO(self); 393 r = self->f->setSmallInt(self, p2); 394 terminateO(p2); 395 ck_assert_ptr_ne(r, null); 396 s = toStringO(r); 397 ck_assert_str_eq(s, "2"); 398 free(s); 399 // NULL parameter 400 r = self->f->setSmallInt(self, null); 401 ck_assert_ptr_eq(r, null); 402 terminateO(self); 403 404 } 405 406 407 void setSmallJsonSmallIntT(void) { 408 409 smallIntt* r; 410 smallIntt* self = allocSmallInt(1); 411 smallJsont* p2 = allocSmallJson(); 412 413 // empty json >> error 414 r = self->f->setSmallJson(self, p2); 415 ck_assert_ptr_eq(r, null); 416 // json bool 417 setTopBoolO(p2, true); 418 r = self->f->setSmallJson(self, p2); 419 ck_assert_ptr_ne(r, null); 420 terminateO(p2); 421 char *s = toStringO(r); 422 ck_assert_str_eq(s, "1"); 423 free(s); 424 // json double 425 p2 = allocSmallJson(); 426 setTopDoubleO(p2, 2); 427 r = self->f->setSmallJson(self, p2); 428 ck_assert_ptr_ne(r, null); 429 terminateO(p2); 430 s = toStringO(r); 431 ck_assert_str_eq(s, "2"); 432 free(s); 433 // json int 434 p2 = allocSmallJson(); 435 setTopIntO(p2, 3); 436 r = self->f->setSmallJson(self, p2); 437 ck_assert_ptr_ne(r, null); 438 terminateO(p2); 439 s = toStringO(r); 440 ck_assert_str_eq(s, "3"); 441 free(s); 442 // json string 443 p2 = allocSmallJson(); 444 setTopSO(p2, "1.5"); 445 r = self->f->setSmallJson(self, p2); 446 ck_assert_ptr_ne(r, null); 447 terminateO(p2); 448 s = toStringO(r); 449 ck_assert_str_eq(s, "1"); 450 free(s); 451 // json dict 452 p2 = allocSmallJson(); 453 setTypeDictO(p2); 454 r = self->f->setSmallJson(self, p2); 455 ck_assert_ptr_eq(r, null); 456 terminateO(p2); 457 // NULL parameter 458 r = self->f->setSmallJson(self, null); 459 ck_assert_ptr_eq(r, null); 460 terminateO(self); 461 462 } 463 464 465 void setSmallStringSmallIntT(void) { 466 467 smallIntt* r; 468 smallIntt* self = allocSmallInt(1); 469 smallStringt* p2 = allocSmallString("1.5"); 470 471 r = self->f->setSmallString(self, p2); 472 ck_assert_ptr_ne(r, null); 473 char *s = toStringO(r); 474 ck_assert_str_eq(s, "1"); 475 free(s); 476 // empty smallInt 477 freeO(self); 478 r = self->f->setSmallString(self, p2); 479 terminateO(p2); 480 ck_assert_ptr_ne(r, null); 481 s = toStringO(r); 482 ck_assert_str_eq(s, "1"); 483 free(s); 484 // NULL parameter 485 r = self->f->setSmallString(self, null); 486 ck_assert_ptr_eq(r, null); 487 terminateO(self); 488 489 } 490 491 492 void getPSmallIntT(void) { 493 494 int64_t* r; 495 smallIntt *self = allocSmallInt(1); 496 497 r = self->f->getP(self); 498 ck_assert_ptr_ne(r, null); 499 ck_assert(*r == 1); 500 // empty smallInt 501 freeO(self); 502 r = self->f->getP(self); 503 ck_assert_ptr_eq(r, null); 504 terminateO(self); 505 506 } 507 508 509 void equalSmallIntChaT(void) { 510 511 bool r; 512 smallIntt* self = allocSmallInt(1); 513 char p2 = '1'; 514 515 // p2 is an int so it is false 516 r = self->f->equalCha(self, p2); 517 ck_assert(r); 518 r = self->f->equalCha(self, '2'); 519 ck_assert(!r); 520 // not a digit 521 r = self->f->equalCha(self, '!'); 522 ck_assert(!r); 523 // empty smallInt 524 freeO(self); 525 r = self->f->equalCha(self, p2); 526 ck_assert(!r); 527 terminateO(self); 528 529 } 530 531 532 void equalSmallIntCharT(void) { 533 534 bool r; 535 smallIntt* self = allocSmallInt(0); 536 537 r = self->f->equalChar(self, "0"); 538 ck_assert(r); 539 r = self->f->equalChar(self, "#"); 540 ck_assert(!r); 541 // NULL parameter 542 r = self->f->equalChar(self, null); 543 ck_assert(!r); 544 // empty smallInt 545 freeO(self); 546 r = self->f->equalChar(self, ""); 547 ck_assert(!r); 548 terminateO(self); 549 550 } 551 552 553 void equalSmallIntBaseT(void) { 554 555 bool r; 556 smallIntt* self = allocSmallInt(1); 557 baset* p2 = (baset*) allocSmallInt(1); 558 smallJsont* p3 = allocSmallJson(); 559 560 setTopBoolO(p3, false); 561 562 r = self->f->equalBase(self, p2); 563 terminateO(p2); 564 ck_assert(r); 565 p2 = (baset*) allocSmallInt(10); 566 r = self->f->equalBase(self, p2); 567 terminateO(p2); 568 ck_assert(!r); 569 p2 = (baset*) allocSmallDouble(1); 570 r = self->f->equalBase(self, p2); 571 terminateO(p2); 572 ck_assert(!r); 573 r = self->f->equalBase(self, (baset*)p3); 574 terminateO(p3); 575 ck_assert(!r); 576 p2 = (baset*) allocSmallString("qwe"); 577 r = self->f->equalBase(self, p2); 578 terminateO(p2); 579 ck_assert(!r); 580 // NULL parameter 581 r = self->f->equalBase(self, null); 582 ck_assert(!r); 583 // empty smallInt 584 freeO(self); 585 r = self->f->equalBase(self, p2); 586 ck_assert(!r); 587 terminateO(self); 588 589 } 590 591 592 void equalSmallIntBoolT(void) { 593 594 bool r; 595 smallIntt* self = allocSmallInt(0); 596 597 r = self->f->equalBool(self, true); 598 ck_assert(!r); 599 r = self->f->equalBool(self, false); 600 ck_assert(r); 601 // empty smallInt 602 freeO(self); 603 r = self->f->equalBool(self, false); 604 ck_assert(!r); 605 terminateO(self); 606 607 } 608 609 610 void equalSmallIntDoubleT(void) { 611 612 bool r; 613 smallIntt* self = allocSmallInt(1); 614 615 r = self->f->equalDouble(self, 1); 616 ck_assert(r); 617 r = self->f->equalDouble(self, 2); 618 ck_assert(!r); 619 // empty smallInt 620 freeO(self); 621 r = self->f->equalDouble(self, 1); 622 ck_assert(!r); 623 terminateO(self); 624 625 } 626 627 628 void equalSmallIntInt64T(void) { 629 630 bool r; 631 smallIntt* self = allocSmallInt(1); 632 633 r = self->f->equalInt64(self, 1); 634 ck_assert(r); 635 r = self->f->equalInt64(self, 0); 636 ck_assert(!r); 637 // empty smallInt 638 freeO(self); 639 r = self->f->equalInt64(self, 2); 640 ck_assert(!r); 641 terminateO(self); 642 643 } 644 645 646 void equalSmallIntInt32T(void) { 647 648 bool r; 649 smallIntt* self = allocSmallInt(1); 650 651 r = self->f->equalInt32(self, 1); 652 ck_assert(r); 653 r = self->f->equalInt32(self, 0); 654 ck_assert(!r); 655 // empty smallInt 656 freeO(self); 657 r = self->f->equalInt32(self, 2); 658 ck_assert(!r); 659 terminateO(self); 660 661 } 662 663 664 void equalSmallIntUint32T(void) { 665 666 bool r; 667 smallIntt* self = allocSmallInt(1); 668 669 r = self->f->equalUint32(self, 1); 670 ck_assert(r); 671 r = self->f->equalUint32(self, 0); 672 ck_assert(!r); 673 // empty smallInt 674 freeO(self); 675 r = self->f->equalUint32(self, 2); 676 ck_assert(!r); 677 terminateO(self); 678 679 } 680 681 682 void equalSmallIntUint64T(void) { 683 684 bool r; 685 smallIntt* self = allocSmallInt(1); 686 687 r = self->f->equalUint64(self, 1); 688 ck_assert(r); 689 r = self->f->equalUint64(self, 0); 690 ck_assert(!r); 691 // empty smallInt 692 freeO(self); 693 r = self->f->equalUint64(self, 2); 694 ck_assert(!r); 695 terminateO(self); 696 697 } 698 699 700 void equalSmallIntSmallBoolT(void) { 701 702 bool r; 703 smallIntt* self = allocSmallInt(1); 704 smallBoolt* p2 = allocSmallBool(true); 705 706 r = self->f->equalSmallBool(self, p2); 707 ck_assert(r); 708 setValO(p2, false); 709 r = self->f->equalSmallBool(self, p2); 710 ck_assert(!r); 711 // empty p2 712 freeO(p2); 713 r = self->f->equalSmallBool(self, p2); 714 ck_assert(!r); 715 // NULL parameter 716 r = self->f->equalSmallBool(self, null); 717 ck_assert(!r); 718 // empty smallInt 719 freeO(self); 720 r = self->f->equalSmallBool(self, p2); 721 ck_assert(!r); 722 terminateO(p2); 723 terminateO(self); 724 725 } 726 727 728 void equalSmallIntSmallBytesT(void) { 729 730 bool r; 731 smallIntt* self = allocSmallInt(1); 732 smallBytest* p2 = allocSmallBytes("1", sizeof("1")); 733 734 r = self->f->equalSmallBytes(self, p2); 735 ck_assert(r); 736 p2->f->set(p2, "false", sizeof("false")); 737 r = self->f->equalSmallBytes(self, p2); 738 ck_assert(!r); 739 p2->f->set(p2, "qwe", sizeof("qwe")); 740 r = self->f->equalSmallBytes(self, p2); 741 ck_assert(!r); 742 // without 0 at string end 743 p2->f->set(p2, "qwe", strlen("qwe")); 744 r = self->f->equalSmallBytes(self, p2); 745 ck_assert(!r); 746 // empty p2 747 freeO(p2); 748 r = self->f->equalSmallBytes(self, p2); 749 ck_assert(!r); 750 // NULL parameter 751 r = self->f->equalSmallBytes(self, null); 752 ck_assert(!r); 753 // empty smallInt 754 freeO(self); 755 r = self->f->equalSmallBytes(self, p2); 756 ck_assert(!r); 757 terminateO(p2); 758 terminateO(self); 759 760 } 761 762 763 void equalSmallIntSmallDoubleT(void) { 764 765 bool r; 766 smallIntt* self = allocSmallInt(1); 767 smallDoublet* p2 = allocSmallDouble(1); 768 769 r = self->f->equalSmallDouble(self, p2); 770 ck_assert(r); 771 setValO(p2, 1.5); 772 r = self->f->equalSmallDouble(self, p2); 773 ck_assert(!r); 774 // empty p2 775 freeO(p2); 776 r = self->f->equalSmallDouble(self, p2); 777 ck_assert(!r); 778 // NULL parameter 779 r = self->f->equalSmallDouble(self, null); 780 ck_assert(!r); 781 // empty smallInt 782 freeO(self); 783 r = self->f->equalSmallDouble(self, p2); 784 ck_assert(!r); 785 terminateO(p2); 786 terminateO(self); 787 788 } 789 790 791 void equalSmallIntT(void) { 792 793 bool r; 794 smallIntt* self = allocSmallInt(1); 795 smallIntt* p2 = allocSmallInt(1); 796 797 r = self->f->equal(self, p2); 798 ck_assert(r); 799 setValO(p2, 2); 800 r = self->f->equal(self, p2); 801 ck_assert(!r); 802 // empty p2 803 setValO(p2, 1); 804 freeO(p2); 805 r = self->f->equal(self, p2); 806 ck_assert(!r); 807 // NULL parameter 808 r = self->f->equal(self, null); 809 ck_assert(!r); 810 // empty smallInt 811 freeO(self); 812 r = self->f->equal(self, p2); 813 ck_assert(!r); 814 terminateO(p2); 815 terminateO(self); 816 817 } 818 819 820 void equalSmallIntSmallJsonT(void) { 821 822 bool r; 823 smallIntt* self = allocSmallInt(1); 824 smallJsont* p2 = allocSmallJson(); 825 826 r = self->f->equalSmallJson(self, p2); 827 ck_assert(!r); 828 // non json paramenter 829 terminateO(p2); 830 p2 = (smallJsont*) allocSmallBool(true); 831 r = self->f->equalSmallJson(self, p2); 832 terminateO(p2); 833 ck_assert(!r); 834 // NULL parameter 835 r = self->f->equalSmallJson(self, null); 836 ck_assert(!r); 837 terminateO(self); 838 839 } 840 841 842 void equalSmallIntSmallStringT(void) { 843 844 bool r; 845 smallIntt* self = allocSmallInt(1); 846 smallStringt* p2 = allocSmallString("1"); 847 848 r = self->f->equalSmallString(self, p2); 849 ck_assert(r); 850 setValO(p2, "qwe"); 851 r = self->f->equalSmallString(self, p2); 852 ck_assert(!r); 853 // empty p2 854 setValO(p2, "1"); 855 freeO(p2); 856 r = self->f->equalSmallString(self, p2); 857 ck_assert(!r); 858 // NULL parameter 859 r = self->f->equalSmallString(self, null); 860 ck_assert(!r); 861 // empty smallInt 862 freeO(self); 863 r = self->f->equalSmallString(self, p2); 864 ck_assert(!r); 865 terminateO(p2); 866 terminateO(self); 867 868 } 869 870 871 void readFileSmallIntT(void) { 872 873 smallIntt* r; 874 smallIntt *self = allocSmallInt(1); 875 const char *filePath = "smallInt.bin"; 876 877 writeFileO(self, filePath); 878 r = readFileO(self, filePath); 879 ck_assert_ptr_ne(r, null); 880 char *s = toStringO(r); 881 ck_assert_str_eq(s, "1"); 882 free(s); 883 // empty smallInt 884 freeO(self); 885 r = readFileO(self, filePath); 886 ck_assert_ptr_ne(r, null); 887 s = toStringO(r); 888 ck_assert_str_eq(s, "1"); 889 free(s); 890 rmAll(filePath); 891 // non existing file 892 r = readFileO(self, "nonexistingfile"); 893 ck_assert_ptr_eq(r, null); 894 // non double file 895 FILE *f = fopen("empty.file", "w"); 896 fclose(f); 897 r = readFileO(self, "empty.file"); 898 rmAll("empty.file"); 899 ck_assert_ptr_eq(r, null); 900 // blank file path 901 r = readFileO(self, " "); 902 ck_assert_ptr_eq(r, null); 903 terminateO(self); 904 905 } 906 907 908 void readFileSmallJsonSmallIntT(void) { 909 910 smallIntt* r; 911 smallIntt *self = allocSmallInt(1); 912 smallJsont *filePath = allocSmallJson(); 913 setTopSO(filePath, "smallInt.bin"); 914 915 writeFileO(self, sjGet(filePath)); 916 r = self->f->readFileSmallJson(self, filePath); 917 ck_assert_ptr_ne(r, null); 918 char *s = toStringO(r); 919 ck_assert_str_eq(s, "1"); 920 free(s); 921 // empty smallInt 922 freeO(self); 923 r = self->f->readFileSmallJson(self, filePath); 924 ck_assert_ptr_ne(r, null); 925 s = toStringO(r); 926 ck_assert_str_eq(s, "1"); 927 free(s); 928 rmAll(sjGet(filePath)); 929 // non existing file 930 freeO(filePath); 931 setTopSO(filePath, "nonexistingfile"); 932 r = self->f->readFileSmallJson(self, filePath); 933 ck_assert_ptr_eq(r, null); 934 // non bool file 935 FILE *f = fopen("empty.file", "w"); 936 fclose(f); 937 freeO(filePath); 938 setTopSO(filePath, "empty.file"); 939 r = self->f->readFileSmallJson(self, filePath); 940 rmAll("empty.file"); 941 ck_assert_ptr_eq(r, null); 942 // blank file path 943 freeO(filePath); 944 setTopSO(filePath, " "); 945 r = self->f->readFileSmallJson(self, filePath); 946 ck_assert_ptr_eq(r, null); 947 // non string json 948 freeO(filePath); 949 setTopIntO(filePath, 101); 950 r = self->f->readFileSmallJson(self, filePath); 951 ck_assert_ptr_eq(r, null); 952 terminateO(filePath); 953 // non smallJson object 954 filePath = (smallJsont*)allocSmallBool(true); 955 r = self->f->readFileSmallJson(self, filePath); 956 ck_assert_ptr_eq(r, null); 957 // NULL path 958 r = self->f->readFileSmallJson(self, null); 959 ck_assert_ptr_eq(r, null); 960 terminateO(filePath); 961 terminateO(self); 962 963 } 964 965 966 void readFileSmallStringSmallIntT(void) { 967 968 smallIntt* r; 969 smallIntt *self = allocSmallInt(1); 970 smallStringt *filePath = allocSmallString("smallInt.bin"); 971 972 writeFileO(self, ssGet(filePath)); 973 r = self->f->readFileSmallString(self, filePath); 974 ck_assert_ptr_ne(r, null); 975 char *s = toStringO(r); 976 ck_assert_str_eq(s, "1"); 977 free(s); 978 // empty smallInt 979 freeO(self); 980 r = self->f->readFileSmallString(self, filePath); 981 ck_assert_ptr_ne(r, null); 982 s = toStringO(r); 983 ck_assert_str_eq(s, "1"); 984 free(s); 985 rmAll(ssGet(filePath)); 986 // non existing file 987 setValO(filePath, "nonexistingfile"); 988 r = self->f->readFileSmallString(self, filePath); 989 ck_assert_ptr_eq(r, null); 990 // non bool file 991 FILE *f = fopen("empty.file", "w"); 992 fclose(f); 993 setValO(filePath, "empty.file"); 994 r = self->f->readFileSmallString(self, filePath); 995 rmAll("empty.file"); 996 ck_assert_ptr_eq(r, null); 997 // blank file path 998 setValO(filePath, " "); 999 r = self->f->readFileSmallString(self, filePath); 1000 ck_assert_ptr_eq(r, null); 1001 terminateO(filePath); 1002 // non smallString object 1003 filePath = (smallStringt*)allocSmallBool(true); 1004 r = self->f->readFileSmallString(self, filePath); 1005 ck_assert_ptr_eq(r, null); 1006 // NULL path 1007 r = self->f->readFileSmallString(self, null); 1008 ck_assert_ptr_eq(r, null); 1009 terminateO(filePath); 1010 terminateO(self); 1011 1012 } 1013 1014 1015 void readStreamSmallIntT(void) { 1016 1017 smallIntt* r; 1018 smallIntt *self = allocSmallInt(1); 1019 FILE *fp; 1020 const char *filePath = "smallInt.bin"; 1021 1022 writeFileO(self, filePath); 1023 fp = fopen("smallInt.bin", "r"); 1024 r = readStreamO(self, fp); 1025 ck_assert_ptr_ne(r, null); 1026 fclose(fp); 1027 char *s = toStringO(r); 1028 ck_assert_str_eq(s, "1"); 1029 free(s); 1030 // empty smallInt 1031 freeO(self); 1032 fp = fopen("smallInt.bin", "r"); 1033 r = readStreamO(self, fp); 1034 ck_assert_ptr_ne(r, null); 1035 fclose(fp); 1036 s = toStringO(r); 1037 ck_assert_str_eq(s, "1"); 1038 free(s); 1039 rmAll(filePath); 1040 // non existing file 1041 r = readStreamO(self, null); 1042 ck_assert_ptr_eq(r, null); 1043 // non bool file 1044 FILE *f = fopen("empty.file", "w"); 1045 fclose(f); 1046 fp = fopen("empty.file", "r"); 1047 r = readStreamO(self, fp); 1048 rmAll("empty.file"); 1049 ck_assert_ptr_eq(r, null); 1050 fclose(fp); 1051 terminateO(self); 1052 1053 } 1054 1055 1056 void writeFileSmallIntT(void) { 1057 1058 int r; 1059 smallIntt *self = allocSmallInt(1); 1060 const char *filePath = "smallInt.bin"; 1061 1062 r = writeFileO(self, filePath); 1063 ck_assert_int_eq(r, 1); 1064 freeO(self); 1065 smallIntt *r2 = readFileO(self, filePath); 1066 ck_assert_ptr_ne(r2, null); 1067 char *s = toStringO(r2); 1068 ck_assert_str_eq(s, "1"); 1069 free(s); 1070 // non writable path 1071 r = writeFileO(self, "/nonexisting/readonly"); 1072 ck_assert_int_eq(r, 0); 1073 // blank path 1074 r = writeFileO(self, " "); 1075 ck_assert_int_eq(r, 0); 1076 // null path 1077 r = writeFileO(self, null); 1078 ck_assert_int_eq(r, 0); 1079 // empty smallInt 1080 freeO(self); 1081 r = writeFileO(self, filePath); 1082 ck_assert_int_eq(r, 0); 1083 terminateO(self); 1084 rmAll("smallInt.bin"); 1085 1086 } 1087 1088 1089 void writeFileSmallJsonSmallIntT(void) { 1090 1091 int r; 1092 smallIntt *self = allocSmallInt(1); 1093 smallJsont *filePath = allocSmallJson(); 1094 setTopSO(filePath, "smallInt.bin"); 1095 1096 r = self->f->writeFileSmallJson(self, filePath); 1097 ck_assert_int_eq(r, 1); 1098 freeO(self); 1099 smallIntt *r2 = readFileO(self, sjGet(filePath)); 1100 ck_assert_ptr_ne(r2, null); 1101 char *s = toStringO(r2); 1102 ck_assert_str_eq(s, "1"); 1103 free(s); 1104 // non writable path 1105 freeO(filePath); 1106 setTopSO(filePath, "/nonexistingfile/readonly"); 1107 r = self->f->writeFileSmallJson(self, filePath); 1108 ck_assert_int_eq(r, 0); 1109 // blank path 1110 freeO(filePath); 1111 setTopSO(filePath, " "); 1112 r = self->f->writeFileSmallJson(self, filePath); 1113 ck_assert_int_eq(r, 0); 1114 // null path 1115 r = self->f->writeFileSmallJson(self, null); 1116 ck_assert_int_eq(r, 0); 1117 // empty smallInt 1118 freeO(self); 1119 freeO(filePath); 1120 setTopSO(filePath, "smallInt.bin"); 1121 r = self->f->writeFileSmallJson(self, filePath); 1122 ck_assert_int_eq(r, 0); 1123 // non string json 1124 freeO(filePath); 1125 setTopIntO(filePath, 101); 1126 r = self->f->writeFileSmallJson(self, filePath); 1127 ck_assert_int_eq(r, 0); 1128 terminateO(filePath); 1129 // non smallJson object 1130 filePath = (smallJsont*)allocSmallBool(true); 1131 r = self->f->writeFileSmallJson(self, filePath); 1132 ck_assert_int_eq(r, 0); 1133 terminateO(filePath); 1134 terminateO(self); 1135 rmAll("smallInt.bin"); 1136 1137 } 1138 1139 1140 void writeFileSmallStringSmallIntT(void) { 1141 1142 int r; 1143 smallIntt *self = allocSmallInt(1); 1144 smallStringt *filePath = allocSmallString("smallInt.bin"); 1145 1146 r = self->f->writeFileSmallString(self, filePath); 1147 ck_assert_int_eq(r, 1); 1148 freeO(self); 1149 smallIntt *r2 = readFileO(self, ssGet(filePath)); 1150 ck_assert_ptr_ne(r2, null); 1151 char *s = toStringO(r2); 1152 ck_assert_str_eq(s, "1"); 1153 free(s); 1154 // non writable path 1155 setValO(filePath, "/nonexistingfile/readonly"); 1156 r = self->f->writeFileSmallString(self, filePath); 1157 ck_assert_int_eq(r, 0); 1158 // blank path 1159 setValO(filePath, " "); 1160 r = self->f->writeFileSmallString(self, filePath); 1161 ck_assert_int_eq(r, 0); 1162 // null path 1163 r = self->f->writeFileSmallString(self, null); 1164 ck_assert_int_eq(r, 0); 1165 // empty smallInt 1166 freeO(self); 1167 setValO(filePath, "smallInt.bin"); 1168 r = self->f->writeFileSmallString(self, filePath); 1169 ck_assert_int_eq(r, 0); 1170 terminateO(filePath); 1171 // non smallString object 1172 filePath = (smallStringt*)allocSmallBool(true); 1173 r = self->f->writeFileSmallString(self, filePath); 1174 ck_assert_int_eq(r, 0); 1175 terminateO(filePath); 1176 terminateO(self); 1177 rmAll("smallInt.bin"); 1178 1179 } 1180 1181 1182 void writeStreamSmallIntT(void) { 1183 1184 int r; 1185 smallIntt *self = allocSmallInt(1); 1186 FILE *fp; 1187 const char *filePath = "smallInt.bin"; 1188 1189 fp = fopen("smallInt.bin", "w"); 1190 r = writeStreamO(self, fp); 1191 ck_assert_int_eq(r, 1); 1192 fclose(fp); 1193 freeO(self); 1194 smallIntt *r2 = readFileO(self, filePath); 1195 ck_assert_ptr_ne(r2, null); 1196 char *s = toStringO(r2); 1197 ck_assert_str_eq(s, "1"); 1198 free(s); 1199 // null file 1200 r = writeStreamO(self, null); 1201 ck_assert_int_eq(r, 0); 1202 // empty smallInt 1203 freeO(self); 1204 fp = fopen("smallInt.bin", "w"); 1205 r = writeStreamO(self, fp); 1206 ck_assert_int_eq(r, 0); 1207 fclose(fp); 1208 terminateO(self); 1209 rmAll("smallInt.bin"); 1210 1211 } 1212 1213 1214 void appendFileSmallIntT(void) { 1215 1216 int r; 1217 smallIntt *self = allocSmallInt(1); 1218 const char *filePath = "smallInt.bin"; 1219 1220 FILE *f = fopen(filePath, "w"); 1221 fclose(f); 1222 r = appendFileO(self, filePath); 1223 ck_assert_int_eq(r, 1); 1224 freeO(self); 1225 smallIntt *r2 = readFileO(self, filePath); 1226 ck_assert_ptr_ne(r2, null); 1227 char *s = toStringO(r2); 1228 ck_assert_str_eq(s, "1"); 1229 free(s); 1230 // non existing file 1231 r = appendFileO(self, "/nonexisting/readonly"); 1232 ck_assert_int_eq(r, 0); 1233 // blank path 1234 r = appendFileO(self, " "); 1235 ck_assert_int_eq(r, 0); 1236 // null path 1237 r = appendFileO(self, null); 1238 ck_assert_int_eq(r, 0); 1239 // empty smallInt 1240 freeO(self); 1241 r = appendFileO(self, filePath); 1242 ck_assert_int_eq(r, 0); 1243 terminateO(self); 1244 rmAll("smallInt.bin"); 1245 1246 } 1247 1248 1249 void appendFileSmallStringSmallIntT(void) { 1250 1251 int r; 1252 smallIntt *self = allocSmallInt(1); 1253 smallStringt *filePath = allocSmallString("smallInt.bin"); 1254 1255 FILE *f = fopen(ssGet(filePath), "w"); 1256 fclose(f); 1257 r = appendFileSmallStringO(self, filePath); 1258 ck_assert_int_eq(r, 1); 1259 freeO(self); 1260 smallIntt *r2 = readFileO(self, ssGet(filePath)); 1261 ck_assert_ptr_ne(r2, null); 1262 char *s = toStringO(r2); 1263 ck_assert_str_eq(s, "1"); 1264 free(s); 1265 // non existing file 1266 setValO(filePath, "/nonexisting/readonly"); 1267 r = appendFileSmallStringO(self, filePath); 1268 ck_assert_int_eq(r, 0); 1269 // blank path 1270 setValO(filePath, " "); 1271 r = appendFileSmallStringO(self, filePath); 1272 ck_assert_int_eq(r, 0); 1273 // null path 1274 r = appendFileSmallStringO(self, null); 1275 ck_assert_int_eq(r, 0); 1276 // empty smallInt 1277 freeO(self); 1278 setValO(filePath, "smallInt.bin"); 1279 r = appendFileSmallStringO(self, filePath); 1280 ck_assert_int_eq(r, 0); 1281 terminateO(filePath); 1282 terminateO(self); 1283 rmAll("smallInt.bin"); 1284 1285 } 1286 1287 1288 void duplicateSmallIntGT(void) { 1289 1290 smallIntt* r; 1291 smallIntt *self = allocSmallInt(1); 1292 1293 r = duplicateSmallIntG(self); 1294 char *s = toStringO(r); 1295 ck_assert_str_eq(s, "1"); 1296 free(s); 1297 terminateO(r); 1298 terminateO(self); 1299 1300 } 1301 1302 1303 void freeSmallIntGT(void) { 1304 1305 smallIntt *self = allocSmallInt(1); 1306 1307 freeSmallIntG(self); 1308 char *s = toStringO(self); 1309 ck_assert_ptr_eq(s, null); 1310 terminateO(self); 1311 1312 } 1313 1314 1315 void getIntSmallIntGT(void) { 1316 1317 int64_t r; 1318 smallIntt *self = allocSmallInt(1); 1319 1320 r = getIntSmallIntG(self, 0, 0); 1321 ck_assert_int_eq(r, 1); 1322 terminateO(self); 1323 1324 } 1325 1326 1327 void getIntPSmallIntGT(void) { 1328 1329 int64_t* r; 1330 smallIntt *self = allocSmallInt(1); 1331 1332 r = getIntPSmallIntG(self, null, 0); 1333 ck_assert_ptr_ne(r, null); 1334 ck_assert_int_eq(*r, 1); 1335 terminateO(self); 1336 1337 } 1338 1339 1340 void getInt32SmallIntGT(void) { 1341 1342 int32_t r; 1343 smallIntt *self = allocSmallInt(1); 1344 1345 r = getInt32SmallIntG(self, 0, 0); 1346 ck_assert_int_eq(r, 1); 1347 terminateO(self); 1348 1349 } 1350 1351 1352 void getInt32PSmallIntGT(void) { 1353 1354 int32_t* r; 1355 smallIntt *self = allocSmallInt(1); 1356 1357 r = getInt32PSmallIntG(self, null, 0); 1358 ck_assert_ptr_ne(r, null); 1359 ck_assert_int_eq(*r, 1); 1360 terminateO(self); 1361 1362 } 1363 1364 1365 void getUintSmallIntGT(void) { 1366 1367 uint64_t r; 1368 smallIntt *self = allocSmallInt(1); 1369 1370 r = getUintSmallIntG(self, 0, 0); 1371 ck_assert_int_eq(r, 1); 1372 terminateO(self); 1373 1374 } 1375 1376 1377 void getUintPSmallIntGT(void) { 1378 1379 uint64_t* r; 1380 smallIntt *self = allocSmallInt(1); 1381 1382 r = getUintPSmallIntG(self, null, 0); 1383 ck_assert_ptr_ne(r, null); 1384 ck_assert_int_eq(*r, 1); 1385 terminateO(self); 1386 1387 } 1388 1389 1390 void getUint32SmallIntGT(void) { 1391 1392 uint32_t r; 1393 smallIntt *self = allocSmallInt(1); 1394 1395 r = getUint32SmallIntG(self, 0, 0); 1396 ck_assert_int_eq(r, 1); 1397 terminateO(self); 1398 1399 } 1400 1401 1402 void getUint32PSmallIntGT(void) { 1403 1404 uint32_t* r; 1405 smallIntt *self = allocSmallInt(1); 1406 1407 r = getUint32PSmallIntG(self, null, 0); 1408 ck_assert_ptr_ne(r, null); 1409 ck_assert_int_eq(*r, 1); 1410 terminateO(self); 1411 1412 } 1413 1414 1415 void setBoolSmallIntGT(void) { 1416 1417 smallIntt* r; 1418 smallIntt* self = allocSmallInt(0); 1419 1420 r = setBoolSmallIntG(self, true); 1421 ck_assert_ptr_ne(r, null); 1422 int64_t r2 = getIntSmallIntG(self, 0, 0); 1423 ck_assert_int_eq(r2, 1); 1424 terminateO(self); 1425 1426 } 1427 1428 1429 void setDoubleSmallIntGT(void) { 1430 1431 smallIntt* r; 1432 smallIntt* self = allocSmallInt(1); 1433 1434 r = setDoubleSmallIntG(self, 1.5); 1435 ck_assert_ptr_ne(r, null); 1436 int64_t r2 = getIntSmallIntG(self, 0, 0); 1437 ck_assert_int_eq(r2, 1); 1438 terminateO(self); 1439 1440 } 1441 1442 1443 void setInt32SmallIntGT(void) { 1444 1445 smallIntt* r; 1446 smallIntt* self = allocSmallInt(1); 1447 1448 r = setInt32SmallIntG(self, 2); 1449 ck_assert_ptr_ne(r, null); 1450 int64_t r2 = getIntSmallIntG(self, 0, 0); 1451 ck_assert_int_eq(r2, 2); 1452 terminateO(self); 1453 1454 } 1455 1456 1457 void setUint32SmallIntGT(void) { 1458 1459 smallIntt* r; 1460 smallIntt* self = allocSmallInt(1); 1461 1462 r = setUint32SmallIntG(self, 2); 1463 ck_assert_ptr_ne(r, null); 1464 int64_t r2 = getIntSmallIntG(self, 0, 0); 1465 ck_assert_int_eq(r2, 2); 1466 terminateO(self); 1467 1468 } 1469 1470 1471 void setUint64SmallIntGT(void) { 1472 1473 smallIntt* r; 1474 smallIntt* self = allocSmallInt(1); 1475 1476 r = setUint64SmallIntG(self, 2); 1477 ck_assert_ptr_ne(r, null); 1478 int64_t r2 = getIntSmallIntG(self, 0, 0); 1479 ck_assert_int_eq(r2, 2); 1480 terminateO(self); 1481 1482 } 1483 1484 1485 void setSSmallIntGT(void) { 1486 1487 smallIntt* r; 1488 smallIntt* self = allocSmallInt(1); 1489 1490 r = setSSmallIntG(self, "2"); 1491 ck_assert_ptr_ne(r, null); 1492 int64_t r2 = getIntSmallIntG(self, 0, 0); 1493 ck_assert_int_eq(r2, 2); 1494 terminateO(self); 1495 1496 } 1497 1498 1499 void setSmallBoolSmallIntGT(void) { 1500 1501 smallIntt* r; 1502 smallIntt* self = allocSmallInt(0); 1503 smallBoolt* p2 = allocSmallBool(true); 1504 1505 r = setSmallBoolSmallIntG(self, p2); 1506 ck_assert_ptr_ne(r, null); 1507 terminateO(p2); 1508 int64_t r2 = getIntSmallIntG(self, 0, 0); 1509 ck_assert_int_eq(r2, 1); 1510 terminateO(self); 1511 1512 } 1513 1514 1515 void setSmallDoubleSmallIntGT(void) { 1516 1517 smallIntt* r; 1518 smallIntt* self = allocSmallInt(1); 1519 smallDoublet* p2 = allocSmallDouble(2.5); 1520 1521 r = setSmallDoubleSmallIntG(self, p2); 1522 ck_assert_ptr_ne(r, null); 1523 terminateO(p2); 1524 int64_t r2 = getIntSmallIntG(self, 0, 0); 1525 ck_assert_int_eq(r2, 2); 1526 terminateO(self); 1527 1528 } 1529 1530 1531 void setSmallIntSmallIntGT(void) { 1532 1533 smallIntt* r; 1534 smallIntt* self = allocSmallInt(1); 1535 smallIntt* p2 = allocSmallInt(2); 1536 1537 r = setSmallIntSmallIntG(self, p2); 1538 ck_assert_ptr_ne(r, null); 1539 terminateO(p2); 1540 double r2 = getIntSmallIntG(self, 0, 0); 1541 ck_assert_int_eq(r2, 2); 1542 terminateO(self); 1543 1544 } 1545 1546 1547 void setSmallJsonSmallIntGT(void) { 1548 1549 smallIntt* r; 1550 smallIntt* self = allocSmallInt(1); 1551 smallJsont* p2 = allocSmallJson(); 1552 setTopIntO(p2, 2); 1553 1554 r = setSmallJsonSmallIntG(self, p2); 1555 ck_assert_ptr_ne(r, null); 1556 terminateO(p2); 1557 int64_t r2 = getIntSmallIntG(self, 0, 0); 1558 ck_assert_int_eq(r2, 2); 1559 terminateO(self); 1560 1561 } 1562 1563 1564 void setSmallStringSmallIntGT(void) { 1565 1566 smallIntt* r; 1567 smallIntt* self = allocSmallInt(1); 1568 smallStringt* p2 = allocSmallString("2.5"); 1569 1570 r = setSmallStringSmallIntG(self, p2); 1571 ck_assert_ptr_ne(r, null); 1572 terminateO(p2); 1573 double r2 = getIntSmallIntG(self, 0, 0); 1574 ck_assert_int_eq(r2, 2); 1575 terminateO(self); 1576 1577 } 1578 1579 1580 void equalSmallIntChaGT(void) { 1581 1582 bool r; 1583 smallIntt* self = allocSmallInt(1); 1584 1585 r = equalSmallIntChaG(self, '1'); 1586 ck_assert(r); 1587 terminateO(self); 1588 1589 } 1590 1591 1592 void equalSmallIntCharGT(void) { 1593 1594 bool r; 1595 smallIntt* self = allocSmallInt(1); 1596 1597 r = equalSmallIntCharG(self, "1"); 1598 ck_assert(r); 1599 terminateO(self); 1600 1601 } 1602 1603 1604 void equalSmallIntBaseGT(void) { 1605 1606 bool r; 1607 smallIntt* self = allocSmallInt(1); 1608 baset* p2 = (baset*) allocSmallInt(1); 1609 1610 r = equalSmallIntBaseG(self, p2); 1611 ck_assert(r); 1612 terminateO(p2); 1613 terminateO(self); 1614 1615 } 1616 1617 1618 void equalSmallIntBoolGT(void) { 1619 1620 bool r; 1621 smallIntt* self = allocSmallInt(1); 1622 1623 r = equalSmallIntBoolG(self, true); 1624 ck_assert(r); 1625 terminateO(self); 1626 1627 } 1628 1629 1630 void equalSmallIntDoubleGT(void) { 1631 1632 bool r; 1633 smallIntt* self = allocSmallInt(1); 1634 1635 r = equalSmallIntDoubleG(self, 1); 1636 ck_assert(r); 1637 terminateO(self); 1638 1639 } 1640 1641 1642 void equalSmallIntInt64GT(void) { 1643 1644 bool r; 1645 smallIntt* self = allocSmallInt(1); 1646 1647 r = equalSmallIntInt64G(self, 1); 1648 ck_assert(r); 1649 terminateO(self); 1650 1651 } 1652 1653 1654 void equalSmallIntInt32GT(void) { 1655 1656 bool r; 1657 smallIntt* self = allocSmallInt(1); 1658 1659 r = equalSmallIntInt32G(self, 1); 1660 ck_assert(r); 1661 terminateO(self); 1662 1663 } 1664 1665 1666 void equalSmallIntUint32GT(void) { 1667 1668 bool r; 1669 smallIntt* self = allocSmallInt(1); 1670 1671 r = equalSmallIntUint32G(self, 1); 1672 ck_assert(r); 1673 terminateO(self); 1674 1675 } 1676 1677 1678 void equalSmallIntUint64GT(void) { 1679 1680 bool r; 1681 smallIntt* self = allocSmallInt(1); 1682 1683 r = equalSmallIntUint64G(self, 1); 1684 ck_assert(r); 1685 terminateO(self); 1686 1687 } 1688 1689 1690 void equalSmallIntSmallBoolGT(void) { 1691 1692 bool r; 1693 smallIntt* self = allocSmallInt(1); 1694 smallBoolt* p2 = allocSmallBool(true); 1695 1696 r = equalSmallIntSmallBoolG(self, p2); 1697 ck_assert(r); 1698 terminateO(p2); 1699 terminateO(self); 1700 1701 } 1702 1703 1704 void equalSmallIntSmallBytesGT(void) { 1705 1706 bool r; 1707 smallIntt* self = allocSmallInt(1); 1708 smallBytest* p2 = allocSmallBytes("1", sizeof("1")); 1709 1710 r = equalSmallIntSmallBytesG(self, p2); 1711 ck_assert(r); 1712 terminateO(p2); 1713 terminateO(self); 1714 1715 } 1716 1717 1718 void equalSmallIntSmallDoubleGT(void) { 1719 1720 bool r; 1721 smallIntt* self = allocSmallInt(1); 1722 smallDoublet* p2 = allocSmallDouble(1); 1723 1724 r = equalSmallIntSmallDoubleG(self, p2); 1725 ck_assert(r); 1726 terminateO(p2); 1727 terminateO(self); 1728 1729 } 1730 1731 1732 void equalSmallIntFGT(void) { 1733 1734 bool r; 1735 smallIntt* self = allocSmallInt(1); 1736 smallIntt* p2 = allocSmallInt(1); 1737 1738 r = equalSmallIntFG(self, p2); 1739 ck_assert(r); 1740 terminateO(p2); 1741 terminateO(self); 1742 1743 } 1744 1745 1746 void equalSmallIntSmallJsonGT(void) { 1747 1748 bool r; 1749 smallIntt* self = allocSmallInt(1); 1750 smallJsont* p2 = allocSmallJson(); 1751 setTopIntO(p2, 1); 1752 1753 r = equalSmallIntSmallJsonG(self, p2); 1754 ck_assert(r); 1755 terminateO(p2); 1756 terminateO(self); 1757 1758 } 1759 1760 1761 void equalSmallIntSmallStringGT(void) { 1762 1763 bool r; 1764 smallIntt* self = allocSmallInt(1); 1765 smallStringt* p2 = allocSmallString("1"); 1766 1767 r = equalSmallIntSmallStringG(self, p2); 1768 ck_assert(r); 1769 terminateO(p2); 1770 terminateO(self); 1771 1772 } 1773 1774 1775 void readFileSmallIntGT(void) { 1776 1777 smallIntt* r; 1778 smallIntt *self = allocSmallInt(1); 1779 const char *filePath = "smallInt.bin"; 1780 1781 writeFileO(self, filePath); 1782 r = readFileSmallIntG(self, filePath); 1783 ck_assert_ptr_ne(r, null); 1784 char *s = toStringO(r); 1785 ck_assert_str_eq(s, "1"); 1786 free(s); 1787 rmAll(filePath); 1788 terminateO(self); 1789 1790 } 1791 1792 1793 void readFileSmallJsonSmallIntGT(void) { 1794 1795 smallIntt* r; 1796 smallIntt *self = allocSmallInt(1); 1797 smallJsont *filePath = allocSmallJson(); 1798 setTopSO(filePath, "smallInt.bin"); 1799 1800 writeFileO(self, sjGet(filePath)); 1801 r = readFileSmallJsonSmallIntG(self, filePath); 1802 ck_assert_ptr_ne(r, null); 1803 char *s = toStringO(r); 1804 ck_assert_str_eq(s, "1"); 1805 free(s); 1806 rmAll(sjGet(filePath)); 1807 terminateO(filePath); 1808 terminateO(self); 1809 1810 } 1811 1812 1813 void readFileSmallStringSmallIntGT(void) { 1814 1815 smallIntt* r; 1816 smallIntt *self = allocSmallInt(1); 1817 smallStringt *filePath = allocSmallString("smallInt.bin"); 1818 1819 writeFileO(self, ssGet(filePath)); 1820 r = readFileSmallStringSmallIntG(self, filePath); 1821 ck_assert_ptr_ne(r, null); 1822 char *s = toStringO(r); 1823 ck_assert_str_eq(s, "1"); 1824 free(s); 1825 rmAll(ssGet(filePath)); 1826 terminateO(filePath); 1827 terminateO(self); 1828 1829 } 1830 1831 1832 void readStreamSmallIntGT(void) { 1833 1834 smallIntt* r; 1835 smallIntt *self = allocSmallInt(1); 1836 FILE *fp; 1837 const char *filePath = "smallInt.bin"; 1838 1839 writeFileO(self, filePath); 1840 fp = fopen(filePath, "r"); 1841 r = readStreamSmallIntG(self, fp); 1842 ck_assert_ptr_ne(r, null); 1843 fclose(fp); 1844 char *s = toStringO(r); 1845 ck_assert_str_eq(s, "1"); 1846 free(s); 1847 rmAll(filePath); 1848 terminateO(self); 1849 1850 } 1851 1852 1853 void writeFileSmallIntGT(void) { 1854 1855 int r; 1856 smallIntt *self = allocSmallInt(1); 1857 const char *filePath = "smallInt.bin"; 1858 1859 r = writeFileSmallIntG(self, filePath); 1860 ck_assert_int_eq(r, 1); 1861 freeO(self); 1862 smallIntt *r2 = readFileO(self, filePath); 1863 ck_assert_ptr_ne(r2, null); 1864 char *s = toStringO(r2); 1865 ck_assert_str_eq(s, "1"); 1866 free(s); 1867 rmAll(filePath); 1868 terminateO(self); 1869 1870 } 1871 1872 1873 void writeFileSmallJsonSmallIntGT(void) { 1874 1875 int r; 1876 smallIntt *self = allocSmallInt(1); 1877 smallJsont *filePath = allocSmallJson(); 1878 setTopSO(filePath, "smallInt.bin"); 1879 1880 r = writeFileSmallJsonSmallIntG(self, filePath); 1881 ck_assert_int_eq(r, 1); 1882 freeO(self); 1883 smallIntt *r2 = readFileO(self, sjGet(filePath)); 1884 ck_assert_ptr_ne(r2, null); 1885 char *s = toStringO(r2); 1886 ck_assert_str_eq(s, "1"); 1887 free(s); 1888 terminateO(filePath); 1889 terminateO(self); 1890 rmAll("smallInt.bin"); 1891 1892 } 1893 1894 1895 void writeFileSmallStringSmallIntGT(void) { 1896 1897 int r; 1898 smallIntt *self = allocSmallInt(1); 1899 smallStringt *filePath = allocSmallString("smallInt.bin"); 1900 1901 r = writeFileSmallStringSmallIntG(self, filePath); 1902 ck_assert_int_eq(r, 1); 1903 freeO(self); 1904 smallIntt *r2 = readFileO(self, ssGet(filePath)); 1905 ck_assert_ptr_ne(r2, null); 1906 char *s = toStringO(r2); 1907 ck_assert_str_eq(s, "1"); 1908 free(s); 1909 terminateO(filePath); 1910 terminateO(self); 1911 rmAll("smallInt.bin"); 1912 1913 } 1914 1915 1916 void writeStreamSmallIntGT(void) { 1917 1918 int r; 1919 smallIntt *self = allocSmallInt(1); 1920 FILE *fp; 1921 const char *filePath = "smallInt.bin"; 1922 1923 fp = fopen(filePath, "w"); 1924 r = writeStreamSmallIntG(self, fp); 1925 ck_assert_int_eq(r, 1); 1926 fclose(fp); 1927 freeO(self); 1928 smallIntt *r2 = readFileO(self, filePath); 1929 ck_assert_ptr_ne(r2, null); 1930 char *s = toStringO(r2); 1931 ck_assert_str_eq(s, "1"); 1932 free(s); 1933 terminateO(self); 1934 rmAll(filePath); 1935 1936 } 1937 1938 1939 void appendFileSmallIntFGT(void) { 1940 1941 int r; 1942 smallIntt *self = allocSmallInt(1); 1943 const char *filePath = "smallInt.bin"; 1944 1945 FILE *f = fopen(filePath, "w"); 1946 fclose(f); 1947 r = appendFileSmallIntFG(self, filePath); 1948 ck_assert_int_eq(r, 1); 1949 freeO(self); 1950 smallIntt *r2 = readFileO(self, filePath); 1951 ck_assert_ptr_ne(r2, null); 1952 char *s = toStringO(r2); 1953 ck_assert_str_eq(s, "1"); 1954 free(s); 1955 terminateO(self); 1956 rmAll("smallInt.bin"); 1957 1958 } 1959 1960 1961 void appendFileSmallStringSmallIntGT(void) { 1962 1963 int r; 1964 smallIntt *self = allocSmallInt(1); 1965 smallStringt *filePath = allocSmallString("smallInt.bin"); 1966 1967 FILE *f = fopen(ssGet(filePath), "w"); 1968 fclose(f); 1969 r = appendFileSmallStringSmallIntG(self, filePath); 1970 ck_assert_int_eq(r, 1); 1971 freeO(self); 1972 smallIntt *r2 = readFileO(self, ssGet(filePath)); 1973 ck_assert_ptr_ne(r2, null); 1974 char *s = toStringO(r2); 1975 ck_assert_str_eq(s, "1"); 1976 free(s); 1977 terminateO(filePath); 1978 terminateO(self); 1979 rmAll("smallInt.bin"); 1980 1981 } 1982 1983 1984 1985 1986 1987 1988 int main(int n UNUSED, char**v UNUSED) { 1989 // disable btrace to make the test run faster 1990 btraceDisable(); 1991 initiateSmallIntT(); 1992 initiateAllocateSmallIntT(); 1993 allocSmallIntT(); 1994 freeSmallIntT(); 1995 terminateSmallIntT(); 1996 toStringSmallIntT(); 1997 duplicateSmallIntT(); 1998 smashSmallIntT(); 1999 finishSmallIntT(); 2000 getSmallIntT(); 2001 setSmallIntT(); 2002 setBoolSmallIntT(); 2003 setDoubleSmallIntT(); 2004 setInt32SmallIntT(); 2005 setUint32SmallIntT(); 2006 setUint64SmallIntT(); 2007 setSSmallIntT(); 2008 setSmallBoolSmallIntT(); 2009 setSmallDoubleSmallIntT(); 2010 setSmallIntSmallIntT(); 2011 setSmallJsonSmallIntT(); 2012 setSmallStringSmallIntT(); 2013 getPSmallIntT(); 2014 equalSmallIntChaT(); 2015 equalSmallIntCharT(); 2016 equalSmallIntBaseT(); 2017 equalSmallIntBoolT(); 2018 equalSmallIntDoubleT(); 2019 equalSmallIntInt64T(); 2020 equalSmallIntInt32T(); 2021 equalSmallIntUint32T(); 2022 equalSmallIntUint64T(); 2023 equalSmallIntSmallBoolT(); 2024 equalSmallIntSmallBytesT(); 2025 equalSmallIntSmallDoubleT(); 2026 equalSmallIntT(); 2027 equalSmallIntSmallJsonT(); 2028 equalSmallIntSmallStringT(); 2029 readFileSmallIntT(); 2030 readFileSmallJsonSmallIntT(); 2031 readFileSmallStringSmallIntT(); 2032 readStreamSmallIntT(); 2033 writeFileSmallIntT(); 2034 writeFileSmallJsonSmallIntT(); 2035 writeFileSmallStringSmallIntT(); 2036 writeStreamSmallIntT(); 2037 appendFileSmallIntT(); 2038 appendFileSmallStringSmallIntT(); 2039 duplicateSmallIntGT(); 2040 freeSmallIntGT(); 2041 getIntSmallIntGT(); 2042 getIntPSmallIntGT(); 2043 getInt32SmallIntGT(); 2044 getInt32PSmallIntGT(); 2045 getUintSmallIntGT(); 2046 getUintPSmallIntGT(); 2047 getUint32SmallIntGT(); 2048 getUint32PSmallIntGT(); 2049 setBoolSmallIntGT(); 2050 setDoubleSmallIntGT(); 2051 setInt32SmallIntGT(); 2052 setUint32SmallIntGT(); 2053 setUint64SmallIntGT(); 2054 setSSmallIntGT(); 2055 setSmallBoolSmallIntGT(); 2056 setSmallDoubleSmallIntGT(); 2057 setSmallIntSmallIntGT(); 2058 setSmallJsonSmallIntGT(); 2059 setSmallStringSmallIntGT(); 2060 equalSmallIntChaGT(); 2061 equalSmallIntCharGT(); 2062 equalSmallIntBaseGT(); 2063 equalSmallIntBoolGT(); 2064 equalSmallIntDoubleGT(); 2065 equalSmallIntInt64GT(); 2066 equalSmallIntInt32GT(); 2067 equalSmallIntUint32GT(); 2068 equalSmallIntUint64GT(); 2069 equalSmallIntSmallBoolGT(); 2070 equalSmallIntSmallBytesGT(); 2071 equalSmallIntSmallDoubleGT(); 2072 equalSmallIntFGT(); 2073 equalSmallIntSmallJsonGT(); 2074 equalSmallIntSmallStringGT(); 2075 readFileSmallIntGT(); 2076 readFileSmallJsonSmallIntGT(); 2077 readFileSmallStringSmallIntGT(); 2078 readStreamSmallIntGT(); 2079 writeFileSmallIntGT(); 2080 writeFileSmallJsonSmallIntGT(); 2081 writeFileSmallStringSmallIntGT(); 2082 writeStreamSmallIntGT(); 2083 appendFileSmallIntFGT(); 2084 appendFileSmallStringSmallIntGT(); 2085 2086 finalizeSmallDict(); 2087 finalizeSmallArray(); 2088 finalizeSmallJson(); 2089 finalizeUndefined(); 2090 finalizeSmallBytes(); 2091 finalizeSmallBool(); 2092 finalizeSmallContainer(); 2093 finalizeSmallDouble(); 2094 finalizeSmallInt(); 2095 finalizeSmallString(); 2096 }