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