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