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