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