libsheepyCSmallJsonTestMem.c (1457247B)
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 createSJFT(void) { 29 30 smallJsont* r; 31 32 r = createSJ("a", "bb"); 33 ck_assert_ptr_ne(r, NULL); 34 char *s = toStringO(r); 35 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 36 free(s); 37 38 terminateO(r); 39 40 } 41 42 43 void getsoSmallJsonT(void) { 44 45 smallt* r; 46 smallJsont *self = allocG(rtSmallJsont); 47 48 // undefined 49 freeO(self); 50 createUndefined(u); 51 setTopO(self, (baset*)&u); 52 r = getsoO(self); 53 ck_assert_ptr_eq(r, self->topU); 54 // bool 55 freeO(self); 56 setTopBoolO(self, true); 57 r = getsoO(self); 58 ck_assert_ptr_eq(r, self->topB); 59 // double 60 freeO(self); 61 setTopDoubleO(self, 1); 62 r = getsoO(self); 63 ck_assert_ptr_eq(r, self->topD); 64 // int 65 freeO(self); 66 setTopIntO(self, 1); 67 r = getsoO(self); 68 ck_assert_ptr_eq(r, self->topI); 69 // string 70 freeO(self); 71 setTopSO(self, "qwe"); 72 r = getsoO(self); 73 ck_assert_ptr_eq(r, self->topS); 74 // dict 75 freeO(self); 76 self->f->setS(self, "qwe", "asd"); 77 r = getsoO(self); 78 ck_assert_ptr_eq(r, self->top); 79 // array 80 freeO(self); 81 pushG(self, 1); 82 r = getsoO(self); 83 ck_assert_ptr_eq(r, self->topA); 84 terminateO(self); 85 86 } 87 88 89 void setsoSmallJsonT(void) { 90 91 smallJsont *self = allocG(rtSmallJsont); 92 smallt *so; 93 94 createSmallJson(src); 95 // undefined 96 createUndefined(u); 97 setTopO(&src, (baset*)&u); 98 so = getsoO(&src); 99 resetO(&src); 100 setsoO(self, so); 101 ck_assert_ptr_eq(so, self->topU); 102 freeO(self); 103 // bool 104 setTopBoolO(&src, true); 105 so = getsoO(&src); 106 resetO(&src); 107 setsoO(self, so); 108 ck_assert_ptr_eq(so, self->topB); 109 freeO(self); 110 // double 111 setTopDoubleO(&src, 1); 112 so = getsoO(&src); 113 resetO(&src); 114 setsoO(self, so); 115 ck_assert_ptr_eq(so, self->topD); 116 freeO(self); 117 // int 118 setTopIntO(&src, 1); 119 so = getsoO(&src); 120 resetO(&src); 121 setsoO(self, so); 122 ck_assert_ptr_eq(so, self->topI); 123 freeO(self); 124 // string 125 setTopSO(&src, "qwe"); 126 so = getsoO(&src); 127 resetO(&src); 128 setsoO(self, so); 129 ck_assert_ptr_eq(so, self->topS); 130 freeO(self); 131 // dict 132 createSmallDict(d); 133 (&d)->f->setS(&d, "1", "1"); 134 (&d)->f->setS(&d, "2", "2"); 135 char *as = null; 136 // reset test: free iterElement in d 137 iter(&d, E) { 138 as = toStringO(E); 139 break; 140 } 141 ck_assert_ptr_ne(as, null); 142 ck_assert_str_eq(as, "1"); 143 free(as); 144 so = (smallt*)getsoO(&d); 145 resetO(&d); 146 setsoO(self, so); 147 ck_assert_ptr_eq(so, self->top); 148 freeO(self); 149 // array 150 createSmallArray(a); 151 pushG(&a, 1); 152 pushG(&a, 2); 153 as = null; 154 // reset test: free iterElement in a 155 iter(&a, E) { 156 as = toStringO(E); 157 break; 158 } 159 ck_assert_str_eq(as, "1"); 160 free(as); 161 so = (smallt*)getsoO(&a); 162 resetO(&a); 163 setsoO(self, so); 164 ck_assert_ptr_eq(so, self->topA); 165 terminateO(self); 166 167 } 168 169 170 void mirrorSmallJsonT(void) { 171 172 smallJsont* r; 173 smallJsont *self = allocG(rtSmallJsont); 174 175 // dict 176 // empty self 177 r = mirrorO(self); 178 ck_assert_ptr_eq(r, null); 179 // non empty with iterator 180 self->f->setS(self, "1", "1"); 181 self->f->setS(self, "2", "2"); 182 char *as = null; 183 iter(self, E) { 184 as = toStringO(E); 185 break; 186 } 187 ck_assert_str_eq(as, "1"); 188 free(as); 189 r = mirrorO(self); 190 ck_assert_ptr_eq(r->top, self->top); 191 finishO(r); 192 freeO(self); 193 // array 194 // empty self 195 r = mirrorO(self); 196 ck_assert_ptr_eq(r, null); 197 // non empty with iterator 198 pushG(self, 1); 199 pushG(self, 2); 200 as = null; 201 iter(self, E) { 202 as = toStringO(E); 203 break; 204 } 205 ck_assert_str_eq(as, "1"); 206 free(as); 207 r = mirrorO(self); 208 ck_assert_ptr_eq(r->topA, self->topA); 209 finishO(r); 210 terminateO(self); 211 212 } 213 214 215 void setTopBoolSmallJsonT(void) { 216 217 smallJsont* r; 218 smallJsont *self = allocG(rtSmallJsont); 219 220 r = setTopBoolO(self, true); 221 ck_assert_ptr_ne(r, null); 222 char *s = toStringO(r); 223 ck_assert_str_eq(s, "true"); 224 free(s); 225 terminateO(self); 226 227 } 228 229 230 void setTopDoubleSmallJsonT(void) { 231 232 smallJsont* r; 233 smallJsont *self = allocG(rtSmallJsont); 234 235 r = setTopDoubleO(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 terminateO(self); 241 242 } 243 244 245 void setTopIntSmallJsonT(void) { 246 247 smallJsont* r; 248 smallJsont *self = allocG(rtSmallJsont); 249 250 r = setTopIntO(self, 2); 251 ck_assert_ptr_ne(r, null); 252 char *s = toStringO(r); 253 ck_assert_str_eq(s, "2"); 254 free(s); 255 terminateO(self); 256 257 } 258 259 260 void setTopStringSmallJsonT(void) { 261 262 smallJsont* r; 263 smallJsont *self = allocG(rtSmallJsont); 264 265 r = setTopStringO(self, "qwe"); 266 ck_assert_ptr_ne(r, null); 267 char *s = toStringO(r); 268 ck_assert_str_eq(s, "qwe"); 269 free(s); 270 // null 271 ck_assert_ptr_eq(setTopStringO(self, null), null); 272 terminateO(self); 273 274 } 275 276 277 void setTopCharSmallJsonT(void) { 278 279 smallJsont* r; 280 smallJsont *self = allocG(rtSmallJsont); 281 282 r = setTopCharO(self, 'X'); 283 ck_assert_ptr_ne(r, null); 284 char *s = toStringO(r); 285 ck_assert_str_eq(s, "X"); 286 free(s); 287 terminateO(self); 288 289 } 290 291 292 void setTopDictSmallJsonT(void) { 293 294 smallJsont* r; 295 smallJsont *self = allocG(rtSmallJsont); 296 smallDictt *value = allocSmallDict(); 297 298 r = setTopDictO(self, value); 299 ck_assert_ptr_ne(r, null); 300 finishG(value); 301 char *s = toStringO(r); 302 ck_assert_str_eq(s, "{}"); 303 free(s); 304 // non smallDict value 305 value = (smallDictt*) allocSmallInt(1); 306 ck_assert_ptr_eq(setTopDictO(self, value), null); 307 terminateO(value); 308 // null 309 ck_assert_ptr_eq(setTopDictO(self, null), null); 310 terminateO(self); 311 312 } 313 314 315 void setTopArraySmallJsonT(void) { 316 317 smallJsont* r; 318 smallJsont *self = allocG(rtSmallJsont); 319 smallArrayt *value = allocSmallArray(); 320 321 r = setTopArrayO(self, value); 322 ck_assert_ptr_ne(r, null); 323 finishG(value); 324 char *s = toStringO(r); 325 ck_assert_str_eq(s, "[]"); 326 free(s); 327 // non smallArray value 328 value = (smallArrayt*) allocSmallInt(1); 329 ck_assert_ptr_eq(setTopArrayO(self, value), null); 330 terminateO(value); 331 // null 332 ck_assert_ptr_eq(setTopArrayO(self, null), null); 333 terminateO(self); 334 335 } 336 337 338 void setTopArraycSmallJsonT(void) { 339 340 smallJsont* r; 341 smallJsont *self = allocG(rtSmallJsont); 342 char **value = listCreateS("a","bb"); 343 344 r = setTopArraycO(self, value); 345 ck_assert_ptr_ne(r, null); 346 listFreeS(value); 347 char *s = toStringO(r); 348 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 349 free(s); 350 // null 351 ck_assert_ptr_eq(setTopArraycO(self, null), null); 352 terminateO(self); 353 354 } 355 356 357 void setTopSmallBoolSmallJsonT(void) { 358 359 smallJsont* r; 360 smallJsont *self = allocG(rtSmallJsont); 361 smallBoolt *value = allocSmallBool(true); 362 363 r = setTopSmallBoolO(self, value); 364 ck_assert_ptr_ne(r, null); 365 finishG(value); 366 char *s = toStringO(r); 367 ck_assert_str_eq(s, "true"); 368 free(s); 369 // non smallBool value 370 value = (smallBoolt*) allocSmallInt(1); 371 ck_assert_ptr_eq(setTopSmallBoolO(self, value), null); 372 terminateO(value); 373 // null 374 ck_assert_ptr_eq(setTopSmallBoolO(self, null), null); 375 terminateO(self); 376 377 } 378 379 380 void setTopSmallDoubleSmallJsonT(void) { 381 382 smallJsont* r; 383 smallJsont *self = allocG(rtSmallJsont); 384 smallDoublet *value = allocSmallDouble(2); 385 386 r = setTopSmallDoubleO(self, value); 387 ck_assert_ptr_ne(r, null); 388 finishG(value); 389 char *s = toStringO(r); 390 ck_assert_str_eq(s, "2.000000e+00"); 391 free(s); 392 // non smallDouble value 393 value = (smallDoublet*) allocSmallInt(1); 394 ck_assert_ptr_eq(setTopSmallDoubleO(self, value), null); 395 terminateO(value); 396 // null 397 ck_assert_ptr_eq(setTopSmallDoubleO(self, null), null); 398 terminateO(self); 399 400 } 401 402 403 void setTopSmallIntSmallJsonT(void) { 404 405 smallJsont* r; 406 smallJsont *self = allocG(rtSmallJsont); 407 smallIntt *value = allocSmallInt(2); 408 409 r = setTopSmallIntO(self, value); 410 ck_assert_ptr_ne(r, null); 411 finishG(value); 412 char *s = toStringO(r); 413 ck_assert_str_eq(s, "2"); 414 free(s); 415 // non smallInt value 416 value = (smallIntt*) allocSmallBool(true); 417 ck_assert_ptr_eq(setTopSmallIntO(self, value), null); 418 terminateO(value); 419 // null 420 ck_assert_ptr_eq(setTopSmallIntO(self, null), null); 421 terminateO(self); 422 423 } 424 425 426 void setTopSmallJsonSmallJsonT(void) { 427 428 smallJsont* r; 429 smallJsont *self = allocG(rtSmallJsont); 430 smallJsont *value = allocSmallJson(); 431 432 r = self->f->setTopSmallJson(self, value); 433 ck_assert_ptr_ne(r, null); 434 finishG(value); 435 char *s = toStringO(r); 436 ck_assert_str_eq(s, "{}"); 437 free(s); 438 // non smallJson value 439 value = (smallJsont*) allocSmallInt(1); 440 ck_assert_ptr_eq(self->f->setTopSmallJson(self, value), null); 441 terminateO(value); 442 // null 443 ck_assert_ptr_eq(self->f->setTopSmallJson(self, null), null); 444 terminateO(self); 445 446 } 447 448 449 void setTopSmallStringSmallJsonT(void) { 450 451 smallJsont* r; 452 smallJsont *self = allocG(rtSmallJsont); 453 smallStringt *value = allocSmallString("qwe"); 454 455 r = setTopSmallStringO(self, value); 456 ck_assert_ptr_ne(r, null); 457 finishG(value); 458 char *s = toStringO(r); 459 ck_assert_str_eq(s, "qwe"); 460 free(s); 461 // non smallString value 462 value = (smallStringt*) allocSmallInt(1); 463 ck_assert_ptr_eq(setTopSmallStringO(self, value), null); 464 terminateO(value); 465 // null 466 ck_assert_ptr_eq(setTopSmallStringO(self, null), null); 467 terminateO(self); 468 469 } 470 471 472 void setTopNFreeSmallJsonT(void) { 473 474 smallJsont* r; 475 smallJsont *self = allocG(rtSmallJsont); 476 baset *value = (baset*)allocSmallInt(2); 477 478 r = setTopNFreeO(self, value); 479 ck_assert_ptr_ne(r, null); 480 char *s = toStringO(r); 481 ck_assert_str_eq(s, "2"); 482 free(s); 483 terminateO(self); 484 485 } 486 487 488 void setTopNFreeBoolSmallJsonT(void) { 489 490 smallJsont* r; 491 smallJsont *self = allocG(rtSmallJsont); 492 493 r = setTopNFreeBoolO(self, true); 494 ck_assert_ptr_ne(r, null); 495 char *s = toStringO(r); 496 ck_assert_str_eq(s, "true"); 497 free(s); 498 terminateO(self); 499 500 } 501 502 503 void setTopNFreeDoubleSmallJsonT(void) { 504 505 smallJsont* r; 506 smallJsont *self = allocG(rtSmallJsont); 507 508 r = setTopNFreeDoubleO(self, 2); 509 ck_assert_ptr_ne(r, null); 510 char *s = toStringO(r); 511 ck_assert_str_eq(s, "2.000000e+00"); 512 free(s); 513 terminateO(self); 514 515 } 516 517 518 void setTopNFreeIntSmallJsonT(void) { 519 520 smallJsont* r; 521 smallJsont *self = allocG(rtSmallJsont); 522 523 r = setTopNFreeIntO(self, 2); 524 ck_assert_ptr_ne(r, null); 525 char *s = toStringO(r); 526 ck_assert_str_eq(s, "2"); 527 free(s); 528 terminateO(self); 529 530 } 531 532 533 void setTopNFreeStringSmallJsonT(void) { 534 535 smallJsont* r; 536 smallJsont *self = allocG(rtSmallJsont); 537 char *value = strdup("qwe"); 538 539 r = setTopNFreeStringO(self, value); 540 ck_assert_ptr_ne(r, null); 541 char *s = toStringO(r); 542 ck_assert_str_eq(s, "qwe"); 543 free(s); 544 // null 545 ck_assert_ptr_eq(setTopNFreeStringO(self, null), null); 546 terminateO(self); 547 548 } 549 550 551 void setTopNFreeDictSmallJsonT(void) { 552 553 smallJsont* r; 554 smallJsont *self = allocG(rtSmallJsont); 555 smallDictt *value = allocSmallDict(); 556 557 r = setTopNFreeDictO(self, value); 558 ck_assert_ptr_ne(r, null); 559 char *s = toStringO(r); 560 ck_assert_str_eq(s, "{}"); 561 free(s); 562 // non smallDict value 563 value = (smallDictt*) allocSmallInt(1); 564 ck_assert_ptr_eq(setTopNFreeDictO(self, value), null); 565 terminateO(value); 566 // null 567 ck_assert_ptr_eq(setTopNFreeDictO(self, null), null); 568 terminateO(self); 569 570 } 571 572 573 void setTopNFreeArraySmallJsonT(void) { 574 575 smallJsont* r; 576 smallJsont *self = allocG(rtSmallJsont); 577 smallArrayt *value = allocSmallArray(); 578 579 r = setTopNFreeArrayO(self, value); 580 ck_assert_ptr_ne(r, null); 581 char *s = toStringO(r); 582 ck_assert_str_eq(s, "[]"); 583 free(s); 584 // non smallArray value 585 value = (smallArrayt*) allocSmallInt(1); 586 ck_assert_ptr_eq(setTopNFreeArrayO(self, value), null); 587 terminateO(value); 588 // null 589 ck_assert_ptr_eq(setTopNFreeArrayO(self, null), null); 590 terminateO(self); 591 592 } 593 594 595 void setTopNFreeArraycSmallJsonT(void) { 596 597 smallJsont* r; 598 smallJsont *self = allocG(rtSmallJsont); 599 char **value = listCreateS("a","bb"); 600 601 r = setTopNFreeArraycO(self, value); 602 ck_assert_ptr_ne(r, null); 603 char *s = toStringO(r); 604 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 605 free(s); 606 // null 607 ck_assert_ptr_eq(setTopNFreeArraycO(self, null), null); 608 terminateO(self); 609 610 } 611 612 613 void setTopNFreeSmallBoolSmallJsonT(void) { 614 615 smallJsont* r; 616 smallJsont *self = allocG(rtSmallJsont); 617 smallBoolt *value = allocSmallBool(true); 618 619 r = setTopNFreeSmallBoolO(self, value); 620 ck_assert_ptr_ne(r, null); 621 char *s = toStringO(r); 622 ck_assert_str_eq(s, "true"); 623 free(s); 624 // non smallBool value 625 value = (smallBoolt*) allocSmallInt(1); 626 ck_assert_ptr_eq(setTopNFreeSmallBoolO(self, value), null); 627 terminateO(value); 628 // null 629 ck_assert_ptr_eq(setTopNFreeSmallBoolO(self, null), null); 630 terminateO(self); 631 632 } 633 634 635 void setTopNFreeSmallDoubleSmallJsonT(void) { 636 637 smallJsont* r; 638 smallJsont *self = allocG(rtSmallJsont); 639 smallDoublet *value = allocSmallDouble(2); 640 641 r = setTopNFreeSmallDoubleO(self, value); 642 ck_assert_ptr_ne(r, null); 643 char *s = toStringO(r); 644 ck_assert_str_eq(s, "2.000000e+00"); 645 free(s); 646 // non smallDouble value 647 value = (smallDoublet*) allocSmallInt(1); 648 ck_assert_ptr_eq(setTopNFreeSmallDoubleO(self, value), null); 649 terminateO(value); 650 // null 651 ck_assert_ptr_eq(setTopNFreeSmallDoubleO(self, null), null); 652 terminateO(self); 653 654 } 655 656 657 void setTopNFreeSmallIntSmallJsonT(void) { 658 659 smallJsont* r; 660 smallJsont *self = allocG(rtSmallJsont); 661 smallIntt *value = allocSmallInt(2); 662 663 r = setTopNFreeSmallIntO(self, value); 664 ck_assert_ptr_ne(r, null); 665 char *s = toStringO(r); 666 ck_assert_str_eq(s, "2"); 667 free(s); 668 // non smallInt value 669 value = (smallIntt*) allocSmallBool(true); 670 ck_assert_ptr_eq(setTopNFreeSmallIntO(self, value), null); 671 terminateO(value); 672 // null 673 ck_assert_ptr_eq(setTopNFreeSmallIntO(self, null), null); 674 terminateO(self); 675 676 } 677 678 679 void setTopNFreeSmallJsonSmallJsonT(void) { 680 681 smallJsont* r; 682 smallJsont *self = allocG(rtSmallJsont); 683 smallJsont *value = allocSmallJson(); 684 685 r = self->f->setTopNFreeSmallJson(self, value); 686 ck_assert_ptr_ne(r, null); 687 char *s = toStringO(r); 688 ck_assert_str_eq(s, "{}"); 689 free(s); 690 // non smallJson value 691 value = (smallJsont*) allocSmallInt(1); 692 ck_assert_ptr_eq(self->f->setTopNFreeSmallJson(self, value), null); 693 terminateO(value); 694 // null 695 ck_assert_ptr_eq(self->f->setTopNFreeSmallJson(self, null), null); 696 terminateO(self); 697 698 } 699 700 701 void setTopNFreeSmallStringSmallJsonT(void) { 702 703 smallJsont* r; 704 smallJsont *self = allocG(rtSmallJsont); 705 smallStringt *value = allocSmallString("qwe"); 706 707 r = setTopNFreeSmallStringO(self, value); 708 ck_assert_ptr_ne(r, null); 709 char *s = toStringO(r); 710 ck_assert_str_eq(s, "qwe"); 711 free(s); 712 // non smallString value 713 value = (smallStringt*) allocSmallInt(1); 714 ck_assert_ptr_eq(setTopNFreeSmallStringO(self, value), null); 715 terminateO(value); 716 // null 717 ck_assert_ptr_eq(setTopNFreeSmallStringO(self, null), null); 718 terminateO(self); 719 720 } 721 722 723 void fromArraySmallJsonT(void) { 724 725 smallJsont* r; 726 smallJsont *self = allocG(rtSmallJsont); 727 char **array; 728 size_t size = 3; 729 730 // libsheepy list 731 array = listCreateS("a", "bb", "ccc"); 732 r = fromArrayO(self, array, 0); 733 ck_assert_ptr_eq(self, r); 734 char *s = toStringO(r); 735 ck_assert_str_eq(s, "[\"a\",\"bb\",\"ccc\"]"); 736 free(s); 737 listFreeS(array); 738 // array with strings 739 freeO(self); 740 array = allocArray(array, size+1); 741 array[0] = strdup("a1"); 742 array[1] = strdup("bb1"); 743 array[2] = strdup("ccc1"); 744 array[3] = array[2]; 745 r = fromArrayO(self, array, size); 746 ck_assert_ptr_eq(self, r); 747 s = toStringO(r); 748 ck_assert_str_eq(s, "[\"a1\",\"bb1\",\"ccc1\"]"); 749 free(s); 750 // null in array 751 freeO(self); 752 char *elem = array[0]; 753 array[0] = null; 754 r = fromArrayO(self, array, size); 755 ck_assert_ptr_eq(self, r); 756 s = toStringO(r); 757 ck_assert_str_eq(s, "[\"bb1\",\"ccc1\"]"); 758 ck_assert_uint_eq(lenO(self), 3); 759 free(s); 760 array[0] = elem; 761 // json dict 762 freeO(self); 763 setTypeIntO(self); 764 r = fromArrayO(self, array, 1); 765 ck_assert_ptr_eq(r, null); 766 array[3] = null; 767 listFreeS(array); 768 // NULL array 769 r = fromArrayO(self, null, 1); 770 ck_assert_ptr_eq(r, null); 771 terminateO(self); 772 773 } 774 775 776 void fromArrayNFreeSmallJsonT(void) { 777 778 smallJsont* r; 779 smallJsont *self = allocSmallJson(); 780 char **array; 781 size_t size = 3; 782 783 // libsheepy list 784 array = listCreateS("a", "bb", "ccc"); 785 r = fromArrayNFreeO(self, array, 0); 786 ck_assert_ptr_eq(self, r); 787 char *s = toStringO(r); 788 ck_assert_str_eq(s, "[\"a\",\"bb\",\"ccc\"]"); 789 free(s); 790 // array with strings 791 array = allocArray(array, size); 792 array[0] = strdup("a1"); 793 array[1] = strdup("bb1"); 794 array[2] = strdup("ccc1"); 795 r = fromArrayNFreeO(self, array, size); 796 ck_assert_ptr_eq(self, r); 797 s = toStringO(r); 798 ck_assert_str_eq(s, "[\"a1\",\"bb1\",\"ccc1\"]"); 799 free(s); 800 // NULL array 801 r = fromArrayNFreeO(self, null, 1); 802 ck_assert_ptr_eq(r, null); 803 terminateO(self); 804 805 } 806 807 808 void fromArrayDictSmallJsonT(void) { 809 810 smallJsont* r; 811 smallJsont *self = allocG(rtSmallJsont); 812 smallArrayt *items = allocSmallArray(); 813 814 self->f->setInt(self, "", 1); 815 // ignored item 816 items->f->pushS(items, "ignored"); 817 createAllocateSmallArray(a); 818 a->f->pushS(a, "a"); 819 a->f->pushInt(a, 1); 820 items->f->pushNFreeArray(items, a); 821 a = allocSmallArray(); 822 items->f->pushNFreeArray(items, a); 823 a = allocSmallArray(); 824 a->f->pushInt(a, 1); 825 a->f->pushInt(a, 2); 826 items->f->pushNFreeArray(items, a); 827 r = fromArrayDictO(self, items); 828 ck_assert_ptr_ne(r, NULL); 829 char *s = toStringO(r); 830 ck_assert_str_eq(s, "{\"\":1,\"a\":1}"); 831 free(s); 832 // empty json 833 freeO(self); 834 r = fromArrayDictO(self, items); 835 ck_assert_ptr_ne(r, NULL); 836 s = toStringO(r); 837 ck_assert_str_eq(s, "{\"a\":1}"); 838 free(s); 839 // non json dict 840 freeO(self); 841 setTypeIntO(self); 842 r = fromArrayDictO(self, items); 843 ck_assert_ptr_eq(r, NULL); 844 terminateO(items); 845 // non smallArray items 846 freeO(self); 847 items = (smallArrayt*) allocSmallInt(2); 848 r = fromArrayDictO(self, items); 849 ck_assert_ptr_eq(r, NULL); 850 // null items 851 r = fromArrayDictO(self, null); 852 ck_assert_ptr_eq(r, NULL); 853 terminateO(items); 854 terminateO(self); 855 856 } 857 858 859 void toArrayDictSmallJsonT(void) { 860 861 smallArrayt* r; 862 smallJsont *self = allocG(rtSmallJsont); 863 864 parseO(self, "{\"a\":2,\"bb\":4}"); 865 866 r = toArrayDictO(self); 867 ck_assert_ptr_ne(r, null); 868 char *s = toStringO(r); 869 terminateO(r); 870 ck_assert_str_eq(s, "[[\"a\",2],[\"bb\",4]]"); 871 free(s); 872 // empty self 873 freeO(self); 874 setTypeDictO(self); 875 ck_assert_ptr_eq(toArrayDictO(self), null); 876 // non json dict 877 freeO(self); 878 ck_assert_ptr_eq(toArrayDictO(self), null); 879 terminateO(self); 880 881 } 882 883 884 void getTopUndefinedSmallJsonT(void) { 885 886 undefinedt* r = allocUndefined(); 887 smallJsont *self = allocG(rtSmallJsont); 888 889 setTopO(self, (baset*) r); 890 finishO(r); 891 r = getTopUndefinedO(self); 892 ck_assert_ptr_ne(r, null); 893 char *s = toStringO(r); 894 finishO(r); 895 ck_assert_str_eq(s, "null"); 896 free(s); 897 // non json undefined 898 freeO(self); 899 ck_assert_ptr_eq(getTopUndefinedO(self), null); 900 terminateO(self); 901 902 } 903 904 905 void getTopBoolSmallJsonT(void) { 906 907 bool r; 908 smallJsont *self = allocG(rtSmallJsont); 909 910 setTopBoolO(self, true); 911 r = getTopBoolO(self); 912 ck_assert(r); 913 terminateO(self); 914 915 } 916 917 918 void getTopBoolPSmallJsonT(void) { 919 920 bool* r; 921 smallJsont *self = allocG(rtSmallJsont); 922 923 setTopBoolO(self, true); 924 r = getTopBoolPO(self); 925 ck_assert_ptr_ne(r, null); 926 ck_assert(*r); 927 terminateO(self); 928 929 } 930 931 932 void getTopDoubleSmallJsonT(void) { 933 934 double r; 935 smallJsont *self = allocG(rtSmallJsont); 936 937 setTopDoubleO(self, 2); 938 r = getTopDoubleO(self); 939 ck_assert(r==2); 940 terminateO(self); 941 942 } 943 944 945 void getTopDoublePSmallJsonT(void) { 946 947 double* r; 948 smallJsont *self = allocG(rtSmallJsont); 949 950 setTopDoubleO(self, 2); 951 r = getTopDoublePO(self); 952 ck_assert_ptr_ne(r, null); 953 ck_assert(*r==2); 954 terminateO(self); 955 956 } 957 958 959 void getTopIntSmallJsonT(void) { 960 961 int64_t r; 962 smallJsont *self = allocG(rtSmallJsont); 963 964 setTopIntO(self, 3); 965 r = getTopIntO(self); 966 ck_assert_int_eq(r, 3); 967 terminateO(self); 968 969 } 970 971 972 void getTopIntPSmallJsonT(void) { 973 974 int64_t* r; 975 smallJsont *self = allocG(rtSmallJsont); 976 977 setTopIntO(self, 3); 978 r = getTopIntPO(self); 979 ck_assert_ptr_ne(r, null); 980 ck_assert_int_eq(*r, 3); 981 terminateO(self); 982 983 } 984 985 986 void getTopInt32SmallJsonT(void) { 987 988 int32_t r; 989 smallJsont *self = allocG(rtSmallJsont); 990 991 setTopIntO(self, 3); 992 r = getTopInt32O(self); 993 ck_assert_int_eq(r, 3); 994 terminateO(self); 995 996 } 997 998 999 void getTopInt32PSmallJsonT(void) { 1000 1001 int32_t* r; 1002 smallJsont *self = allocG(rtSmallJsont); 1003 1004 setTopIntO(self, 3); 1005 r = getTopInt32PO(self); 1006 ck_assert_ptr_ne(r, null); 1007 ck_assert_int_eq(*r, 3); 1008 terminateO(self); 1009 1010 } 1011 1012 1013 void getTopUintSmallJsonT(void) { 1014 1015 uint64_t r; 1016 smallJsont *self = allocG(rtSmallJsont); 1017 1018 setTopIntO(self, 3); 1019 r = getTopUintO(self); 1020 ck_assert_int_eq(r, 3); 1021 terminateO(self); 1022 1023 } 1024 1025 1026 void getTopUintPSmallJsonT(void) { 1027 1028 uint64_t* r; 1029 smallJsont *self = allocG(rtSmallJsont); 1030 1031 setTopIntO(self, 3); 1032 r = getTopUintPO(self); 1033 ck_assert_ptr_ne(r, null); 1034 ck_assert_int_eq(*r, 3); 1035 terminateO(self); 1036 1037 } 1038 1039 1040 void getTopUint32SmallJsonT(void) { 1041 1042 uint32_t r; 1043 smallJsont *self = allocG(rtSmallJsont); 1044 1045 setTopIntO(self, 3); 1046 r = getTopUint32O(self); 1047 ck_assert_int_eq(r, 3); 1048 terminateO(self); 1049 1050 } 1051 1052 1053 void getTopUint32PSmallJsonT(void) { 1054 1055 uint32_t* r; 1056 smallJsont *self = allocG(rtSmallJsont); 1057 1058 setTopIntO(self, 3); 1059 r = getTopUint32PO(self); 1060 ck_assert_ptr_ne(r, null); 1061 ck_assert_int_eq(*r, 3); 1062 terminateO(self); 1063 1064 } 1065 1066 1067 void getTopSSmallJsonT(void) { 1068 1069 char* r; 1070 smallJsont *self = allocG(rtSmallJsont); 1071 1072 setTopStringO(self, "qwe"); 1073 r = getTopSO(self); 1074 ck_assert_ptr_ne(r, null); 1075 ck_assert_str_eq(r, "qwe"); 1076 terminateO(self); 1077 1078 } 1079 1080 1081 void getTopDictSmallJsonT(void) { 1082 1083 smallDictt* r = allocSmallDict(); 1084 smallJsont *self = allocG(rtSmallJsont); 1085 1086 setTopNFreeDictO(self, r); 1087 r = getTopDictO(self); 1088 ck_assert_ptr_ne(r, null); 1089 char *s = toStringO(r); 1090 finishO(r); 1091 ck_assert_str_eq(s, "{}"); 1092 free(s); 1093 // non json dict 1094 freeO(self); 1095 ck_assert_ptr_eq(getTopDictO(self), null); 1096 terminateO(self); 1097 1098 } 1099 1100 1101 void getTopArraySmallJsonT(void) { 1102 1103 smallArrayt* r = allocSmallArray(); 1104 smallJsont *self = allocG(rtSmallJsont); 1105 1106 setTopNFreeArrayO(self, r); 1107 r = getTopArrayO(self); 1108 ck_assert_ptr_ne(r, null); 1109 char *s = toStringO(r); 1110 finishO(r); 1111 ck_assert_str_eq(s, "[]"); 1112 free(s); 1113 // non json array 1114 freeO(self); 1115 ck_assert_ptr_eq(getTopArrayO(self), null); 1116 terminateO(self); 1117 1118 } 1119 1120 1121 void getTopSmallBoolSmallJsonT(void) { 1122 1123 smallBoolt* r = allocSmallBool(true); 1124 smallJsont *self = allocG(rtSmallJsont); 1125 1126 setTopNFreeSmallBoolO(self, r); 1127 r = getTopSmallBoolO(self); 1128 ck_assert_ptr_ne(r, null); 1129 char *s = toStringO(r); 1130 finishO(r); 1131 ck_assert_str_eq(s, "true"); 1132 free(s); 1133 // non json bool 1134 freeO(self); 1135 ck_assert_ptr_eq(getTopSmallBoolO(self), null); 1136 terminateO(self); 1137 1138 } 1139 1140 1141 void getTopSmallDoubleSmallJsonT(void) { 1142 1143 smallDoublet* r = allocSmallDouble(2); 1144 smallJsont *self = allocG(rtSmallJsont); 1145 1146 setTopNFreeSmallDoubleO(self, r); 1147 r = getTopSmallDoubleO(self); 1148 ck_assert_ptr_ne(r, null); 1149 char *s = toStringO(r); 1150 finishO(r); 1151 ck_assert_str_eq(s, "2.000000e+00"); 1152 free(s); 1153 // non json double 1154 freeO(self); 1155 ck_assert_ptr_eq(getTopSmallDoubleO(self), null); 1156 terminateO(self); 1157 1158 } 1159 1160 1161 void getTopSmallIntSmallJsonT(void) { 1162 1163 smallIntt* r = allocSmallInt(2); 1164 smallJsont *self = allocG(rtSmallJsont); 1165 1166 setTopNFreeSmallIntO(self, r); 1167 r = getTopSmallIntO(self); 1168 ck_assert_ptr_ne(r, null); 1169 char *s = toStringO(r); 1170 finishO(r); 1171 ck_assert_str_eq(s, "2"); 1172 free(s); 1173 // non json int 1174 freeO(self); 1175 ck_assert_ptr_eq(getTopSmallIntO(self), null); 1176 terminateO(self); 1177 1178 } 1179 1180 1181 void getTopSmallStringSmallJsonT(void) { 1182 1183 smallStringt* r = allocSmallString("qwe"); 1184 smallJsont *self = allocG(rtSmallJsont); 1185 1186 setTopNFreeSmallStringO(self, r); 1187 r = getTopSmallStringO(self); 1188 ck_assert_ptr_ne(r, null); 1189 char *s = toStringO(r); 1190 finishO(r); 1191 ck_assert_str_eq(s, "qwe"); 1192 free(s); 1193 // non json string 1194 freeO(self); 1195 ck_assert_ptr_eq(getTopSmallStringO(self), null); 1196 terminateO(self); 1197 1198 } 1199 1200 1201 void keyIsSmallJsonT(void) { 1202 1203 jsonPathRest r; 1204 smallJsont *self = allocG(rtSmallJsont); 1205 1206 // array path 1207 r = keyIsO(self, "[123].\"wef\""); 1208 ck_assert_int_eq(r, ARRAY_PATH); 1209 // dict path 1210 r = keyIsO(self, "\"wef\"[-123]"); 1211 ck_assert_int_eq(r, DICT_PATH); 1212 // not a path 1213 r = keyIsO(self, "[\""); 1214 ck_assert_int_eq(r, NOT_A_PATH); 1215 r = keyIsO(self, "[[123]"); 1216 ck_assert_int_eq(r, NOT_A_PATH); 1217 r = keyIsO(self, "[123]]"); 1218 ck_assert_int_eq(r, NOT_A_PATH); 1219 r = keyIsO(self, "[123]qwe"); 1220 ck_assert_int_eq(r, NOT_A_PATH); 1221 r = keyIsO(self, "['123]"); 1222 ck_assert_int_eq(r, NOT_A_PATH); 1223 r = keyIsO(self, "[1-]"); 1224 ck_assert_int_eq(r, NOT_A_PATH); 1225 // null key 1226 r = keyIsO(self, null); 1227 ck_assert_int_eq(r, KEY_IS_NULL); 1228 terminateO(self); 1229 1230 } 1231 1232 1233 void keyIsSSmallJsonT(void) { 1234 1235 const char* r; 1236 smallJsont *self = allocG(rtSmallJsont); 1237 1238 // array path 1239 r = keyIsSO(self, "[123].\"wef\""); 1240 ck_assert_ptr_ne(r, null); 1241 ck_assert_str_eq(r, "ARRAY_PATH"); 1242 // dict path 1243 r = keyIsSO(self, "\"wef\"[-123]"); 1244 ck_assert_ptr_ne(r, null); 1245 ck_assert_str_eq(r, "DICT_PATH"); 1246 // not a path 1247 r = keyIsSO(self, "key"); 1248 ck_assert_ptr_ne(r, null); 1249 ck_assert_str_eq(r, "NOT_A_PATH"); 1250 // null key 1251 r = keyIsSO(self, null); 1252 ck_assert_ptr_eq(r, null); 1253 terminateO(self); 1254 1255 } 1256 1257 1258 void makeKeySmallJsonT(void) { 1259 1260 char* r; 1261 smallJsont *self = allocG(rtSmallJsont); 1262 1263 1264 r = makeKeyO(self, "\"\\asd"); 1265 ck_assert_ptr_ne(r, null); 1266 ck_assert_str_eq(r, "\"\\\"\\\\asd\""); 1267 free(r); 1268 // null key 1269 r = makeKeyO(self, null); 1270 ck_assert_ptr_eq(r, null); 1271 terminateO(self); 1272 1273 } 1274 1275 1276 void iMakeKeySmallJsonT(void) { 1277 1278 char* r; 1279 smallJsont *self = allocG(rtSmallJsont); 1280 char *key = strdup("qwe"); 1281 1282 r = iMakeKeyO(self, &key); 1283 ck_assert_ptr_ne(r, null); 1284 ck_assert_ptr_eq(r, key); 1285 ck_assert_str_eq(r, "\"qwe\""); 1286 // null key 1287 freen(key); 1288 r = iMakeKeyO(self, &key); 1289 ck_assert_ptr_eq(r, null); 1290 r = iMakeKeyO(self, null); 1291 ck_assert_ptr_eq(r, null); 1292 terminateO(self); 1293 1294 } 1295 1296 1297 void bMakeKeySmallJsonT(void) { 1298 1299 char* r; 1300 smallJsont *self = allocG(rtSmallJsont); 1301 char dest[20]; 1302 1303 r = bMakeKeyO(self, dest, "\"\\123"); 1304 ck_assert_ptr_ne(r, null); 1305 ck_assert_str_eq(r, "\"\\\"\\\\123\""); 1306 // null 1307 r = bMakeKeyO(self, dest, null); 1308 ck_assert_ptr_eq(r, null); 1309 r = bMakeKeyO(self, null, "\"\\123"); 1310 ck_assert_ptr_eq(r, null); 1311 terminateO(self); 1312 1313 } 1314 1315 1316 void bLMakeKeySmallJsonT(void) { 1317 1318 char* r; 1319 smallJsont *self = allocG(rtSmallJsont); 1320 char dest[20]; 1321 1322 r = bLMakeKeyO(self, dest, sizeof(dest), "\"\\123"); 1323 ck_assert_ptr_ne(r, null); 1324 ck_assert_str_eq(r, "\"\\\"\\\\123\""); 1325 // just enough space 1326 r = bLMakeKeyO(self, dest, 10, "\"\\123"); 1327 ck_assert_ptr_ne(r, null); 1328 ck_assert_str_eq(r, "\"\\\"\\\\123\""); 1329 // dest too short 1330 r = bLMakeKeyO(self, dest, 9, "\"\\123"); 1331 ck_assert_ptr_eq(r, null); 1332 // null 1333 r = bLMakeKeyO(self, dest, 45, null); 1334 ck_assert_ptr_eq(r, null); 1335 r = bLMakeKeyO(self, null, 4, "\"\\123"); 1336 ck_assert_ptr_eq(r, null); 1337 r = bLMakeKeyO(self, dest, 0, "\"\\123"); 1338 ck_assert_ptr_eq(r, null); 1339 terminateO(self); 1340 1341 } 1342 1343 1344 void makeKeyLenSmallJsonT(void) { 1345 1346 size_t r; 1347 smallJsont *self = allocG(rtSmallJsont); 1348 1349 r = makeKeyLenO(self, "\"\\asd"); 1350 ck_assert_int_eq(r, 9); 1351 r = makeKeyLenO(self, ""); 1352 ck_assert_int_eq(r, 2); 1353 // null 1354 ck_assert_int_eq(makeKeyLenO(self, null), 0); 1355 terminateO(self); 1356 1357 } 1358 1359 1360 void setSmallJsonT(void) { 1361 1362 smallJsont* r; 1363 smallJsont *self = allocSmallJson(); 1364 baset *value = (baset*) allocSmallInt(1); 1365 1366 r = self->f->set(self, "1", value); 1367 ck_assert_ptr_ne(r, null); 1368 finishO(value); 1369 char *s = toStringO(r); 1370 ck_assert_str_eq(s, "{\"1\":1}"); 1371 free(s); 1372 // path 1373 value = (baset*) allocSmallInt(2); 1374 createSmallArray(a); 1375 createSmallDict(d); 1376 a.f->pushDict(&a, &d); 1377 self->f->setArray(self, "array", &a); 1378 r = self->f->set(self, "\"array\"[0].\"key\"", value); 1379 ck_assert_ptr_ne(r, null); 1380 finishO(value); 1381 s = toStringO(r); 1382 ck_assert_str_eq(s, "{\"1\":1,\"array\":[{\"key\":2}]}"); 1383 free(s); 1384 // json bool 1385 freeO(self); 1386 value = (baset*) allocSmallInt(2); 1387 setTypeBoolO(self); 1388 r = self->f->set(self, "1", value); 1389 ck_assert_ptr_eq(r, null); 1390 // json array 1391 freeO(self); 1392 setTypeArrayO(self); 1393 r = self->f->set(self, "1", value); 1394 ck_assert_ptr_eq(r, null); 1395 // non existing dict path 1396 freeO(self); 1397 r = self->f->set(self, "\"1\"[1]", value); 1398 ck_assert_ptr_eq(r, null); 1399 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 1400 createSmallInt(i); 1401 r = self->f->set(self, "\"1\".[1]", (baset*)&i); 1402 ck_assert_ptr_eq(r, null); 1403 freeO(&i); 1404 // wrong path and user class 1405 i.type = "myclass"; 1406 r = self->f->set(self, "\"1\".[1]", (baset*)&i); 1407 ck_assert_ptr_eq(r, null); 1408 // dict path but the object is an array 1409 resetO(&a); 1410 self->f->setArray(self, "1", &a); 1411 r = self->f->set(self, "\"1\".\"1\"", value); 1412 ck_assert_ptr_eq(r, null); 1413 // dict object in path but the key doesn't exists 1414 resetO(&d); 1415 self->f->setDict(self, "2", &d); 1416 r = self->f->set(self, "\"2\".\"1\".[12]", value); 1417 ck_assert_ptr_eq(r, null); 1418 // null key 1419 r = self->f->set(self, null, value); 1420 ck_assert_ptr_eq(r, null); 1421 terminateO(value); 1422 terminateO(self); 1423 1424 } 1425 1426 1427 void setUndefinedSmallJsonT(void) { 1428 1429 smallJsont* r; 1430 smallJsont *self = allocSmallJson(); 1431 1432 r = self->f->setUndefined(self, "1"); 1433 ck_assert_ptr_ne(r, null); 1434 char *s = toStringO(r); 1435 ck_assert_str_eq(s, "{\"1\":null}"); 1436 free(s); 1437 // path 1438 createSmallArray(a); 1439 createSmallDict(d); 1440 a.f->pushDict(&a, &d); 1441 self->f->setArray(self, "array", &a); 1442 r = self->f->setUndefined(self, "\"array\"[0].\"key\""); 1443 ck_assert_ptr_ne(r, null); 1444 s = toStringO(r); 1445 ck_assert_str_eq(s, "{\"1\":null,\"array\":[{\"key\":null}]}"); 1446 free(s); 1447 // json bool 1448 freeO(self); 1449 setTypeBoolO(self); 1450 r = self->f->setUndefined(self, "1"); 1451 ck_assert_ptr_eq(r, null); 1452 // json array 1453 freeO(self); 1454 setTypeArrayO(self); 1455 r = self->f->setUndefined(self, "1"); 1456 ck_assert_ptr_eq(r, null); 1457 // non existing dict path 1458 freeO(self); 1459 r = self->f->setUndefined(self, "\"1\"[1]"); 1460 ck_assert_ptr_eq(r, null); 1461 // dict path but the object is an array 1462 resetO(&a); 1463 self->f->setArray(self, "1", &a); 1464 r = self->f->setUndefined(self, "\"1\".\"1\""); 1465 ck_assert_ptr_eq(r, null); 1466 // dict object in path but the key doesn't exists 1467 resetO(&d); 1468 self->f->setDict(self, "2", &d); 1469 r = self->f->setUndefined(self, "\"2\".\"1\".[12]"); 1470 ck_assert_ptr_eq(r, null); 1471 // null key 1472 r = self->f->setUndefined(self, null); 1473 ck_assert_ptr_eq(r, null); 1474 terminateO(self); 1475 1476 } 1477 1478 1479 void setBoolSmallJsonT(void) { 1480 1481 smallJsont* r; 1482 smallJsont *self = allocSmallJson(); 1483 1484 r = self->f->setBool(self, "1", true); 1485 ck_assert_ptr_ne(r, null); 1486 char *s = toStringO(r); 1487 ck_assert_str_eq(s, "{\"1\":true}"); 1488 free(s); 1489 // path 1490 createSmallArray(a); 1491 createSmallDict(d); 1492 a.f->pushDict(&a, &d); 1493 self->f->setArray(self, "array", &a); 1494 r = self->f->setBool(self, "\"array\"[0].\"key\"", false); 1495 ck_assert_ptr_ne(r, null); 1496 s = toStringO(r); 1497 ck_assert_str_eq(s, "{\"1\":true,\"array\":[{\"key\":false}]}"); 1498 free(s); 1499 // json bool 1500 freeO(self); 1501 setTypeBoolO(self); 1502 r = self->f->setBool(self, "1", true); 1503 ck_assert_ptr_eq(r, null); 1504 // json array 1505 freeO(self); 1506 setTypeArrayO(self); 1507 r = self->f->setBool(self, "1", true); 1508 ck_assert_ptr_eq(r, null); 1509 // non existing dict path 1510 freeO(self); 1511 r = self->f->setBool(self, "\"1\"[1]", true); 1512 ck_assert_ptr_eq(r, null); 1513 // dict path but the object is an array 1514 resetO(&a); 1515 self->f->setArray(self, "1", &a); 1516 r = self->f->setBool(self, "\"1\".\"1\"", true); 1517 ck_assert_ptr_eq(r, null); 1518 // dict object in path but the key doesn't exists 1519 resetO(&d); 1520 self->f->setDict(self, "2", &d); 1521 r = self->f->setBool(self, "\"2\".\"1\".[12]", true); 1522 ck_assert_ptr_eq(r, null); 1523 // null key 1524 r = self->f->setBool(self, null, false); 1525 ck_assert_ptr_eq(r, null); 1526 terminateO(self); 1527 1528 } 1529 1530 1531 void setDoubleSmallJsonT(void) { 1532 1533 smallJsont* r; 1534 smallJsont *self = allocSmallJson(); 1535 1536 r = self->f->setDouble(self, "1", 2.2); 1537 ck_assert_ptr_ne(r, null); 1538 char *s = toStringO(r); 1539 ck_assert_str_eq(s, "{\"1\":2.200000e+00}"); 1540 free(s); 1541 // path 1542 createSmallArray(a); 1543 createSmallDict(d); 1544 a.f->pushDict(&a, &d); 1545 self->f->setArray(self, "array", &a); 1546 r = self->f->setDouble(self, "\"array\"[0].\"key\"", 1.2); 1547 ck_assert_ptr_ne(r, null); 1548 s = toStringO(r); 1549 ck_assert_str_eq(s, "{\"1\":2.200000e+00,\"array\":[{\"key\":1.200000e+00}]}"); 1550 free(s); 1551 // json bool 1552 freeO(self); 1553 setTypeBoolO(self); 1554 r = self->f->setDouble(self, "1", 2.2); 1555 ck_assert_ptr_eq(r, null); 1556 // json array 1557 freeO(self); 1558 setTypeArrayO(self); 1559 r = self->f->setDouble(self, "1", 2.2); 1560 ck_assert_ptr_eq(r, null); 1561 // non existing dict path 1562 freeO(self); 1563 r = self->f->setDouble(self, "\"1\"[1]", 2.2); 1564 ck_assert_ptr_eq(r, null); 1565 // dict path but the object is an array 1566 resetO(&a); 1567 self->f->setArray(self, "1", &a); 1568 r = self->f->setDouble(self, "\"1\".\"1\"", 2.2); 1569 ck_assert_ptr_eq(r, null); 1570 // dict object in path but the key doesn't exists 1571 resetO(&d); 1572 self->f->setDict(self, "2", &d); 1573 r = self->f->setDouble(self, "\"2\".\"1\".[12]", 2.2); 1574 ck_assert_ptr_eq(r, null); 1575 // null key 1576 r = self->f->setDouble(self, null, 1); 1577 ck_assert_ptr_eq(r, null); 1578 terminateO(self); 1579 1580 } 1581 1582 1583 void setIntSmallJsonT(void) { 1584 1585 smallJsont* r; 1586 smallJsont *self = allocSmallJson(); 1587 1588 r = self->f->setInt(self, "1", 2); 1589 ck_assert_ptr_ne(r, null); 1590 char *s = toStringO(r); 1591 ck_assert_str_eq(s, "{\"1\":2}"); 1592 free(s); 1593 // path 1594 createSmallArray(a); 1595 createSmallDict(d); 1596 a.f->pushDict(&a, &d); 1597 self->f->setArray(self, "array", &a); 1598 r = self->f->setInt(self, "\"array\"[0].\"key\"", 4); 1599 ck_assert_ptr_ne(r, null); 1600 s = toStringO(r); 1601 ck_assert_str_eq(s, "{\"1\":2,\"array\":[{\"key\":4}]}"); 1602 free(s); 1603 // json bool 1604 freeO(self); 1605 setTypeBoolO(self); 1606 r = self->f->setInt(self, "1", 1); 1607 ck_assert_ptr_eq(r, null); 1608 // json array 1609 freeO(self); 1610 setTypeArrayO(self); 1611 r = self->f->setInt(self, "1", 1); 1612 ck_assert_ptr_eq(r, null); 1613 // non existing dict path 1614 freeO(self); 1615 r = self->f->setInt(self, "\"1\"[1]", 1); 1616 ck_assert_ptr_eq(r, null); 1617 // dict path but the object is an array 1618 resetO(&a); 1619 self->f->setArray(self, "1", &a); 1620 r = self->f->setInt(self, "\"1\".\"1\"", 1); 1621 ck_assert_ptr_eq(r, null); 1622 // dict object in path but the key doesn't exists 1623 resetO(&d); 1624 self->f->setDict(self, "2", &d); 1625 r = self->f->setInt(self, "\"2\".\"1\".[12]", 1); 1626 ck_assert_ptr_eq(r, null); 1627 // null key 1628 r = self->f->setInt(self, null, 1); 1629 ck_assert_ptr_eq(r, null); 1630 terminateO(self); 1631 1632 } 1633 1634 1635 void setSSmallJsonT(void) { 1636 1637 smallJsont* r; 1638 smallJsont *self = allocSmallJson(); 1639 1640 r = self->f->setS(self, "1", "qwe"); 1641 ck_assert_ptr_ne(r, null); 1642 char *s = toStringO(r); 1643 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 1644 free(s); 1645 // path 1646 createSmallArray(a); 1647 createSmallDict(d); 1648 a.f->pushDict(&a, &d); 1649 self->f->setArray(self, "array", &a); 1650 r = self->f->setS(self, "\"array\"[0].\"key\"", "a"); 1651 ck_assert_ptr_ne(r, null); 1652 s = toStringO(r); 1653 ck_assert_str_eq(s, "{\"1\":\"qwe\",\"array\":[{\"key\":\"a\"}]}"); 1654 free(s); 1655 // json bool 1656 freeO(self); 1657 setTypeBoolO(self); 1658 r = self->f->setS(self, "1", ""); 1659 ck_assert_ptr_eq(r, null); 1660 // json array 1661 freeO(self); 1662 setTypeArrayO(self); 1663 r = self->f->setS(self, "1", ""); 1664 ck_assert_ptr_eq(r, null); 1665 // non existing dict path 1666 freeO(self); 1667 r = self->f->setS(self, "\"1\"[1]", ""); 1668 ck_assert_ptr_eq(r, null); 1669 // dict path but the object is an array 1670 resetO(&a); 1671 self->f->setArray(self, "1", &a); 1672 r = self->f->setS(self, "\"1\".\"1\"", ""); 1673 ck_assert_ptr_eq(r, null); 1674 // dict object in path but the key doesn't exists 1675 resetO(&d); 1676 self->f->setDict(self, "2", &d); 1677 r = self->f->setS(self, "\"2\".\"1\".[12]", ""); 1678 ck_assert_ptr_eq(r, null); 1679 // null value 1680 r = self->f->setS(self, "1", null); 1681 ck_assert_ptr_eq(r, null); 1682 // null key 1683 r = self->f->setS(self, null, ""); 1684 ck_assert_ptr_eq(r, null); 1685 terminateO(self); 1686 1687 } 1688 1689 1690 void setCharSmallJsonT(void) { 1691 1692 smallJsont* r; 1693 smallJsont *self = allocSmallJson(); 1694 1695 r = self->f->setChar(self, "1", 'x'); 1696 ck_assert_ptr_ne(r, null); 1697 char *s = toStringO(r); 1698 ck_assert_str_eq(s, "{\"1\":\"x\"}"); 1699 free(s); 1700 // path 1701 createSmallArray(a); 1702 createSmallDict(d); 1703 a.f->pushDict(&a, &d); 1704 self->f->setArray(self, "array", &a); 1705 r = self->f->setChar(self, "\"array\"[0].\"key\"", 'q'); 1706 ck_assert_ptr_ne(r, null); 1707 s = toStringO(r); 1708 ck_assert_str_eq(s, "{\"1\":\"x\",\"array\":[{\"key\":\"q\"}]}"); 1709 free(s); 1710 // json bool 1711 freeO(self); 1712 setTypeBoolO(self); 1713 r = self->f->setChar(self, "1", 'c'); 1714 ck_assert_ptr_eq(r, null); 1715 // json array 1716 freeO(self); 1717 setTypeArrayO(self); 1718 r = self->f->setChar(self, "1", 'x'); 1719 ck_assert_ptr_eq(r, null); 1720 // non existing dict path 1721 freeO(self); 1722 r = self->f->setChar(self, "\"1\"[1]", 'x'); 1723 ck_assert_ptr_eq(r, null); 1724 // dict path but the object is an array 1725 resetO(&a); 1726 self->f->setArray(self, "1", &a); 1727 r = self->f->setChar(self, "\"1\".\"1\"", 'q'); 1728 ck_assert_ptr_eq(r, null); 1729 // dict object in path but the key doesn't exists 1730 resetO(&d); 1731 self->f->setDict(self, "2", &d); 1732 r = self->f->setChar(self, "\"2\".\"1\".[12]", 'q'); 1733 ck_assert_ptr_eq(r, null); 1734 // null key 1735 r = self->f->setChar(self, null, '1'); 1736 ck_assert_ptr_eq(r, null); 1737 terminateO(self); 1738 1739 } 1740 1741 1742 void setDictSmallJsonT(void) { 1743 1744 smallJsont* r; 1745 smallJsont *self = allocSmallJson(); 1746 smallDictt *dict = allocSmallDict(); 1747 1748 // empty dict 1749 r = self->f->setDict(self, "1", dict); 1750 ck_assert_ptr_ne(r, null); 1751 finishO(dict); 1752 char *s = toStringO(r); 1753 ck_assert_str_eq(s, "{\"1\":{}}"); 1754 free(s); 1755 // set dict 1756 dict = allocSmallDict(); 1757 dict->f->setS(dict, "a", "zxc"); 1758 r = self->f->setDict(self, "1", dict); 1759 ck_assert_ptr_ne(r, null); 1760 finishO(dict); 1761 s = toStringO(r); 1762 ck_assert_str_eq(s, "{\"1\":{\"a\":\"zxc\"}}"); 1763 free(s); 1764 // non smallDict object 1765 dict = (smallDictt*) allocSmallInt(2); 1766 r = self->f->setDict(self, "1", dict); 1767 ck_assert_ptr_eq(r, null); 1768 terminateO(dict); 1769 // path 1770 dict = allocSmallDict(); 1771 createSmallArray(a); 1772 createSmallDict(d); 1773 a.f->pushDict(&a, &d); 1774 self->f->setArray(self, "array", &a); 1775 r = self->f->setDict(self, "\"array\"[0].\"key\"", dict); 1776 ck_assert_ptr_ne(r, null); 1777 finishO(dict); 1778 s = toStringO(r); 1779 ck_assert_str_eq(s, "{\"1\":{\"a\":\"zxc\"},\"array\":[{\"key\":{}}]}"); 1780 free(s); 1781 // json bool 1782 freeO(self); 1783 setTypeBoolO(self); 1784 dict = allocSmallDict(); 1785 r = self->f->setDict(self, "1", dict); 1786 ck_assert_ptr_eq(r, null); 1787 // json array 1788 freeO(self); 1789 setTypeArrayO(self); 1790 r = self->f->setDict(self, "1", dict); 1791 ck_assert_ptr_eq(r, null); 1792 // non existing dict path 1793 freeO(self); 1794 r = self->f->setDict(self, "\"1\"[1]", dict); 1795 ck_assert_ptr_eq(r, null); 1796 // dict path but the object is an array 1797 resetO(&a); 1798 self->f->setArray(self, "1", &a); 1799 r = self->f->setDict(self, "\"1\".\"1\"", dict); 1800 ck_assert_ptr_eq(r, null); 1801 // dict object in path but the key doesn't exists 1802 resetO(&d); 1803 self->f->setDict(self, "2", &d); 1804 r = self->f->setDict(self, "\"2\".\"1\".[12]", dict); 1805 ck_assert_ptr_eq(r, null); 1806 // null value 1807 r = self->f->setDict(self, "1", null); 1808 ck_assert_ptr_eq(r, null); 1809 // null key 1810 r = self->f->setDict(self, null, dict); 1811 ck_assert_ptr_eq(r, null); 1812 terminateO(dict); 1813 terminateO(self); 1814 1815 } 1816 1817 1818 void setArraySmallJsonT(void) { 1819 1820 smallJsont* r; 1821 smallJsont *self = allocSmallJson(); 1822 smallArrayt *array = allocSmallArray(); 1823 1824 // empty array 1825 r = self->f->setArray(self, "1", array); 1826 ck_assert_ptr_ne(r, null); 1827 finishO(array); 1828 char *s = toStringO(r); 1829 ck_assert_str_eq(s, "{\"1\":[]}"); 1830 free(s); 1831 // set array 1832 array = allocSmallArray(); 1833 array->f->pushS(array, "zxc"); 1834 r = self->f->setArray(self, "1", array); 1835 ck_assert_ptr_ne(r, null); 1836 finishO(array); 1837 s = toStringO(r); 1838 ck_assert_str_eq(s, "{\"1\":[\"zxc\"]}"); 1839 free(s); 1840 // non smallArray object 1841 array = (smallArrayt*) allocSmallInt(2); 1842 r = self->f->setArray(self, "1", array); 1843 ck_assert_ptr_eq(r, null); 1844 terminateO(array); 1845 // path 1846 array = allocSmallArray(); 1847 createSmallArray(a); 1848 createSmallDict(d); 1849 a.f->pushDict(&a, &d); 1850 self->f->setArray(self, "array", &a); 1851 r = self->f->setArray(self, "\"array\"[0].\"key\"", array); 1852 ck_assert_ptr_ne(r, null); 1853 s = toStringO(r); 1854 ck_assert_str_eq(s, "{\"1\":[\"zxc\"],\"array\":[{\"key\":[]}]}"); 1855 free(s); 1856 // json bool 1857 freeO(self); 1858 setTypeBoolO(self); 1859 r = self->f->setArray(self, "1", array); 1860 ck_assert_ptr_eq(r, null); 1861 // json array 1862 freeO(self); 1863 setTypeArrayO(self); 1864 r = self->f->setArray(self, "1", array); 1865 ck_assert_ptr_eq(r, null); 1866 // non existing dict path 1867 freeO(self); 1868 r = self->f->setArray(self, "\"1\"[1]", array); 1869 ck_assert_ptr_eq(r, null); 1870 // dict path but the object is an array 1871 resetO(&a); 1872 self->f->setArray(self, "1", &a); 1873 r = self->f->setArray(self, "\"1\".\"1\"", array); 1874 ck_assert_ptr_eq(r, null); 1875 // dict object in path but the key doesn't exists 1876 resetO(&d); 1877 self->f->setDict(self, "2", &d); 1878 r = self->f->setArray(self, "\"2\".\"1\".[12]", array); 1879 ck_assert_ptr_eq(r, null); 1880 // null value 1881 r = self->f->setArray(self, "1", null); 1882 ck_assert_ptr_eq(r, null); 1883 // null key 1884 r = self->f->setArray(self, null, array); 1885 ck_assert_ptr_eq(r, null); 1886 finishO(array); 1887 terminateO(self); 1888 1889 } 1890 1891 1892 void setArraycSmallJsonT(void) { 1893 1894 smallJsont* r; 1895 smallJsont *self = allocSmallJson(); 1896 char **array = listCreateS("a", "b"); 1897 1898 r = self->f->setArrayc(self, "1", array); 1899 ck_assert_ptr_ne(r, null); 1900 char *s = toStringO(r); 1901 ck_assert_str_eq(s, "{\"1\":[\"a\",\"b\"]}"); 1902 free(s); 1903 // zero element list 1904 char *e0 = array[0]; 1905 array[0] = null; 1906 r = self->f->setArrayc(self, "1", array); 1907 ck_assert_ptr_ne(r, null); 1908 array[0] = e0; 1909 listFreeS(array); 1910 s = toStringO(r); 1911 ck_assert_str_eq(s, "{\"1\":[]}"); 1912 free(s); 1913 // path 1914 array = listCreateS("1", "2"); 1915 createSmallArray(a); 1916 createSmallDict(d); 1917 a.f->pushDict(&a, &d); 1918 self->f->setArray(self, "array", &a); 1919 r = self->f->setArrayc(self, "\"array\"[0].\"key\"", array); 1920 ck_assert_ptr_ne(r, null); 1921 s = toStringO(r); 1922 ck_assert_str_eq(s, "{\"1\":[],\"array\":[{\"key\":[\"1\",\"2\"]}]}"); 1923 free(s); 1924 // json bool 1925 freeO(self); 1926 setTypeBoolO(self); 1927 r = self->f->setArrayc(self, "1", array); 1928 ck_assert_ptr_eq(r, null); 1929 // json array 1930 freeO(self); 1931 setTypeArrayO(self); 1932 r = self->f->setArrayc(self, "1", array); 1933 ck_assert_ptr_eq(r, null); 1934 // non existing dict path 1935 freeO(self); 1936 r = self->f->setArrayc(self, "\"1\"[1]", array); 1937 ck_assert_ptr_eq(r, null); 1938 // dict path but the object is an array 1939 resetO(&a); 1940 self->f->setArray(self, "1", &a); 1941 r = self->f->setArrayc(self, "\"1\".\"1\"", array); 1942 ck_assert_ptr_eq(r, null); 1943 // dict object in path but the key doesn't exists 1944 resetO(&d); 1945 self->f->setDict(self, "2", &d); 1946 r = self->f->setArrayc(self, "\"2\".\"1\".[12]", array); 1947 ck_assert_ptr_eq(r, null); 1948 // null value 1949 r = self->f->setArrayc(self, "1", null); 1950 ck_assert_ptr_eq(r, null); 1951 // null key 1952 r = self->f->setArrayc(self, null, array); 1953 ck_assert_ptr_eq(r, null); 1954 listFreeS(array); 1955 terminateO(self); 1956 1957 } 1958 1959 1960 void setSmallBoolSmallJsonT(void) { 1961 1962 smallJsont* r; 1963 smallJsont *self = allocSmallJson(); 1964 smallBoolt *value = allocSmallBool(true); 1965 1966 r = self->f->setSmallBool(self, "1", value); 1967 ck_assert_ptr_ne(r, null); 1968 char *s = toStringO(r); 1969 ck_assert_str_eq(s, "{\"1\":true}"); 1970 free(s); 1971 // empty smallBool 1972 value->value = null; 1973 r = self->f->setSmallBool(self, "1", value); 1974 ck_assert_ptr_ne(r, null); 1975 finishO(value); 1976 s = toStringO(r); 1977 ck_assert_str_eq(s, "{\"1\":false}"); 1978 free(s); 1979 // non smallBool object 1980 value = (smallBoolt*) allocSmallInt(2); 1981 r = self->f->setSmallBool(self, "1", value); 1982 ck_assert_ptr_eq(r, null); 1983 terminateO(value); 1984 // path 1985 value = allocSmallBool(true); 1986 createSmallArray(a); 1987 createSmallDict(d); 1988 a.f->pushDict(&a, &d); 1989 self->f->setArray(self, "array", &a); 1990 r = self->f->setSmallBool(self, "\"array\"[0].\"key\"", value); 1991 ck_assert_ptr_ne(r, null); 1992 s = toStringO(r); 1993 ck_assert_str_eq(s, "{\"1\":false,\"array\":[{\"key\":true}]}"); 1994 free(s); 1995 // json bool 1996 freeO(self); 1997 setTypeBoolO(self); 1998 r = self->f->setSmallBool(self, "1", value); 1999 ck_assert_ptr_eq(r, null); 2000 // json array 2001 freeO(self); 2002 setTypeArrayO(self); 2003 r = self->f->setSmallBool(self, "1", value); 2004 ck_assert_ptr_eq(r, null); 2005 // non existing dict path 2006 freeO(self); 2007 r = self->f->setSmallBool(self, "\"1\"[1]", value); 2008 ck_assert_ptr_eq(r, null); 2009 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2010 createSmallBool(i); 2011 r = self->f->setSmallBool(self, "\"1\".[1]", &i); 2012 ck_assert_ptr_eq(r, null); 2013 freeO(&i); 2014 // dict path but the object is an array 2015 resetO(&a); 2016 self->f->setArray(self, "1", &a); 2017 r = self->f->setSmallBool(self, "\"1\".\"1\"", value); 2018 ck_assert_ptr_eq(r, null); 2019 // dict object in path but the key doesn't exists 2020 resetO(&d); 2021 self->f->setDict(self, "2", &d); 2022 r = self->f->setSmallBool(self, "\"2\".\"1\".[12]", value); 2023 ck_assert_ptr_eq(r, null); 2024 // null value 2025 r = self->f->setSmallBool(self, "1", null); 2026 ck_assert_ptr_eq(r, null); 2027 // null key 2028 r = self->f->setSmallBool(self, null, value); 2029 ck_assert_ptr_eq(r, null); 2030 finishO(value); 2031 terminateO(self); 2032 2033 } 2034 2035 2036 void setSmallBytesSmallJsonT(void) { 2037 2038 smallJsont* r; 2039 smallJsont *self = allocSmallJson(); 2040 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 2041 2042 r = self->f->setSmallBytes(self, "1", value); 2043 ck_assert_ptr_ne(r, null); 2044 char *s = toStringO(r); 2045 ck_assert_str_eq(s, "{\"1\":[0x71,0x77,0x65,0x00]}"); 2046 free(s); 2047 // empty smallBytes 2048 value->B = null; 2049 r = self->f->setSmallBytes(self, "1", value); 2050 ck_assert_ptr_ne(r, null); 2051 finishO(value); 2052 s = toStringO(r); 2053 ck_assert_str_eq(s, "{\"1\":[]}"); 2054 free(s); 2055 // non smallBytes object 2056 value = (smallBytest*) allocSmallInt(2); 2057 r = self->f->setSmallBytes(self, "1", value); 2058 ck_assert_ptr_eq(r, null); 2059 terminateO(value); 2060 // path 2061 value = allocSmallBytes("qwf", sizeof("qwf")); 2062 createSmallArray(a); 2063 createSmallDict(d); 2064 a.f->pushDict(&a, &d); 2065 self->f->setArray(self, "array", &a); 2066 r = self->f->setSmallBytes(self, "\"array\"[0].\"key\"", value); 2067 ck_assert_ptr_ne(r, null); 2068 s = toStringO(r); 2069 ck_assert_str_eq(s, "{\"1\":[],\"array\":[{\"key\":[0x71,0x77,0x66,0x00]}]}"); 2070 free(s); 2071 // json bool 2072 freeO(self); 2073 setTypeBoolO(self); 2074 r = self->f->setSmallBytes(self, "1", value); 2075 ck_assert_ptr_eq(r, null); 2076 // json array 2077 freeO(self); 2078 setTypeArrayO(self); 2079 r = self->f->setSmallBytes(self, "1", value); 2080 ck_assert_ptr_eq(r, null); 2081 // non existing dict path 2082 freeO(self); 2083 r = self->f->setSmallBytes(self, "\"1\"[1]", value); 2084 ck_assert_ptr_eq(r, null); 2085 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2086 createSmallBytes(i); 2087 r = self->f->setSmallBytes(self, "\"1\".[1]", &i); 2088 ck_assert_ptr_eq(r, null); 2089 freeO(&i); 2090 // dict path but the object is an array 2091 resetO(&a); 2092 self->f->setArray(self, "1", &a); 2093 r = self->f->setSmallBytes(self, "\"1\".\"1\"", value); 2094 ck_assert_ptr_eq(r, null); 2095 // dict object in path but the key doesn't exists 2096 resetO(&d); 2097 self->f->setDict(self, "2", &d); 2098 r = self->f->setSmallBytes(self, "\"2\".\"1\".[12]", value); 2099 ck_assert_ptr_eq(r, null); 2100 // null value 2101 r = self->f->setSmallBytes(self, "1", null); 2102 ck_assert_ptr_eq(r, null); 2103 // null key 2104 r = self->f->setSmallBytes(self, null, value); 2105 ck_assert_ptr_eq(r, null); 2106 finishO(value); 2107 terminateO(self); 2108 2109 } 2110 2111 2112 void setSmallDoubleSmallJsonT(void) { 2113 2114 smallJsont* r; 2115 smallJsont *self = allocSmallJson(); 2116 smallDoublet *value = allocSmallDouble(2.2); 2117 2118 r = self->f->setSmallDouble(self, "1", value); 2119 ck_assert_ptr_ne(r, null); 2120 char *s = toStringO(r); 2121 ck_assert_str_eq(s, "{\"1\":2.200000e+00}"); 2122 free(s); 2123 // empty smallDouble 2124 value->value = null; 2125 r = self->f->setSmallDouble(self, "1", value); 2126 ck_assert_ptr_ne(r, null); 2127 finishO(value); 2128 s = toStringO(r); 2129 ck_assert_str_eq(s, "{\"1\":0.000000e+00}"); 2130 free(s); 2131 // non smallDouble object 2132 value = (smallDoublet*) allocSmallInt(2); 2133 r = self->f->setSmallDouble(self, "1", value); 2134 ck_assert_ptr_eq(r, null); 2135 terminateO(value); 2136 // path 2137 value = allocSmallDouble(1.2); 2138 createSmallArray(a); 2139 createSmallDict(d); 2140 a.f->pushDict(&a, &d); 2141 self->f->setArray(self, "array", &a); 2142 r = self->f->setSmallDouble(self, "\"array\"[0].\"key\"", value); 2143 ck_assert_ptr_ne(r, null); 2144 s = toStringO(r); 2145 ck_assert_str_eq(s, "{\"1\":0.000000e+00,\"array\":[{\"key\":1.200000e+00}]}"); 2146 free(s); 2147 // json bool 2148 freeO(self); 2149 setTypeBoolO(self); 2150 r = self->f->setSmallDouble(self, "1", value); 2151 ck_assert_ptr_eq(r, null); 2152 // json array 2153 freeO(self); 2154 setTypeArrayO(self); 2155 r = self->f->setSmallDouble(self, "1", value); 2156 ck_assert_ptr_eq(r, null); 2157 // non existing dict path 2158 freeO(self); 2159 r = self->f->setSmallDouble(self, "\"1\"[1]", value); 2160 ck_assert_ptr_eq(r, null); 2161 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2162 createSmallDouble(i); 2163 r = self->f->setSmallDouble(self, "\"1\".[1]", &i); 2164 ck_assert_ptr_eq(r, null); 2165 freeO(&i); 2166 // dict path but the object is an array 2167 resetO(&a); 2168 self->f->setArray(self, "1", &a); 2169 r = self->f->setSmallDouble(self, "\"1\".\"1\"", value); 2170 ck_assert_ptr_eq(r, null); 2171 // dict object in path but the key doesn't exists 2172 resetO(&d); 2173 self->f->setDict(self, "2", &d); 2174 r = self->f->setSmallDouble(self, "\"2\".\"1\".[12]", value); 2175 ck_assert_ptr_eq(r, null); 2176 // null value 2177 r = self->f->setSmallDouble(self, "1", null); 2178 ck_assert_ptr_eq(r, null); 2179 // null key 2180 r = self->f->setSmallDouble(self, null, value); 2181 ck_assert_ptr_eq(r, null); 2182 finishO(value); 2183 terminateO(self); 2184 2185 } 2186 2187 2188 void setSmallIntSmallJsonT(void) { 2189 2190 smallJsont* r; 2191 smallJsont *self = allocSmallJson(); 2192 smallIntt *value = allocSmallInt(2); 2193 2194 r = self->f->setSmallInt(self, "1", value); 2195 ck_assert_ptr_ne(r, null); 2196 char *s = toStringO(r); 2197 ck_assert_str_eq(s, "{\"1\":2}"); 2198 free(s); 2199 // empty smallInt 2200 value->value = null; 2201 r = self->f->setSmallInt(self, "1", value); 2202 ck_assert_ptr_ne(r, null); 2203 finishO(value); 2204 s = toStringO(r); 2205 ck_assert_str_eq(s, "{\"1\":0}"); 2206 free(s); 2207 // non smallInt object 2208 value = (smallIntt*) allocSmallBool(true); 2209 r = self->f->setSmallInt(self, "1", value); 2210 ck_assert_ptr_eq(r, null); 2211 terminateO(value); 2212 // path 2213 value = allocSmallInt(1); 2214 createSmallArray(a); 2215 createSmallDict(d); 2216 a.f->pushDict(&a, &d); 2217 self->f->setArray(self, "array", &a); 2218 r = self->f->setSmallInt(self, "\"array\"[0].\"key\"", value); 2219 ck_assert_ptr_ne(r, null); 2220 s = toStringO(r); 2221 ck_assert_str_eq(s, "{\"1\":0,\"array\":[{\"key\":1}]}"); 2222 free(s); 2223 // json bool 2224 freeO(self); 2225 setTypeBoolO(self); 2226 r = self->f->setSmallInt(self, "1", value); 2227 ck_assert_ptr_eq(r, null); 2228 // json array 2229 freeO(self); 2230 setTypeArrayO(self); 2231 r = self->f->setSmallInt(self, "1", value); 2232 ck_assert_ptr_eq(r, null); 2233 // non existing dict path 2234 freeO(self); 2235 r = self->f->setSmallInt(self, "\"1\"[1]", value); 2236 ck_assert_ptr_eq(r, null); 2237 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2238 createSmallInt(i); 2239 r = self->f->setSmallInt(self, "\"1\".[1]", &i); 2240 freeO(&i); 2241 ck_assert_ptr_eq(r, null); 2242 // dict path but the object is an array 2243 resetO(&a); 2244 self->f->setArray(self, "1", &a); 2245 r = self->f->setSmallInt(self, "\"1\".\"1\"", value); 2246 ck_assert_ptr_eq(r, null); 2247 // dict object in path but the key doesn't exists 2248 resetO(&d); 2249 self->f->setDict(self, "2", &d); 2250 r = self->f->setSmallInt(self, "\"2\".\"1\".[12]", value); 2251 ck_assert_ptr_eq(r, null); 2252 // null value 2253 r = self->f->setSmallInt(self, "1", null); 2254 ck_assert_ptr_eq(r, null); 2255 // null key 2256 r = self->f->setSmallInt(self, null, value); 2257 ck_assert_ptr_eq(r, null); 2258 finishO(value); 2259 terminateO(self); 2260 2261 } 2262 2263 2264 void setSmallJsonSmallJsonT(void) { 2265 2266 smallJsont* r; 2267 smallJsont *self = allocSmallJson(); 2268 smallJsont *value = allocSmallJson(); 2269 2270 setTopIntO(value, 2); 2271 r = self->f->setSmallJson(self, "1", value); 2272 ck_assert_ptr_ne(r, null); 2273 char *s = toStringO(r); 2274 ck_assert_str_eq(s, "{\"1\":2}"); 2275 free(s); 2276 // empty smallJson 2277 resetO(value); 2278 r = self->f->setSmallJson(self, "1", value); 2279 ck_assert_ptr_ne(r, null); 2280 finishO(value); 2281 s = toStringO(r); 2282 ck_assert_str_eq(s, "{\"1\":{}}"); 2283 free(s); 2284 // non smallJson object 2285 value = (smallJsont*) allocSmallInt(2); 2286 r = self->f->setSmallJson(self, "1", value); 2287 ck_assert_ptr_eq(r, null); 2288 terminateO(value); 2289 // path 2290 value = allocSmallJson(); 2291 createSmallArray(a); 2292 createSmallDict(d); 2293 a.f->pushDict(&a, &d); 2294 self->f->setArray(self, "array", &a); 2295 r = self->f->setSmallJson(self, "\"array\"[0].\"key\"", value); 2296 ck_assert_ptr_ne(r, null); 2297 s = toStringO(r); 2298 ck_assert_str_eq(s, "{\"1\":{},\"array\":[{\"key\":{}}]}"); 2299 free(s); 2300 // json bool 2301 freeO(self); 2302 setTypeBoolO(self); 2303 r = self->f->setSmallJson(self, "1", value); 2304 ck_assert_ptr_eq(r, null); 2305 // json array 2306 freeO(self); 2307 setTypeArrayO(self); 2308 r = self->f->setSmallJson(self, "1", value); 2309 ck_assert_ptr_eq(r, null); 2310 // non existing dict path 2311 freeO(self); 2312 r = self->f->setSmallJson(self, "\"1\"[1]", value); 2313 ck_assert_ptr_eq(r, null); 2314 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2315 createSmallJson(i); 2316 r = self->f->setSmallJson(self, "\"1\".[1]", &i); 2317 ck_assert_ptr_eq(r, null); 2318 freeO(&i); 2319 // dict path but the object is an array 2320 resetO(&a); 2321 self->f->setArray(self, "1", &a); 2322 r = self->f->setSmallJson(self, "\"1\".\"1\"", value); 2323 ck_assert_ptr_eq(r, null); 2324 // dict object in path but the key doesn't exists 2325 resetO(&d); 2326 self->f->setDict(self, "2", &d); 2327 r = self->f->setSmallJson(self, "\"2\".\"1\".[12]", value); 2328 ck_assert_ptr_eq(r, null); 2329 // null value 2330 r = self->f->setSmallJson(self, "1", null); 2331 ck_assert_ptr_eq(r, null); 2332 // null key 2333 r = self->f->setSmallJson(self, null, value); 2334 ck_assert_ptr_eq(r, null); 2335 finishO(value); 2336 terminateO(self); 2337 2338 } 2339 2340 2341 void setSmallStringSmallJsonT(void) { 2342 2343 smallJsont* r; 2344 smallJsont *self = allocSmallJson(); 2345 smallStringt *string = allocSmallString("qwe"); 2346 2347 r = self->f->setSmallString(self, "1", string); 2348 ck_assert_ptr_ne(r, null); 2349 char *s = toStringO(r); 2350 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 2351 free(s); 2352 // empty smallString 2353 string->data = null; 2354 r = self->f->setSmallString(self, "1", string); 2355 ck_assert_ptr_ne(r, null); 2356 finishO(string); 2357 s = toStringO(r); 2358 ck_assert_str_eq(s, "{\"1\":\"\"}"); 2359 free(s); 2360 // non smallString object 2361 string = (smallStringt*) allocSmallInt(2); 2362 r = self->f->setSmallString(self, "1", string); 2363 ck_assert_ptr_eq(r, null); 2364 terminateO(string); 2365 // path 2366 smallStringt *value = allocSmallString("asd"); 2367 createSmallArray(a); 2368 createSmallDict(d); 2369 a.f->pushDict(&a, &d); 2370 self->f->setArray(self, "array", &a); 2371 r = self->f->setSmallString(self, "\"array\"[0].\"key\"", value); 2372 ck_assert_ptr_ne(r, null); 2373 s = toStringO(r); 2374 ck_assert_str_eq(s, "{\"1\":\"\",\"array\":[{\"key\":\"asd\"}]}"); 2375 free(s); 2376 // json bool 2377 freeO(self); 2378 setTypeBoolO(self); 2379 r = self->f->setSmallString(self, "1", value); 2380 ck_assert_ptr_eq(r, null); 2381 // json array 2382 freeO(self); 2383 setTypeArrayO(self); 2384 r = self->f->setSmallString(self, "1", value); 2385 ck_assert_ptr_eq(r, null); 2386 // non existing dict path 2387 freeO(self); 2388 r = self->f->setSmallString(self, "\"1\"[1]", value); 2389 ck_assert_ptr_eq(r, null); 2390 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2391 createSmallString(i); 2392 r = self->f->setSmallString(self, "\"1\".[1]", &i); 2393 ck_assert_ptr_eq(r, null); 2394 freeO(&i); 2395 // dict path but the object is an array 2396 resetO(&a); 2397 self->f->setArray(self, "1", &a); 2398 r = self->f->setSmallString(self, "\"1\".\"1\"", value); 2399 ck_assert_ptr_eq(r, null); 2400 // dict object in path but the key doesn't exists 2401 resetO(&d); 2402 self->f->setDict(self, "2", &d); 2403 r = self->f->setSmallString(self, "\"2\".\"1\".[12]", value); 2404 ck_assert_ptr_eq(r, null); 2405 // null value 2406 r = self->f->setSmallString(self, "1", null); 2407 ck_assert_ptr_eq(r, null); 2408 // null key 2409 r = self->f->setSmallString(self, null, string); 2410 ck_assert_ptr_eq(r, null); 2411 finishO(value); 2412 terminateO(self); 2413 2414 } 2415 2416 2417 void setSmallContainerSmallJsonT(void) { 2418 2419 smallJsont* r; 2420 smallJsont *self = allocSmallJson(); 2421 smallContainert *container = allocSmallContainer(null); 2422 2423 r = self->f->setSmallContainer(self, "1", container); 2424 ck_assert_ptr_ne(r, null); 2425 char *s = toStringO(r); 2426 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 2427 free(s); 2428 // empty smallContainer 2429 container->data = null; 2430 r = self->f->setSmallContainer(self, "1", container); 2431 ck_assert_ptr_ne(r, null); 2432 finishO(container); 2433 s = toStringO(r); 2434 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 2435 free(s); 2436 // non smallContainer object 2437 container = (smallContainert*) allocSmallInt(2); 2438 r = self->f->setSmallContainer(self, "1", container); 2439 ck_assert_ptr_eq(r, null); 2440 terminateO(container); 2441 // path 2442 smallContainert *value = allocSmallContainer(null); 2443 createSmallArray(a); 2444 createSmallDict(d); 2445 a.f->pushDict(&a, &d); 2446 self->f->setArray(self, "array", &a); 2447 r = self->f->setSmallContainer(self, "\"array\"[0].\"key\"", value); 2448 ck_assert_ptr_ne(r, null); 2449 s = toStringO(r); 2450 ck_assert_str_eq(s, "{\"1\":\"<data container>\",\"array\":[{\"key\":\"<data container>\"}]}"); 2451 free(s); 2452 // json bool 2453 freeO(self); 2454 setTypeBoolO(self); 2455 r = self->f->setSmallContainer(self, "1", value); 2456 ck_assert_ptr_eq(r, null); 2457 // json array 2458 freeO(self); 2459 setTypeArrayO(self); 2460 r = self->f->setSmallContainer(self, "1", value); 2461 ck_assert_ptr_eq(r, null); 2462 // non existing dict path 2463 freeO(self); 2464 r = self->f->setSmallContainer(self, "\"1\"[1]", value); 2465 ck_assert_ptr_eq(r, null); 2466 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2467 createSmallContainer(i); 2468 r = self->f->setSmallContainer(self, "\"1\".[1]", &i); 2469 ck_assert_ptr_eq(r, null); 2470 freeO(&i); 2471 // dict path but the object is an array 2472 resetO(&a); 2473 self->f->setArray(self, "1", &a); 2474 r = self->f->setSmallContainer(self, "\"1\".\"1\"", value); 2475 ck_assert_ptr_eq(r, null); 2476 // dict object in path but the key doesn't exists 2477 resetO(&d); 2478 self->f->setDict(self, "2", &d); 2479 r = self->f->setSmallContainer(self, "\"2\".\"1\".[12]", value); 2480 ck_assert_ptr_eq(r, null); 2481 // null value 2482 r = self->f->setSmallContainer(self, "1", null); 2483 ck_assert_ptr_eq(r, null); 2484 // null key 2485 r = self->f->setSmallContainer(self, null, container); 2486 ck_assert_ptr_eq(r, null); 2487 finishO(value); 2488 terminateO(self); 2489 2490 } 2491 2492 2493 void setNFreeSmallJsonT(void) { 2494 2495 smallJsont* r; 2496 smallJsont *self = allocSmallJson(); 2497 baset *value; 2498 2499 // undefined object 2500 value = (baset*)allocUndefined(); 2501 r = self->f->setNFree(self, "1", value); 2502 ck_assert_ptr_ne(r, null); 2503 char *s = toStringO(r); 2504 ck_assert_str_eq(s, "{\"1\":null}"); 2505 free(s); 2506 // container 2507 createAllocateSmallContainer(c); 2508 r = self->f->setNFree(self, "1", (baset*)c); 2509 ck_assert_ptr_ne(r, null); 2510 s = toStringO(r); 2511 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 2512 free(s); 2513 // base object in container 2514 createAllocateSmallInt(I); 2515 setValG(I, 11); 2516 I->type = "anothertype"; 2517 r = self->f->setNFree(self, "1", (baset*)I); 2518 ck_assert_ptr_ne(r, null); 2519 s = toStringO(r); 2520 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 2521 free(s); 2522 // path 2523 value = (baset*) allocSmallInt(2); 2524 createSmallArray(a); 2525 createSmallDict(d); 2526 a.f->pushDict(&a, &d); 2527 self->f->setArray(self, "array", &a); 2528 r = self->f->setNFree(self, "\"array\"[0].\"key\"", value); 2529 ck_assert_ptr_ne(r, null); 2530 s = toStringO(r); 2531 ck_assert_str_eq(s, "{\"1\":\"<data container>\",\"array\":[{\"key\":2}]}"); 2532 free(s); 2533 // json bool 2534 freeO(self); 2535 setTypeBoolO(self); 2536 value = (baset*) allocSmallInt(2); 2537 r = self->f->setNFree(self, "1", value); 2538 ck_assert_ptr_eq(r, null); 2539 // json array 2540 freeO(self); 2541 setTypeArrayO(self); 2542 r = self->f->setNFree(self, "1", value); 2543 ck_assert_ptr_eq(r, null); 2544 // non existing dict path 2545 freeO(self); 2546 r = self->f->setNFree(self, "\"1\"[1]", value); 2547 ck_assert_ptr_eq(r, null); 2548 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 2549 createSmallInt(i); 2550 r = self->f->setNFree(self, "\"1\".[1]", (baset*)&i); 2551 ck_assert_ptr_eq(r, null); 2552 freeO(&i); 2553 // wrong path and user class 2554 i.type = "myclass"; 2555 r = self->f->setNFree(self, "\"1\".[1]", (baset*)&i); 2556 ck_assert_ptr_eq(r, null); 2557 // dict path but the object is an array 2558 resetO(&a); 2559 self->f->setArray(self, "1", &a); 2560 r = self->f->setNFree(self, "\"1\".\"1\"", value); 2561 ck_assert_ptr_eq(r, null); 2562 // dict object in path but the key doesn't exists 2563 resetO(&d); 2564 self->f->setDict(self, "2", &d); 2565 r = self->f->setNFree(self, "\"2\".\"1\".[12]", value); 2566 ck_assert_ptr_eq(r, null); 2567 terminateO(value); 2568 // null value 2569 r = self->f->setNFree(self, "1", null); 2570 ck_assert_ptr_eq(r, null); 2571 // null key 2572 r = self->f->setNFree(self, null, value); 2573 ck_assert_ptr_eq(r, null); 2574 terminateO(self); 2575 2576 } 2577 2578 2579 void setNFreeUndefinedSmallJsonT(void) { 2580 2581 smallJsont* r; 2582 smallJsont *self = allocSmallJson(); 2583 undefinedt *undefined = allocUndefined(); 2584 2585 r = self->f->setNFreeUndefined(self, "1", undefined); 2586 ck_assert_ptr_ne(r, null); 2587 char *s = toStringO(r); 2588 ck_assert_str_eq(s, "{\"1\":null}"); 2589 free(s); 2590 // path 2591 undefined = allocUndefined(); 2592 createSmallArray(a); 2593 createSmallDict(d); 2594 a.f->pushDict(&a, &d); 2595 self->f->setArray(self, "array", &a); 2596 r = self->f->setNFreeUndefined(self, "\"array\"[0].\"key\"", undefined); 2597 ck_assert_ptr_ne(r, null); 2598 s = toStringO(r); 2599 ck_assert_str_eq(s, "{\"1\":null,\"array\":[{\"key\":null}]}"); 2600 free(s); 2601 // json bool 2602 freeO(self); 2603 setTypeBoolO(self); 2604 undefined = allocUndefined(); 2605 r = self->f->setNFreeUndefined(self, "1", undefined); 2606 ck_assert_ptr_eq(r, null); 2607 // json array 2608 freeO(self); 2609 setTypeArrayO(self); 2610 r = self->f->setNFreeUndefined(self, "1", undefined); 2611 ck_assert_ptr_eq(r, null); 2612 // non existing dict path 2613 freeO(self); 2614 r = self->f->setNFreeUndefined(self, "\"1\"[1]", undefined); 2615 ck_assert_ptr_eq(r, null); 2616 // dict path but the object is an array 2617 resetO(&a); 2618 self->f->setArray(self, "1", &a); 2619 r = self->f->setNFreeUndefined(self, "\"1\".\"1\"", undefined); 2620 ck_assert_ptr_eq(r, null); 2621 // dict object in path but the key doesn't exists 2622 resetO(&d); 2623 self->f->setDict(self, "2", &d); 2624 r = self->f->setNFreeUndefined(self, "\"2\".\"1\".[12]", undefined); 2625 ck_assert_ptr_eq(r, null); 2626 terminateO(undefined); 2627 // null value 2628 r = self->f->setNFreeUndefined(self, "1", null); 2629 ck_assert_ptr_eq(r, null); 2630 // null key 2631 undefined = allocUndefined(); 2632 r = self->f->setNFreeUndefined(self, null, undefined); 2633 ck_assert_ptr_eq(r, null); 2634 terminateO(self); 2635 terminateO(undefined); 2636 2637 } 2638 2639 2640 void setNFreeSSmallJsonT(void) { 2641 2642 smallJsont* r; 2643 smallJsont *self = allocSmallJson(); 2644 char *string = strdup("qwe"); 2645 2646 r = self->f->setNFreeS(self, "1", string); 2647 ck_assert_ptr_ne(r, null); 2648 char *s = toStringO(r); 2649 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 2650 free(s); 2651 // path 2652 string = strdup("asd"); 2653 createSmallArray(a); 2654 createSmallDict(d); 2655 a.f->pushDict(&a, &d); 2656 self->f->setArray(self, "array", &a); 2657 r = self->f->setNFreeS(self, "\"array\"[0].\"key\"", string); 2658 ck_assert_ptr_ne(r, null); 2659 s = toStringO(r); 2660 ck_assert_str_eq(s, "{\"1\":\"qwe\",\"array\":[{\"key\":\"asd\"}]}"); 2661 free(s); 2662 // json bool 2663 freeO(self); 2664 setTypeBoolO(self); 2665 string = strdup("asd"); 2666 r = self->f->setNFreeS(self, "1", string); 2667 ck_assert_ptr_eq(r, null); 2668 // json array 2669 freeO(self); 2670 setTypeArrayO(self); 2671 r = self->f->setNFreeS(self, "1", string); 2672 ck_assert_ptr_eq(r, null); 2673 // non existing dict path 2674 freeO(self); 2675 r = self->f->setNFreeS(self, "\"1\"[1]", string); 2676 ck_assert_ptr_eq(r, null); 2677 // dict path but the object is an array 2678 resetO(&a); 2679 self->f->setArray(self, "1", &a); 2680 r = self->f->setNFreeS(self, "\"1\".\"1\"", string); 2681 ck_assert_ptr_eq(r, null); 2682 // dict object in path but the key doesn't exists 2683 resetO(&d); 2684 self->f->setDict(self, "2", &d); 2685 r = self->f->setNFreeS(self, "\"2\".\"1\".[12]", string); 2686 ck_assert_ptr_eq(r, null); 2687 free(string); 2688 // null value 2689 r = self->f->setNFreeS(self, "1", null); 2690 ck_assert_ptr_eq(r, null); 2691 // null key 2692 string = strdup("qwe"); 2693 r = self->f->setNFreeS(self, null, string); 2694 ck_assert_ptr_eq(r, null); 2695 terminateO(self); 2696 free(string); 2697 2698 } 2699 2700 2701 void setNFreeDictSmallJsonT(void) { 2702 2703 smallJsont* r; 2704 smallJsont *self = allocSmallJson(); 2705 smallDictt *dict = allocSmallDict(); 2706 2707 r = self->f->setNFreeDict(self, "1", dict); 2708 ck_assert_ptr_ne(r, null); 2709 char *s = toStringO(r); 2710 ck_assert_str_eq(s, "{\"1\":{}}"); 2711 free(s); 2712 // null value 2713 r = self->f->setNFreeDict(self, "1", null); 2714 ck_assert_ptr_eq(r, null); 2715 // path 2716 smallDictt *value = allocSmallDict(); 2717 createSmallArray(a); 2718 createSmallDict(d); 2719 a.f->pushDict(&a, &d); 2720 self->f->setArray(self, "array", &a); 2721 r = self->f->setNFreeDict(self, "\"array\"[0].\"key\"", value); 2722 ck_assert_ptr_ne(r, null); 2723 s = toStringO(r); 2724 ck_assert_str_eq(s, "{\"1\":{},\"array\":[{\"key\":{}}]}"); 2725 free(s); 2726 // json bool 2727 freeO(self); 2728 setTypeBoolO(self); 2729 value = allocSmallDict(); 2730 r = self->f->setNFreeDict(self, "1", value); 2731 ck_assert_ptr_eq(r, null); 2732 // json array 2733 freeO(self); 2734 setTypeArrayO(self); 2735 r = self->f->setNFreeDict(self, "1", value); 2736 ck_assert_ptr_eq(r, null); 2737 // non existing dict path 2738 freeO(self); 2739 r = self->f->setNFreeDict(self, "\"1\"[1]", value); 2740 ck_assert_ptr_eq(r, null); 2741 // dict path but the object is an array 2742 resetO(&a); 2743 self->f->setArray(self, "1", &a); 2744 r = self->f->setNFreeDict(self, "\"1\".\"1\"", value); 2745 ck_assert_ptr_eq(r, null); 2746 // dict object in path but the key doesn't exists 2747 resetO(&d); 2748 self->f->setDict(self, "2", &d); 2749 r = self->f->setNFreeDict(self, "\"2\".\"1\".[12]", value); 2750 ck_assert_ptr_eq(r, null); 2751 terminateO(value); 2752 // null key 2753 dict = allocSmallDict(); 2754 r = self->f->setNFreeDict(self, null, dict); 2755 ck_assert_ptr_eq(r, null); 2756 terminateO(self); 2757 terminateO(dict); 2758 2759 } 2760 2761 2762 void setNFreeArraySmallJsonT(void) { 2763 2764 smallJsont* r; 2765 smallJsont *self = allocSmallJson(); 2766 smallArrayt *array = allocSmallArray(); 2767 2768 // empty array 2769 r = self->f->setNFreeArray(self, "1", array); 2770 ck_assert_ptr_ne(r, null); 2771 char *s = toStringO(r); 2772 ck_assert_str_eq(s, "{\"1\":[]}"); 2773 free(s); 2774 // path 2775 smallArrayt *value = allocSmallArray(); 2776 createSmallArray(a); 2777 createSmallDict(d); 2778 a.f->pushDict(&a, &d); 2779 self->f->setArray(self, "array", &a); 2780 r = self->f->setNFreeArray(self, "\"array\"[0].\"key\"", value); 2781 ck_assert_ptr_ne(r, null); 2782 s = toStringO(r); 2783 ck_assert_str_eq(s, "{\"1\":[],\"array\":[{\"key\":[]}]}"); 2784 free(s); 2785 // json bool 2786 freeO(self); 2787 setTypeBoolO(self); 2788 value = allocSmallArray(); 2789 r = self->f->setNFreeArray(self, "1", value); 2790 ck_assert_ptr_eq(r, null); 2791 // json array 2792 freeO(self); 2793 setTypeArrayO(self); 2794 r = self->f->setNFreeArray(self, "1", value); 2795 ck_assert_ptr_eq(r, null); 2796 // non existing dict path 2797 freeO(self); 2798 r = self->f->setNFreeArray(self, "\"1\"[1]", value); 2799 ck_assert_ptr_eq(r, null); 2800 // dict path but the object is an array 2801 resetO(&a); 2802 self->f->setArray(self, "1", &a); 2803 r = self->f->setNFreeArray(self, "\"1\".\"1\"", value); 2804 ck_assert_ptr_eq(r, null); 2805 // dict object in path but the key doesn't exists 2806 resetO(&d); 2807 self->f->setDict(self, "2", &d); 2808 r = self->f->setNFreeArray(self, "\"2\".\"1\".[12]", value); 2809 ck_assert_ptr_eq(r, null); 2810 terminateO(value); 2811 // null value 2812 r = self->f->setNFreeArray(self, "1", null); 2813 ck_assert_ptr_eq(r, null); 2814 // null key 2815 r = self->f->setNFreeArray(self, null, array); 2816 ck_assert_ptr_eq(r, null); 2817 terminateO(self); 2818 2819 } 2820 2821 2822 void setNFreeArraycSmallJsonT(void) { 2823 2824 smallJsont* r; 2825 smallJsont *self = allocSmallJson(); 2826 char **array = listCreateS("a", "b"); 2827 2828 r = self->f->setNFreeArrayc(self, "1", array); 2829 ck_assert_ptr_ne(r, null); 2830 char *s = toStringO(r); 2831 ck_assert_str_eq(s, "{\"1\":[\"a\",\"b\"]}"); 2832 free(s); 2833 // path 2834 char **value = listCreateS("1", "2"); 2835 createSmallArray(a); 2836 createSmallDict(d); 2837 a.f->pushDict(&a, &d); 2838 self->f->setArray(self, "array", &a); 2839 r = self->f->setNFreeArrayc(self, "\"array\"[0].\"key\"", value); 2840 ck_assert_ptr_ne(r, null); 2841 s = toStringO(r); 2842 ck_assert_str_eq(s, "{\"1\":[\"a\",\"b\"],\"array\":[{\"key\":[\"1\",\"2\"]}]}"); 2843 free(s); 2844 // json bool 2845 freeO(self); 2846 setTypeBoolO(self); 2847 value = listCreateS("1", "2"); 2848 r = self->f->setNFreeArrayc(self, "1", value); 2849 ck_assert_ptr_eq(r, null); 2850 // json array 2851 freeO(self); 2852 setTypeArrayO(self); 2853 r = self->f->setNFreeArrayc(self, "1", value); 2854 ck_assert_ptr_eq(r, null); 2855 // non existing dict path 2856 freeO(self); 2857 r = self->f->setNFreeArrayc(self, "\"1\"[1]", value); 2858 ck_assert_ptr_eq(r, null); 2859 // dict path but the object is an array 2860 resetO(&a); 2861 self->f->setArray(self, "1", &a); 2862 r = self->f->setNFreeArrayc(self, "\"1\".\"1\"", value); 2863 ck_assert_ptr_eq(r, null); 2864 // dict object in path but the key doesn't exists 2865 resetO(&d); 2866 self->f->setDict(self, "2", &d); 2867 r = self->f->setNFreeArrayc(self, "\"2\".\"1\".[12]", value); 2868 ck_assert_ptr_eq(r, null); 2869 listFreeS(value); 2870 // null value 2871 r = self->f->setNFreeArrayc(self, "1", null); 2872 ck_assert_ptr_eq(r, null); 2873 // null key 2874 r = self->f->setNFreeArrayc(self, null, array); 2875 ck_assert_ptr_eq(r, null); 2876 terminateO(self); 2877 2878 } 2879 2880 2881 void setNFreeSmallBoolSmallJsonT(void) { 2882 2883 smallJsont* r; 2884 smallJsont *self = allocSmallJson(); 2885 smallBoolt *value = allocSmallBool(true); 2886 2887 r = self->f->setNFreeSmallBool(self, "1", value); 2888 ck_assert_ptr_ne(r, null); 2889 char *s = toStringO(r); 2890 ck_assert_str_eq(s, "{\"1\":true}"); 2891 free(s); 2892 // path 2893 value = allocSmallBool(false); 2894 createSmallArray(a); 2895 createSmallDict(d); 2896 a.f->pushDict(&a, &d); 2897 self->f->setArray(self, "array", &a); 2898 r = self->f->setNFreeSmallBool(self, "\"array\"[0].\"key\"", value); 2899 ck_assert_ptr_ne(r, null); 2900 s = toStringO(r); 2901 ck_assert_str_eq(s, "{\"1\":true,\"array\":[{\"key\":false}]}"); 2902 free(s); 2903 // json bool 2904 freeO(self); 2905 setTypeBoolO(self); 2906 value = allocSmallBool(true); 2907 r = self->f->setNFreeSmallBool(self, "1", value); 2908 ck_assert_ptr_eq(r, null); 2909 // json array 2910 freeO(self); 2911 setTypeArrayO(self); 2912 r = self->f->setNFreeSmallBool(self, "1", value); 2913 ck_assert_ptr_eq(r, null); 2914 // non existing dict path 2915 freeO(self); 2916 r = self->f->setNFreeSmallBool(self, "\"1\"[1]", value); 2917 ck_assert_ptr_eq(r, null); 2918 // dict path but the object is an array 2919 resetO(&a); 2920 self->f->setArray(self, "1", &a); 2921 r = self->f->setNFreeSmallBool(self, "\"1\".\"1\"", value); 2922 ck_assert_ptr_eq(r, null); 2923 // dict object in path but the key doesn't exists 2924 resetO(&d); 2925 self->f->setDict(self, "2", &d); 2926 r = self->f->setNFreeSmallBool(self, "\"2\".\"1\".[12]", value); 2927 ck_assert_ptr_eq(r, null); 2928 // null value 2929 r = self->f->setNFreeSmallBool(self, "1", null); 2930 ck_assert_ptr_eq(r, null); 2931 // null key 2932 r = self->f->setNFreeSmallBool(self, null, value); 2933 ck_assert_ptr_eq(r, null); 2934 terminateO(value); 2935 terminateO(self); 2936 2937 } 2938 2939 2940 void setNFreeSmallBytesSmallJsonT(void) { 2941 2942 smallJsont* r; 2943 smallJsont *self = allocSmallJson(); 2944 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 2945 2946 r = self->f->setNFreeSmallBytes(self, "1", value); 2947 ck_assert_ptr_ne(r, null); 2948 char *s = toStringO(r); 2949 ck_assert_str_eq(s, "{\"1\":[0x71,0x77,0x65,0x00]}"); 2950 free(s); 2951 // path 2952 value = allocSmallBytes("qwf", sizeof("qwf")); 2953 createSmallArray(a); 2954 createSmallDict(d); 2955 a.f->pushDict(&a, &d); 2956 self->f->setArray(self, "array", &a); 2957 r = self->f->setNFreeSmallBytes(self, "\"array\"[0].\"key\"", value); 2958 ck_assert_ptr_ne(r, null); 2959 s = toStringO(r); 2960 ck_assert_str_eq(s, "{\"1\":[0x71,0x77,0x65,0x00],\"array\":[{\"key\":[0x71,0x77,0x66,0x00]}]}"); 2961 free(s); 2962 // json bool 2963 freeO(self); 2964 setTypeBoolO(self); 2965 value = allocSmallBytes("qwf", sizeof("qwf")); 2966 r = self->f->setNFreeSmallBytes(self, "1", value); 2967 ck_assert_ptr_eq(r, null); 2968 // json array 2969 freeO(self); 2970 setTypeArrayO(self); 2971 r = self->f->setNFreeSmallBytes(self, "1", value); 2972 ck_assert_ptr_eq(r, null); 2973 // non existing dict path 2974 freeO(self); 2975 r = self->f->setNFreeSmallBytes(self, "\"1\"[1]", value); 2976 ck_assert_ptr_eq(r, null); 2977 // dict path but the object is an array 2978 resetO(&a); 2979 self->f->setArray(self, "1", &a); 2980 r = self->f->setNFreeSmallBytes(self, "\"1\".\"1\"", value); 2981 ck_assert_ptr_eq(r, null); 2982 // dict object in path but the key doesn't exists 2983 resetO(&d); 2984 self->f->setDict(self, "2", &d); 2985 r = self->f->setNFreeSmallBytes(self, "\"2\".\"1\".[12]", value); 2986 ck_assert_ptr_eq(r, null); 2987 // null value 2988 r = self->f->setNFreeSmallBytes(self, "1", null); 2989 ck_assert_ptr_eq(r, null); 2990 // null key 2991 r = self->f->setNFreeSmallBytes(self, null, value); 2992 ck_assert_ptr_eq(r, null); 2993 terminateO(value); 2994 terminateO(self); 2995 2996 } 2997 2998 2999 void setNFreeSmallDoubleSmallJsonT(void) { 3000 3001 smallJsont* r; 3002 smallJsont *self = allocSmallJson(); 3003 smallDoublet *value = allocSmallDouble(2.2); 3004 3005 r = self->f->setNFreeSmallDouble(self, "1", value); 3006 ck_assert_ptr_ne(r, null); 3007 char *s = toStringO(r); 3008 ck_assert_str_eq(s, "{\"1\":2.200000e+00}"); 3009 free(s); 3010 // path 3011 value = allocSmallDouble(1.2); 3012 createSmallArray(a); 3013 createSmallDict(d); 3014 a.f->pushDict(&a, &d); 3015 self->f->setArray(self, "array", &a); 3016 r = self->f->setNFreeSmallDouble(self, "\"array\"[0].\"key\"", value); 3017 ck_assert_ptr_ne(r, null); 3018 s = toStringO(r); 3019 ck_assert_str_eq(s, "{\"1\":2.200000e+00,\"array\":[{\"key\":1.200000e+00}]}"); 3020 free(s); 3021 // json bool 3022 freeO(self); 3023 setTypeBoolO(self); 3024 value = allocSmallDouble(3.2); 3025 r = self->f->setNFreeSmallDouble(self, "1", value); 3026 ck_assert_ptr_eq(r, null); 3027 // json array 3028 freeO(self); 3029 setTypeArrayO(self); 3030 r = self->f->setNFreeSmallDouble(self, "1", value); 3031 ck_assert_ptr_eq(r, null); 3032 // non existing dict path 3033 freeO(self); 3034 r = self->f->setNFreeSmallDouble(self, "\"1\"[1]", value); 3035 ck_assert_ptr_eq(r, null); 3036 // dict path but the object is an array 3037 resetO(&a); 3038 self->f->setArray(self, "1", &a); 3039 r = self->f->setNFreeSmallDouble(self, "\"1\".\"1\"", value); 3040 ck_assert_ptr_eq(r, null); 3041 // dict object in path but the key doesn't exists 3042 resetO(&d); 3043 self->f->setDict(self, "2", &d); 3044 r = self->f->setNFreeSmallDouble(self, "\"2\".\"1\".[12]", value); 3045 ck_assert_ptr_eq(r, null); 3046 // null value 3047 r = self->f->setNFreeSmallDouble(self, "1", null); 3048 ck_assert_ptr_eq(r, null); 3049 // null key 3050 r = self->f->setNFreeSmallDouble(self, null, value); 3051 ck_assert_ptr_eq(r, null); 3052 terminateO(value); 3053 terminateO(self); 3054 3055 } 3056 3057 3058 void setNFreeSmallIntSmallJsonT(void) { 3059 3060 smallJsont* r; 3061 smallJsont *self = allocSmallJson(); 3062 smallIntt *value = allocSmallInt(2); 3063 3064 r = self->f->setNFreeSmallInt(self, "1", value); 3065 ck_assert_ptr_ne(r, null); 3066 char *s = toStringO(r); 3067 ck_assert_str_eq(s, "{\"1\":2}"); 3068 free(s); 3069 // path 3070 value = allocSmallInt(3); 3071 createSmallArray(a); 3072 createSmallDict(d); 3073 a.f->pushDict(&a, &d); 3074 self->f->setArray(self, "array", &a); 3075 r = self->f->setNFreeSmallInt(self, "\"array\"[0].\"key\"", value); 3076 ck_assert_ptr_ne(r, null); 3077 s = toStringO(r); 3078 ck_assert_str_eq(s, "{\"1\":2,\"array\":[{\"key\":3}]}"); 3079 free(s); 3080 // json bool 3081 freeO(self); 3082 setTypeBoolO(self); 3083 value = allocSmallInt(1); 3084 r = self->f->setNFreeSmallInt(self, "1", value); 3085 ck_assert_ptr_eq(r, null); 3086 // json array 3087 freeO(self); 3088 setTypeArrayO(self); 3089 r = self->f->setNFreeSmallInt(self, "1", value); 3090 ck_assert_ptr_eq(r, null); 3091 // non existing dict path 3092 freeO(self); 3093 r = self->f->setNFreeSmallInt(self, "\"1\"[1]", value); 3094 ck_assert_ptr_eq(r, null); 3095 // dict path but the object is an array 3096 resetO(&a); 3097 self->f->setArray(self, "1", &a); 3098 r = self->f->setNFreeSmallInt(self, "\"1\".\"1\"", value); 3099 ck_assert_ptr_eq(r, null); 3100 // dict object in path but the key doesn't exists 3101 resetO(&d); 3102 self->f->setDict(self, "2", &d); 3103 r = self->f->setNFreeSmallInt(self, "\"2\".\"1\".[12]", value); 3104 ck_assert_ptr_eq(r, null); 3105 // null value 3106 r = self->f->setNFreeSmallInt(self, "1", null); 3107 ck_assert_ptr_eq(r, null); 3108 // null key 3109 r = self->f->setNFreeSmallInt(self, null, value); 3110 ck_assert_ptr_eq(r, null); 3111 terminateO(value); 3112 terminateO(self); 3113 3114 } 3115 3116 3117 void setNFreeSmallJsonSmallJsonT(void) { 3118 3119 smallJsont* r; 3120 smallJsont *self = allocSmallJson(); 3121 smallJsont *value = allocSmallJson(); 3122 3123 setTopIntO(value, 2); 3124 r = self->f->setNFreeSmallJson(self, "1", value); 3125 ck_assert_ptr_ne(r, null); 3126 char *s = toStringO(r); 3127 ck_assert_str_eq(s, "{\"1\":2}"); 3128 free(s); 3129 // path 3130 value = allocSmallJson(); 3131 createSmallArray(a); 3132 createSmallDict(d); 3133 a.f->pushDict(&a, &d); 3134 self->f->setArray(self, "array", &a); 3135 r = self->f->setNFreeSmallJson(self, "\"array\"[0].\"key\"", value); 3136 ck_assert_ptr_ne(r, null); 3137 s = toStringO(r); 3138 ck_assert_str_eq(s, "{\"1\":2,\"array\":[{\"key\":{}}]}"); 3139 free(s); 3140 // json bool 3141 freeO(self); 3142 setTypeBoolO(self); 3143 value = allocSmallJson(); 3144 r = self->f->setNFreeSmallJson(self, "1", value); 3145 ck_assert_ptr_eq(r, null); 3146 // json array 3147 freeO(self); 3148 setTypeArrayO(self); 3149 r = self->f->setNFreeSmallJson(self, "1", value); 3150 ck_assert_ptr_eq(r, null); 3151 // non existing dict path 3152 freeO(self); 3153 r = self->f->setNFreeSmallJson(self, "\"1\"[1]", value); 3154 ck_assert_ptr_eq(r, null); 3155 // dict path but the object is an array 3156 resetO(&a); 3157 self->f->setArray(self, "1", &a); 3158 r = self->f->setNFreeSmallJson(self, "\"1\".\"1\"", value); 3159 ck_assert_ptr_eq(r, null); 3160 // dict object in path but the key doesn't exists 3161 resetO(&d); 3162 self->f->setDict(self, "2", &d); 3163 r = self->f->setNFreeSmallJson(self, "\"2\".\"1\".[12]", value); 3164 ck_assert_ptr_eq(r, null); 3165 // null value 3166 r = self->f->setNFreeSmallJson(self, "1", null); 3167 ck_assert_ptr_eq(r, null); 3168 // null key 3169 r = self->f->setNFreeSmallJson(self, null, value); 3170 ck_assert_ptr_eq(r, null); 3171 terminateO(value); 3172 terminateO(self); 3173 3174 } 3175 3176 3177 void setNFreeSmallStringSmallJsonT(void) { 3178 3179 smallJsont* r; 3180 smallJsont *self = allocSmallJson(); 3181 smallStringt *string = allocSmallString("qwe"); 3182 3183 r = self->f->setNFreeSmallString(self, "1", string); 3184 ck_assert_ptr_ne(r, null); 3185 char *s = toStringO(r); 3186 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 3187 free(s); 3188 // path 3189 smallStringt *value = allocSmallString("asd"); 3190 createSmallArray(a); 3191 createSmallDict(d); 3192 a.f->pushDict(&a, &d); 3193 self->f->setArray(self, "array", &a); 3194 r = self->f->setNFreeSmallString(self, "\"array\"[0].\"key\"", value); 3195 ck_assert_ptr_ne(r, null); 3196 s = toStringO(r); 3197 ck_assert_str_eq(s, "{\"1\":\"qwe\",\"array\":[{\"key\":\"asd\"}]}"); 3198 free(s); 3199 // json bool 3200 freeO(self); 3201 setTypeBoolO(self); 3202 value = allocSmallString("123"); 3203 r = self->f->setNFreeSmallString(self, "1", value); 3204 ck_assert_ptr_eq(r, null); 3205 // json array 3206 freeO(self); 3207 setTypeArrayO(self); 3208 r = self->f->setNFreeSmallString(self, "1", value); 3209 ck_assert_ptr_eq(r, null); 3210 // non existing dict path 3211 freeO(self); 3212 r = self->f->setNFreeSmallString(self, "\"1\"[1]", value); 3213 ck_assert_ptr_eq(r, null); 3214 // dict path but the object is an array 3215 resetO(&a); 3216 self->f->setArray(self, "1", &a); 3217 r = self->f->setNFreeSmallString(self, "\"1\".\"1\"", value); 3218 ck_assert_ptr_eq(r, null); 3219 // dict object in path but the key doesn't exists 3220 resetO(&d); 3221 self->f->setDict(self, "2", &d); 3222 r = self->f->setNFreeSmallString(self, "\"2\".\"1\".[12]", value); 3223 ck_assert_ptr_eq(r, null); 3224 // null value 3225 r = self->f->setNFreeSmallString(self, "1", null); 3226 ck_assert_ptr_eq(r, null); 3227 // null key 3228 r = self->f->setNFreeSmallString(self, null, string); 3229 ck_assert_ptr_eq(r, null); 3230 terminateO(value); 3231 terminateO(self); 3232 3233 } 3234 3235 3236 void setNFreeSmallContainerSmallJsonT(void) { 3237 3238 smallJsont* r; 3239 smallJsont *self = allocSmallJson(); 3240 smallContainert *container = allocSmallContainer(null); 3241 3242 r = self->f->setNFreeSmallContainer(self, "1", container); 3243 ck_assert_ptr_ne(r, null); 3244 char *s = toStringO(r); 3245 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 3246 free(s); 3247 // path 3248 smallContainert *value = allocSmallContainer(null); 3249 createSmallArray(a); 3250 createSmallDict(d); 3251 a.f->pushDict(&a, &d); 3252 self->f->setArray(self, "array", &a); 3253 r = self->f->setNFreeSmallContainer(self, "\"array\"[0].\"key\"", value); 3254 ck_assert_ptr_ne(r, null); 3255 s = toStringO(r); 3256 ck_assert_str_eq(s, "{\"1\":\"<data container>\",\"array\":[{\"key\":\"<data container>\"}]}"); 3257 free(s); 3258 // json bool 3259 freeO(self); 3260 setTypeBoolO(self); 3261 value = allocSmallContainer(null); 3262 r = self->f->setNFreeSmallContainer(self, "1", value); 3263 ck_assert_ptr_eq(r, null); 3264 // json array 3265 freeO(self); 3266 setTypeArrayO(self); 3267 r = self->f->setNFreeSmallContainer(self, "1", value); 3268 ck_assert_ptr_eq(r, null); 3269 // non existing dict path 3270 freeO(self); 3271 r = self->f->setNFreeSmallContainer(self, "\"1\"[1]", value); 3272 ck_assert_ptr_eq(r, null); 3273 // dict path but the object is an array 3274 resetO(&a); 3275 self->f->setArray(self, "1", &a); 3276 r = self->f->setNFreeSmallContainer(self, "\"1\".\"1\"", value); 3277 ck_assert_ptr_eq(r, null); 3278 // dict object in path but the key doesn't exists 3279 resetO(&d); 3280 self->f->setDict(self, "2", &d); 3281 r = self->f->setNFreeSmallContainer(self, "\"2\".\"1\".[12]", value); 3282 ck_assert_ptr_eq(r, null); 3283 // null value 3284 r = self->f->setNFreeSmallContainer(self, "1", null); 3285 ck_assert_ptr_eq(r, null); 3286 // null key 3287 r = self->f->setNFreeSmallContainer(self, null, container); 3288 ck_assert_ptr_eq(r, null); 3289 terminateO(value); 3290 terminateO(self); 3291 3292 } 3293 3294 3295 void setPDictSmallJsonT(void) { 3296 3297 smallJsont* r; 3298 smallJsont *self = allocSmallJson(); 3299 smallDictt *dict; 3300 3301 dict = allocSmallDict(); 3302 r = self->f->setDict(self, "1", dict); 3303 ck_assert_ptr_ne(r, null); 3304 dict->f->setInt(dict, "a", 1); 3305 r = self->f->setPDict(self, "1", dict); 3306 ck_assert_ptr_ne(r, null); 3307 char *s = toStringO(r); 3308 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 3309 free(s); 3310 // empty dict 3311 finishO(dict); 3312 dict = allocSmallDict(); 3313 r = self->f->setPDict(self, "1", dict); 3314 ck_assert_ptr_eq(r, null); 3315 finishO(dict); 3316 s = toStringO(self); 3317 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 3318 free(s); 3319 // non smallDict object 3320 dict = (smallDictt*) allocSmallInt(2); 3321 r = self->f->setPDict(self, "1", dict); 3322 ck_assert_ptr_eq(r, null); 3323 terminateO(dict); 3324 // path 3325 dict = allocSmallDict(); 3326 dict->f->setInt(dict, "b", 2); 3327 createSmallArray(a); 3328 createSmallDict(d); 3329 a.f->pushDict(&a, &d); 3330 self->f->setArray(self, "array", &a); 3331 r = self->f->setPDict(self, "\"array\"[0].\"key\"", dict); 3332 ck_assert_ptr_ne(r, null); 3333 finishO(dict); 3334 s = toStringO(r); 3335 ck_assert_str_eq(s, "{\"1\":{\"a\":1},\"array\":[{\"key\":{\"b\":2}}]}"); 3336 free(s); 3337 // json bool 3338 freeO(self); 3339 setTypeBoolO(self); 3340 dict = allocSmallDict(); 3341 dict->f->setInt(dict, "b", 2); 3342 r = self->f->setPDict(self, "1", dict); 3343 ck_assert_ptr_eq(r, null); 3344 // json array 3345 freeO(self); 3346 setTypeArrayO(self); 3347 r = self->f->setPDict(self, "1", dict); 3348 ck_assert_ptr_eq(r, null); 3349 // non existing dict path 3350 freeO(self); 3351 r = self->f->setPDict(self, "\"1\"[1]", dict); 3352 ck_assert_ptr_eq(r, null); 3353 // dict path but the object is an array 3354 resetO(&a); 3355 self->f->setArray(self, "1", &a); 3356 r = self->f->setPDict(self, "\"1\".\"1\"", dict); 3357 ck_assert_ptr_eq(r, null); 3358 // dict object in path but the key doesn't exists 3359 resetO(&d); 3360 self->f->setDict(self, "2", &d); 3361 r = self->f->setPDict(self, "\"2\".\"1\".[12]", dict); 3362 ck_assert_ptr_eq(r, null); 3363 // null value 3364 r = self->f->setPDict(self, "1", null); 3365 ck_assert_ptr_eq(r, null); 3366 // null key 3367 r = self->f->setPDict(self, null, dict); 3368 ck_assert_ptr_eq(r, null); 3369 terminateO(dict); 3370 terminateO(self); 3371 3372 } 3373 3374 3375 void setPArraySmallJsonT(void) { 3376 3377 smallJsont* r; 3378 smallJsont *self = allocSmallJson(); 3379 smallArrayt *array; 3380 3381 array = allocSmallArray(); 3382 r = self->f->setArray(self, "1", array); 3383 ck_assert_ptr_ne(r, null); 3384 array->f->pushInt(array, 1); 3385 r = self->f->setPArray(self, "1", array); 3386 ck_assert_ptr_ne(r, null); 3387 char *s = toStringO(r); 3388 ck_assert_str_eq(s, "{\"1\":[1]}"); 3389 free(s); 3390 // empty array 3391 finishO(array); 3392 array = allocSmallArray(); 3393 r = self->f->setPArray(self, "1", array); 3394 ck_assert_ptr_eq(r, null); 3395 finishO(array); 3396 s = toStringO(self); 3397 ck_assert_str_eq(s, "{\"1\":[1]}"); 3398 free(s); 3399 // non smallDict object 3400 array = (smallArrayt*) allocSmallInt(2); 3401 r = self->f->setPArray(self, "1", array); 3402 ck_assert_ptr_eq(r, null); 3403 terminateO(array); 3404 // path 3405 array = allocSmallArray(); 3406 array->f->pushInt(array, 2); 3407 createSmallArray(a); 3408 createSmallDict(d); 3409 a.f->pushDict(&a, &d); 3410 self->f->setArray(self, "array", &a); 3411 r = self->f->setPArray(self, "\"array\"[0].\"key\"", array); 3412 ck_assert_ptr_ne(r, null); 3413 finishO(array); 3414 s = toStringO(r); 3415 ck_assert_str_eq(s, "{\"1\":[1],\"array\":[{\"key\":[2]}]}"); 3416 free(s); 3417 // json bool 3418 array = allocSmallArray(); 3419 array->f->pushInt(array, 2); 3420 freeO(self); 3421 setTypeBoolO(self); 3422 r = self->f->setPArray(self, "1", array); 3423 ck_assert_ptr_eq(r, null); 3424 // json array 3425 freeO(self); 3426 setTypeArrayO(self); 3427 r = self->f->setPArray(self, "1", array); 3428 ck_assert_ptr_eq(r, null); 3429 // non existing dict path 3430 freeO(self); 3431 r = self->f->setPArray(self, "\"1\"[1]", array); 3432 ck_assert_ptr_eq(r, null); 3433 // dict path but the object is an array 3434 resetO(&a); 3435 self->f->setArray(self, "1", &a); 3436 r = self->f->setPArray(self, "\"1\".\"1\"", array); 3437 ck_assert_ptr_eq(r, null); 3438 // dict object in path but the key doesn't exists 3439 resetO(&d); 3440 self->f->setDict(self, "2", &d); 3441 r = self->f->setPArray(self, "\"2\".\"1\".[12]", array); 3442 ck_assert_ptr_eq(r, null); 3443 // null value 3444 r = self->f->setPArray(self, "1", null); 3445 ck_assert_ptr_eq(r, null); 3446 // null key 3447 r = self->f->setPArray(self, null, array); 3448 ck_assert_ptr_eq(r, null); 3449 terminateO(array); 3450 terminateO(self); 3451 3452 } 3453 3454 3455 void setPSmallJsonSmallJsonT(void) { 3456 3457 smallJsont* r; 3458 smallJsont *self = allocSmallJson(); 3459 smallJsont *json; 3460 3461 json = allocSmallJson(); 3462 r = self->f->setSmallJson(self, "1", json); 3463 ck_assert_ptr_ne(r, null); 3464 json->f->setInt(json, "a", 1); 3465 r = self->f->setPSmallJson(self, "1", json); 3466 ck_assert_ptr_ne(r, null); 3467 finishO(json); 3468 char *s = toStringO(r); 3469 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 3470 free(s); 3471 // empty smallJson 3472 json = allocSmallJson(); 3473 r = self->f->setPSmallJson(self, "1", json); 3474 ck_assert_ptr_eq(r, null); 3475 terminateO(json); 3476 // non smallJson object 3477 json = (smallJsont*) allocSmallInt(2); 3478 r = self->f->setPSmallJson(self, "1", json); 3479 ck_assert_ptr_eq(r, null); 3480 // path 3481 smallJsont *value = allocSmallJson(); 3482 value->f->setInt(value, "b", 2); 3483 createSmallArray(a); 3484 createSmallDict(d); 3485 a.f->pushDict(&a, &d); 3486 self->f->setArray(self, "array", &a); 3487 r = self->f->setPSmallJson(self, "\"array\"[0].\"key\"", value); 3488 ck_assert_ptr_ne(r, null); 3489 finishO(value); 3490 s = toStringO(r); 3491 ck_assert_str_eq(s, "{\"1\":{\"a\":1},\"array\":[{\"key\":{\"b\":2}}]}"); 3492 free(s); 3493 // json bool 3494 value = allocSmallJson(); 3495 value->f->setInt(value, "b", 2); 3496 freeO(self); 3497 setTypeBoolO(self); 3498 r = self->f->setPSmallJson(self, "1", value); 3499 ck_assert_ptr_eq(r, null); 3500 // json array 3501 freeO(self); 3502 setTypeArrayO(self); 3503 r = self->f->setPSmallJson(self, "1", value); 3504 ck_assert_ptr_eq(r, null); 3505 // non existing dict path 3506 freeO(self); 3507 r = self->f->setPSmallJson(self, "\"1\"[1]", value); 3508 ck_assert_ptr_eq(r, null); 3509 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 3510 createSmallJson(i); 3511 r = self->f->setPSmallJson(self, "\"1\".[1]", &i); 3512 ck_assert_ptr_eq(r, null); 3513 freeO(&i); 3514 // dict path but the object is an array 3515 resetO(&a); 3516 self->f->setArray(self, "1", &a); 3517 r = self->f->setPSmallJson(self, "\"1\".\"1\"", value); 3518 ck_assert_ptr_eq(r, null); 3519 // dict object in path but the key doesn't exists 3520 resetO(&d); 3521 self->f->setDict(self, "2", &d); 3522 r = self->f->setPSmallJson(self, "\"2\".\"1\".[12]", value); 3523 ck_assert_ptr_eq(r, null); 3524 terminateO(value); 3525 // null value 3526 r = self->f->setPSmallJson(self, "1", null); 3527 ck_assert_ptr_eq(r, null); 3528 // null key 3529 r = self->f->setPSmallJson(self, null, json); 3530 ck_assert_ptr_eq(r, null); 3531 terminateO(self); 3532 terminateO(json); 3533 3534 } 3535 3536 3537 void setPSmallStringSmallJsonT(void) { 3538 3539 smallJsont* r; 3540 smallJsont *self = allocSmallJson(); 3541 smallStringt *string; 3542 3543 string = allocSmallString(""); 3544 r = self->f->setSmallString(self, "1", string); 3545 ck_assert_ptr_ne(r, null); 3546 string->f->appendS(string, "s"); 3547 r = self->f->setPSmallString(self, "1", string); 3548 ck_assert_ptr_ne(r, null); 3549 finishO(string); 3550 char *s = toStringO(r); 3551 ck_assert_str_eq(s, "{\"1\":\"s\"}"); 3552 free(s); 3553 // empty SmallString 3554 string = allocSmallString(""); 3555 freeO(string); 3556 r = self->f->setPSmallString(self, "1", string); 3557 ck_assert_ptr_eq(r, null); 3558 terminateO(string); 3559 // non smallString object 3560 string = (smallStringt*) allocSmallInt(2); 3561 r = self->f->setPSmallString(self, "1", string); 3562 ck_assert_ptr_eq(r, null); 3563 terminateO(string); 3564 // path 3565 smallStringt *value = allocSmallString("asd"); 3566 createSmallArray(a); 3567 createSmallDict(d); 3568 a.f->pushDict(&a, &d); 3569 self->f->setArray(self, "array", &a); 3570 r = self->f->setPSmallString(self, "\"array\"[0].\"key\"", value); 3571 ck_assert_ptr_ne(r, null); 3572 finishO(value); 3573 s = toStringO(r); 3574 ck_assert_str_eq(s, "{\"1\":\"s\",\"array\":[{\"key\":\"asd\"}]}"); 3575 free(s); 3576 // json bool 3577 value = allocSmallString("ASD"); 3578 freeO(self); 3579 setTypeBoolO(self); 3580 r = self->f->setPSmallString(self, "1", value); 3581 ck_assert_ptr_eq(r, null); 3582 // json array 3583 freeO(self); 3584 setTypeArrayO(self); 3585 r = self->f->setPSmallString(self, "1", value); 3586 ck_assert_ptr_eq(r, null); 3587 // non existing dict path 3588 freeO(self); 3589 r = self->f->setPSmallString(self, "\"1\"[1]", value); 3590 ck_assert_ptr_eq(r, null); 3591 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 3592 createSmallString(i); 3593 r = self->f->setPSmallString(self, "\"1\".[1]", &i); 3594 ck_assert_ptr_eq(r, null); 3595 freeO(&i); 3596 // dict path but the object is an array 3597 resetO(&a); 3598 self->f->setArray(self, "1", &a); 3599 r = self->f->setPSmallString(self, "\"1\".\"1\"", value); 3600 ck_assert_ptr_eq(r, null); 3601 // dict object in path but the key doesn't exists 3602 resetO(&d); 3603 self->f->setDict(self, "2", &d); 3604 r = self->f->setPSmallString(self, "\"2\".\"1\".[12]", value); 3605 ck_assert_ptr_eq(r, null); 3606 terminateO(value); 3607 // null value 3608 r = self->f->setPSmallString(self, "1", null); 3609 ck_assert_ptr_eq(r, null); 3610 // null key 3611 string = allocSmallString(""); 3612 r = self->f->setPSmallString(self, null, string); 3613 ck_assert_ptr_eq(r, null); 3614 terminateO(self); 3615 terminateO(string); 3616 3617 } 3618 3619 3620 void setNFreePDictSmallJsonT(void) { 3621 3622 smallJsont* r; 3623 smallJsont *self = allocSmallJson(); 3624 smallDictt *value; 3625 3626 value = allocSmallDict(); 3627 r = self->f->setDict(self, "1", value); 3628 ck_assert_ptr_ne(r, null); 3629 value->f->setInt(value, "a", 1); 3630 r = self->f->setNFreePDict(self, "1", value); 3631 ck_assert_ptr_ne(r, null); 3632 char *s = toStringO(r); 3633 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 3634 free(s); 3635 // empty smallDict 3636 value = allocSmallDict(); 3637 r = self->f->setNFreePDict(self, "1", value); 3638 ck_assert_ptr_eq(r, null); 3639 terminateO(value); 3640 // non smallDict object 3641 value = (smallDictt*) allocSmallInt(2); 3642 r = self->f->setNFreePDict(self, "1", value); 3643 ck_assert_ptr_eq(r, null); 3644 terminateO(value); 3645 // path 3646 value = allocSmallDict(); 3647 value->f->setInt(value, "b", 2); 3648 createSmallArray(a); 3649 createSmallDict(d); 3650 a.f->pushDict(&a, &d); 3651 self->f->setArray(self, "array", &a); 3652 r = self->f->setNFreePDict(self, "\"array\"[0].\"key\"", value); 3653 ck_assert_ptr_ne(r, null); 3654 s = toStringO(r); 3655 ck_assert_str_eq(s, "{\"1\":{\"a\":1},\"array\":[{\"key\":{\"b\":2}}]}"); 3656 free(s); 3657 // json bool 3658 freeO(self); 3659 setTypeBoolO(self); 3660 value = allocSmallDict(); 3661 value->f->setInt(value, "b", 2); 3662 r = self->f->setNFreePDict(self, "1", value); 3663 ck_assert_ptr_eq(r, null); 3664 // json array 3665 freeO(self); 3666 setTypeArrayO(self); 3667 r = self->f->setNFreePDict(self, "1", value); 3668 ck_assert_ptr_eq(r, null); 3669 // non existing dict path 3670 freeO(self); 3671 r = self->f->setNFreePDict(self, "\"1\"[1]", value); 3672 ck_assert_ptr_eq(r, null); 3673 // dict path but the object is an array 3674 resetO(&a); 3675 self->f->setArray(self, "1", &a); 3676 r = self->f->setNFreePDict(self, "\"1\".\"1\"", value); 3677 ck_assert_ptr_eq(r, null); 3678 // dict object in path but the key doesn't exists 3679 resetO(&d); 3680 self->f->setDict(self, "2", &d); 3681 r = self->f->setNFreePDict(self, "\"2\".\"1\".[12]", value); 3682 ck_assert_ptr_eq(r, null); 3683 // null value 3684 r = self->f->setNFreePDict(self, "1", null); 3685 ck_assert_ptr_eq(r, null); 3686 // null key 3687 r = self->f->setNFreePDict(self, null, value); 3688 ck_assert_ptr_eq(r, null); 3689 terminateO(self); 3690 terminateO(value); 3691 3692 } 3693 3694 3695 void setNFreePArraySmallJsonT(void) { 3696 3697 smallJsont* r; 3698 smallJsont *self = allocSmallJson(); 3699 smallArrayt *value; 3700 3701 value = allocSmallArray(); 3702 r = self->f->setArray(self, "1", value); 3703 ck_assert_ptr_ne(r, null); 3704 value->f->pushInt(value, 2); 3705 r = self->f->setNFreePArray(self, "1", value); 3706 ck_assert_ptr_ne(r, null); 3707 char *s = toStringO(r); 3708 ck_assert_str_eq(s, "{\"1\":[2]}"); 3709 free(s); 3710 // empty smallArray 3711 value = allocSmallArray(); 3712 r = self->f->setNFreePArray(self, "1", value); 3713 ck_assert_ptr_eq(r, null); 3714 terminateO(value); 3715 // non smallArray object 3716 value = (smallArrayt*) allocSmallInt(2); 3717 r = self->f->setNFreePArray(self, "1", value); 3718 ck_assert_ptr_eq(r, null); 3719 terminateO(value); 3720 // path 3721 value = allocSmallArray(); 3722 value->f->pushInt(value, 3); 3723 createSmallArray(a); 3724 createSmallDict(d); 3725 a.f->pushDict(&a, &d); 3726 self->f->setArray(self, "array", &a); 3727 r = self->f->setNFreePArray(self, "\"array\"[0].\"key\"", value); 3728 ck_assert_ptr_ne(r, null); 3729 s = toStringO(r); 3730 ck_assert_str_eq(s, "{\"1\":[2],\"array\":[{\"key\":[3]}]}"); 3731 free(s); 3732 // json bool 3733 value = allocSmallArray(); 3734 value->f->pushInt(value, 2); 3735 freeO(self); 3736 setTypeBoolO(self); 3737 r = self->f->setNFreePArray(self, "1", value); 3738 ck_assert_ptr_eq(r, null); 3739 // json array 3740 freeO(self); 3741 setTypeArrayO(self); 3742 r = self->f->setNFreePArray(self, "1", value); 3743 ck_assert_ptr_eq(r, null); 3744 // non existing dict path 3745 freeO(self); 3746 r = self->f->setNFreePArray(self, "\"1\"[1]", value); 3747 ck_assert_ptr_eq(r, null); 3748 // dict path but the object is an array 3749 resetO(&a); 3750 self->f->setArray(self, "1", &a); 3751 r = self->f->setNFreePArray(self, "\"1\".\"1\"", value); 3752 ck_assert_ptr_eq(r, null); 3753 // dict object in path but the key doesn't exists 3754 resetO(&d); 3755 self->f->setDict(self, "2", &d); 3756 r = self->f->setNFreePArray(self, "\"2\".\"1\".[12]", value); 3757 ck_assert_ptr_eq(r, null); 3758 // null value 3759 r = self->f->setNFreePArray(self, "1", null); 3760 ck_assert_ptr_eq(r, null); 3761 // null key 3762 r = self->f->setNFreePArray(self, null, value); 3763 ck_assert_ptr_eq(r, null); 3764 terminateO(self); 3765 terminateO(value); 3766 3767 } 3768 3769 3770 void setNFreePSmallJsonSmallJsonT(void) { 3771 3772 smallJsont* r; 3773 smallJsont *self = allocSmallJson(); 3774 smallJsont *value; 3775 3776 value = allocSmallJson(); 3777 r = self->f->setSmallJson(self, "1", value); 3778 ck_assert_ptr_ne(r, null); 3779 value->f->setInt(value, "a", 1); 3780 r = self->f->setNFreePSmallJson(self, "1", value); 3781 ck_assert_ptr_ne(r, null); 3782 char *s = toStringO(r); 3783 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 3784 free(s); 3785 // empty smallJson 3786 value = allocSmallJson(); 3787 r = self->f->setNFreePSmallJson(self, "1", value); 3788 ck_assert_ptr_eq(r, null); 3789 terminateO(value); 3790 // non smallJson object 3791 value = (smallJsont*) allocSmallInt(2); 3792 r = self->f->setNFreePSmallJson(self, "1", value); 3793 ck_assert_ptr_eq(r, null); 3794 terminateO(value); 3795 // path 3796 value = allocSmallJson(); 3797 value->f->setInt(value, "b", 2); 3798 createSmallArray(a); 3799 createSmallDict(d); 3800 a.f->pushDict(&a, &d); 3801 self->f->setArray(self, "array", &a); 3802 r = self->f->setNFreePSmallJson(self, "\"array\"[0].\"key\"", value); 3803 ck_assert_ptr_ne(r, null); 3804 s = toStringO(r); 3805 ck_assert_str_eq(s, "{\"1\":{\"a\":1},\"array\":[{\"key\":{\"b\":2}}]}"); 3806 free(s); 3807 // json bool 3808 value = allocSmallJson(); 3809 value->f->setInt(value, "b", 2); 3810 freeO(self); 3811 setTypeBoolO(self); 3812 r = self->f->setNFreePSmallJson(self, "1", value); 3813 ck_assert_ptr_eq(r, null); 3814 // json array 3815 freeO(self); 3816 setTypeArrayO(self); 3817 r = self->f->setNFreePSmallJson(self, "1", value); 3818 ck_assert_ptr_eq(r, null); 3819 // non existing dict path 3820 freeO(self); 3821 r = self->f->setNFreePSmallJson(self, "\"1\"[1]", value); 3822 ck_assert_ptr_eq(r, null); 3823 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 3824 createSmallJson(i); 3825 r = self->f->setNFreePSmallJson(self, "\"1\".[1]", &i); 3826 ck_assert_ptr_eq(r, null); 3827 freeO(&i); 3828 // dict path but the object is an array 3829 resetO(&a); 3830 self->f->setArray(self, "1", &a); 3831 r = self->f->setNFreePSmallJson(self, "\"1\".\"1\"", value); 3832 ck_assert_ptr_eq(r, null); 3833 // dict object in path but the key doesn't exists 3834 resetO(&d); 3835 self->f->setDict(self, "2", &d); 3836 r = self->f->setNFreePSmallJson(self, "\"2\".\"1\".[12]", value); 3837 ck_assert_ptr_eq(r, null); 3838 // null value 3839 r = self->f->setNFreePSmallJson(self, "1", null); 3840 ck_assert_ptr_eq(r, null); 3841 // null key 3842 r = self->f->setNFreePSmallJson(self, null, value); 3843 ck_assert_ptr_eq(r, null); 3844 terminateO(self); 3845 terminateO(value); 3846 3847 } 3848 3849 3850 void setNFreePSmallStringSmallJsonT(void) { 3851 3852 smallJsont* r; 3853 smallJsont *self = allocSmallJson(); 3854 smallStringt *value; 3855 3856 value = allocSmallString(""); 3857 r = self->f->setSmallString(self, "1", value); 3858 ck_assert_ptr_ne(r, null); 3859 value->f->appendS(value, "2"); 3860 r = self->f->setNFreePSmallString(self, "1", value); 3861 ck_assert_ptr_ne(r, null); 3862 char *s = toStringO(r); 3863 ck_assert_str_eq(s, "{\"1\":\"2\"}"); 3864 free(s); 3865 // empty SmallString 3866 value = allocSmallString(""); 3867 freeO(value); 3868 r = self->f->setNFreePSmallString(self, "1", value); 3869 ck_assert_ptr_eq(r, null); 3870 terminateO(value); 3871 // non smallString object 3872 value = (smallStringt*) allocSmallInt(2); 3873 r = self->f->setNFreePSmallString(self, "1", value); 3874 ck_assert_ptr_eq(r, null); 3875 terminateO(value); 3876 // path 3877 value = allocSmallString("asd"); 3878 createSmallArray(a); 3879 createSmallDict(d); 3880 a.f->pushDict(&a, &d); 3881 self->f->setArray(self, "array", &a); 3882 r = self->f->setNFreePSmallString(self, "\"array\"[0].\"key\"", value); 3883 ck_assert_ptr_ne(r, null); 3884 s = toStringO(r); 3885 ck_assert_str_eq(s, "{\"1\":\"2\",\"array\":[{\"key\":\"asd\"}]}"); 3886 free(s); 3887 // json bool 3888 value = allocSmallString("ASD"); 3889 freeO(self); 3890 setTypeBoolO(self); 3891 r = self->f->setNFreePSmallString(self, "1", value); 3892 ck_assert_ptr_eq(r, null); 3893 // json array 3894 freeO(self); 3895 setTypeArrayO(self); 3896 r = self->f->setNFreePSmallString(self, "1", value); 3897 ck_assert_ptr_eq(r, null); 3898 // non existing dict path 3899 freeO(self); 3900 r = self->f->setNFreePSmallString(self, "\"1\"[1]", value); 3901 ck_assert_ptr_eq(r, null); 3902 // wrong path and empty smallInt container (sInt is allocated in toSmallt) 3903 createSmallString(i); 3904 r = self->f->setNFreePSmallString(self, "\"1\".[1]", &i); 3905 ck_assert_ptr_eq(r, null); 3906 freeO(&i); 3907 // dict path but the object is an array 3908 resetO(&a); 3909 self->f->setArray(self, "1", &a); 3910 r = self->f->setNFreePSmallString(self, "\"1\".\"1\"", value); 3911 ck_assert_ptr_eq(r, null); 3912 // dict object in path but the key doesn't exists 3913 resetO(&d); 3914 self->f->setDict(self, "2", &d); 3915 r = self->f->setNFreePSmallString(self, "\"2\".\"1\".[12]", value); 3916 ck_assert_ptr_eq(r, null); 3917 // null value 3918 r = self->f->setNFreePSmallString(self, "1", null); 3919 ck_assert_ptr_eq(r, null); 3920 // null key 3921 r = self->f->setNFreePSmallString(self, null, value); 3922 ck_assert_ptr_eq(r, null); 3923 terminateO(self); 3924 terminateO(value); 3925 3926 } 3927 3928 3929 void setAtSmallJsonT(void) { 3930 3931 smallJsont* r; 3932 smallJsont *self = allocSmallJson(); 3933 baset *value; 3934 3935 // add elements to self 3936 r = self->f->pushInt(self, 1); 3937 ck_assert_ptr_ne(r, null); 3938 r = self->f->pushInt(self, 2); 3939 ck_assert_ptr_ne(r, null); 3940 r = self->f->pushInt(self, 3); 3941 ck_assert_ptr_ne(r, null); 3942 r = self->f->pushInt(self, 4); 3943 ck_assert_ptr_ne(r, null); 3944 3945 // positive index 3946 value = (baset*)allocSmallInt(123); 3947 r = self->f->setAt(self, 1, value); 3948 ck_assert_ptr_ne(r, null); 3949 finishO(value); 3950 char *s = toStringO(r); 3951 ck_assert_str_eq(s, "[1,123,3,4]"); 3952 free(s); 3953 // negative index 3954 value = (baset*)allocSmallInt(234); 3955 r = self->f->setAt(self, -1, value); 3956 ck_assert_ptr_ne(r, null); 3957 finishO(value); 3958 s = toStringO(r); 3959 ck_assert_str_eq(s, "[1,123,3,234]"); 3960 free(s); 3961 // undefined object 3962 value = (baset*)allocUndefined(); 3963 r = self->f->setAt(self, -1, value); 3964 ck_assert_ptr_ne(r, null); 3965 finishO(value); 3966 s = toStringO(r); 3967 ck_assert_str_eq(s, "[1,123,3,null]"); 3968 free(s); 3969 // container 3970 createAllocateSmallContainer(c); 3971 r = self->f->setAt(self, -1, (baset*)c); 3972 ck_assert_ptr_ne(r, null); 3973 finishO(c); 3974 s = toStringO(r); 3975 ck_assert_str_eq(s, "[1,123,3,\"<data container>\"]"); 3976 free(s); 3977 // base object in container 3978 createAllocateSmallInt(I); 3979 setValG(I, 11); 3980 I->type = "anothertype"; 3981 r = self->f->setAt(self, -1, (baset*)I); 3982 ck_assert_ptr_ne(r, null); 3983 s = toStringO(r); 3984 ck_assert_str_eq(s, "[1,123,3,\"<data container>\"]"); 3985 free(s); 3986 // index outside 3987 value = (baset*)allocSmallInt(123); 3988 ck_assert_ptr_eq(self->f->setAt(self, 20, value), NULL); 3989 ck_assert_ptr_eq(self->f->setAt(self, -8, value), NULL); 3990 // empty list 3991 emptyO(self); 3992 ck_assert_ptr_eq(self->f->setAt(self, 0, value), NULL); 3993 ck_assert_ptr_eq(self->f->setAt(self, -1, value), NULL); 3994 terminateO(value); 3995 // NULL value 3996 ck_assert_ptr_eq(self->f->setAt(self, 0, NULL), NULL); 3997 terminateO(self); 3998 3999 } 4000 4001 4002 void setAtUndefinedSmallJsonT(void) { 4003 4004 smallJsont* r; 4005 smallJsont *self = allocSmallJson(); 4006 4007 // add elements to self 4008 r = self->f->pushInt(self, 1); 4009 ck_assert_ptr_ne(r, null); 4010 r = self->f->pushInt(self, 2); 4011 ck_assert_ptr_ne(r, null); 4012 r = self->f->pushInt(self, 3); 4013 ck_assert_ptr_ne(r, null); 4014 r = self->f->pushInt(self, 4); 4015 ck_assert_ptr_ne(r, null); 4016 4017 // positive index 4018 r = self->f->setAtUndefined(self, 1); 4019 ck_assert_ptr_ne(r, null); 4020 char *s = toStringO(r); 4021 ck_assert_str_eq(s, "[1,null,3,4]"); 4022 free(s); 4023 // negative index 4024 r = self->f->setAtUndefined(self, -1); 4025 ck_assert_ptr_ne(r, null); 4026 s = toStringO(r); 4027 ck_assert_str_eq(s, "[1,null,3,null]"); 4028 free(s); 4029 // index outside 4030 ck_assert_ptr_eq(self->f->setAtUndefined(self, 20), NULL); 4031 ck_assert_ptr_eq(self->f->setAtUndefined(self, -8), NULL); 4032 // empty list 4033 emptyO(self); 4034 ck_assert_ptr_eq(self->f->setAtUndefined(self, 0), NULL); 4035 ck_assert_ptr_eq(self->f->setAtUndefined(self, -1), NULL); 4036 // non json array 4037 freeO(self); 4038 setTypeBoolO(self); 4039 ck_assert_ptr_eq(self->f->setAtUndefined(self, 0), NULL); 4040 terminateO(self); 4041 4042 } 4043 4044 4045 void setAtBoolSmallJsonT(void) { 4046 4047 smallJsont* r; 4048 smallJsont *self = allocSmallJson(); 4049 4050 // add elements to self 4051 r = self->f->pushInt(self, 1); 4052 ck_assert_ptr_ne(r, null); 4053 r = self->f->pushInt(self, 2); 4054 ck_assert_ptr_ne(r, null); 4055 r = self->f->pushInt(self, 3); 4056 ck_assert_ptr_ne(r, null); 4057 r = self->f->pushInt(self, 4); 4058 ck_assert_ptr_ne(r, null); 4059 4060 // positive index 4061 r = self->f->setAtBool(self, 1, true); 4062 ck_assert_ptr_ne(r, null); 4063 char *s = toStringO(r); 4064 ck_assert_str_eq(s, "[1,true,3,4]"); 4065 free(s); 4066 // negative index 4067 r = self->f->setAtBool(self, -1, true); 4068 ck_assert_ptr_ne(r, null); 4069 s = toStringO(r); 4070 ck_assert_str_eq(s, "[1,true,3,true]"); 4071 free(s); 4072 // index outside 4073 ck_assert_ptr_eq(self->f->setAtBool(self, 20, true), NULL); 4074 ck_assert_ptr_eq(self->f->setAtBool(self, -8, true), NULL); 4075 // empty list 4076 emptyO(self); 4077 ck_assert_ptr_eq(self->f->setAtBool(self, 0, true), NULL); 4078 ck_assert_ptr_eq(self->f->setAtBool(self, -1, true), NULL); 4079 // non json array 4080 freeO(self); 4081 setTypeBoolO(self); 4082 ck_assert_ptr_eq(self->f->setAtBool(self, 0, true), NULL); 4083 terminateO(self); 4084 4085 } 4086 4087 4088 void setAtDoubleSmallJsonT(void) { 4089 4090 smallJsont* r; 4091 smallJsont *self = allocSmallJson(); 4092 4093 // add elements to self 4094 r = self->f->pushInt(self, 1); 4095 ck_assert_ptr_ne(r, null); 4096 r = self->f->pushInt(self, 2); 4097 ck_assert_ptr_ne(r, null); 4098 r = self->f->pushInt(self, 3); 4099 ck_assert_ptr_ne(r, null); 4100 r = self->f->pushInt(self, 4); 4101 ck_assert_ptr_ne(r, null); 4102 4103 // positive index 4104 r = self->f->setAtDouble(self, 1, 12); 4105 ck_assert_ptr_ne(r, null); 4106 char *s = toStringO(r); 4107 ck_assert_str_eq(s, "[1,1.200000e+01,3,4]"); 4108 free(s); 4109 // negative index 4110 r = self->f->setAtDouble(self, -1, 14); 4111 ck_assert_ptr_ne(r, null); 4112 s = toStringO(r); 4113 ck_assert_str_eq(s, "[1,1.200000e+01,3,1.400000e+01]"); 4114 free(s); 4115 // index outside 4116 ck_assert_ptr_eq(self->f->setAtDouble(self, 20, 1), NULL); 4117 ck_assert_ptr_eq(self->f->setAtDouble(self, -8, 1), NULL); 4118 // empty list 4119 emptyO(self); 4120 ck_assert_ptr_eq(self->f->setAtDouble(self, 0, 1), NULL); 4121 ck_assert_ptr_eq(self->f->setAtDouble(self, -1, 1), NULL); 4122 // non json array 4123 freeO(self); 4124 setTypeBoolO(self); 4125 ck_assert_ptr_eq(self->f->setAtDouble(self, 0, 1), NULL); 4126 terminateO(self); 4127 4128 } 4129 4130 4131 void setAtIntSmallJsonT(void) { 4132 4133 smallJsont* r; 4134 smallJsont *self = allocSmallJson(); 4135 4136 // add elements to self 4137 r = self->f->pushInt(self, 1); 4138 ck_assert_ptr_ne(r, null); 4139 r = self->f->pushInt(self, 2); 4140 ck_assert_ptr_ne(r, null); 4141 r = self->f->pushInt(self, 3); 4142 ck_assert_ptr_ne(r, null); 4143 r = self->f->pushInt(self, 4); 4144 ck_assert_ptr_ne(r, null); 4145 4146 // positive index 4147 r = self->f->setAtInt(self, 1, 12); 4148 ck_assert_ptr_ne(r, null); 4149 char *s = toStringO(r); 4150 ck_assert_str_eq(s, "[1,12,3,4]"); 4151 free(s); 4152 // negative index 4153 r = self->f->setAtInt(self, -1, 14); 4154 ck_assert_ptr_ne(r, null); 4155 s = toStringO(r); 4156 ck_assert_str_eq(s, "[1,12,3,14]"); 4157 free(s); 4158 // index outside 4159 ck_assert_ptr_eq(self->f->setAtInt(self, 20, 1), NULL); 4160 ck_assert_ptr_eq(self->f->setAtInt(self, -8, 1), NULL); 4161 // empty list 4162 emptyO(self); 4163 ck_assert_ptr_eq(self->f->setAtInt(self, 0, 1), NULL); 4164 ck_assert_ptr_eq(self->f->setAtInt(self, -1, 1), NULL); 4165 // non json array 4166 freeO(self); 4167 setTypeBoolO(self); 4168 ck_assert_ptr_eq(self->f->setAtInt(self, 0, 1), NULL); 4169 terminateO(self); 4170 4171 } 4172 4173 4174 void setAtSSmallJsonT(void) { 4175 4176 smallJsont* r; 4177 smallJsont *self = allocSmallJson(); 4178 4179 // add elements to self 4180 r = self->f->pushInt(self, 1); 4181 ck_assert_ptr_ne(r, null); 4182 r = self->f->pushInt(self, 2); 4183 ck_assert_ptr_ne(r, null); 4184 r = self->f->pushInt(self, 3); 4185 ck_assert_ptr_ne(r, null); 4186 r = self->f->pushInt(self, 4); 4187 ck_assert_ptr_ne(r, null); 4188 4189 // positive index 4190 r = self->f->setAtS(self, 1, "a"); 4191 ck_assert_ptr_ne(r, null); 4192 char *s = toStringO(r); 4193 ck_assert_str_eq(s, "[1,\"a\",3,4]"); 4194 free(s); 4195 // negative index 4196 r = self->f->setAtS(self, -1, "b"); 4197 ck_assert_ptr_ne(r, null); 4198 s = toStringO(r); 4199 ck_assert_str_eq(s, "[1,\"a\",3,\"b\"]"); 4200 free(s); 4201 // NULL string 4202 r = self->f->setAtS(self, -1, NULL); 4203 ck_assert_ptr_eq(r, null); 4204 // index outside 4205 ck_assert_ptr_eq(self->f->setAtS(self, 20, ""), NULL); 4206 ck_assert_ptr_eq(self->f->setAtS(self, -8, ""), NULL); 4207 // empty list 4208 emptyO(self); 4209 ck_assert_ptr_eq(self->f->setAtS(self, 0, ""), NULL); 4210 ck_assert_ptr_eq(self->f->setAtS(self, -1, ""), NULL); 4211 terminateO(self); 4212 4213 } 4214 4215 4216 void setAtCharSmallJsonT(void) { 4217 4218 smallJsont* r; 4219 smallJsont *self = allocSmallJson(); 4220 4221 // add elements to self 4222 r = self->f->pushInt(self, 1); 4223 ck_assert_ptr_ne(r, null); 4224 r = self->f->pushInt(self, 2); 4225 ck_assert_ptr_ne(r, null); 4226 r = self->f->pushInt(self, 3); 4227 ck_assert_ptr_ne(r, null); 4228 r = self->f->pushInt(self, 4); 4229 ck_assert_ptr_ne(r, null); 4230 4231 // positive index 4232 r = self->f->setAtChar(self, 1, 'a'); 4233 ck_assert_ptr_ne(r, null); 4234 char *s = toStringO(r); 4235 ck_assert_str_eq(s, "[1,\"a\",3,4]"); 4236 free(s); 4237 // negative index 4238 r = self->f->setAtChar(self, -1, 'b'); 4239 ck_assert_ptr_ne(r, null); 4240 s = toStringO(r); 4241 ck_assert_str_eq(s, "[1,\"a\",3,\"b\"]"); 4242 free(s); 4243 // index outside 4244 ck_assert_ptr_eq(self->f->setAtChar(self, 20, 'a'), NULL); 4245 ck_assert_ptr_eq(self->f->setAtChar(self, -8, 's'), NULL); 4246 // empty list 4247 emptyO(self); 4248 ck_assert_ptr_eq(self->f->setAtChar(self, 0, 'a'), NULL); 4249 ck_assert_ptr_eq(self->f->setAtChar(self, -1, 's'), NULL); 4250 terminateO(self); 4251 4252 } 4253 4254 4255 void setAtDictSmallJsonT(void) { 4256 4257 smallJsont* r; 4258 smallJsont *self = allocSmallJson(); 4259 smallDictt *value; 4260 4261 // add elements to self 4262 r = self->f->pushInt(self, 1); 4263 ck_assert_ptr_ne(r, null); 4264 r = self->f->pushInt(self, 2); 4265 ck_assert_ptr_ne(r, null); 4266 r = self->f->pushInt(self, 3); 4267 ck_assert_ptr_ne(r, null); 4268 r = self->f->pushInt(self, 4); 4269 ck_assert_ptr_ne(r, null); 4270 4271 // positive index 4272 value = allocSmallDict(); 4273 r = self->f->setAtDict(self, 1, value); 4274 ck_assert_ptr_ne(r, null); 4275 finishO(value); 4276 char *s = toStringO(r); 4277 ck_assert_str_eq(s, "[1,{},3,4]"); 4278 free(s); 4279 // negative index 4280 value = allocSmallDict(); 4281 r = self->f->setAtDict(self, -1, value); 4282 ck_assert_ptr_ne(r, null); 4283 finishO(value); 4284 s = toStringO(r); 4285 ck_assert_str_eq(s, "[1,{},3,{}]"); 4286 free(s); 4287 // index outside 4288 value = allocSmallDict(); 4289 ck_assert_ptr_eq(self->f->setAtDict(self, 20, value), NULL); 4290 ck_assert_ptr_eq(self->f->setAtDict(self, -8, value), NULL); 4291 // empty list 4292 emptyO(self); 4293 ck_assert_ptr_eq(self->f->setAtDict(self, 0, value), NULL); 4294 ck_assert_ptr_eq(self->f->setAtDict(self, -1, value), NULL); 4295 terminateO(value); 4296 // non smallDict object 4297 value = (smallDictt*) allocSmallInt(2); 4298 r = self->f->setAtDict(self, 0, value); 4299 ck_assert_ptr_eq(r, null); 4300 terminateO(value); 4301 // NULL value 4302 ck_assert_ptr_eq(self->f->setAtDict(self, 0, NULL), NULL); 4303 terminateO(self); 4304 4305 } 4306 4307 4308 void setAtArraySmallJsonT(void) { 4309 4310 smallJsont* r; 4311 smallJsont *self = allocSmallJson(); 4312 smallArrayt *value; 4313 4314 // add elements to self 4315 r = self->f->pushInt(self, 1); 4316 ck_assert_ptr_ne(r, null); 4317 r = self->f->pushInt(self, 2); 4318 ck_assert_ptr_ne(r, null); 4319 r = self->f->pushInt(self, 3); 4320 ck_assert_ptr_ne(r, null); 4321 r = self->f->pushInt(self, 4); 4322 ck_assert_ptr_ne(r, null); 4323 4324 // positive index 4325 value = allocSmallArray(); 4326 r = self->f->setAtArray(self, 1, value); 4327 ck_assert_ptr_ne(r, null); 4328 finishO(value); 4329 char *s = toStringO(r); 4330 ck_assert_str_eq(s, "[1,[],3,4]"); 4331 free(s); 4332 // negative index 4333 value = allocSmallArray(); 4334 r = self->f->setAtArray(self, -1, value); 4335 ck_assert_ptr_ne(r, null); 4336 finishO(value); 4337 s = toStringO(r); 4338 ck_assert_str_eq(s, "[1,[],3,[]]"); 4339 free(s); 4340 // index outside 4341 value = allocSmallArray(); 4342 ck_assert_ptr_eq(self->f->setAtArray(self, 20, value), NULL); 4343 ck_assert_ptr_eq(self->f->setAtArray(self, -8, value), NULL); 4344 // empty list 4345 emptyO(self); 4346 ck_assert_ptr_eq(self->f->setAtArray(self, 0, value), NULL); 4347 ck_assert_ptr_eq(self->f->setAtArray(self, -1, value), NULL); 4348 terminateO(value); 4349 // non smallArray object 4350 value = (smallArrayt*) allocSmallInt(2); 4351 r = self->f->setAtArray(self, 0, value); 4352 ck_assert_ptr_eq(r, null); 4353 terminateO(value); 4354 // NULL value 4355 ck_assert_ptr_eq(self->f->setAtArray(self, 0, NULL), NULL); 4356 terminateO(self); 4357 4358 } 4359 4360 4361 void setAtArraycSmallJsonT(void) { 4362 4363 smallJsont* r; 4364 smallJsont *self = allocSmallJson(); 4365 char **value; 4366 4367 // add elements to self 4368 r = self->f->pushInt(self, 1); 4369 ck_assert_ptr_ne(r, null); 4370 r = self->f->pushInt(self, 2); 4371 ck_assert_ptr_ne(r, null); 4372 r = self->f->pushInt(self, 3); 4373 ck_assert_ptr_ne(r, null); 4374 r = self->f->pushInt(self, 4); 4375 ck_assert_ptr_ne(r, null); 4376 4377 // positive index 4378 value = listCreateS("a"); 4379 r = self->f->setAtArrayc(self, 1, value); 4380 ck_assert_ptr_ne(r, null); 4381 listFreeS(value); 4382 char *s = toStringO(r); 4383 ck_assert_str_eq(s, "[1,[\"a\"],3,4]"); 4384 free(s); 4385 // negative index 4386 value = listCreateS("b"); 4387 r = self->f->setAtArrayc(self, -1, value); 4388 ck_assert_ptr_ne(r, null); 4389 listFreeS(value); 4390 s = toStringO(r); 4391 ck_assert_str_eq(s, "[1,[\"a\"],3,[\"b\"]]"); 4392 free(s); 4393 // index outside 4394 value = (char**)r; 4395 ck_assert_ptr_eq(self->f->setAtArrayc(self, 20, value), NULL); 4396 ck_assert_ptr_eq(self->f->setAtArrayc(self, -8, value), NULL); 4397 // empty list 4398 emptyO(self); 4399 ck_assert_ptr_eq(self->f->setAtArrayc(self, 0, value), NULL); 4400 ck_assert_ptr_eq(self->f->setAtArrayc(self, -1, value), NULL); 4401 // NULL value 4402 ck_assert_ptr_eq(self->f->setAtArrayc(self, 0, NULL), NULL); 4403 terminateO(self); 4404 4405 } 4406 4407 4408 void setAtSmallBoolSmallJsonT(void) { 4409 4410 smallJsont* r; 4411 smallJsont *self = allocSmallJson(); 4412 smallBoolt *value; 4413 4414 // add elements to self 4415 r = self->f->pushInt(self, 1); 4416 ck_assert_ptr_ne(r, null); 4417 r = self->f->pushInt(self, 2); 4418 ck_assert_ptr_ne(r, null); 4419 r = self->f->pushInt(self, 3); 4420 ck_assert_ptr_ne(r, null); 4421 r = self->f->pushInt(self, 4); 4422 ck_assert_ptr_ne(r, null); 4423 4424 // positive index 4425 value = allocSmallBool(true); 4426 r = self->f->setAtSmallBool(self, 1, value); 4427 ck_assert_ptr_ne(r, null); 4428 finishO(value); 4429 char *s = toStringO(r); 4430 ck_assert_str_eq(s, "[1,true,3,4]"); 4431 free(s); 4432 // negative index 4433 value = allocSmallBool(true); 4434 r = self->f->setAtSmallBool(self, -1, value); 4435 ck_assert_ptr_ne(r, null); 4436 finishO(value); 4437 s = toStringO(r); 4438 ck_assert_str_eq(s, "[1,true,3,true]"); 4439 free(s); 4440 // empty smallBool 4441 value = allocSmallBool(true); 4442 freeO(value); 4443 r = self->f->setAtSmallBool(self, -1, value); 4444 ck_assert_ptr_ne(r, null); 4445 finishO(value); 4446 s = toStringO(r); 4447 ck_assert_str_eq(s, "[1,true,3,false]"); 4448 free(s); 4449 // index outside 4450 value = allocSmallBool(true); 4451 ck_assert_ptr_eq(self->f->setAtSmallBool(self, 20, value), NULL); 4452 ck_assert_ptr_eq(self->f->setAtSmallBool(self, -8, value), NULL); 4453 // empty list 4454 emptyO(self); 4455 ck_assert_ptr_eq(self->f->setAtSmallBool(self, 0, value), NULL); 4456 ck_assert_ptr_eq(self->f->setAtSmallBool(self, -1, value), NULL); 4457 terminateO(value); 4458 // non smallBool object 4459 value = (smallBoolt*) allocSmallInt(2); 4460 r = self->f->setAtSmallBool(self, 0, value); 4461 ck_assert_ptr_eq(r, null); 4462 terminateO(value); 4463 // NULL value 4464 ck_assert_ptr_eq(self->f->setAtSmallBool(self, 0, NULL), NULL); 4465 terminateO(self); 4466 4467 } 4468 4469 4470 void setAtSmallBytesSmallJsonT(void) { 4471 4472 smallJsont* r; 4473 smallJsont *self = allocSmallJson(); 4474 smallBytest *value; 4475 4476 // add elements to self 4477 r = self->f->pushInt(self, 1); 4478 ck_assert_ptr_ne(r, null); 4479 r = self->f->pushInt(self, 2); 4480 ck_assert_ptr_ne(r, null); 4481 r = self->f->pushInt(self, 3); 4482 ck_assert_ptr_ne(r, null); 4483 r = self->f->pushInt(self, 4); 4484 ck_assert_ptr_ne(r, null); 4485 4486 // positive index 4487 value = allocSmallBytes(NULL, 0); 4488 r = self->f->setAtSmallBytes(self, 1, value); 4489 ck_assert_ptr_ne(r, null); 4490 finishO(value); 4491 char *s = toStringO(r); 4492 ck_assert_str_eq(s, "[1,[],3,4]"); 4493 free(s); 4494 // empty smallBytes 4495 value = allocSmallBytes(NULL, 0); 4496 freeO(value); 4497 r = self->f->setAtSmallBytes(self, 1, value); 4498 ck_assert_ptr_ne(r, null); 4499 finishO(value); 4500 s = toStringO(r); 4501 ck_assert_str_eq(s, "[1,[],3,4]"); 4502 free(s); 4503 // negative index 4504 value = allocSmallBytes(NULL, 0); 4505 r = self->f->setAtSmallBytes(self, -1, value); 4506 ck_assert_ptr_ne(r, null); 4507 finishO(value); 4508 s = toStringO(r); 4509 ck_assert_str_eq(s, "[1,[],3,[]]"); 4510 free(s); 4511 // index outside 4512 value = allocSmallBytes(NULL, 0); 4513 ck_assert_ptr_eq(self->f->setAtSmallBytes(self, 20, value), NULL); 4514 ck_assert_ptr_eq(self->f->setAtSmallBytes(self, -5, value), NULL); 4515 // empty list 4516 emptyO(self); 4517 ck_assert_ptr_eq(self->f->setAtSmallBytes(self, 0, value), NULL); 4518 ck_assert_ptr_eq(self->f->setAtSmallBytes(self, -1, value), NULL); 4519 terminateO(value); 4520 // non smallBytes object 4521 value = (smallBytest*) allocSmallInt(2); 4522 r = self->f->setAtSmallBytes(self, 0, value); 4523 ck_assert_ptr_eq(r, null); 4524 terminateO(value); 4525 // NULL value 4526 ck_assert_ptr_eq(self->f->setAtSmallBytes(self, 0, NULL), NULL); 4527 terminateO(self); 4528 4529 } 4530 4531 4532 void setAtSmallDoubleSmallJsonT(void) { 4533 4534 smallJsont* r; 4535 smallJsont *self = allocSmallJson(); 4536 smallDoublet *value; 4537 4538 // add elements to self 4539 r = self->f->pushInt(self, 1); 4540 ck_assert_ptr_ne(r, null); 4541 r = self->f->pushInt(self, 2); 4542 ck_assert_ptr_ne(r, null); 4543 r = self->f->pushInt(self, 3); 4544 ck_assert_ptr_ne(r, null); 4545 r = self->f->pushInt(self, 4); 4546 ck_assert_ptr_ne(r, null); 4547 4548 // positive index 4549 value = allocSmallDouble(5); 4550 r = self->f->setAtSmallDouble(self, 1, value); 4551 ck_assert_ptr_ne(r, null); 4552 finishO(value); 4553 char *s = toStringO(r); 4554 ck_assert_str_eq(s, "[1,5.000000e+00,3,4]"); 4555 free(s); 4556 // negative index 4557 value = allocSmallDouble(6); 4558 r = self->f->setAtSmallDouble(self, -1, value); 4559 ck_assert_ptr_ne(r, null); 4560 finishO(value); 4561 s = toStringO(r); 4562 ck_assert_str_eq(s, "[1,5.000000e+00,3,6.000000e+00]"); 4563 free(s); 4564 // empty smallDouble 4565 value = allocSmallDouble(0); 4566 freeO(value); 4567 r = self->f->setAtSmallDouble(self, -1, value); 4568 ck_assert_ptr_ne(r, null); 4569 finishO(value); 4570 s = toStringO(r); 4571 ck_assert_str_eq(s, "[1,5.000000e+00,3,0.000000e+00]"); 4572 free(s); 4573 // index outside 4574 value = allocSmallDouble(1); 4575 ck_assert_ptr_eq(self->f->setAtSmallDouble(self, 20, value), NULL); 4576 ck_assert_ptr_eq(self->f->setAtSmallDouble(self, -8, value), NULL); 4577 // empty list 4578 emptyO(self); 4579 ck_assert_ptr_eq(self->f->setAtSmallDouble(self, 0, value), NULL); 4580 ck_assert_ptr_eq(self->f->setAtSmallDouble(self, -1, value), NULL); 4581 terminateO(value); 4582 // non smallDouble object 4583 value = (smallDoublet*) allocSmallInt(2); 4584 r = self->f->setAtSmallDouble(self, 0, value); 4585 ck_assert_ptr_eq(r, null); 4586 terminateO(value); 4587 // NULL value 4588 ck_assert_ptr_eq(self->f->setAtSmallDouble(self, 0, NULL), NULL); 4589 terminateO(self); 4590 4591 } 4592 4593 4594 void setAtSmallIntSmallJsonT(void) { 4595 4596 smallJsont* r; 4597 smallJsont *self = allocSmallJson(); 4598 smallIntt *value; 4599 4600 // add elements to self 4601 r = self->f->pushInt(self, 1); 4602 ck_assert_ptr_ne(r, null); 4603 r = self->f->pushInt(self, 2); 4604 ck_assert_ptr_ne(r, null); 4605 r = self->f->pushInt(self, 3); 4606 ck_assert_ptr_ne(r, null); 4607 r = self->f->pushInt(self, 4); 4608 ck_assert_ptr_ne(r, null); 4609 4610 // positive index 4611 value = allocSmallInt(5); 4612 r = self->f->setAtSmallInt(self, 1, value); 4613 ck_assert_ptr_ne(r, null); 4614 finishO(value); 4615 char *s = toStringO(r); 4616 ck_assert_str_eq(s, "[1,5,3,4]"); 4617 free(s); 4618 // negative index 4619 value = allocSmallInt(6); 4620 r = self->f->setAtSmallInt(self, -1, value); 4621 ck_assert_ptr_ne(r, null); 4622 finishO(value); 4623 s = toStringO(r); 4624 ck_assert_str_eq(s, "[1,5,3,6]"); 4625 free(s); 4626 // empty SmallInt 4627 value = allocSmallInt(0); 4628 freeO(value); 4629 r = self->f->setAtSmallInt(self, -1, value); 4630 ck_assert_ptr_ne(r, null); 4631 finishO(value); 4632 s = toStringO(r); 4633 ck_assert_str_eq(s, "[1,5,3,0]"); 4634 free(s); 4635 // index outside 4636 value = allocSmallInt(1); 4637 ck_assert_ptr_eq(self->f->setAtSmallInt(self, 20, value), NULL); 4638 ck_assert_ptr_eq(self->f->setAtSmallInt(self, -8, value), NULL); 4639 // empty list 4640 emptyO(self); 4641 ck_assert_ptr_eq(self->f->setAtSmallInt(self, 0, value), NULL); 4642 ck_assert_ptr_eq(self->f->setAtSmallInt(self, -1, value), NULL); 4643 terminateO(value); 4644 // non smallInt object 4645 value = (smallIntt*) allocSmallBool(true); 4646 r = self->f->setAtSmallInt(self, 0, value); 4647 ck_assert_ptr_eq(r, null); 4648 terminateO(value); 4649 // NULL value 4650 ck_assert_ptr_eq(self->f->setAtSmallInt(self, 0, NULL), NULL); 4651 terminateO(self); 4652 4653 } 4654 4655 4656 void setAtSmallJsonSmallJsonT(void) { 4657 4658 smallJsont* r; 4659 smallJsont *self = allocSmallJson(); 4660 smallJsont *value; 4661 4662 // add elements to self 4663 r = self->f->pushInt(self, 1); 4664 ck_assert_ptr_ne(r, null); 4665 r = self->f->pushInt(self, 2); 4666 ck_assert_ptr_ne(r, null); 4667 r = self->f->pushInt(self, 3); 4668 ck_assert_ptr_ne(r, null); 4669 r = self->f->pushInt(self, 4); 4670 ck_assert_ptr_ne(r, null); 4671 4672 // positive index 4673 value = allocSmallJson(); 4674 r = self->f->setAtSmallJson(self, 1, value); 4675 ck_assert_ptr_ne(r, null); 4676 finishO(value); 4677 char *s = toStringO(r); 4678 ck_assert_str_eq(s, "[1,{},3,4]"); 4679 free(s); 4680 // negative index 4681 value = allocSmallJson(); 4682 r = self->f->setAtSmallJson(self, -1, value); 4683 ck_assert_ptr_ne(r, null); 4684 finishO(value); 4685 s = toStringO(r); 4686 ck_assert_str_eq(s, "[1,{},3,{}]"); 4687 free(s); 4688 // index outside 4689 value = allocSmallJson(); 4690 ck_assert_ptr_eq(self->f->setAtSmallJson(self, 20, value), NULL); 4691 ck_assert_ptr_eq(self->f->setAtSmallJson(self, -8, value), NULL); 4692 // empty list 4693 emptyO(self); 4694 ck_assert_ptr_eq(self->f->setAtSmallJson(self, 0, value), NULL); 4695 ck_assert_ptr_eq(self->f->setAtSmallJson(self, -1, value), NULL); 4696 terminateO(value); 4697 // non smallJson object 4698 value = (smallJsont*) allocSmallInt(2); 4699 r = self->f->setAtSmallJson(self, 0, value); 4700 ck_assert_ptr_eq(r, null); 4701 terminateO(value); 4702 // NULL value 4703 ck_assert_ptr_eq(self->f->setAtSmallJson(self, 0, NULL), NULL); 4704 terminateO(self); 4705 4706 } 4707 4708 4709 void setAtSmallStringSmallJsonT(void) { 4710 4711 smallJsont* r; 4712 smallJsont *self = allocSmallJson(); 4713 smallStringt *value; 4714 4715 // add elements to self 4716 r = self->f->pushInt(self, 1); 4717 ck_assert_ptr_ne(r, null); 4718 r = self->f->pushInt(self, 2); 4719 ck_assert_ptr_ne(r, null); 4720 r = self->f->pushInt(self, 3); 4721 ck_assert_ptr_ne(r, null); 4722 r = self->f->pushInt(self, 4); 4723 ck_assert_ptr_ne(r, null); 4724 4725 // positive index 4726 initiateAllocateSmallString(&value); 4727 r = self->f->setAtSmallString(self, 1, value); 4728 ck_assert_ptr_ne(r, null); 4729 finishO(value); 4730 char *s = toStringO(r); 4731 ck_assert_str_eq(s, "[1,\"\",3,4]"); 4732 free(s); 4733 // negative index 4734 value = allocSmallString("a"); 4735 r = self->f->setAtSmallString(self, -1, value); 4736 ck_assert_ptr_ne(r, null); 4737 finishO(value); 4738 s = toStringO(r); 4739 ck_assert_str_eq(s, "[1,\"\",3,\"a\"]"); 4740 free(s); 4741 // index outside 4742 value = allocSmallString("asd"); 4743 ck_assert_ptr_eq(self->f->setAtSmallString(self, 20, value), NULL); 4744 ck_assert_ptr_eq(self->f->setAtSmallString(self, -8, value), NULL); 4745 // empty list 4746 emptyO(self); 4747 ck_assert_ptr_eq(self->f->setAtSmallString(self, 0, value), NULL); 4748 ck_assert_ptr_eq(self->f->setAtSmallString(self, -1, value), NULL); 4749 terminateO(value); 4750 // non smallString object 4751 value = (smallStringt*) allocSmallInt(2); 4752 r = self->f->setAtSmallString(self, 0, value); 4753 ck_assert_ptr_eq(r, null); 4754 terminateO(value); 4755 // NULL value 4756 ck_assert_ptr_eq(self->f->setAtSmallString(self, 0, NULL), NULL); 4757 terminateO(self); 4758 4759 } 4760 4761 4762 void setAtSmallContainerSmallJsonT(void) { 4763 4764 smallJsont* r; 4765 smallJsont *self = allocSmallJson(); 4766 smallContainert *value; 4767 4768 // add elements to self 4769 r = self->f->pushInt(self, 1); 4770 ck_assert_ptr_ne(r, null); 4771 r = self->f->pushInt(self, 2); 4772 ck_assert_ptr_ne(r, null); 4773 r = self->f->pushInt(self, 3); 4774 ck_assert_ptr_ne(r, null); 4775 r = self->f->pushInt(self, 4); 4776 ck_assert_ptr_ne(r, null); 4777 4778 // positive index 4779 initiateAllocateSmallContainer(&value); 4780 r = self->f->setAtSmallContainer(self, 1, value); 4781 ck_assert_ptr_ne(r, null); 4782 finishO(value); 4783 char *s = toStringO(r); 4784 ck_assert_str_eq(s, "[1,\"<data container>\",3,4]"); 4785 free(s); 4786 // negative index 4787 initiateAllocateSmallContainer(&value); 4788 r = self->f->setAtSmallContainer(self, -1, value); 4789 ck_assert_ptr_ne(r, null); 4790 finishO(value); 4791 s = toStringO(r); 4792 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 4793 free(s); 4794 // index outside 4795 initiateAllocateSmallContainer(&value); 4796 ck_assert_ptr_eq(self->f->setAtSmallContainer(self, 20, value), NULL); 4797 ck_assert_ptr_eq(self->f->setAtSmallContainer(self, -8, value), NULL); 4798 // empty list 4799 emptyO(self); 4800 ck_assert_ptr_eq(self->f->setAtSmallContainer(self, 0, value), NULL); 4801 ck_assert_ptr_eq(self->f->setAtSmallContainer(self, -1, value), NULL); 4802 terminateO(value); 4803 // non smallContainer object 4804 value = (smallContainert*) allocSmallInt(2); 4805 r = self->f->setAtSmallContainer(self, 0, value); 4806 ck_assert_ptr_eq(r, null); 4807 terminateO(value); 4808 // NULL value 4809 ck_assert_ptr_eq(self->f->setAtSmallContainer(self, 0, NULL), NULL); 4810 terminateO(self); 4811 4812 } 4813 4814 4815 void setAtNFreeSmallJsonT(void) { 4816 4817 smallJsont* r; 4818 smallJsont *self = allocSmallJson(); 4819 baset *value; 4820 4821 // add elements to self 4822 r = self->f->pushInt(self, 1); 4823 ck_assert_ptr_ne(r, null); 4824 r = self->f->pushInt(self, 2); 4825 ck_assert_ptr_ne(r, null); 4826 r = self->f->pushInt(self, 3); 4827 ck_assert_ptr_ne(r, null); 4828 r = self->f->pushInt(self, 4); 4829 ck_assert_ptr_ne(r, null); 4830 4831 // positive index 4832 value = (baset*)allocSmallInt(123); 4833 r = self->f->setAtNFree(self, 1, value); 4834 ck_assert_ptr_ne(r, null); 4835 char *s = toStringO(r); 4836 ck_assert_str_eq(s, "[1,123,3,4]"); 4837 free(s); 4838 // negative index 4839 value = (baset*)allocSmallInt(234); 4840 r = self->f->setAtNFree(self, -1, value); 4841 ck_assert_ptr_ne(r, null); 4842 s = toStringO(r); 4843 ck_assert_str_eq(s, "[1,123,3,234]"); 4844 free(s); 4845 // undefined object 4846 value = (baset*)allocUndefined(); 4847 r = self->f->setAtNFree(self, -1, value); 4848 ck_assert_ptr_ne(r, null); 4849 s = toStringO(r); 4850 ck_assert_str_eq(s, "[1,123,3,null]"); 4851 free(s); 4852 // container 4853 createAllocateSmallContainer(c); 4854 r = self->f->setAtNFree(self, -1, (baset*)c); 4855 ck_assert_ptr_ne(r, null); 4856 s = toStringO(r); 4857 ck_assert_str_eq(s, "[1,123,3,\"<data container>\"]"); 4858 free(s); 4859 // base object in container 4860 createAllocateSmallInt(I); 4861 setValG(I, 11); 4862 I->type = "anothertype"; 4863 r = self->f->setAtNFree(self, -1, (baset*)I); 4864 ck_assert_ptr_ne(r, null); 4865 s = toStringO(r); 4866 ck_assert_str_eq(s, "[1,123,3,\"<data container>\"]"); 4867 free(s); 4868 // index outside 4869 value = (baset*)allocSmallInt(123); 4870 ck_assert_ptr_eq(self->f->setAtNFree(self, 20, value), NULL); 4871 ck_assert_ptr_eq(self->f->setAtNFree(self, -8, value), NULL); 4872 // empty list 4873 emptyO(self); 4874 ck_assert_ptr_eq(self->f->setAtNFree(self, 0, value), NULL); 4875 ck_assert_ptr_eq(self->f->setAtNFree(self, -1, value), NULL); 4876 // NULL value 4877 ck_assert_ptr_eq(self->f->setAtNFree(self, 0, NULL), NULL); 4878 terminateO(value); 4879 terminateO(self); 4880 4881 } 4882 4883 4884 void setAtNFreeUndefinedSmallJsonT(void) { 4885 4886 smallJsont* r; 4887 smallJsont *self = allocSmallJson(); 4888 undefinedt *value = NULL; 4889 4890 4891 // add elements to self 4892 r = self->f->pushInt(self, 1); 4893 ck_assert_ptr_ne(r, null); 4894 r = self->f->pushInt(self, 2); 4895 ck_assert_ptr_ne(r, null); 4896 r = self->f->pushInt(self, 3); 4897 ck_assert_ptr_ne(r, null); 4898 r = self->f->pushInt(self, 4); 4899 ck_assert_ptr_ne(r, null); 4900 4901 // positive index 4902 value = allocUndefined(); 4903 r = self->f->setAtNFreeUndefined(self, 1, value); 4904 ck_assert_ptr_ne(r, null); 4905 char *s = toStringO(r); 4906 ck_assert_str_eq(s, "[1,null,3,4]"); 4907 free(s); 4908 // negative index 4909 value = allocUndefined(); 4910 r = self->f->setAtNFreeUndefined(self, -1, value); 4911 ck_assert_ptr_ne(r, null); 4912 s = toStringO(r); 4913 ck_assert_str_eq(s, "[1,null,3,null]"); 4914 free(s); 4915 // index outside 4916 value = allocUndefined(); 4917 ck_assert_ptr_eq(self->f->setAtNFreeUndefined(self, 20, value), NULL); 4918 terminateO(value); 4919 value = allocUndefined(); 4920 ck_assert_ptr_eq(self->f->setAtNFreeUndefined(self, -8, value), NULL); 4921 terminateO(value); 4922 // empty list 4923 emptyO(self); 4924 value = allocUndefined(); 4925 ck_assert_ptr_eq(self->f->setAtNFreeUndefined(self, 0, value), NULL); 4926 terminateO(value); 4927 value = allocUndefined(); 4928 ck_assert_ptr_eq(self->f->setAtNFreeUndefined(self, -1, value), NULL); 4929 terminateO(value); 4930 // non json array 4931 freeO(self); 4932 setTypeBoolO(self); 4933 value = allocUndefined(); 4934 ck_assert_ptr_eq(self->f->setAtNFreeUndefined(self, 0, value), NULL); 4935 terminateO(value); 4936 terminateO(self); 4937 4938 } 4939 4940 4941 void setAtNFreeSSmallJsonT(void) { 4942 4943 smallJsont* r; 4944 smallJsont *self = allocSmallJson(); 4945 4946 // add elements to self 4947 r = self->f->pushInt(self, 1); 4948 ck_assert_ptr_ne(r, null); 4949 r = self->f->pushInt(self, 2); 4950 ck_assert_ptr_ne(r, null); 4951 r = self->f->pushInt(self, 3); 4952 ck_assert_ptr_ne(r, null); 4953 r = self->f->pushInt(self, 4); 4954 ck_assert_ptr_ne(r, null); 4955 4956 // positive index 4957 r = self->f->setAtNFreeS(self, 1, strdup("a")); 4958 ck_assert_ptr_ne(r, null); 4959 char *s = toStringO(r); 4960 ck_assert_str_eq(s, "[1,\"a\",3,4]"); 4961 free(s); 4962 // negative index 4963 r = self->f->setAtNFreeS(self, -1, strdup("b")); 4964 ck_assert_ptr_ne(r, null); 4965 s = toStringO(r); 4966 ck_assert_str_eq(s, "[1,\"a\",3,\"b\"]"); 4967 free(s); 4968 // NULL string 4969 r = self->f->setAtNFreeS(self, -1, NULL); 4970 ck_assert_ptr_eq(r, null); 4971 // index outside 4972 ck_assert_ptr_eq(self->f->setAtNFreeS(self, 20, ""), NULL); 4973 ck_assert_ptr_eq(self->f->setAtNFreeS(self, -8, ""), NULL); 4974 // empty list 4975 emptyO(self); 4976 ck_assert_ptr_eq(self->f->setAtNFreeS(self, 0, ""), NULL); 4977 ck_assert_ptr_eq(self->f->setAtNFreeS(self, -1, ""), NULL); 4978 // non json array 4979 freeO(self); 4980 setTypeBoolO(self); 4981 ck_assert_ptr_eq(self->f->setAtNFreeS(self, 0, ""), NULL); 4982 terminateO(self); 4983 4984 } 4985 4986 4987 void setAtNFreeDictSmallJsonT(void) { 4988 4989 smallJsont* r; 4990 smallJsont *self = allocSmallJson(); 4991 smallDictt *value; 4992 4993 // add elements to self 4994 r = self->f->pushInt(self, 1); 4995 ck_assert_ptr_ne(r, null); 4996 r = self->f->pushInt(self, 2); 4997 ck_assert_ptr_ne(r, null); 4998 r = self->f->pushInt(self, 3); 4999 ck_assert_ptr_ne(r, null); 5000 r = self->f->pushInt(self, 4); 5001 ck_assert_ptr_ne(r, null); 5002 5003 // positive index 5004 value = allocSmallDict(); 5005 r = self->f->setAtNFreeDict(self, 1, value); 5006 ck_assert_ptr_ne(r, null); 5007 char *s = toStringO(r); 5008 ck_assert_str_eq(s, "[1,{},3,4]"); 5009 free(s); 5010 // negative index 5011 value = allocSmallDict(); 5012 r = self->f->setAtNFreeDict(self, -1, value); 5013 ck_assert_ptr_ne(r, null); 5014 s = toStringO(r); 5015 ck_assert_str_eq(s, "[1,{},3,{}]"); 5016 free(s); 5017 // index outside 5018 value = allocSmallDict(); 5019 ck_assert_ptr_eq(self->f->setAtNFreeDict(self, 20, value), NULL); 5020 ck_assert_ptr_eq(self->f->setAtNFreeDict(self, -8, value), NULL); 5021 // empty list 5022 emptyO(self); 5023 ck_assert_ptr_eq(self->f->setAtNFreeDict(self, 0, value), NULL); 5024 ck_assert_ptr_eq(self->f->setAtNFreeDict(self, -1, value), NULL); 5025 terminateO(value); 5026 // NULL value 5027 ck_assert_ptr_eq(self->f->setAtNFreeDict(self, 0, NULL), NULL); 5028 // non json array 5029 freeO(self); 5030 setTypeBoolO(self); 5031 value = allocSmallDict(); 5032 ck_assert_ptr_eq(self->f->setAtNFreeDict(self, 0, value), NULL); 5033 terminateO(value); 5034 terminateO(self); 5035 5036 } 5037 5038 5039 void setAtNFreeArraySmallJsonT(void) { 5040 5041 smallJsont* r; 5042 smallJsont *self = allocSmallJson(); 5043 smallArrayt *value; 5044 5045 // add elements to self 5046 r = self->f->pushInt(self, 1); 5047 ck_assert_ptr_ne(r, null); 5048 r = self->f->pushInt(self, 2); 5049 ck_assert_ptr_ne(r, null); 5050 r = self->f->pushInt(self, 3); 5051 ck_assert_ptr_ne(r, null); 5052 r = self->f->pushInt(self, 4); 5053 ck_assert_ptr_ne(r, null); 5054 5055 // positive index 5056 value = allocSmallArray(); 5057 r = self->f->setAtNFreeArray(self, 1, value); 5058 ck_assert_ptr_ne(r, null); 5059 char *s = toStringO(r); 5060 ck_assert_str_eq(s, "[1,[],3,4]"); 5061 free(s); 5062 // negative index 5063 value = allocSmallArray(); 5064 r = self->f->setAtNFreeArray(self, -1, value); 5065 ck_assert_ptr_ne(r, null); 5066 s = toStringO(r); 5067 ck_assert_str_eq(s, "[1,[],3,[]]"); 5068 free(s); 5069 // index outside 5070 value = allocSmallArray(); 5071 ck_assert_ptr_eq(self->f->setAtNFreeArray(self, 20, value), NULL); 5072 ck_assert_ptr_eq(self->f->setAtNFreeArray(self, -8, value), NULL); 5073 // empty list 5074 emptyO(self); 5075 ck_assert_ptr_eq(self->f->setAtNFreeArray(self, 0, value), NULL); 5076 ck_assert_ptr_eq(self->f->setAtNFreeArray(self, -1, value), NULL); 5077 terminateO(value); 5078 // NULL value 5079 ck_assert_ptr_eq(self->f->setAtNFreeArray(self, 0, NULL), NULL); 5080 // non json array 5081 freeO(self); 5082 setTypeBoolO(self); 5083 value = allocSmallArray(); 5084 ck_assert_ptr_eq(self->f->setAtNFreeArray(self, 0, value), NULL); 5085 terminateO(value); 5086 terminateO(self); 5087 5088 } 5089 5090 5091 void setAtNFreeArraycSmallJsonT(void) { 5092 5093 smallJsont* r; 5094 smallJsont *self = allocSmallJson(); 5095 char **value; 5096 5097 // add elements to self 5098 r = self->f->pushInt(self, 1); 5099 ck_assert_ptr_ne(r, null); 5100 r = self->f->pushInt(self, 2); 5101 ck_assert_ptr_ne(r, null); 5102 r = self->f->pushInt(self, 3); 5103 ck_assert_ptr_ne(r, null); 5104 r = self->f->pushInt(self, 4); 5105 ck_assert_ptr_ne(r, null); 5106 5107 // positive index 5108 value = listCreateS("a"); 5109 r = self->f->setAtNFreeArrayc(self, 1, value); 5110 ck_assert_ptr_ne(r, null); 5111 char *s = toStringO(r); 5112 ck_assert_str_eq(s, "[1,[\"a\"],3,4]"); 5113 free(s); 5114 // negative index 5115 value = listCreateS("b"); 5116 r = self->f->setAtNFreeArrayc(self, -1, value); 5117 ck_assert_ptr_ne(r, null); 5118 s = toStringO(r); 5119 ck_assert_str_eq(s, "[1,[\"a\"],3,[\"b\"]]"); 5120 free(s); 5121 // index outside 5122 value = (char**)r; 5123 ck_assert_ptr_eq(self->f->setAtNFreeArrayc(self, 20, value), NULL); 5124 ck_assert_ptr_eq(self->f->setAtNFreeArrayc(self, -8, value), NULL); 5125 // empty list 5126 emptyO(self); 5127 ck_assert_ptr_eq(self->f->setAtNFreeArrayc(self, 0, value), NULL); 5128 ck_assert_ptr_eq(self->f->setAtNFreeArrayc(self, -1, value), NULL); 5129 // NULL value 5130 ck_assert_ptr_eq(self->f->setAtNFreeArrayc(self, 0, NULL), NULL); 5131 // non json array 5132 freeO(self); 5133 setTypeBoolO(self); 5134 value = listCreateS("b"); 5135 ck_assert_ptr_eq(self->f->setAtNFreeArrayc(self, 0, value), NULL); 5136 listFreeS(value); 5137 terminateO(self); 5138 5139 } 5140 5141 5142 void setAtNFreeSmallBoolSmallJsonT(void) { 5143 5144 smallJsont* r; 5145 smallJsont *self = allocSmallJson(); 5146 smallBoolt *value; 5147 5148 // add elements to self 5149 r = self->f->pushInt(self, 1); 5150 ck_assert_ptr_ne(r, null); 5151 r = self->f->pushInt(self, 2); 5152 ck_assert_ptr_ne(r, null); 5153 r = self->f->pushInt(self, 3); 5154 ck_assert_ptr_ne(r, null); 5155 r = self->f->pushInt(self, 4); 5156 ck_assert_ptr_ne(r, null); 5157 5158 // positive index 5159 value = allocSmallBool(true); 5160 r = self->f->setAtNFreeSmallBool(self, 1, value); 5161 ck_assert_ptr_ne(r, null); 5162 char *s = toStringO(r); 5163 ck_assert_str_eq(s, "[1,true,3,4]"); 5164 free(s); 5165 // negative index 5166 value = allocSmallBool(true); 5167 r = self->f->setAtNFreeSmallBool(self, -1, value); 5168 ck_assert_ptr_ne(r, null); 5169 s = toStringO(r); 5170 ck_assert_str_eq(s, "[1,true,3,true]"); 5171 free(s); 5172 // index outside 5173 value = allocSmallBool(true); 5174 ck_assert_ptr_eq(self->f->setAtNFreeSmallBool(self, 20, value), NULL); 5175 ck_assert_ptr_eq(self->f->setAtNFreeSmallBool(self, -8, value), NULL); 5176 // empty list 5177 emptyO(self); 5178 ck_assert_ptr_eq(self->f->setAtNFreeSmallBool(self, 0, value), NULL); 5179 ck_assert_ptr_eq(self->f->setAtNFreeSmallBool(self, -1, value), NULL); 5180 terminateO(value); 5181 // NULL value 5182 ck_assert_ptr_eq(self->f->setAtNFreeSmallBool(self, 0, NULL), NULL); 5183 // non json array 5184 freeO(self); 5185 setTypeBoolO(self); 5186 value = allocSmallBool(true); 5187 ck_assert_ptr_eq(self->f->setAtNFreeSmallBool(self, 0, value), NULL); 5188 terminateO(value); 5189 terminateO(self); 5190 5191 } 5192 5193 5194 void setAtNFreeSmallBytesSmallJsonT(void) { 5195 5196 smallJsont* r; 5197 smallJsont *self = allocSmallJson(); 5198 smallBytest *value; 5199 5200 // add elements to self 5201 r = self->f->pushInt(self, 1); 5202 ck_assert_ptr_ne(r, null); 5203 r = self->f->pushInt(self, 2); 5204 ck_assert_ptr_ne(r, null); 5205 r = self->f->pushInt(self, 3); 5206 ck_assert_ptr_ne(r, null); 5207 r = self->f->pushInt(self, 4); 5208 ck_assert_ptr_ne(r, null); 5209 5210 // positive index 5211 value = allocSmallBytes(NULL, 0); 5212 r = self->f->setAtNFreeSmallBytes(self, 1, value); 5213 ck_assert_ptr_ne(r, null); 5214 char *s = toStringO(r); 5215 ck_assert_str_eq(s, "[1,[],3,4]"); 5216 free(s); 5217 // negative index 5218 value = allocSmallBytes(NULL, 0); 5219 r = self->f->setAtNFreeSmallBytes(self, -1, value); 5220 ck_assert_ptr_ne(r, null); 5221 s = toStringO(r); 5222 ck_assert_str_eq(s, "[1,[],3,[]]"); 5223 free(s); 5224 // index outside 5225 value = allocSmallBytes(NULL, 0); 5226 ck_assert_ptr_eq(self->f->setAtNFreeSmallBytes(self, 20, value), NULL); 5227 ck_assert_ptr_eq(self->f->setAtNFreeSmallBytes(self, -5, value), NULL); 5228 // empty list 5229 emptyO(self); 5230 ck_assert_ptr_eq(self->f->setAtNFreeSmallBytes(self, 0, value), NULL); 5231 ck_assert_ptr_eq(self->f->setAtNFreeSmallBytes(self, -1, value), NULL); 5232 terminateO(value); 5233 // NULL value 5234 ck_assert_ptr_eq(self->f->setAtNFreeSmallBytes(self, 0, NULL), NULL); 5235 // non json array 5236 freeO(self); 5237 setTypeBoolO(self); 5238 value = allocSmallBytes("", sizeof("")); 5239 ck_assert_ptr_eq(self->f->setAtNFreeSmallBytes(self, 0, value), NULL); 5240 terminateO(value); 5241 terminateO(self); 5242 5243 } 5244 5245 5246 void setAtNFreeSmallDoubleSmallJsonT(void) { 5247 5248 smallJsont* r; 5249 smallJsont *self = allocSmallJson(); 5250 smallDoublet *value; 5251 5252 // add elements to self 5253 r = self->f->pushInt(self, 1); 5254 ck_assert_ptr_ne(r, null); 5255 r = self->f->pushInt(self, 2); 5256 ck_assert_ptr_ne(r, null); 5257 r = self->f->pushInt(self, 3); 5258 ck_assert_ptr_ne(r, null); 5259 r = self->f->pushInt(self, 4); 5260 ck_assert_ptr_ne(r, null); 5261 5262 // positive index 5263 value = allocSmallDouble(5); 5264 r = self->f->setAtNFreeSmallDouble(self, 1, value); 5265 ck_assert_ptr_ne(r, null); 5266 char *s = toStringO(r); 5267 ck_assert_str_eq(s, "[1,5.000000e+00,3,4]"); 5268 free(s); 5269 // negative index 5270 value = allocSmallDouble(6); 5271 r = self->f->setAtNFreeSmallDouble(self, -1, value); 5272 ck_assert_ptr_ne(r, null); 5273 s = toStringO(r); 5274 ck_assert_str_eq(s, "[1,5.000000e+00,3,6.000000e+00]"); 5275 free(s); 5276 // index outside 5277 value = allocSmallDouble(1); 5278 ck_assert_ptr_eq(self->f->setAtNFreeSmallDouble(self, 20, value), NULL); 5279 ck_assert_ptr_eq(self->f->setAtNFreeSmallDouble(self, -8, value), NULL); 5280 // empty list 5281 emptyO(self); 5282 ck_assert_ptr_eq(self->f->setAtNFreeSmallDouble(self, 0, value), NULL); 5283 ck_assert_ptr_eq(self->f->setAtNFreeSmallDouble(self, -1, value), NULL); 5284 terminateO(value); 5285 // NULL value 5286 ck_assert_ptr_eq(self->f->setAtNFreeSmallDouble(self, 0, NULL), NULL); 5287 // non json array 5288 freeO(self); 5289 setTypeBoolO(self); 5290 value = allocSmallDouble(1); 5291 ck_assert_ptr_eq(self->f->setAtNFreeSmallDouble(self, 0, value), NULL); 5292 terminateO(value); 5293 terminateO(self); 5294 5295 } 5296 5297 5298 void setAtNFreeSmallIntSmallJsonT(void) { 5299 5300 smallJsont* r; 5301 smallJsont *self = allocSmallJson(); 5302 smallIntt *value; 5303 5304 // add elements to self 5305 r = self->f->pushInt(self, 1); 5306 ck_assert_ptr_ne(r, null); 5307 r = self->f->pushInt(self, 2); 5308 ck_assert_ptr_ne(r, null); 5309 r = self->f->pushInt(self, 3); 5310 ck_assert_ptr_ne(r, null); 5311 r = self->f->pushInt(self, 4); 5312 ck_assert_ptr_ne(r, null); 5313 5314 // positive index 5315 value = allocSmallInt(5); 5316 r = self->f->setAtNFreeSmallInt(self, 1, value); 5317 ck_assert_ptr_ne(r, null); 5318 char *s = toStringO(r); 5319 ck_assert_str_eq(s, "[1,5,3,4]"); 5320 free(s); 5321 // negative index 5322 value = allocSmallInt(6); 5323 r = self->f->setAtNFreeSmallInt(self, -1, value); 5324 ck_assert_ptr_ne(r, null); 5325 s = toStringO(r); 5326 ck_assert_str_eq(s, "[1,5,3,6]"); 5327 free(s); 5328 // index outside 5329 value = allocSmallInt(1); 5330 ck_assert_ptr_eq(self->f->setAtNFreeSmallInt(self, 20, value), NULL); 5331 ck_assert_ptr_eq(self->f->setAtNFreeSmallInt(self, -8, value), NULL); 5332 // empty list 5333 emptyO(self); 5334 ck_assert_ptr_eq(self->f->setAtNFreeSmallInt(self, 0, value), NULL); 5335 ck_assert_ptr_eq(self->f->setAtNFreeSmallInt(self, -1, value), NULL); 5336 terminateO(value); 5337 // NULL value 5338 ck_assert_ptr_eq(self->f->setAtNFreeSmallInt(self, 0, NULL), NULL); 5339 // non json array 5340 freeO(self); 5341 setTypeBoolO(self); 5342 value = allocSmallInt(2); 5343 ck_assert_ptr_eq(self->f->setAtNFreeSmallInt(self, 0, value), NULL); 5344 terminateO(value); 5345 terminateO(self); 5346 5347 } 5348 5349 5350 void setAtNFreeSmallJsonSmallJsonT(void) { 5351 5352 smallJsont* r; 5353 smallJsont *self = allocSmallJson(); 5354 smallJsont *value; 5355 5356 // add elements to self 5357 r = self->f->pushInt(self, 1); 5358 ck_assert_ptr_ne(r, null); 5359 r = self->f->pushInt(self, 2); 5360 ck_assert_ptr_ne(r, null); 5361 r = self->f->pushInt(self, 3); 5362 ck_assert_ptr_ne(r, null); 5363 r = self->f->pushInt(self, 4); 5364 ck_assert_ptr_ne(r, null); 5365 5366 // positive index 5367 value = allocSmallJson(); 5368 r = self->f->setAtNFreeSmallJson(self, 1, value); 5369 ck_assert_ptr_ne(r, null); 5370 char *s = toStringO(r); 5371 ck_assert_str_eq(s, "[1,{},3,4]"); 5372 free(s); 5373 // negative index 5374 value = allocSmallJson(); 5375 r = self->f->setAtNFreeSmallJson(self, -1, value); 5376 ck_assert_ptr_ne(r, null); 5377 s = toStringO(r); 5378 ck_assert_str_eq(s, "[1,{},3,{}]"); 5379 free(s); 5380 // index outside 5381 value = allocSmallJson(); 5382 ck_assert_ptr_eq(self->f->setAtNFreeSmallJson(self, 20, value), NULL); 5383 ck_assert_ptr_eq(self->f->setAtNFreeSmallJson(self, -8, value), NULL); 5384 // empty list 5385 emptyO(self); 5386 ck_assert_ptr_eq(self->f->setAtNFreeSmallJson(self, 0, value), NULL); 5387 ck_assert_ptr_eq(self->f->setAtNFreeSmallJson(self, -1, value), NULL); 5388 terminateO(value); 5389 // NULL value 5390 ck_assert_ptr_eq(self->f->setAtNFreeSmallJson(self, 0, NULL), NULL); 5391 // non json array 5392 freeO(self); 5393 setTypeBoolO(self); 5394 value = allocSmallJson(); 5395 ck_assert_ptr_eq(self->f->setAtNFreeSmallJson(self, 0, value), NULL); 5396 terminateO(value); 5397 terminateO(self); 5398 5399 } 5400 5401 5402 void setAtNFreeSmallStringSmallJsonT(void) { 5403 5404 smallJsont* r; 5405 smallJsont *self = allocSmallJson(); 5406 smallStringt *value; 5407 5408 // add elements to self 5409 r = self->f->pushInt(self, 1); 5410 ck_assert_ptr_ne(r, null); 5411 r = self->f->pushInt(self, 2); 5412 ck_assert_ptr_ne(r, null); 5413 r = self->f->pushInt(self, 3); 5414 ck_assert_ptr_ne(r, null); 5415 r = self->f->pushInt(self, 4); 5416 ck_assert_ptr_ne(r, null); 5417 5418 // positive index 5419 initiateAllocateSmallString(&value); 5420 r = self->f->setAtNFreeSmallString(self, 1, value); 5421 ck_assert_ptr_ne(r, null); 5422 char *s = toStringO(r); 5423 ck_assert_str_eq(s, "[1,\"\",3,4]"); 5424 free(s); 5425 // negative index 5426 value = allocSmallString("a"); 5427 r = self->f->setAtNFreeSmallString(self, -1, value); 5428 ck_assert_ptr_ne(r, null); 5429 s = toStringO(r); 5430 ck_assert_str_eq(s, "[1,\"\",3,\"a\"]"); 5431 free(s); 5432 // index outside 5433 value = allocSmallString("asd"); 5434 ck_assert_ptr_eq(self->f->setAtNFreeSmallString(self, 20, value), NULL); 5435 ck_assert_ptr_eq(self->f->setAtNFreeSmallString(self, -8, value), NULL); 5436 // empty list 5437 emptyO(self); 5438 ck_assert_ptr_eq(self->f->setAtNFreeSmallString(self, 0, value), NULL); 5439 ck_assert_ptr_eq(self->f->setAtNFreeSmallString(self, -1, value), NULL); 5440 terminateO(value); 5441 // NULL value 5442 ck_assert_ptr_eq(self->f->setAtNFreeSmallString(self, 0, NULL), NULL); 5443 // non json array 5444 freeO(self); 5445 setTypeBoolO(self); 5446 value = allocSmallString("qwe"); 5447 ck_assert_ptr_eq(self->f->setAtNFreeSmallString(self, 0, value), NULL); 5448 terminateO(value); 5449 terminateO(self); 5450 5451 } 5452 5453 5454 void setAtNFreeSmallContainerSmallJsonT(void) { 5455 5456 smallJsont* r; 5457 smallJsont *self = allocSmallJson(); 5458 smallContainert *value; 5459 5460 // add elements to self 5461 r = self->f->pushInt(self, 1); 5462 ck_assert_ptr_ne(r, null); 5463 r = self->f->pushInt(self, 2); 5464 ck_assert_ptr_ne(r, null); 5465 r = self->f->pushInt(self, 3); 5466 ck_assert_ptr_ne(r, null); 5467 r = self->f->pushInt(self, 4); 5468 ck_assert_ptr_ne(r, null); 5469 5470 // positive index 5471 initiateAllocateSmallContainer(&value); 5472 r = self->f->setAtNFreeSmallContainer(self, 1, value); 5473 ck_assert_ptr_ne(r, null); 5474 char *s = toStringO(r); 5475 ck_assert_str_eq(s, "[1,\"<data container>\",3,4]"); 5476 free(s); 5477 // negative index 5478 initiateAllocateSmallContainer(&value); 5479 r = self->f->setAtNFreeSmallContainer(self, -1, value); 5480 ck_assert_ptr_ne(r, null); 5481 s = toStringO(r); 5482 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 5483 free(s); 5484 // index outside 5485 initiateAllocateSmallContainer(&value); 5486 ck_assert_ptr_eq(self->f->setAtNFreeSmallContainer(self, 20, value), NULL); 5487 ck_assert_ptr_eq(self->f->setAtNFreeSmallContainer(self, -8, value), NULL); 5488 // empty list 5489 emptyO(self); 5490 ck_assert_ptr_eq(self->f->setAtNFreeSmallContainer(self, 0, value), NULL); 5491 ck_assert_ptr_eq(self->f->setAtNFreeSmallContainer(self, -1, value), NULL); 5492 terminateO(value); 5493 // NULL value 5494 ck_assert_ptr_eq(self->f->setAtNFreeSmallContainer(self, 0, NULL), NULL); 5495 // non json array 5496 freeO(self); 5497 setTypeBoolO(self); 5498 initiateAllocateSmallContainer(&value); 5499 ck_assert_ptr_eq(self->f->setAtNFreeSmallContainer(self, 0, value), NULL); 5500 terminateO(value); 5501 terminateO(self); 5502 5503 } 5504 5505 5506 void setPAtDictSmallJsonT(void) { 5507 5508 smallJsont* r; 5509 smallJsont *self = allocSmallJson(); 5510 smallDictt *value; 5511 5512 // add elements to self 5513 r = self->f->pushInt(self, 1); 5514 ck_assert_ptr_ne(r, null); 5515 r = self->f->pushInt(self, 2); 5516 ck_assert_ptr_ne(r, null); 5517 r = self->f->pushInt(self, 3); 5518 ck_assert_ptr_ne(r, null); 5519 r = self->f->pushInt(self, 4); 5520 ck_assert_ptr_ne(r, null); 5521 5522 // positive index 5523 value = allocSmallDict(); 5524 r = self->f->setAtDict(self, 1, value); 5525 ck_assert_ptr_ne(r, null); 5526 value->f->setInt(value, "a", 1); 5527 r = self->f->setPAtDict(self, 1, value); 5528 ck_assert_ptr_ne(r, null); 5529 finishO(value); 5530 char *s = toStringO(r); 5531 ck_assert_str_eq(s, "[1,{\"a\":1},3,4]"); 5532 free(s); 5533 // negative index 5534 value = allocSmallDict(); 5535 r = self->f->setAtDict(self, -1, value); 5536 ck_assert_ptr_ne(r, null); 5537 value->f->setInt(value, "a", 2); 5538 r = self->f->setPAtDict(self, -1, value); 5539 ck_assert_ptr_ne(r, null); 5540 finishO(value); 5541 s = toStringO(r); 5542 ck_assert_str_eq(s, "[1,{\"a\":1},3,{\"a\":2}]"); 5543 free(s); 5544 // empty smallDict 5545 value = allocSmallDict(); 5546 r = self->f->setPAtDict(self, -1, value); 5547 ck_assert_ptr_eq(r, null); 5548 terminateO(value); 5549 // non smallDict object 5550 value = (smallDictt*) allocSmallInt(2); 5551 r = self->f->setPAtDict(self, 0, value); 5552 ck_assert_ptr_eq(r, null); 5553 terminateO(value); 5554 // index outside 5555 value = allocSmallDict(); 5556 ck_assert_ptr_eq(self->f->setPAtDict(self, 20, value), NULL); 5557 ck_assert_ptr_eq(self->f->setPAtDict(self, -8, value), NULL); 5558 // empty list 5559 emptyO(self); 5560 ck_assert_ptr_eq(self->f->setPAtDict(self, 0, value), NULL); 5561 ck_assert_ptr_eq(self->f->setPAtDict(self, -1, value), NULL); 5562 terminateO(value); 5563 // NULL value 5564 ck_assert_ptr_eq(self->f->setPAtDict(self, 0, NULL), NULL); 5565 terminateO(self); 5566 5567 } 5568 5569 5570 void setPAtArraySmallJsonT(void) { 5571 5572 smallJsont* r; 5573 smallJsont *self = allocSmallJson(); 5574 smallArrayt *value; 5575 5576 // add elements to self 5577 r = self->f->pushInt(self, 1); 5578 ck_assert_ptr_ne(r, null); 5579 r = self->f->pushInt(self, 2); 5580 ck_assert_ptr_ne(r, null); 5581 r = self->f->pushInt(self, 3); 5582 ck_assert_ptr_ne(r, null); 5583 r = self->f->pushInt(self, 4); 5584 ck_assert_ptr_ne(r, null); 5585 5586 // positive index 5587 value = allocSmallArray(); 5588 r = self->f->setAtArray(self, 1, value); 5589 ck_assert_ptr_ne(r, null); 5590 value->f->pushInt(value, 1); 5591 r = self->f->setPAtArray(self, 1, value); 5592 ck_assert_ptr_ne(r, null); 5593 finishO(value); 5594 char *s = toStringO(r); 5595 ck_assert_str_eq(s, "[1,[1],3,4]"); 5596 free(s); 5597 // negative index 5598 value = allocSmallArray(); 5599 r = self->f->setAtArray(self, -1, value); 5600 ck_assert_ptr_ne(r, null); 5601 value->f->pushInt(value, 2); 5602 r = self->f->setPAtArray(self, -1, value); 5603 ck_assert_ptr_ne(r, null); 5604 finishO(value); 5605 s = toStringO(r); 5606 ck_assert_str_eq(s, "[1,[1],3,[2]]"); 5607 free(s); 5608 // empty smallArray 5609 value = allocSmallArray(); 5610 r = self->f->setPAtArray(self, -1, value); 5611 ck_assert_ptr_eq(r, null); 5612 terminateO(value); 5613 // non smallArray object 5614 value = (smallArrayt*) allocSmallInt(2); 5615 r = self->f->setPAtArray(self, 0, value); 5616 ck_assert_ptr_eq(r, null); 5617 terminateO(value); 5618 // index outside 5619 value = allocSmallArray(); 5620 ck_assert_ptr_eq(self->f->setPAtArray(self, 20, value), NULL); 5621 ck_assert_ptr_eq(self->f->setPAtArray(self, -8, value), NULL); 5622 // empty list 5623 emptyO(self); 5624 ck_assert_ptr_eq(self->f->setPAtArray(self, 0, value), NULL); 5625 ck_assert_ptr_eq(self->f->setPAtArray(self, -1, value), NULL); 5626 terminateO(value); 5627 // NULL value 5628 ck_assert_ptr_eq(self->f->setPAtArray(self, 0, NULL), NULL); 5629 terminateO(self); 5630 5631 } 5632 5633 5634 void setPAtSmallJsonSmallJsonT(void) { 5635 5636 smallJsont* r; 5637 smallJsont *self = allocSmallJson(); 5638 smallJsont *value; 5639 5640 // add elements to self 5641 r = self->f->pushInt(self, 1); 5642 ck_assert_ptr_ne(r, null); 5643 r = self->f->pushInt(self, 2); 5644 ck_assert_ptr_ne(r, null); 5645 r = self->f->pushInt(self, 3); 5646 ck_assert_ptr_ne(r, null); 5647 r = self->f->pushInt(self, 4); 5648 ck_assert_ptr_ne(r, null); 5649 5650 // positive index 5651 value = allocSmallJson(); 5652 r = self->f->setAtSmallJson(self, 1, value); 5653 ck_assert_ptr_ne(r, null); 5654 value->f->setInt(value, "a", 1); 5655 r = self->f->setPAtSmallJson(self, 1, value); 5656 ck_assert_ptr_ne(r, null); 5657 finishO(value); 5658 char *s = toStringO(r); 5659 ck_assert_str_eq(s, "[1,{\"a\":1},3,4]"); 5660 free(s); 5661 // negative index 5662 value = allocSmallJson(); 5663 r = self->f->setAtSmallJson(self, -1, value); 5664 ck_assert_ptr_ne(r, null); 5665 value->f->setInt(value, "a", 2); 5666 r = self->f->setPAtSmallJson(self, -1, value); 5667 ck_assert_ptr_ne(r, null); 5668 finishO(value); 5669 s = toStringO(r); 5670 ck_assert_str_eq(s, "[1,{\"a\":1},3,{\"a\":2}]"); 5671 free(s); 5672 // empty smallJson 5673 value = allocSmallJson(); 5674 r = self->f->setPAtSmallJson(self, -1, value); 5675 ck_assert_ptr_eq(r, null); 5676 terminateO(value); 5677 // non smallJson object 5678 value = (smallJsont*) allocSmallInt(2); 5679 r = self->f->setPAtSmallJson(self, 0, value); 5680 ck_assert_ptr_eq(r, null); 5681 terminateO(value); 5682 // index outside 5683 value = allocSmallJson(); 5684 ck_assert_ptr_eq(self->f->setPAtSmallJson(self, 20, value), NULL); 5685 ck_assert_ptr_eq(self->f->setPAtSmallJson(self, -8, value), NULL); 5686 // empty list 5687 emptyO(self); 5688 ck_assert_ptr_eq(self->f->setPAtSmallJson(self, 0, value), NULL); 5689 ck_assert_ptr_eq(self->f->setPAtSmallJson(self, -1, value), NULL); 5690 terminateO(value); 5691 // NULL value 5692 ck_assert_ptr_eq(self->f->setPAtSmallJson(self, 0, NULL), NULL); 5693 terminateO(self); 5694 5695 } 5696 5697 5698 void setPAtSmallStringSmallJsonT(void) { 5699 5700 smallJsont* r; 5701 smallJsont *self = allocSmallJson(); 5702 smallStringt *value; 5703 5704 // add elements to self 5705 r = self->f->pushInt(self, 1); 5706 ck_assert_ptr_ne(r, null); 5707 r = self->f->pushInt(self, 2); 5708 ck_assert_ptr_ne(r, null); 5709 r = self->f->pushInt(self, 3); 5710 ck_assert_ptr_ne(r, null); 5711 r = self->f->pushInt(self, 4); 5712 ck_assert_ptr_ne(r, null); 5713 5714 // positive index 5715 initiateAllocateSmallString(&value); 5716 r = self->f->setAtSmallString(self, 1, value); 5717 ck_assert_ptr_ne(r, null); 5718 value->f->appendS(value, "1"); 5719 r = self->f->setPAtSmallString(self, 1, value); 5720 ck_assert_ptr_ne(r, null); 5721 finishO(value); 5722 char *s = toStringO(r); 5723 ck_assert_str_eq(s, "[1,\"1\",3,4]"); 5724 free(s); 5725 // negative index 5726 value = allocSmallString("a"); 5727 r = self->f->setAtSmallString(self, -1, value); 5728 ck_assert_ptr_ne(r, null); 5729 value->f->appendS(value, "2"); 5730 r = self->f->setPAtSmallString(self, -1, value); 5731 ck_assert_ptr_ne(r, null); 5732 finishO(value); 5733 s = toStringO(r); 5734 ck_assert_str_eq(s, "[1,\"1\",3,\"a2\"]"); 5735 free(s); 5736 // empty SmallString 5737 value = allocSmallString(""); 5738 freeO(value); 5739 r = self->f->setPAtSmallString(self, -1, value); 5740 ck_assert_ptr_eq(r, null); 5741 terminateO(value); 5742 // non smallString object 5743 value = (smallStringt*) allocSmallInt(2); 5744 r = self->f->setPAtSmallString(self, 0, value); 5745 ck_assert_ptr_eq(r, null); 5746 terminateO(value); 5747 // index outside 5748 value = allocSmallString("asd"); 5749 ck_assert_ptr_eq(self->f->setPAtSmallString(self, 20, value), NULL); 5750 ck_assert_ptr_eq(self->f->setPAtSmallString(self, -8, value), NULL); 5751 // empty list 5752 emptyO(self); 5753 ck_assert_ptr_eq(self->f->setPAtSmallString(self, 0, value), NULL); 5754 ck_assert_ptr_eq(self->f->setPAtSmallString(self, -1, value), NULL); 5755 terminateO(value); 5756 // NULL value 5757 ck_assert_ptr_eq(self->f->setPAtSmallString(self, 0, NULL), NULL); 5758 terminateO(self); 5759 5760 } 5761 5762 5763 void setPAtNFreeDictSmallJsonT(void) { 5764 5765 smallJsont* r; 5766 smallJsont *self = allocSmallJson(); 5767 smallDictt *value; 5768 5769 // add elements to self 5770 r = self->f->pushInt(self, 1); 5771 ck_assert_ptr_ne(r, null); 5772 r = self->f->pushInt(self, 2); 5773 ck_assert_ptr_ne(r, null); 5774 r = self->f->pushInt(self, 3); 5775 ck_assert_ptr_ne(r, null); 5776 r = self->f->pushInt(self, 4); 5777 ck_assert_ptr_ne(r, null); 5778 5779 // positive index 5780 value = allocSmallDict(); 5781 r = self->f->setAtDict(self, 1, value); 5782 ck_assert_ptr_ne(r, null); 5783 value->f->setInt(value, "a", 1); 5784 r = self->f->setPAtNFreeDict(self, 1, value); 5785 ck_assert_ptr_ne(r, null); 5786 char *s = toStringO(r); 5787 ck_assert_str_eq(s, "[1,{\"a\":1},3,4]"); 5788 free(s); 5789 // negative index 5790 value = allocSmallDict(); 5791 r = self->f->setAtDict(self, -1, value); 5792 ck_assert_ptr_ne(r, null); 5793 value->f->setInt(value, "a", 2); 5794 r = self->f->setPAtNFreeDict(self, -1, value); 5795 ck_assert_ptr_ne(r, null); 5796 s = toStringO(r); 5797 ck_assert_str_eq(s, "[1,{\"a\":1},3,{\"a\":2}]"); 5798 free(s); 5799 // empty smallDict 5800 value = allocSmallDict(); 5801 r = self->f->setPAtNFreeDict(self, -1, value); 5802 ck_assert_ptr_eq(r, null); 5803 terminateO(value); 5804 // non smallDict object 5805 value = (smallDictt*) allocSmallInt(2); 5806 r = self->f->setPAtNFreeDict(self, 0, value); 5807 ck_assert_ptr_eq(r, null); 5808 terminateO(value); 5809 // index outside 5810 value = allocSmallDict(); 5811 ck_assert_ptr_eq(self->f->setPAtNFreeDict(self, 20, value), NULL); 5812 ck_assert_ptr_eq(self->f->setPAtNFreeDict(self, -8, value), NULL); 5813 // empty list 5814 emptyO(self); 5815 ck_assert_ptr_eq(self->f->setPAtNFreeDict(self, 0, value), NULL); 5816 ck_assert_ptr_eq(self->f->setPAtNFreeDict(self, -1, value), NULL); 5817 terminateO(value); 5818 // NULL value 5819 ck_assert_ptr_eq(self->f->setPAtNFreeDict(self, 0, NULL), NULL); 5820 terminateO(self); 5821 5822 } 5823 5824 5825 void setPAtNFreeArraySmallJsonT(void) { 5826 5827 smallJsont* r; 5828 smallJsont *self = allocSmallJson(); 5829 smallArrayt *value; 5830 5831 // add elements to self 5832 r = self->f->pushInt(self, 1); 5833 ck_assert_ptr_ne(r, null); 5834 r = self->f->pushInt(self, 2); 5835 ck_assert_ptr_ne(r, null); 5836 r = self->f->pushInt(self, 3); 5837 ck_assert_ptr_ne(r, null); 5838 r = self->f->pushInt(self, 4); 5839 ck_assert_ptr_ne(r, null); 5840 5841 // positive index 5842 value = allocSmallArray(); 5843 r = self->f->setAtArray(self, 1, value); 5844 ck_assert_ptr_ne(r, null); 5845 value->f->pushInt(value, 1); 5846 r = self->f->setPAtNFreeArray(self, 1, value); 5847 ck_assert_ptr_ne(r, null); 5848 char *s = toStringO(r); 5849 ck_assert_str_eq(s, "[1,[1],3,4]"); 5850 free(s); 5851 // negative index 5852 value = allocSmallArray(); 5853 r = self->f->setAtArray(self, -1, value); 5854 ck_assert_ptr_ne(r, null); 5855 value->f->pushInt(value, 2); 5856 r = self->f->setPAtNFreeArray(self, -1, value); 5857 ck_assert_ptr_ne(r, null); 5858 s = toStringO(r); 5859 ck_assert_str_eq(s, "[1,[1],3,[2]]"); 5860 free(s); 5861 // empty smallArray 5862 value = allocSmallArray(); 5863 r = self->f->setPAtNFreeArray(self, -1, value); 5864 ck_assert_ptr_eq(r, null); 5865 terminateO(value); 5866 // non smallArray object 5867 value = (smallArrayt*) allocSmallInt(2); 5868 r = self->f->setPAtNFreeArray(self, 0, value); 5869 ck_assert_ptr_eq(r, null); 5870 terminateO(value); 5871 // index outside 5872 value = allocSmallArray(); 5873 ck_assert_ptr_eq(self->f->setPAtNFreeArray(self, 20, value), NULL); 5874 ck_assert_ptr_eq(self->f->setPAtNFreeArray(self, -8, value), NULL); 5875 // empty list 5876 emptyO(self); 5877 ck_assert_ptr_eq(self->f->setPAtNFreeArray(self, 0, value), NULL); 5878 ck_assert_ptr_eq(self->f->setPAtNFreeArray(self, -1, value), NULL); 5879 terminateO(value); 5880 // NULL value 5881 ck_assert_ptr_eq(self->f->setPAtNFreeArray(self, 0, NULL), NULL); 5882 terminateO(self); 5883 5884 } 5885 5886 5887 void setPAtNFreeSmallJsonSmallJsonT(void) { 5888 5889 smallJsont* r; 5890 smallJsont *self = allocSmallJson(); 5891 smallJsont *value; 5892 5893 // add elements to self 5894 r = self->f->pushInt(self, 1); 5895 ck_assert_ptr_ne(r, null); 5896 r = self->f->pushInt(self, 2); 5897 ck_assert_ptr_ne(r, null); 5898 r = self->f->pushInt(self, 3); 5899 ck_assert_ptr_ne(r, null); 5900 r = self->f->pushInt(self, 4); 5901 ck_assert_ptr_ne(r, null); 5902 5903 // positive index 5904 value = allocSmallJson(); 5905 r = self->f->setAtSmallJson(self, 1, value); 5906 ck_assert_ptr_ne(r, null); 5907 value->f->setInt(value, "a", 1); 5908 r = self->f->setPAtNFreeSmallJson(self, 1, value); 5909 ck_assert_ptr_ne(r, null); 5910 char *s = toStringO(r); 5911 ck_assert_str_eq(s, "[1,{\"a\":1},3,4]"); 5912 free(s); 5913 // negative index 5914 value = allocSmallJson(); 5915 r = self->f->setAtSmallJson(self, -1, value); 5916 ck_assert_ptr_ne(r, null); 5917 value->f->setInt(value, "a", 2); 5918 r = self->f->setPAtNFreeSmallJson(self, -1, value); 5919 ck_assert_ptr_ne(r, null); 5920 s = toStringO(r); 5921 ck_assert_str_eq(s, "[1,{\"a\":1},3,{\"a\":2}]"); 5922 free(s); 5923 // empty smallJson 5924 value = allocSmallJson(); 5925 r = self->f->setPAtNFreeSmallJson(self, -1, value); 5926 ck_assert_ptr_eq(r, null); 5927 terminateO(value); 5928 // non smallJson object 5929 value = (smallJsont*) allocSmallInt(2); 5930 r = self->f->setPAtNFreeSmallJson(self, 0, value); 5931 ck_assert_ptr_eq(r, null); 5932 terminateO(value); 5933 // index outside 5934 value = allocSmallJson(); 5935 ck_assert_ptr_eq(self->f->setPAtNFreeSmallJson(self, 20, value), NULL); 5936 ck_assert_ptr_eq(self->f->setPAtNFreeSmallJson(self, -8, value), NULL); 5937 // empty list 5938 emptyO(self); 5939 ck_assert_ptr_eq(self->f->setPAtNFreeSmallJson(self, 0, value), NULL); 5940 ck_assert_ptr_eq(self->f->setPAtNFreeSmallJson(self, -1, value), NULL); 5941 terminateO(value); 5942 // NULL value 5943 ck_assert_ptr_eq(self->f->setPAtNFreeSmallJson(self, 0, NULL), NULL); 5944 terminateO(self); 5945 5946 } 5947 5948 5949 void setPAtNFreeSmallStringSmallJsonT(void) { 5950 5951 smallJsont* r; 5952 smallJsont *self = allocSmallJson(); 5953 smallStringt *value; 5954 5955 // add elements to self 5956 r = self->f->pushInt(self, 1); 5957 ck_assert_ptr_ne(r, null); 5958 r = self->f->pushInt(self, 2); 5959 ck_assert_ptr_ne(r, null); 5960 r = self->f->pushInt(self, 3); 5961 ck_assert_ptr_ne(r, null); 5962 r = self->f->pushInt(self, 4); 5963 ck_assert_ptr_ne(r, null); 5964 5965 // positive index 5966 initiateAllocateSmallString(&value); 5967 r = self->f->setAtSmallString(self, 1, value); 5968 ck_assert_ptr_ne(r, null); 5969 value->f->appendS(value, "1"); 5970 r = self->f->setPAtNFreeSmallString(self, 1, value); 5971 ck_assert_ptr_ne(r, null); 5972 char *s = toStringO(r); 5973 ck_assert_str_eq(s, "[1,\"1\",3,4]"); 5974 free(s); 5975 // negative index 5976 value = allocSmallString("a"); 5977 r = self->f->setAtSmallString(self, -1, value); 5978 ck_assert_ptr_ne(r, null); 5979 value->f->appendS(value, "2"); 5980 r = self->f->setPAtNFreeSmallString(self, -1, value); 5981 ck_assert_ptr_ne(r, null); 5982 s = toStringO(r); 5983 ck_assert_str_eq(s, "[1,\"1\",3,\"a2\"]"); 5984 free(s); 5985 // empty SmallString 5986 value = allocSmallString(""); 5987 freeO(value); 5988 r = self->f->setPAtNFreeSmallString(self, -1, value); 5989 ck_assert_ptr_eq(r, null); 5990 terminateO(value); 5991 // non smallString object 5992 value = (smallStringt*) allocSmallInt(2); 5993 r = self->f->setPAtNFreeSmallString(self, 0, value); 5994 ck_assert_ptr_eq(r, null); 5995 terminateO(value); 5996 // index outside 5997 value = allocSmallString("asd"); 5998 ck_assert_ptr_eq(self->f->setPAtNFreeSmallString(self, 20, value), NULL); 5999 ck_assert_ptr_eq(self->f->setPAtNFreeSmallString(self, -8, value), NULL); 6000 // empty list 6001 emptyO(self); 6002 ck_assert_ptr_eq(self->f->setPAtNFreeSmallString(self, 0, value), NULL); 6003 ck_assert_ptr_eq(self->f->setPAtNFreeSmallString(self, -1, value), NULL); 6004 terminateO(value); 6005 // NULL value 6006 ck_assert_ptr_eq(self->f->setPAtNFreeSmallString(self, 0, NULL), NULL); 6007 terminateO(self); 6008 6009 } 6010 6011 6012 void pushUndefinedSmallJsonT(void) { 6013 6014 smallJsont* r; 6015 smallJsont *self = allocSmallJson(); 6016 6017 // add an element to check that push adds the second element 6018 // at the end 6019 r = self->f->pushInt(self, 1); 6020 ck_assert_ptr_ne(r, null); 6021 r = self->f->pushUndefined(self); 6022 ck_assert_ptr_ne(r, null); 6023 ck_assert_int_eq(lenO(r), 2); 6024 char *s = toStringO(r); 6025 ck_assert_str_eq(s, "[1,null]"); 6026 free(s); 6027 // non json array 6028 freeO(self); 6029 setTypeBoolO(self); 6030 ck_assert_ptr_eq(self->f->pushUndefined(self), NULL); 6031 terminateO(self); 6032 6033 } 6034 6035 6036 void pushBoolSmallJsonT(void) { 6037 6038 smallJsont* r; 6039 smallJsont *self = allocSmallJson(); 6040 6041 // add an element to check that push adds the second element 6042 // at the end 6043 r = self->f->pushInt(self, 1); 6044 ck_assert_ptr_ne(r, null); 6045 r = self->f->pushBool(self, TRUE); 6046 ck_assert_ptr_ne(r, null); 6047 ck_assert_int_eq(lenO(r), 2); 6048 char *s = toStringO(r); 6049 ck_assert_str_eq(s, "[1,true]"); 6050 free(s); 6051 // non json array 6052 freeO(self); 6053 setTypeBoolO(self); 6054 ck_assert_ptr_eq(self->f->pushBool(self, true), NULL); 6055 terminateO(self); 6056 6057 } 6058 6059 6060 void pushDoubleSmallJsonT(void) { 6061 6062 smallJsont* r; 6063 smallJsont *self = allocSmallJson(); 6064 6065 // add an element to check that push adds the second element 6066 // at the end 6067 r = self->f->pushInt(self, 1); 6068 ck_assert_ptr_ne(r, null); 6069 r = self->f->pushDouble(self, 1.0); 6070 ck_assert_ptr_ne(r, null); 6071 ck_assert_int_eq(lenO(r), 2); 6072 char *s = toStringO(r); 6073 ck_assert_str_eq(s, "[1,1.000000e+00]"); 6074 free(s); 6075 // non json array 6076 freeO(self); 6077 setTypeBoolO(self); 6078 ck_assert_ptr_eq(self->f->pushDouble(self, 2.2), NULL); 6079 terminateO(self); 6080 6081 } 6082 6083 6084 void pushIntSmallJsonT(void) { 6085 6086 smallJsont* r; 6087 smallJsont *self = allocSmallJson(); 6088 6089 // add an element to check that push adds the second element 6090 // at the end 6091 r = self->f->pushInt(self, 1); 6092 ck_assert_ptr_ne(r, null); 6093 r = self->f->pushInt(self, 1); 6094 ck_assert_ptr_ne(r, null); 6095 ck_assert_int_eq(lenO(r), 2); 6096 char *s = toStringO(r); 6097 ck_assert_str_eq(s, "[1,1]"); 6098 free(s); 6099 // non json array 6100 freeO(self); 6101 setTypeBoolO(self); 6102 ck_assert_ptr_eq(self->f->pushInt(self, 3), NULL); 6103 terminateO(self); 6104 6105 } 6106 6107 6108 void pushSSmallJsonT(void) { 6109 6110 smallJsont* r; 6111 smallJsont *self = allocSmallJson(); 6112 6113 // add an element to check that push adds the second element 6114 // at the end 6115 r = self->f->pushInt(self, 1); 6116 ck_assert_ptr_ne(r, null); 6117 r = self->f->pushS(self, null); 6118 ck_assert_ptr_eq(r, null); 6119 ck_assert_int_eq(lenO(self), 1); 6120 char *s = toStringO(self); 6121 ck_assert_str_eq(s, "[1]"); 6122 free(s); 6123 char *str = "poi"; 6124 r = self->f->pushS(self, str); 6125 ck_assert_ptr_ne(r, null); 6126 ck_assert_int_eq(lenO(self), 2); 6127 s = toStringO(r); 6128 ck_assert_str_eq(s, "[1,\"poi\"]"); 6129 free(s); 6130 // non json array 6131 freeO(self); 6132 setTypeBoolO(self); 6133 ck_assert_ptr_eq(self->f->pushS(self, "qwe"), NULL); 6134 terminateO(self); 6135 // json string 6136 self = allocSmallJson(); 6137 setTopSO(self, "qwe"); 6138 r = self->f->pushS(self, "!@#"); 6139 ck_assert_ptr_ne(r, null); 6140 s = toStringO(r); 6141 ck_assert_str_eq(s, "qwe!@#"); 6142 free(s); 6143 // empty string 6144 r = self->f->pushS(self, ""); 6145 ck_assert_ptr_ne(r, null); 6146 s = toStringO(r); 6147 ck_assert_str_eq(s, "qwe!@#"); 6148 free(s); 6149 // empty self 6150 freeO(self); 6151 setTypeStringO(self); 6152 r = self->f->pushS(self, "asd"); 6153 ck_assert_ptr_ne(r, null); 6154 s = toStringO(r); 6155 ck_assert_str_eq(s, "asd"); 6156 free(s); 6157 terminateO(self); 6158 6159 } 6160 6161 6162 void pushCharSmallJsonT(void) { 6163 6164 smallJsont* r; 6165 smallJsont *self = allocSmallJson(); 6166 6167 // add an element to check that push adds the second element 6168 // at the end 6169 r = self->f->pushInt(self, 1); 6170 ck_assert_ptr_ne(r, null); 6171 r = self->f->pushChar(self, 'a'); 6172 ck_assert_ptr_ne(r, null); 6173 ck_assert_int_eq(lenO(r), 2); 6174 char *s = toStringO(r); 6175 ck_assert_str_eq(s, "[1,\"a\"]"); 6176 free(s); 6177 // non json array 6178 freeO(self); 6179 setTypeBoolO(self); 6180 ck_assert_ptr_eq(self->f->pushChar(self, 'a'), NULL); 6181 terminateO(self); 6182 6183 } 6184 6185 6186 void pushDictSmallJsonT(void) { 6187 6188 smallJsont* r; 6189 smallJsont *self = allocSmallJson(); 6190 smallDictt *dict = allocG(rtSmallDictt); 6191 6192 // add an element to check that push adds the second element 6193 // at the end 6194 r = self->f->pushInt(self, 1); 6195 ck_assert_ptr_ne(r, null); 6196 // push dict 6197 r = self->f->pushDict(self, dict); 6198 ck_assert_ptr_ne(r, null); 6199 ck_assert_int_eq(lenO(r), 2); 6200 ck_assert_ptr_ne(r, null); 6201 char *s = toStringO(r); 6202 ck_assert_str_eq(s, "[1,{}]"); 6203 free(s); 6204 // non json array 6205 freeO(self); 6206 setTypeBoolO(self); 6207 ck_assert_ptr_eq(self->f->pushDict(self, dict), NULL); 6208 finishO(dict); 6209 setTypeArrayO(self); 6210 // non smallDict object 6211 dict = (smallDictt*) allocSmallInt(2); 6212 r = self->f->pushDict(self, dict); 6213 ck_assert_ptr_eq(r, null); 6214 terminateO(dict); 6215 // null 6216 r = self->f->pushDict(self, null); 6217 ck_assert_ptr_eq(r, null); 6218 ck_assert_int_eq(lenO(self), 0); 6219 s = toStringO(self); 6220 ck_assert_str_eq(s, "[]"); 6221 free(s); 6222 terminateO(self); 6223 6224 } 6225 6226 6227 void pushArraySmallJsonT(void) { 6228 6229 smallJsont* r; 6230 smallJsont *self = allocSmallJson(); 6231 smallArrayt *array = allocG(rtSmallArrayt); 6232 6233 // add an element to check that push adds the second element 6234 // at the end 6235 r = self->f->pushInt(self, 1); 6236 ck_assert_ptr_ne(r, null); 6237 r = self->f->pushArray(self, array); 6238 ck_assert_ptr_ne(r, null); 6239 ck_assert_int_eq(lenO(r), 2); 6240 char *s = toStringO(r); 6241 ck_assert_str_eq(s, "[1,[]]"); 6242 free(s); 6243 // non json array 6244 freeO(self); 6245 setTypeBoolO(self); 6246 ck_assert_ptr_eq(self->f->pushArray(self, array), NULL); 6247 finishO(array); 6248 setTypeArrayO(self); 6249 // non smallArray object 6250 array = (smallArrayt*) allocSmallInt(2); 6251 r = self->f->pushArray(self, array); 6252 ck_assert_ptr_eq(r, null); 6253 terminateO(array); 6254 // null 6255 r = self->f->pushArray(self, null); 6256 ck_assert_ptr_eq(r, null); 6257 ck_assert_int_eq(lenO(self), 0); 6258 s = toStringO(self); 6259 ck_assert_str_eq(s, "[]"); 6260 free(s); 6261 terminateO(self); 6262 6263 } 6264 6265 6266 void pushArraycSmallJsonT(void) { 6267 6268 smallJsont* r; 6269 smallJsont *self = allocSmallJson(); 6270 char **array = listCreateS("a","bb"); 6271 6272 // add an element to check that push adds the second element 6273 // at the end 6274 r = self->f->pushInt(self, 1); 6275 ck_assert_ptr_ne(r, null); 6276 6277 r = self->f->pushArrayc(self, array); 6278 ck_assert_ptr_ne(r, null); 6279 ck_assert_int_eq(lenO(r), 2); 6280 char *s = toStringO(r); 6281 ck_assert_str_eq(s, "[1,[\"a\",\"bb\"]]"); 6282 free(s); 6283 // non json array 6284 freeO(self); 6285 setTypeBoolO(self); 6286 ck_assert_ptr_eq(self->f->pushArrayc(self, array), NULL); 6287 listFreeS(array); 6288 setTypeArrayO(self); 6289 // null 6290 r = self->f->pushArrayc(self, null); 6291 ck_assert_ptr_eq(r, null); 6292 ck_assert_int_eq(lenO(self), 0); 6293 s = toStringO(self); 6294 ck_assert_str_eq(s, "[]"); 6295 free(s); 6296 terminateO(self); 6297 6298 } 6299 6300 6301 void pushSmallBoolSmallJsonT(void) { 6302 6303 smallJsont* r; 6304 smallJsont *self = allocSmallJson(); 6305 smallBoolt *value = allocG(TRUE); 6306 6307 // add an element to check that push adds the second element 6308 // at the end 6309 r = self->f->pushInt(self, 1); 6310 ck_assert_ptr_ne(r, null); 6311 r = self->f->pushSmallBool(self, value); 6312 ck_assert_ptr_ne(r, null); 6313 ck_assert_int_eq(lenO(r), 2); 6314 char *s = toStringO(r); 6315 ck_assert_str_eq(s, "[1,true]"); 6316 free(s); 6317 // non json array 6318 freeO(self); 6319 setTypeBoolO(self); 6320 ck_assert_ptr_eq(self->f->pushSmallBool(self, value), NULL); 6321 finishO(value); 6322 setTypeArrayO(self); 6323 // non smallBool object 6324 value = (smallBoolt*) allocSmallInt(2); 6325 r = self->f->pushSmallBool(self, value); 6326 ck_assert_ptr_eq(r, null); 6327 terminateO(value); 6328 // bool object with no data 6329 createAllocateSmallBool(b); 6330 r = self->f->pushSmallBool(self, b); 6331 ck_assert_ptr_ne(r, null); 6332 ck_assert_int_eq(lenO(r), 1); 6333 finishO(b); 6334 s = toStringO(r); 6335 ck_assert_str_eq(s, "[false]"); 6336 free(s); 6337 // null 6338 r = self->f->pushSmallBool(self, null); 6339 ck_assert_ptr_eq(r, null); 6340 ck_assert_int_eq(lenO(self), 1); 6341 s = toStringO(self); 6342 ck_assert_str_eq(s, "[false]"); 6343 free(s); 6344 terminateO(self); 6345 6346 } 6347 6348 6349 void pushSmallBytesSmallJsonT(void) { 6350 6351 smallJsont* r; 6352 smallJsont *self = allocSmallJson(); 6353 createAllocateSmallBytes(value); 6354 6355 // add an element to check that push adds the second element 6356 // at the end 6357 r = self->f->pushInt(self, 1); 6358 ck_assert_ptr_ne(r, null); 6359 // the smallBytes container is empty 6360 r = self->f->pushSmallBytes(self, value); 6361 ck_assert_ptr_ne(r, null); 6362 ck_assert_int_eq(lenO(r), 2); 6363 char *s = toStringO(r); 6364 ck_assert_str_eq(s, "[1,[]]"); 6365 free(s); 6366 // non json array 6367 freeO(self); 6368 setTypeBoolO(self); 6369 ck_assert_ptr_eq(self->f->pushSmallBytes(self, value), NULL); 6370 setTypeArrayO(self); 6371 // reuse value 6372 value->B = null; 6373 char *buffer = "poi"; 6374 pushBufferO(value, buffer, strlen(buffer)); 6375 r = self->f->pushSmallBytes(self, value); 6376 finishO(value); 6377 ck_assert_ptr_ne(r, null); 6378 ck_assert_int_eq(lenO(r), 1); 6379 s = toStringO(r); 6380 ck_assert_str_eq(s, "[[0x70,0x6f,0x69]]"); 6381 free(s); 6382 // non smallBytes object 6383 value = (smallBytest*) allocSmallInt(2); 6384 r = self->f->pushSmallBytes(self, value); 6385 ck_assert_ptr_eq(r, null); 6386 terminateO(value); 6387 // null 6388 r = self->f->pushSmallBytes(self, null); 6389 ck_assert_ptr_eq(r, null); 6390 ck_assert_int_eq(lenO(self), 1); 6391 s = toStringO(self); 6392 ck_assert_str_eq(s, "[[0x70,0x6f,0x69]]"); 6393 free(s); 6394 terminateO(self); 6395 6396 } 6397 6398 6399 void pushSmallDoubleSmallJsonT(void) { 6400 6401 smallJsont* r; 6402 smallJsont *self = allocSmallJson(); 6403 smallDoublet *value = allocG(1.0); 6404 6405 // add an element to check that push adds the second element 6406 // at the end 6407 r = self->f->pushInt(self, 1); 6408 ck_assert_ptr_ne(r, null); 6409 r = self->f->pushSmallDouble(self, value); 6410 ck_assert_ptr_ne(r, null); 6411 ck_assert_int_eq(lenO(r), 2); 6412 char *s = toStringO(r); 6413 ck_assert_str_eq(s, "[1,1.000000e+00]"); 6414 free(s); 6415 // non json array 6416 freeO(self); 6417 setTypeBoolO(self); 6418 ck_assert_ptr_eq(self->f->pushSmallDouble(self, value), NULL); 6419 finishO(value); 6420 setTypeArrayO(self); 6421 // object with no data 6422 createAllocateSmallDouble(b); 6423 r = self->f->pushSmallDouble(self, b); 6424 ck_assert_ptr_ne(r, null); 6425 ck_assert_int_eq(lenO(r), 1); 6426 finishO(b); 6427 s = toStringO(r); 6428 ck_assert_str_eq(s, "[0.000000e+00]"); 6429 free(s); 6430 // non smallDouble object 6431 value = (smallDoublet*) allocSmallInt(2); 6432 r = self->f->pushSmallDouble(self, value); 6433 ck_assert_ptr_eq(r, null); 6434 terminateO(value); 6435 // null 6436 r = self->f->pushSmallDouble(self, null); 6437 ck_assert_ptr_eq(r, null); 6438 ck_assert_int_eq(lenO(self), 1); 6439 s = toStringO(self); 6440 ck_assert_str_eq(s, "[0.000000e+00]"); 6441 free(s); 6442 terminateO(self); 6443 6444 } 6445 6446 6447 void pushSmallIntSmallJsonT(void) { 6448 6449 smallJsont* r; 6450 smallJsont *self = allocSmallJson(); 6451 smallIntt *value = allocG(1); 6452 6453 // add an element to check that push adds the second element 6454 // at the end 6455 r = self->f->pushInt(self, 1); 6456 ck_assert_ptr_ne(r, null); 6457 r = self->f->pushSmallInt(self, value); 6458 ck_assert_ptr_ne(r, null); 6459 ck_assert_int_eq(lenO(r), 2); 6460 char *s = toStringO(r); 6461 ck_assert_str_eq(s, "[1,1]"); 6462 free(s); 6463 // non json array 6464 freeO(self); 6465 setTypeBoolO(self); 6466 ck_assert_ptr_eq(self->f->pushSmallInt(self, value), NULL); 6467 finishO(value); 6468 setTypeArrayO(self); 6469 // int object with no data 6470 createAllocateSmallInt(b); 6471 r = self->f->pushSmallInt(self, b); 6472 ck_assert_ptr_ne(r, null); 6473 ck_assert_int_eq(lenO(r), 1); 6474 finishO(b); 6475 s = toStringO(r); 6476 ck_assert_str_eq(s, "[0]"); 6477 free(s); 6478 // non smallInt object 6479 value = (smallIntt*) allocSmallBool(true); 6480 r = self->f->pushSmallInt(self, value); 6481 ck_assert_ptr_eq(r, null); 6482 terminateO(value); 6483 // null 6484 r = self->f->pushSmallInt(self, null); 6485 ck_assert_ptr_eq(r, null); 6486 ck_assert_int_eq(lenO(self), 1); 6487 s = toStringO(self); 6488 ck_assert_str_eq(s, "[0]"); 6489 free(s); 6490 terminateO(self); 6491 6492 } 6493 6494 6495 void pushSmallJsonSmallJsonT(void) { 6496 6497 smallJsont* r; 6498 smallJsont *self = allocSmallJson(); 6499 smallJsont *value = allocG(rtSmallJsont); 6500 6501 // add an element to check that push adds the second element 6502 // at the end 6503 r = self->f->pushInt(self, 1); 6504 ck_assert_ptr_ne(r, null); 6505 // the smallJson container is empty 6506 r = self->f->pushSmallJson(self, value); 6507 ck_assert_ptr_ne(r, null); 6508 ck_assert_int_eq(lenO(r), 2); 6509 char *s = toStringO(r); 6510 ck_assert_str_eq(s, "[1,{}]"); 6511 free(s); 6512 // non json array 6513 freeO(self); 6514 setTypeBoolO(self); 6515 ck_assert_ptr_eq(self->f->pushSmallJson(self, value), NULL); 6516 setTypeArrayO(self); 6517 resetO(value); 6518 parseO(value, "{}"); 6519 r = self->f->pushSmallJson(self, value); 6520 finishO(value); 6521 ck_assert_ptr_ne(r, null); 6522 ck_assert_int_eq(lenO(r), 1); 6523 s = toStringO(r); 6524 ck_assert_str_eq(s, "[{}]"); 6525 free(s); 6526 // non smallJson object 6527 value = (smallJsont*) allocSmallInt(2); 6528 r = self->f->pushSmallJson(self, value); 6529 ck_assert_ptr_eq(r, null); 6530 terminateO(value); 6531 // null 6532 r = self->f->pushSmallJson(self, null); 6533 ck_assert_ptr_eq(r, null); 6534 ck_assert_int_eq(lenO(self), 1); 6535 s = toStringO(self); 6536 ck_assert_str_eq(s, "[{}]"); 6537 free(s); 6538 terminateO(self); 6539 6540 } 6541 6542 6543 void pushSmallStringSmallJsonT(void) { 6544 6545 smallJsont* r; 6546 smallJsont *self = allocSmallJson(); 6547 createAllocateSmallString(string); 6548 6549 // add an element to check that push adds the second element 6550 // at the end 6551 r = self->f->pushInt(self, 1); 6552 ck_assert_ptr_ne(r, null); 6553 r = self->f->pushSmallString(self, string); 6554 ck_assert_ptr_ne(r, null); 6555 ck_assert_int_eq(lenO(r), 2); 6556 char *s = toStringO(r); 6557 ck_assert_str_eq(s, "[1,\"\"]"); 6558 free(s); 6559 // non json array 6560 freeO(self); 6561 setTypeBoolO(self); 6562 ck_assert_ptr_eq(self->f->pushSmallString(self, string), NULL); 6563 finishO(string); 6564 setTypeArrayO(self); 6565 // non smallString object 6566 string = (smallStringt*) allocSmallInt(2); 6567 r = self->f->pushSmallString(self, string); 6568 ck_assert_ptr_eq(r, null); 6569 terminateO(string); 6570 // null 6571 r = self->f->pushSmallString(self, null); 6572 ck_assert_ptr_eq(r, null); 6573 ck_assert_int_eq(lenO(self), 0); 6574 s = toStringO(self); 6575 ck_assert_str_eq(s, "[]"); 6576 free(s); 6577 terminateO(self); 6578 // json string 6579 self = allocSmallJson(); 6580 setTopSO(self, "qwe"); 6581 string = allocSmallString("!@#"); 6582 r = self->f->pushSmallString(self, string); 6583 ck_assert_ptr_ne(r, null); 6584 s = toStringO(r); 6585 ck_assert_str_eq(s, "qwe!@#"); 6586 free(s); 6587 // empty string 6588 setValO(string, ""); 6589 r = self->f->pushSmallString(self, string); 6590 ck_assert_ptr_ne(r, null); 6591 s = toStringO(r); 6592 ck_assert_str_eq(s, "qwe!@#"); 6593 free(s); 6594 freeO(string); 6595 r = self->f->pushSmallString(self, string); 6596 ck_assert_ptr_ne(r, null); 6597 s = toStringO(r); 6598 ck_assert_str_eq(s, "qwe!@#"); 6599 free(s); 6600 // empty self 6601 freeO(self); 6602 setTypeStringO(self); 6603 setValO(string, "asd"); 6604 r = self->f->pushSmallString(self, string); 6605 ck_assert_ptr_ne(r, null); 6606 s = toStringO(r); 6607 ck_assert_str_eq(s, "asd"); 6608 free(s); 6609 terminateO(string); 6610 // not smallString object 6611 string = (smallStringt*) allocSmallInt(1); 6612 r = self->f->pushSmallString(self, string); 6613 ck_assert_ptr_eq(r, null); 6614 terminateO(string); 6615 terminateO(self); 6616 6617 } 6618 6619 6620 void pushSmallContainerSmallJsonT(void) { 6621 6622 smallJsont* r; 6623 smallJsont *self = allocSmallJson(); 6624 createAllocateSmallContainer(container); 6625 6626 // add an element to check that push adds the second element 6627 // at the end 6628 r = self->f->pushInt(self, 1); 6629 ck_assert_ptr_ne(r, null); 6630 r = self->f->pushSmallContainer(self, container); 6631 ck_assert_ptr_ne(r, null); 6632 ck_assert_int_eq(lenO(r), 2); 6633 char *s = toStringO(r); 6634 ck_assert_str_eq(s, "[1,\"<data container>\"]"); 6635 free(s); 6636 // non json array 6637 freeO(self); 6638 setTypeBoolO(self); 6639 ck_assert_ptr_eq(self->f->pushSmallContainer(self, container), NULL); 6640 finishO(container); 6641 setTypeArrayO(self); 6642 // non smallContainer object 6643 container = (smallContainert*) allocSmallInt(2); 6644 r = self->f->pushSmallContainer(self, container); 6645 ck_assert_ptr_eq(r, null); 6646 terminateO(container); 6647 // null 6648 r = self->f->pushSmallContainer(self, null); 6649 ck_assert_ptr_eq(r, null); 6650 ck_assert_int_eq(lenO(self), 0); 6651 s = toStringO(self); 6652 ck_assert_str_eq(s, "[]"); 6653 free(s); 6654 terminateO(self); 6655 6656 } 6657 6658 6659 void pushNFreeSmallJsonT(void) { 6660 6661 smallJsont* r; 6662 smallJsont *self = allocSmallJson(); 6663 baset *value = (baset*) allocG(2); 6664 6665 // add an element to check that push adds the second element 6666 // at the end 6667 r = self->f->pushInt(self, 1); 6668 ck_assert_ptr_ne(r, null); 6669 r = self->f->pushNFree(self, value); 6670 ck_assert_ptr_ne(r, null); 6671 ck_assert_int_eq(lenO(r), 2); 6672 char *s = toStringO(r); 6673 ck_assert_str_eq(s, "[1,2]"); 6674 free(s); 6675 // null 6676 r = self->f->pushNFree(self, null); 6677 ck_assert_ptr_eq(r, null); 6678 ck_assert_int_eq(lenO(self), 2); 6679 s = toStringO(self); 6680 ck_assert_str_eq(s, "[1,2]"); 6681 free(s); 6682 // non json array 6683 freeO(self); 6684 value = (baset*) allocSmallInt(2); 6685 setTypeBoolO(self); 6686 ck_assert_ptr_eq(self->f->pushNFree(self, value), NULL); 6687 terminateO(value); 6688 terminateO(self); 6689 6690 } 6691 6692 6693 void pushNFreeUndefinedSmallJsonT(void) { 6694 6695 smallJsont* r; 6696 smallJsont *self = allocSmallJson(); 6697 6698 // add an element to check that push adds the second element 6699 // at the end 6700 r = self->f->pushInt(self, 1); 6701 ck_assert_ptr_ne(r, null); 6702 6703 createAllocateUndefined(value); 6704 r = self->f->pushNFreeUndefined(self, value); 6705 ck_assert_ptr_ne(r, null); 6706 ck_assert_int_eq(lenO(r), 2); 6707 char *s = toStringO(r); 6708 ck_assert_str_eq(s, "[1,null]"); 6709 free(s); 6710 terminateO(self); 6711 6712 } 6713 6714 6715 void pushNFreeSSmallJsonT(void) { 6716 6717 smallJsont* r; 6718 smallJsont *self = allocSmallJson(); 6719 6720 // add an element to check that push adds the second element 6721 // at the end 6722 r = self->f->pushInt(self, 1); 6723 ck_assert_ptr_ne(r, null); 6724 6725 r = self->f->pushNFreeS(self, null); 6726 ck_assert_ptr_eq(r, null); 6727 ck_assert_int_eq(lenO(self), 1); 6728 char *s = toStringO(self); 6729 ck_assert_str_eq(s, "[1]"); 6730 free(s); 6731 6732 char *str = strdup("poi"); 6733 r = self->f->pushNFreeS(self, str); 6734 ck_assert_ptr_ne(r, null); 6735 ck_assert_int_eq(lenO(self), 2); 6736 s = toStringO(r); 6737 ck_assert_str_eq(s, "[1,\"poi\"]"); 6738 free(s); 6739 6740 terminateO(self); 6741 6742 } 6743 6744 6745 void pushNFreeDictSmallJsonT(void) { 6746 6747 smallJsont* r; 6748 smallJsont *self = allocSmallJson(); 6749 smallDictt *dict = allocG(rtSmallDictt); 6750 6751 // add an element to check that push adds the second element 6752 // at the end 6753 r = self->f->pushInt(self, 1); 6754 ck_assert_ptr_ne(r, null); 6755 6756 // push dict 6757 r = self->f->pushNFreeDict(self, dict); 6758 ck_assert_ptr_ne(r, null); 6759 ck_assert_int_eq(lenO(r), 2); 6760 ck_assert_ptr_ne(r, null); 6761 char *s = toStringO(r); 6762 ck_assert_str_eq(s, "[1,{}]"); 6763 free(s); 6764 // null 6765 r = self->f->pushNFreeDict(self, null); 6766 ck_assert_ptr_eq(r, null); 6767 ck_assert_int_eq(lenO(self), 2); 6768 s = toStringO(self); 6769 ck_assert_str_eq(s, "[1,{}]"); 6770 free(s); 6771 terminateO(self); 6772 6773 } 6774 6775 6776 void pushNFreeArraySmallJsonT(void) { 6777 6778 smallJsont* r; 6779 smallJsont *self = allocSmallJson(); 6780 smallArrayt *array = allocG(rtSmallArrayt); 6781 6782 // add an element to check that push adds the second element 6783 // at the end 6784 r = self->f->pushInt(self, 1); 6785 ck_assert_ptr_ne(r, null); 6786 6787 r = self->f->pushNFreeArray(self, array); 6788 ck_assert_ptr_ne(r, null); 6789 ck_assert_int_eq(lenO(r), 2); 6790 char *s = toStringO(r); 6791 ck_assert_str_eq(s, "[1,[]]"); 6792 free(s); 6793 // null 6794 r = self->f->pushNFreeArray(self, null); 6795 ck_assert_ptr_eq(r, null); 6796 ck_assert_int_eq(lenO(self), 2); 6797 s = toStringO(self); 6798 ck_assert_str_eq(s, "[1,[]]"); 6799 free(s); 6800 terminateO(self); 6801 6802 } 6803 6804 6805 void pushNFreeArraycSmallJsonT(void) { 6806 6807 smallJsont* r; 6808 smallJsont *self = allocSmallJson(); 6809 char **array = listCreateS("a","bb"); 6810 6811 // add an element to check that push adds the second element 6812 // at the end 6813 r = self->f->pushInt(self, 1); 6814 ck_assert_ptr_ne(r, null); 6815 6816 r = self->f->pushNFreeArrayc(self, array); 6817 ck_assert_ptr_ne(r, null); 6818 ck_assert_int_eq(lenO(r), 2); 6819 char *s = toStringO(r); 6820 ck_assert_str_eq(s, "[1,[\"a\",\"bb\"]]"); 6821 free(s); 6822 // null 6823 r = self->f->pushNFreeArrayc(self, null); 6824 ck_assert_ptr_eq(r, null); 6825 ck_assert_int_eq(lenO(self), 2); 6826 s = toStringO(self); 6827 ck_assert_str_eq(s, "[1,[\"a\",\"bb\"]]"); 6828 free(s); 6829 terminateO(self); 6830 6831 } 6832 6833 6834 void pushNFreeSmallBoolSmallJsonT(void) { 6835 6836 smallJsont* r; 6837 smallJsont *self = allocSmallJson(); 6838 smallBoolt *value = allocG(TRUE); 6839 6840 // add an element to check that push adds the second element 6841 // at the end 6842 r = self->f->pushInt(self, 1); 6843 ck_assert_ptr_ne(r, null); 6844 6845 r = self->f->pushNFreeSmallBool(self, value); 6846 ck_assert_ptr_ne(r, null); 6847 ck_assert_int_eq(lenO(r), 2); 6848 char *s = toStringO(r); 6849 ck_assert_str_eq(s, "[1,true]"); 6850 free(s); 6851 // bool object with no data 6852 createAllocateSmallBool(b); 6853 r = self->f->pushNFreeSmallBool(self, b); 6854 ck_assert_ptr_ne(r, null); 6855 ck_assert_int_eq(lenO(r), 3); 6856 s = toStringO(r); 6857 ck_assert_str_eq(s, "[1,true,false]"); 6858 free(s); 6859 // null 6860 r = self->f->pushNFreeSmallBool(self, null); 6861 ck_assert_ptr_eq(r, null); 6862 ck_assert_int_eq(lenO(self), 3); 6863 s = toStringO(self); 6864 ck_assert_str_eq(s, "[1,true,false]"); 6865 free(s); 6866 terminateO(self); 6867 6868 } 6869 6870 6871 void pushNFreeSmallBytesSmallJsonT(void) { 6872 6873 smallJsont* r; 6874 smallJsont *self = allocSmallJson(); 6875 createAllocateSmallBytes(value); 6876 6877 // add an element to check that push adds the second element 6878 // at the end 6879 r = self->f->pushInt(self, 1); 6880 ck_assert_ptr_ne(r, null); 6881 6882 // the smallBytes container is empty 6883 r = self->f->pushNFreeSmallBytes(self, value); 6884 ck_assert_ptr_ne(r, null); 6885 ck_assert_int_eq(lenO(r), 2); 6886 char *s = toStringO(r); 6887 ck_assert_str_eq(s, "[1,[]]"); 6888 free(s); 6889 6890 char *buffer = "poi"; 6891 value = allocSmallBytes(buffer, strlen(buffer)); 6892 r = self->f->pushNFreeSmallBytes(self, value); 6893 ck_assert_ptr_ne(r, null); 6894 ck_assert_int_eq(lenO(r), 3); 6895 s = toStringO(r); 6896 ck_assert_str_eq(s, "[1,[],[0x70,0x6f,0x69]]"); 6897 free(s); 6898 // null 6899 r = self->f->pushNFreeSmallBytes(self, null); 6900 ck_assert_ptr_eq(r, null); 6901 ck_assert_int_eq(lenO(self), 3); 6902 s = toStringO(self); 6903 ck_assert_str_eq(s, "[1,[],[0x70,0x6f,0x69]]"); 6904 free(s); 6905 terminateO(self); 6906 6907 } 6908 6909 6910 void pushNFreeSmallDoubleSmallJsonT(void) { 6911 6912 smallJsont* r; 6913 smallJsont *self = allocSmallJson(); 6914 smallDoublet *value = allocG(1.0); 6915 6916 // add an element to check that push adds the second element 6917 // at the end 6918 r = self->f->pushInt(self, 1); 6919 ck_assert_ptr_ne(r, null); 6920 6921 r = self->f->pushNFreeSmallDouble(self, value); 6922 ck_assert_ptr_ne(r, null); 6923 ck_assert_int_eq(lenO(r), 2); 6924 char *s = toStringO(r); 6925 ck_assert_str_eq(s, "[1,1.000000e+00]"); 6926 free(s); 6927 // object with no data 6928 createAllocateSmallDouble(b); 6929 r = self->f->pushNFreeSmallDouble(self, b); 6930 ck_assert_ptr_ne(r, null); 6931 ck_assert_int_eq(lenO(r), 3); 6932 s = toStringO(r); 6933 ck_assert_str_eq(s, "[1,1.000000e+00,0.000000e+00]"); 6934 free(s); 6935 // null 6936 r = self->f->pushNFreeSmallDouble(self, null); 6937 ck_assert_ptr_eq(r, null); 6938 ck_assert_int_eq(lenO(self), 3); 6939 s = toStringO(self); 6940 ck_assert_str_eq(s, "[1,1.000000e+00,0.000000e+00]"); 6941 free(s); 6942 terminateO(self); 6943 6944 } 6945 6946 6947 void pushNFreeSmallIntSmallJsonT(void) { 6948 6949 smallJsont* r; 6950 smallJsont *self = allocSmallJson(); 6951 smallIntt *value = allocG(1); 6952 6953 // add an element to check that push adds the second element 6954 // at the end 6955 r = self->f->pushInt(self, 1); 6956 ck_assert_ptr_ne(r, null); 6957 6958 r = self->f->pushNFreeSmallInt(self, value); 6959 ck_assert_ptr_ne(r, null); 6960 ck_assert_int_eq(lenO(r), 2); 6961 char *s = toStringO(r); 6962 ck_assert_str_eq(s, "[1,1]"); 6963 free(s); 6964 // bool object with no data 6965 createAllocateSmallInt(b); 6966 r = self->f->pushNFreeSmallInt(self, b); 6967 ck_assert_ptr_ne(r, null); 6968 ck_assert_int_eq(lenO(r), 3); 6969 s = toStringO(r); 6970 ck_assert_str_eq(s, "[1,1,0]"); 6971 free(s); 6972 // null 6973 r = self->f->pushNFreeSmallInt(self, null); 6974 ck_assert_ptr_eq(r, null); 6975 ck_assert_int_eq(lenO(self), 3); 6976 s = toStringO(self); 6977 ck_assert_str_eq(s, "[1,1,0]"); 6978 free(s); 6979 terminateO(self); 6980 6981 } 6982 6983 6984 void pushNFreeSmallJsonSmallJsonT(void) { 6985 6986 smallJsont* r; 6987 smallJsont *self = allocSmallJson(); 6988 smallJsont *value = allocG(rtSmallJsont); 6989 6990 // add an element to check that push adds the second element 6991 // at the end 6992 r = self->f->pushInt(self, 1); 6993 ck_assert_ptr_ne(r, null); 6994 6995 // the smallJson container is empty 6996 r = self->f->pushNFreeSmallJson(self, value); 6997 ck_assert_ptr_ne(r, null); 6998 ck_assert_int_eq(lenO(r), 2); 6999 char *s = toStringO(r); 7000 ck_assert_str_eq(s, "[1,{}]"); 7001 free(s); 7002 7003 value = allocG(rtSmallJsont); 7004 parseO(value, "{}"); 7005 r = self->f->pushNFreeSmallJson(self, value); 7006 ck_assert_ptr_ne(r, null); 7007 ck_assert_int_eq(lenO(r), 3); 7008 s = toStringO(r); 7009 ck_assert_str_eq(s, "[1,{},{}]"); 7010 free(s); 7011 // null 7012 r = self->f->pushNFreeSmallJson(self, null); 7013 ck_assert_ptr_eq(r, null); 7014 ck_assert_int_eq(lenO(self), 3); 7015 s = toStringO(self); 7016 ck_assert_str_eq(s, "[1,{},{}]"); 7017 free(s); 7018 terminateO(self); 7019 7020 } 7021 7022 7023 void pushNFreeSmallStringSmallJsonT(void) { 7024 7025 smallJsont* r; 7026 smallJsont *self = allocSmallJson(); 7027 createAllocateSmallString(string); 7028 7029 // add an element to check that push adds the second element 7030 // at the end 7031 r = self->f->pushInt(self, 1); 7032 ck_assert_ptr_ne(r, null); 7033 7034 r = self->f->pushNFreeSmallString(self, string); 7035 ck_assert_ptr_ne(r, null); 7036 ck_assert_int_eq(lenO(r), 2); 7037 char *s = toStringO(r); 7038 ck_assert_str_eq(s, "[1,\"\"]"); 7039 free(s); 7040 // null 7041 r = self->f->pushNFreeSmallString(self, null); 7042 ck_assert_ptr_eq(r, null); 7043 ck_assert_int_eq(lenO(self), 2); 7044 s = toStringO(self); 7045 ck_assert_str_eq(s, "[1,\"\"]"); 7046 free(s); 7047 terminateO(self); 7048 7049 } 7050 7051 7052 void pushNFreeSmallContainerSmallJsonT(void) { 7053 7054 smallJsont* r; 7055 smallJsont *self = allocSmallJson(); 7056 createAllocateSmallContainer(container); 7057 7058 // add an element to check that push adds the second element 7059 // at the end 7060 r = self->f->pushInt(self, 1); 7061 ck_assert_ptr_ne(r, null); 7062 7063 r = self->f->pushNFreeSmallContainer(self, container); 7064 ck_assert_ptr_ne(r, null); 7065 ck_assert_int_eq(lenO(r), 2); 7066 char *s = toStringO(r); 7067 ck_assert_str_eq(s, "[1,\"<data container>\"]"); 7068 free(s); 7069 // null 7070 r = self->f->pushNFreeSmallContainer(self, null); 7071 ck_assert_ptr_eq(r, null); 7072 ck_assert_int_eq(lenO(self), 2); 7073 s = toStringO(self); 7074 ck_assert_str_eq(s, "[1,\"<data container>\"]"); 7075 free(s); 7076 terminateO(self); 7077 7078 } 7079 7080 7081 void pushManySmallJsonT(void) { 7082 7083 smallJsont* r; 7084 smallJsont *self = allocSmallJson(); 7085 smallIntt *v1 = allocG(1); 7086 smallIntt *v2 = allocG(2); 7087 7088 r = self->f->pushMany(self, v1, v2, null); 7089 finishO(v1); 7090 finishO(v2); 7091 ck_assert_ptr_ne(r, null); 7092 ck_assert_int_eq(lenO(r), 2); 7093 char *s = toStringO(r); 7094 ck_assert_str_eq(s, "[1,2]"); 7095 free(s); 7096 terminateO(self); 7097 // json string 7098 self = allocSmallJson(); 7099 setTopSO(self, "qwe"); 7100 smallStringt *s1 = allocSmallString("123"); 7101 smallStringt *s2 = allocSmallString("456"); 7102 r = self->f->pushMany(self, s1, s2, null); 7103 ck_assert_ptr_ne(r, null); 7104 terminateO(s1); 7105 terminateO(s2); 7106 s = toStringO(r); 7107 ck_assert_str_eq(s, "qwe123456"); 7108 free(s); 7109 // non smallString object 7110 s1 = allocSmallString("123"); 7111 s2 = (smallStringt*) allocSmallInt(1); 7112 r = self->f->pushMany(self, s1, s2, null); 7113 ck_assert_ptr_eq(r, null); 7114 s = toStringO(self); 7115 ck_assert_str_eq(s, "qwe123456"); 7116 free(s); 7117 terminateO(s1); 7118 terminateO(s2); 7119 terminateO(self); 7120 7121 } 7122 7123 7124 void pushManySSmallJsonT(void) { 7125 7126 smallJsont* r; 7127 smallJsont *self = allocSmallJson(); 7128 char *v1 = "a"; 7129 char *v2 = "bb"; 7130 7131 r = self->f->pushManyS(self, v1, v2, null); 7132 ck_assert_ptr_ne(r, null); 7133 ck_assert_int_eq(lenO(r), 2); 7134 char *s = toStringO(r); 7135 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 7136 free(s); 7137 terminateO(self); 7138 // json string 7139 self = allocSmallJson(); 7140 setTopSO(self, "qwe"); 7141 r = self->f->pushManyS(self, "123", "456", null); 7142 ck_assert_ptr_ne(r, null); 7143 s = toStringO(r); 7144 ck_assert_str_eq(s, "qwe123456"); 7145 free(s); 7146 terminateO(self); 7147 7148 } 7149 7150 7151 void pushNFreeManySmallJsonT(void) { 7152 7153 smallJsont* r; 7154 smallJsont *self = allocSmallJson(); 7155 smallIntt *v1 = allocG(1); 7156 smallIntt *v2 = allocG(2); 7157 7158 r = self->f->pushNFreeMany(self, v1, v2, null); 7159 ck_assert_ptr_ne(r, null); 7160 ck_assert_int_eq(lenO(r), 2); 7161 char *s = toStringO(r); 7162 ck_assert_str_eq(s, "[1,2]"); 7163 free(s); 7164 terminateO(self); 7165 // json string 7166 self = allocSmallJson(); 7167 setTopSO(self, "qwe"); 7168 smallStringt *s1 = allocSmallString("123"); 7169 smallStringt *s2 = allocSmallString("456"); 7170 r = pushNFreeManyO(self, s1, s2); 7171 ck_assert_ptr_ne(r, null); 7172 s = toStringO(r); 7173 ck_assert_str_eq(s, "qwe123456"); 7174 free(s); 7175 // non smallString object 7176 s1 = allocSmallString("123"); 7177 s2 = (smallStringt*) allocSmallInt(1); 7178 r = pushNFreeManyO(self, s1, s2); 7179 ck_assert_ptr_eq(r, null); 7180 s = toStringO(self); 7181 ck_assert_str_eq(s, "qwe123456"); 7182 free(s); 7183 terminateO(s2); 7184 terminateO(self); 7185 7186 } 7187 7188 7189 void pushNFreeManySSmallJsonT(void) { 7190 7191 smallJsont* r; 7192 smallJsont *self = allocSmallJson(); 7193 char *v1 = strdup("a"); 7194 char *v2 = strdup("bb"); 7195 7196 r = self->f->pushNFreeManyS(self, v1, v2, null); 7197 ck_assert_ptr_ne(r, null); 7198 ck_assert_int_eq(lenO(r), 2); 7199 char *s = toStringO(r); 7200 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 7201 free(s); 7202 terminateO(self); 7203 // json string 7204 self = allocSmallJson(); 7205 setTopSO(self, "qwe"); 7206 r = pushNFreeManySO(self, strdup("123"), strdup("456")); 7207 ck_assert_ptr_ne(r, null); 7208 s = toStringO(r); 7209 ck_assert_str_eq(s, "qwe123456"); 7210 free(s); 7211 terminateO(self); 7212 7213 } 7214 7215 7216 void popSmallJsonT(void) { 7217 7218 baset* r; 7219 smallJsont *self = allocSmallJson(); 7220 smallJsont *r2; 7221 7222 // add an element to check that the second element is poped 7223 // at the end 7224 r2 = self->f->pushInt(self, 1); 7225 ck_assert_ptr_ne(r2, null); 7226 // push a base object of unknown type 7227 smallIntt *o = allocSmallInt(2); 7228 o->type = "newType"; 7229 r2 = self->f->pushNFree(self, (baset*)o); 7230 ck_assert_ptr_ne(r2, null); 7231 r2 = self->f->pushUndefined(self); 7232 ck_assert_ptr_ne(r2, null); 7233 r2 = self->f->pushUndefined(self); 7234 ck_assert_ptr_ne(r2, null); 7235 delElemIndexO(self,-1); 7236 r = self->f->pop(self); 7237 ck_assert_ptr_ne(r, null); 7238 ck_assert(isOUndefined(r)); 7239 terminateO(r); 7240 r = self->f->pop(self); 7241 ck_assert_ptr_ne(r, null); 7242 ck_assert_str_eq(r->type, "newType"); 7243 char *s = toStringO(r); 7244 terminateO(r); 7245 ck_assert_str_eq(s, "2"); 7246 free(s); 7247 ck_assert_int_eq(lenO(self), 1); 7248 s = toStringO(self); 7249 ck_assert_str_eq(s, "[1]"); 7250 free(s); 7251 // empty array 7252 r = self->f->pop(self); 7253 ck_assert_ptr_ne(r, null); 7254 terminateO(r); 7255 s = toStringO(self); 7256 ck_assert_str_eq(s, "[]"); 7257 free(s); 7258 r = self->f->pop(self); 7259 ck_assert_ptr_eq(r, null); 7260 s = toStringO(self); 7261 ck_assert_str_eq(s, "[]"); 7262 free(s); 7263 r2 = self->f->pushUndefined(self); 7264 ck_assert_ptr_ne(r2, null); 7265 delElemIndexO(self,-1); 7266 r = self->f->pop(self); 7267 ck_assert_ptr_eq(r, null); 7268 // non json array 7269 freeO(self); 7270 setTypeBoolO(self); 7271 ck_assert_ptr_eq(self->f->pop(self), NULL); 7272 terminateO(self); 7273 7274 } 7275 7276 7277 void popUndefinedSmallJsonT(void) { 7278 7279 undefinedt* r; 7280 smallJsont *self = allocSmallJson(); 7281 smallJsont *r2; 7282 baset *r3; 7283 7284 // add an element to check that the second element is poped 7285 // at the end 7286 r2 = self->f->pushInt(self, 1); 7287 ck_assert_ptr_ne(r2, null); 7288 // add second element 7289 r2 = self->f->pushUndefined(self); 7290 ck_assert_ptr_ne(r2, null); 7291 // pop 7292 r2 = self->f->pushUndefined(self); 7293 ck_assert_ptr_ne(r2, null); 7294 delElemIndexO(self,-1); 7295 r = self->f->popUndefined(self); 7296 ck_assert_ptr_ne(r, null); 7297 char *s = toStringO(r); 7298 terminateO(r); 7299 ck_assert_str_eq(s, "null"); 7300 free(s); 7301 ck_assert_int_eq(lenO(self), 1); 7302 s = toStringO(self); 7303 ck_assert_str_eq(s, "[1]"); 7304 free(s); 7305 // pop element of unexpected type 7306 r = self->f->popUndefined(self); 7307 ck_assert_ptr_eq(r, null); 7308 ck_assert_int_eq(lenO(self), 1); 7309 s = toStringO(self); 7310 ck_assert_str_eq(s, "[1]"); 7311 free(s); 7312 // empty array 7313 r3 = self->f->pop(self); 7314 ck_assert_ptr_ne(r3, null); 7315 terminateO(r3); 7316 s = toStringO(self); 7317 ck_assert_str_eq(s, "[]"); 7318 free(s); 7319 r = self->f->popUndefined(self); 7320 ck_assert_ptr_eq(r, null); 7321 s = toStringO(self); 7322 ck_assert_str_eq(s, "[]"); 7323 free(s); 7324 r2 = self->f->pushUndefined(self); 7325 ck_assert_ptr_ne(r2, null); 7326 delElemIndexO(self,-1); 7327 r = self->f->popUndefined(self); 7328 ck_assert_ptr_eq(r, null); 7329 // non json array 7330 freeO(self); 7331 setTypeBoolO(self); 7332 ck_assert_ptr_eq(self->f->popUndefined(self), NULL); 7333 terminateO(self); 7334 7335 } 7336 7337 7338 void popBoolSmallJsonT(void) { 7339 7340 bool r; 7341 smallJsont *self = allocSmallJson(); 7342 smallJsont *r2; 7343 baset *r3; 7344 7345 // add an element to check that the second element is poped 7346 // at the end 7347 r2 = self->f->pushInt(self, 1); 7348 ck_assert_ptr_ne(r2, null); 7349 // add second element 7350 r2 = self->f->pushBool(self, TRUE); 7351 ck_assert_ptr_ne(r2, null); 7352 // pop 7353 r = self->f->popBool(self); 7354 ck_assert(r); 7355 ck_assert_int_eq(lenO(self), 1); 7356 char *s = toStringO(self); 7357 ck_assert_str_eq(s, "[1]"); 7358 free(s); 7359 // pop element of unexpected type 7360 r = self->f->popBool(self); 7361 ck_assert(!r); 7362 ck_assert_int_eq(lenO(self), 1); 7363 s = toStringO(self); 7364 ck_assert_str_eq(s, "[1]"); 7365 free(s); 7366 // empty array 7367 r3 = self->f->pop(self); 7368 ck_assert_ptr_ne(r3, null); 7369 terminateO(r3); 7370 s = toStringO(self); 7371 ck_assert_str_eq(s, "[]"); 7372 free(s); 7373 r = self->f->popBool(self); 7374 ck_assert(!r); 7375 s = toStringO(self); 7376 ck_assert_str_eq(s, "[]"); 7377 free(s); 7378 terminateO(self); 7379 7380 } 7381 7382 7383 void popDoubleSmallJsonT(void) { 7384 7385 double r; 7386 smallJsont *self = allocSmallJson(); 7387 smallJsont *r2; 7388 baset *r3; 7389 7390 // add an element to check that the second element is poped 7391 // at the end 7392 r2 = self->f->pushInt(self, 1); 7393 ck_assert_ptr_ne(r2, null); 7394 // add second element 7395 r2 = self->f->pushDouble(self, 2.0); 7396 ck_assert_ptr_ne(r2, null); 7397 // pop 7398 r = self->f->popDouble(self); 7399 ck_assert(r==2.0); 7400 ck_assert_int_eq(lenO(self), 1); 7401 char *s = toStringO(self); 7402 ck_assert_str_eq(s, "[1]"); 7403 free(s); 7404 // pop element of unexpected type 7405 r = self->f->popDouble(self); 7406 ck_assert(!r); 7407 ck_assert_int_eq(lenO(self), 1); 7408 s = toStringO(self); 7409 ck_assert_str_eq(s, "[1]"); 7410 free(s); 7411 // empty array 7412 r3 = self->f->pop(self); 7413 ck_assert_ptr_ne(r3, null); 7414 terminateO(r3); 7415 s = toStringO(self); 7416 ck_assert_str_eq(s, "[]"); 7417 free(s); 7418 r = self->f->popDouble(self); 7419 ck_assert(!r); 7420 s = toStringO(self); 7421 ck_assert_str_eq(s, "[]"); 7422 free(s); 7423 terminateO(self); 7424 7425 } 7426 7427 7428 void popIntSmallJsonT(void) { 7429 7430 int64_t r; 7431 smallJsont *self = allocSmallJson(); 7432 smallJsont *r2; 7433 baset *r3; 7434 7435 // add an element to check that the second element is poped 7436 // at the end 7437 r2 = self->f->pushBool(self, FALSE); 7438 ck_assert_ptr_ne(r2, null); 7439 // add second element 7440 r2 = self->f->pushInt(self, 2); 7441 ck_assert_ptr_ne(r2, null); 7442 // pop 7443 r = self->f->popInt(self); 7444 ck_assert_int_eq(r, 2); 7445 ck_assert_int_eq(lenO(self), 1); 7446 char *s = toStringO(self); 7447 ck_assert_str_eq(s, "[false]"); 7448 free(s); 7449 // pop element of unexpected type 7450 r = self->f->popInt(self); 7451 ck_assert(!r); 7452 ck_assert_int_eq(lenO(self), 1); 7453 s = toStringO(self); 7454 ck_assert_str_eq(s, "[false]"); 7455 free(s); 7456 // empty array 7457 r3 = self->f->pop(self); 7458 ck_assert_ptr_ne(r3, null); 7459 terminateO(r3); 7460 s = toStringO(self); 7461 ck_assert_str_eq(s, "[]"); 7462 free(s); 7463 r = self->f->popInt(self); 7464 ck_assert(!r); 7465 s = toStringO(self); 7466 ck_assert_str_eq(s, "[]"); 7467 free(s); 7468 terminateO(self); 7469 7470 } 7471 7472 7473 void popInt32SmallJsonT(void) { 7474 7475 int32_t r; 7476 smallJsont *self = allocSmallJson(); 7477 smallJsont *r2; 7478 baset *r3; 7479 7480 // add an element to check that the second element is poped 7481 // at the end 7482 r2 = self->f->pushBool(self, FALSE); 7483 ck_assert_ptr_ne(r2, null); 7484 // add second element 7485 r2 = self->f->pushInt(self, 2); 7486 ck_assert_ptr_ne(r2, null); 7487 // pop 7488 r = self->f->popInt32(self); 7489 ck_assert_int_eq(r, 2); 7490 ck_assert_int_eq(lenO(self), 1); 7491 char *s = toStringO(self); 7492 ck_assert_str_eq(s, "[false]"); 7493 free(s); 7494 // pop element of unexpected type 7495 r = self->f->popInt32(self); 7496 ck_assert(!r); 7497 ck_assert_int_eq(lenO(self), 1); 7498 s = toStringO(self); 7499 ck_assert_str_eq(s, "[false]"); 7500 free(s); 7501 // empty array 7502 r3 = self->f->pop(self); 7503 ck_assert_ptr_ne(r3, null); 7504 terminateO(r3); 7505 s = toStringO(self); 7506 ck_assert_str_eq(s, "[]"); 7507 free(s); 7508 r = self->f->popInt32(self); 7509 ck_assert(!r); 7510 s = toStringO(self); 7511 ck_assert_str_eq(s, "[]"); 7512 free(s); 7513 terminateO(self); 7514 7515 } 7516 7517 7518 void popUintSmallJsonT(void) { 7519 7520 uint64_t r; 7521 smallJsont *self = allocSmallJson(); 7522 smallJsont *r2; 7523 baset *r3; 7524 7525 // add an element to check that the second element is poped 7526 // at the end 7527 r2 = self->f->pushBool(self, FALSE); 7528 ck_assert_ptr_ne(r2, null); 7529 // add second element 7530 r2 = self->f->pushInt(self, 2); 7531 ck_assert_ptr_ne(r2, null); 7532 // pop 7533 r = self->f->popUint(self); 7534 ck_assert_int_eq(r, 2); 7535 ck_assert_int_eq(lenO(self), 1); 7536 char *s = toStringO(self); 7537 ck_assert_str_eq(s, "[false]"); 7538 free(s); 7539 // pop element of unexpected type 7540 r = self->f->popUint(self); 7541 ck_assert(!r); 7542 ck_assert_int_eq(lenO(self), 1); 7543 s = toStringO(self); 7544 ck_assert_str_eq(s, "[false]"); 7545 free(s); 7546 // empty array 7547 r3 = self->f->pop(self); 7548 ck_assert_ptr_ne(r3, null); 7549 terminateO(r3); 7550 s = toStringO(self); 7551 ck_assert_str_eq(s, "[]"); 7552 free(s); 7553 r = self->f->popUint(self); 7554 ck_assert(!r); 7555 s = toStringO(self); 7556 ck_assert_str_eq(s, "[]"); 7557 free(s); 7558 terminateO(self); 7559 7560 } 7561 7562 7563 void popUint32SmallJsonT(void) { 7564 7565 uint32_t r; 7566 smallJsont *self = allocSmallJson(); 7567 smallJsont *r2; 7568 baset *r3; 7569 7570 // add an element to check that the second element is poped 7571 // at the end 7572 r2 = self->f->pushBool(self, FALSE); 7573 ck_assert_ptr_ne(r2, null); 7574 // add second element 7575 r2 = self->f->pushInt(self, 2); 7576 ck_assert_ptr_ne(r2, null); 7577 // pop 7578 r = self->f->popUint32(self); 7579 ck_assert_int_eq(r, 2); 7580 ck_assert_int_eq(lenO(self), 1); 7581 char *s = toStringO(self); 7582 ck_assert_str_eq(s, "[false]"); 7583 free(s); 7584 // pop element of unexpected type 7585 r = self->f->popUint32(self); 7586 ck_assert(!r); 7587 ck_assert_int_eq(lenO(self), 1); 7588 s = toStringO(self); 7589 ck_assert_str_eq(s, "[false]"); 7590 free(s); 7591 // empty array 7592 r3 = self->f->pop(self); 7593 ck_assert_ptr_ne(r3, null); 7594 terminateO(r3); 7595 s = toStringO(self); 7596 ck_assert_str_eq(s, "[]"); 7597 free(s); 7598 r = self->f->popUint32(self); 7599 ck_assert(!r); 7600 s = toStringO(self); 7601 ck_assert_str_eq(s, "[]"); 7602 free(s); 7603 terminateO(self); 7604 7605 } 7606 7607 7608 void popSSmallJsonT(void) { 7609 7610 char* r; 7611 smallJsont *self = allocSmallJson(); 7612 smallJsont *r2; 7613 baset *r3; 7614 7615 // add an element to check that the second element is poped 7616 // at the end 7617 r2 = self->f->pushInt(self, 1); 7618 ck_assert_ptr_ne(r2, null); 7619 // add second element 7620 r2 = self->f->pushS(self, "bb"); 7621 ck_assert_ptr_ne(r2, null); 7622 // pop 7623 r = self->f->popS(self); 7624 ck_assert_str_eq(r, "bb"); 7625 free(r); 7626 ck_assert_int_eq(lenO(self), 1); 7627 char *s = toStringO(self); 7628 ck_assert_str_eq(s, "[1]"); 7629 free(s); 7630 // pop element of unexpected type 7631 r = self->f->popS(self); 7632 ck_assert(!r); 7633 ck_assert_int_eq(lenO(self), 1); 7634 s = toStringO(self); 7635 ck_assert_str_eq(s, "[1]"); 7636 free(s); 7637 // empty array 7638 r3 = self->f->pop(self); 7639 ck_assert_ptr_ne(r3, null); 7640 terminateO(r3); 7641 s = toStringO(self); 7642 ck_assert_str_eq(s, "[]"); 7643 free(s); 7644 r = self->f->popS(self); 7645 ck_assert(!r); 7646 s = toStringO(self); 7647 ck_assert_str_eq(s, "[]"); 7648 free(s); 7649 terminateO(self); 7650 7651 } 7652 7653 7654 void popDictSmallJsonT(void) { 7655 7656 smallDictt* r; 7657 smallJsont *self = allocSmallJson(); 7658 smallJsont *r2; 7659 baset *r3; 7660 7661 // add an element to check that the second element is poped 7662 // at the end 7663 r2 = self->f->pushInt(self, 1); 7664 ck_assert_ptr_ne(r2, null); 7665 // add second element 7666 createSmallDict(e); 7667 r2 = self->f->pushDict(self, &e); 7668 ck_assert_ptr_ne(r2, null); 7669 // pop 7670 r2 = self->f->pushUndefined(self); 7671 ck_assert_ptr_ne(r2, null); 7672 delElemIndexO(self,-1); 7673 r = self->f->popDict(self); 7674 ck_assert_ptr_ne(r, null); 7675 char *s = toStringO(r); 7676 terminateO(r); 7677 ck_assert_str_eq(s, "{}"); 7678 free(s); 7679 ck_assert_int_eq(lenO(self), 1); 7680 s = toStringO(self); 7681 ck_assert_str_eq(s, "[1]"); 7682 free(s); 7683 // pop element of unexpected type 7684 r = self->f->popDict(self); 7685 ck_assert(!r); 7686 ck_assert_int_eq(lenO(self), 1); 7687 s = toStringO(self); 7688 ck_assert_str_eq(s, "[1]"); 7689 free(s); 7690 // empty array 7691 r3 = self->f->pop(self); 7692 ck_assert_ptr_ne(r3, null); 7693 terminateO(r3); 7694 s = toStringO(self); 7695 ck_assert_str_eq(s, "[]"); 7696 free(s); 7697 r = self->f->popDict(self); 7698 ck_assert(!r); 7699 s = toStringO(self); 7700 ck_assert_str_eq(s, "[]"); 7701 free(s); 7702 r2 = self->f->pushUndefined(self); 7703 ck_assert_ptr_ne(r2, null); 7704 delElemIndexO(self,-1); 7705 r = self->f->popDict(self); 7706 ck_assert_ptr_eq(r, null); 7707 // non json array 7708 freeO(self); 7709 setTypeBoolO(self); 7710 ck_assert_ptr_eq(self->f->popDict(self), NULL); 7711 terminateO(self); 7712 7713 } 7714 7715 7716 void popArraySmallJsonT(void) { 7717 7718 smallArrayt* r; 7719 smallJsont *self = allocSmallJson(); 7720 smallJsont *r2; 7721 baset *r3; 7722 7723 // add an element to check that the second element is poped 7724 // at the end 7725 r2 = self->f->pushInt(self, 1); 7726 ck_assert_ptr_ne(r2, null); 7727 // add second element 7728 createSmallArray(e); 7729 r2 = self->f->pushArray(self, &e); 7730 ck_assert_ptr_ne(r2, null); 7731 // pop 7732 r2 = self->f->pushUndefined(self); 7733 ck_assert_ptr_ne(r2, null); 7734 delElemIndexO(self,-1); 7735 r = self->f->popArray(self); 7736 ck_assert_ptr_ne(r, null); 7737 char *s = toStringO(r); 7738 terminateO(r); 7739 ck_assert_str_eq(s, "[]"); 7740 free(s); 7741 ck_assert_int_eq(lenO(self), 1); 7742 s = toStringO(self); 7743 ck_assert_str_eq(s, "[1]"); 7744 free(s); 7745 // pop element of unexpected type 7746 r = self->f->popArray(self); 7747 ck_assert(!r); 7748 ck_assert_int_eq(lenO(self), 1); 7749 s = toStringO(self); 7750 ck_assert_str_eq(s, "[1]"); 7751 free(s); 7752 // empty array 7753 r3 = self->f->pop(self); 7754 ck_assert_ptr_ne(r3, null); 7755 terminateO(r3); 7756 s = toStringO(self); 7757 ck_assert_str_eq(s, "[]"); 7758 free(s); 7759 r = self->f->popArray(self); 7760 ck_assert(!r); 7761 s = toStringO(self); 7762 ck_assert_str_eq(s, "[]"); 7763 free(s); 7764 r2 = self->f->pushUndefined(self); 7765 ck_assert_ptr_ne(r2, null); 7766 delElemIndexO(self,-1); 7767 r = self->f->popArray(self); 7768 // non json array 7769 freeO(self); 7770 setTypeBoolO(self); 7771 ck_assert_ptr_eq(self->f->popArray(self), NULL); 7772 ck_assert_ptr_eq(r, null); 7773 terminateO(self); 7774 7775 } 7776 7777 7778 void popSmallBoolSmallJsonT(void) { 7779 7780 smallBoolt* r; 7781 smallJsont *self = allocSmallJson(); 7782 smallJsont *r2; 7783 baset *r3; 7784 7785 // add an element to check that the second element is poped 7786 // at the end 7787 r2 = self->f->pushInt(self, 1); 7788 ck_assert_ptr_ne(r2, null); 7789 // add second element 7790 createSmallBool(e); 7791 r2 = self->f->pushSmallBool(self, &e); 7792 ck_assert_ptr_ne(r2, null); 7793 // pop 7794 r2 = self->f->pushUndefined(self); 7795 ck_assert_ptr_ne(r2, null); 7796 delElemIndexO(self,-1); 7797 r = self->f->popSmallBool(self); 7798 ck_assert_ptr_ne(r, null); 7799 char *s = toStringO(r); 7800 terminateO(r); 7801 ck_assert_str_eq(s, "false"); 7802 free(s); 7803 ck_assert_int_eq(lenO(self), 1); 7804 s = toStringO(self); 7805 ck_assert_str_eq(s, "[1]"); 7806 free(s); 7807 // pop element of unexpected type 7808 r = self->f->popSmallBool(self); 7809 ck_assert(!r); 7810 ck_assert_int_eq(lenO(self), 1); 7811 s = toStringO(self); 7812 ck_assert_str_eq(s, "[1]"); 7813 free(s); 7814 // empty array 7815 r3 = self->f->pop(self); 7816 ck_assert_ptr_ne(r3, null); 7817 terminateO(r3); 7818 s = toStringO(self); 7819 ck_assert_str_eq(s, "[]"); 7820 free(s); 7821 r = self->f->popSmallBool(self); 7822 ck_assert(!r); 7823 s = toStringO(self); 7824 ck_assert_str_eq(s, "[]"); 7825 free(s); 7826 r2 = self->f->pushUndefined(self); 7827 ck_assert_ptr_ne(r2, null); 7828 delElemIndexO(self,-1); 7829 r = self->f->popSmallBool(self); 7830 ck_assert_ptr_eq(r, null); 7831 // non json array 7832 freeO(self); 7833 setTypeBoolO(self); 7834 ck_assert_ptr_eq(self->f->popSmallBool(self), NULL); 7835 terminateO(self); 7836 7837 } 7838 7839 7840 void popSmallBytesSmallJsonT(void) { 7841 7842 smallBytest* r; 7843 smallJsont *self = allocSmallJson(); 7844 smallJsont *r2; 7845 baset *r3; 7846 7847 // add an element to check that the second element is poped 7848 // at the end 7849 r2 = self->f->pushInt(self, 1); 7850 ck_assert_ptr_ne(r2, null); 7851 // add second element 7852 createSmallBytes(e); 7853 r2 = self->f->pushSmallBytes(self, &e); 7854 ck_assert_ptr_ne(r2, null); 7855 // pop 7856 r2 = self->f->pushUndefined(self); 7857 ck_assert_ptr_ne(r2, null); 7858 delElemIndexO(self,-1); 7859 r = self->f->popSmallBytes(self); 7860 ck_assert_ptr_ne(r, null); 7861 char *s = toStringO(r); 7862 terminateO(r); 7863 ck_assert_str_eq(s, "[]"); 7864 free(s); 7865 ck_assert_int_eq(lenO(self), 1); 7866 s = toStringO(self); 7867 ck_assert_str_eq(s, "[1]"); 7868 free(s); 7869 // pop element of unexpected type 7870 r = self->f->popSmallBytes(self); 7871 ck_assert(!r); 7872 ck_assert_int_eq(lenO(self), 1); 7873 s = toStringO(self); 7874 ck_assert_str_eq(s, "[1]"); 7875 free(s); 7876 // empty array 7877 r3 = self->f->pop(self); 7878 ck_assert_ptr_ne(r3, null); 7879 terminateO(r3); 7880 s = toStringO(self); 7881 ck_assert_str_eq(s, "[]"); 7882 free(s); 7883 r = self->f->popSmallBytes(self); 7884 ck_assert(!r); 7885 s = toStringO(self); 7886 ck_assert_str_eq(s, "[]"); 7887 free(s); 7888 r2 = self->f->pushUndefined(self); 7889 ck_assert_ptr_ne(r2, null); 7890 delElemIndexO(self,-1); 7891 r = self->f->popSmallBytes(self); 7892 ck_assert_ptr_eq(r, null); 7893 // non json array 7894 freeO(self); 7895 setTypeBoolO(self); 7896 ck_assert_ptr_eq(self->f->popSmallBytes(self), NULL); 7897 terminateO(self); 7898 7899 } 7900 7901 7902 void popSmallDoubleSmallJsonT(void) { 7903 7904 smallDoublet* r; 7905 smallJsont *self = allocSmallJson(); 7906 smallJsont *r2; 7907 baset *r3; 7908 7909 // add an element to check that the second element is poped 7910 // at the end 7911 r2 = self->f->pushInt(self, 1); 7912 ck_assert_ptr_ne(r2, null); 7913 // add second element 7914 createSmallDouble(e); 7915 r2 = self->f->pushSmallDouble(self, &e); 7916 ck_assert_ptr_ne(r2, null); 7917 // pop 7918 r2 = self->f->pushUndefined(self); 7919 ck_assert_ptr_ne(r2, null); 7920 delElemIndexO(self,-1); 7921 r = self->f->popSmallDouble(self); 7922 ck_assert_ptr_ne(r, null); 7923 char *s = toStringO(r); 7924 terminateO(r); 7925 ck_assert_str_eq(s, "0.000000e+00"); 7926 free(s); 7927 ck_assert_int_eq(lenO(self), 1); 7928 s = toStringO(self); 7929 ck_assert_str_eq(s, "[1]"); 7930 free(s); 7931 // pop element of unexpected type 7932 r = self->f->popSmallDouble(self); 7933 ck_assert(!r); 7934 ck_assert_int_eq(lenO(self), 1); 7935 s = toStringO(self); 7936 ck_assert_str_eq(s, "[1]"); 7937 free(s); 7938 // empty array 7939 r3 = self->f->pop(self); 7940 ck_assert_ptr_ne(r3, null); 7941 terminateO(r3); 7942 s = toStringO(self); 7943 ck_assert_str_eq(s, "[]"); 7944 free(s); 7945 r = self->f->popSmallDouble(self); 7946 ck_assert(!r); 7947 s = toStringO(self); 7948 ck_assert_str_eq(s, "[]"); 7949 free(s); 7950 r2 = self->f->pushUndefined(self); 7951 ck_assert_ptr_ne(r2, null); 7952 delElemIndexO(self,-1); 7953 r = self->f->popSmallDouble(self); 7954 ck_assert_ptr_eq(r, null); 7955 // non json array 7956 freeO(self); 7957 setTypeBoolO(self); 7958 ck_assert_ptr_eq(self->f->popSmallDouble(self), NULL); 7959 terminateO(self); 7960 7961 } 7962 7963 7964 void popSmallIntSmallJsonT(void) { 7965 7966 smallIntt* r; 7967 smallJsont *self = allocSmallJson(); 7968 smallJsont *r2; 7969 baset *r3; 7970 7971 // add an element to check that the second element is poped 7972 // at the end 7973 r2 = self->f->pushBool(self, TRUE); 7974 ck_assert_ptr_ne(r2, null); 7975 // add second element 7976 createSmallInt(e); 7977 r2 = self->f->pushSmallInt(self, &e); 7978 ck_assert_ptr_ne(r2, null); 7979 // pop 7980 r2 = self->f->pushUndefined(self); 7981 ck_assert_ptr_ne(r2, null); 7982 delElemIndexO(self,-1); 7983 r = self->f->popSmallInt(self); 7984 ck_assert_ptr_ne(r, null); 7985 char *s = toStringO(r); 7986 terminateO(r); 7987 ck_assert_str_eq(s, "0"); 7988 free(s); 7989 ck_assert_int_eq(lenO(self), 1); 7990 s = toStringO(self); 7991 ck_assert_str_eq(s, "[true]"); 7992 free(s); 7993 // pop element of unexpected type 7994 r = self->f->popSmallInt(self); 7995 ck_assert(!r); 7996 ck_assert_int_eq(lenO(self), 1); 7997 s = toStringO(self); 7998 ck_assert_str_eq(s, "[true]"); 7999 free(s); 8000 // empty array 8001 r3 = self->f->pop(self); 8002 ck_assert_ptr_ne(r3, null); 8003 terminateO(r3); 8004 s = toStringO(self); 8005 ck_assert_str_eq(s, "[]"); 8006 free(s); 8007 r = self->f->popSmallInt(self); 8008 ck_assert(!r); 8009 s = toStringO(self); 8010 ck_assert_str_eq(s, "[]"); 8011 free(s); 8012 r2 = self->f->pushUndefined(self); 8013 ck_assert_ptr_ne(r2, null); 8014 delElemIndexO(self,-1); 8015 r = self->f->popSmallInt(self); 8016 ck_assert_ptr_eq(r, null); 8017 // non json array 8018 freeO(self); 8019 setTypeBoolO(self); 8020 ck_assert_ptr_eq(self->f->popSmallInt(self), NULL); 8021 terminateO(self); 8022 8023 } 8024 8025 8026 void popSmallJsonSmallJsonT(void) { 8027 8028 smallJsont* r; 8029 smallJsont *self = allocSmallJson(); 8030 smallJsont *r2; 8031 baset *r3; 8032 8033 // add an element to check that the second element is poped 8034 // at the end 8035 createSmallBytes(B); 8036 r2 = self->f->pushSmallBytes(self, &B); 8037 ck_assert_ptr_ne(r2, null); 8038 // add second element 8039 createSmallJson(e); 8040 r2 = self->f->pushSmallJson(self, &e); 8041 ck_assert_ptr_ne(r2, null); 8042 // pop 8043 r2 = self->f->pushUndefined(self); 8044 ck_assert_ptr_ne(r2, null); 8045 delElemIndexO(self,-1); 8046 r = self->f->popSmallJson(self); 8047 ck_assert_ptr_ne(r, null); 8048 char *s = toStringO(r); 8049 terminateO(r); 8050 ck_assert_str_eq(s, "{}"); 8051 free(s); 8052 ck_assert_int_eq(lenO(self), 1); 8053 s = toStringO(self); 8054 ck_assert_str_eq(s, "[[]]"); 8055 free(s); 8056 // pop element of unexpected type 8057 r = self->f->popSmallJson(self); 8058 ck_assert(!r); 8059 ck_assert_int_eq(lenO(self), 1); 8060 s = toStringO(self); 8061 ck_assert_str_eq(s, "[[]]"); 8062 free(s); 8063 // empty array 8064 r3 = self->f->pop(self); 8065 ck_assert_ptr_ne(r3, null); 8066 terminateO(r3); 8067 s = toStringO(self); 8068 ck_assert_str_eq(s, "[]"); 8069 free(s); 8070 r = self->f->popSmallJson(self); 8071 ck_assert(!r); 8072 s = toStringO(self); 8073 ck_assert_str_eq(s, "[]"); 8074 free(s); 8075 r2 = self->f->pushUndefined(self); 8076 ck_assert_ptr_ne(r2, null); 8077 delElemIndexO(self,-1); 8078 r = self->f->popSmallJson(self); 8079 ck_assert_ptr_eq(r, null); 8080 // non json array 8081 freeO(self); 8082 setTypeBoolO(self); 8083 ck_assert_ptr_eq(self->f->popSmallJson(self), NULL); 8084 terminateO(self); 8085 8086 } 8087 8088 8089 void popSmallStringSmallJsonT(void) { 8090 8091 smallStringt* r; 8092 smallJsont *self = allocSmallJson(); 8093 smallJsont *r2; 8094 baset *r3; 8095 8096 // add an element to check that the second element is poped 8097 // at the end 8098 r2 = self->f->pushInt(self, 1); 8099 ck_assert_ptr_ne(r2, null); 8100 // add second element 8101 createSmallString(e); 8102 r2 = self->f->pushSmallString(self, &e); 8103 ck_assert_ptr_ne(r2, null); 8104 // pop 8105 r2 = self->f->pushUndefined(self); 8106 ck_assert_ptr_ne(r2, null); 8107 delElemIndexO(self,-1); 8108 r = self->f->popSmallString(self); 8109 ck_assert_ptr_ne(r, null); 8110 char *s = toStringO(r); 8111 terminateO(r); 8112 ck_assert_str_eq(s, ""); 8113 free(s); 8114 ck_assert_int_eq(lenO(self), 1); 8115 s = toStringO(self); 8116 ck_assert_str_eq(s, "[1]"); 8117 free(s); 8118 // pop element of unexpected type 8119 r = self->f->popSmallString(self); 8120 ck_assert(!r); 8121 ck_assert_int_eq(lenO(self), 1); 8122 s = toStringO(self); 8123 ck_assert_str_eq(s, "[1]"); 8124 free(s); 8125 // empty array 8126 r3 = self->f->pop(self); 8127 ck_assert_ptr_ne(r3, null); 8128 terminateO(r3); 8129 s = toStringO(self); 8130 ck_assert_str_eq(s, "[]"); 8131 free(s); 8132 r = self->f->popSmallString(self); 8133 ck_assert(!r); 8134 s = toStringO(self); 8135 ck_assert_str_eq(s, "[]"); 8136 free(s); 8137 r2 = self->f->pushUndefined(self); 8138 ck_assert_ptr_ne(r2, null); 8139 delElemIndexO(self,-1); 8140 r = self->f->popSmallString(self); 8141 ck_assert_ptr_eq(r, null); 8142 // non json array 8143 freeO(self); 8144 setTypeBoolO(self); 8145 ck_assert_ptr_eq(self->f->popSmallString(self), NULL); 8146 terminateO(self); 8147 8148 } 8149 8150 8151 void popVoidSmallJsonT(void) { 8152 8153 void* r; 8154 smallJsont *self = allocSmallJson(); 8155 smallJsont *r2; 8156 baset *r3; 8157 8158 // add an element to check that the second element is poped 8159 // at the end 8160 r2 = self->f->pushInt(self, 1); 8161 ck_assert_ptr_ne(r2, null); 8162 // add second element 8163 createSmallContainer(e); 8164 setValO(&e, &r); 8165 r2 = self->f->pushSmallContainer(self, &e); 8166 ck_assert_ptr_ne(r2, null); 8167 // pop 8168 r = self->f->popVoid(self); 8169 ck_assert_ptr_eq(r, &r); 8170 ck_assert_int_eq(lenO(self), 1); 8171 char *s = toStringO(self); 8172 ck_assert_str_eq(s, "[1]"); 8173 free(s); 8174 // pop element of unexpected type 8175 r = self->f->popVoid(self); 8176 ck_assert(!r); 8177 ck_assert_int_eq(lenO(self), 1); 8178 s = toStringO(self); 8179 ck_assert_str_eq(s, "[1]"); 8180 free(s); 8181 // empty array 8182 r3 = self->f->pop(self); 8183 ck_assert_ptr_ne(r3, null); 8184 terminateO(r3); 8185 s = toStringO(self); 8186 ck_assert_str_eq(s, "[]"); 8187 free(s); 8188 r = self->f->popVoid(self); 8189 ck_assert(!r); 8190 s = toStringO(self); 8191 ck_assert_str_eq(s, "[]"); 8192 free(s); 8193 terminateO(self); 8194 8195 } 8196 8197 8198 void popSmallContainerSmallJsonT(void) { 8199 8200 smallContainert* r; 8201 smallJsont *self = allocSmallJson(); 8202 smallJsont *r2; 8203 baset *r3; 8204 8205 // add an element to check that the second element is poped 8206 // at the end 8207 r2 = self->f->pushInt(self, 1); 8208 ck_assert_ptr_ne(r2, null); 8209 // add second element 8210 createSmallContainer(e); 8211 r2 = self->f->pushSmallContainer(self, &e); 8212 ck_assert_ptr_ne(r2, null); 8213 // pop 8214 r2 = self->f->pushUndefined(self); 8215 ck_assert_ptr_ne(r2, null); 8216 delElemIndexO(self,-1); 8217 r = self->f->popSmallContainer(self); 8218 ck_assert_ptr_ne(r, null); 8219 char *s = toStringO(r); 8220 terminateO(r); 8221 ck_assert_str_eq(s, "<data smallContainer>"); 8222 free(s); 8223 ck_assert_int_eq(lenO(self), 1); 8224 s = toStringO(self); 8225 ck_assert_str_eq(s, "[1]"); 8226 free(s); 8227 // container with baset object 8228 // push a base object of unknown type 8229 smallIntt *o = allocSmallInt(2); 8230 o->type = "newType"; 8231 r2 = self->f->pushNFree(self, (baset*)o); 8232 ck_assert_ptr_ne(r2, null); 8233 r = self->f->popSmallContainer(self); 8234 ck_assert_ptr_eq(r, NULL); 8235 ck_assert_int_eq(lenO(self), 2); 8236 s = toStringO(self); 8237 ck_assert_str_eq(s, "[1,\"<data container>\"]"); 8238 free(s); 8239 r3 = self->f->pop(self); 8240 ck_assert_ptr_ne(r3, null); 8241 terminateO(r3); 8242 // pop element of unexpected type 8243 r = self->f->popSmallContainer(self); 8244 ck_assert_ptr_eq(r, NULL); 8245 ck_assert_int_eq(lenO(self), 1); 8246 s = toStringO(self); 8247 ck_assert_str_eq(s, "[1]"); 8248 free(s); 8249 // empty array 8250 r3 = self->f->pop(self); 8251 ck_assert_ptr_ne(r3, null); 8252 terminateO(r3); 8253 s = toStringO(self); 8254 ck_assert_str_eq(s, "[]"); 8255 free(s); 8256 r = self->f->popSmallContainer(self); 8257 ck_assert(!r); 8258 s = toStringO(self); 8259 ck_assert_str_eq(s, "[]"); 8260 free(s); 8261 r2 = self->f->pushUndefined(self); 8262 ck_assert_ptr_ne(r2, null); 8263 delElemIndexO(self,-1); 8264 r = self->f->popSmallContainer(self); 8265 ck_assert_ptr_eq(r, null); 8266 // non json array 8267 freeO(self); 8268 setTypeBoolO(self); 8269 ck_assert_ptr_eq(self->f->popSmallContainer(self), NULL); 8270 terminateO(self); 8271 8272 } 8273 8274 8275 void popNumSmallJsonT(void) { 8276 8277 double r; 8278 smallJsont *self = allocSmallJson(); 8279 smallJsont *r2; 8280 baset *r3; 8281 8282 // add an element to check that the second element is poped 8283 // at the end 8284 r2 = self->f->pushBool(self, TRUE); 8285 ck_assert_ptr_ne(r2, null); 8286 // add second element 8287 r2 = self->f->pushInt(self, 2); 8288 ck_assert_ptr_ne(r2, null); 8289 r2 = self->f->pushDouble(self, 2.5); 8290 ck_assert_ptr_ne(r2, null); 8291 // pop 8292 r2 = self->f->pushUndefined(self); 8293 ck_assert_ptr_ne(r2, null); 8294 delElemIndexO(self,-1); 8295 r = self->f->popNum(self); 8296 ck_assert(r==2.5); 8297 ck_assert_int_eq(lenO(self), 2); 8298 char *s = toStringO(self); 8299 ck_assert_str_eq(s, "[true,2]"); 8300 free(s); 8301 r = self->f->popNum(self); 8302 ck_assert_int_eq(r, 2); 8303 ck_assert_int_eq(lenO(self), 1); 8304 s = toStringO(self); 8305 ck_assert_str_eq(s, "[true]"); 8306 free(s); 8307 // pop element of unexpected type 8308 r = self->f->popNum(self); 8309 ck_assert(!r); 8310 ck_assert_int_eq(lenO(self), 1); 8311 s = toStringO(self); 8312 ck_assert_str_eq(s, "[true]"); 8313 free(s); 8314 // empty array 8315 r3 = self->f->pop(self); 8316 ck_assert_ptr_ne(r3, null); 8317 terminateO(r3); 8318 s = toStringO(self); 8319 ck_assert_str_eq(s, "[]"); 8320 free(s); 8321 r = self->f->popNum(self); 8322 ck_assert(!r); 8323 s = toStringO(self); 8324 ck_assert_str_eq(s, "[]"); 8325 free(s); 8326 r2 = self->f->pushUndefined(self); 8327 ck_assert_ptr_ne(r2, null); 8328 delElemIndexO(self,-1); 8329 r = self->f->popNum(self); 8330 ck_assert(!r); 8331 // non json array 8332 freeO(self); 8333 setTypeBoolO(self); 8334 ck_assert(!self->f->popNum(self)); 8335 terminateO(self); 8336 8337 } 8338 8339 8340 void prependSmallJsonT(void) { 8341 8342 smallJsont* r; 8343 smallJsont *self = allocSmallJson(); 8344 baset *value = (baset*) allocG(2); 8345 8346 // add an element to check that prepend adds the second element 8347 // at the start 8348 r = self->f->pushInt(self, 1); 8349 ck_assert_ptr_ne(r, null); 8350 r = self->f->prepend(self, value); 8351 ck_assert_ptr_ne(r, null); 8352 ck_assert_int_eq(lenO(r), 2); 8353 finishO(value); 8354 char *s = toStringO(r); 8355 ck_assert_str_eq(s, "[2,1]"); 8356 free(s); 8357 // null 8358 r = self->f->prepend(self, null); 8359 ck_assert_ptr_eq(r, null); 8360 ck_assert_int_eq(lenO(self), 2); 8361 s = toStringO(self); 8362 ck_assert_str_eq(s, "[2,1]"); 8363 free(s); 8364 // non json array 8365 freeO(self); 8366 setTypeBoolO(self); 8367 value = (baset*) allocSmallInt(2); 8368 ck_assert_ptr_eq(self->f->prepend(self, value), NULL); 8369 terminateO(value); 8370 terminateO(self); 8371 8372 } 8373 8374 8375 void prependUndefinedSmallJsonT(void) { 8376 8377 smallJsont* r; 8378 smallJsont *self = allocSmallJson(); 8379 8380 // add an element to check that push adds the second element 8381 // at the end 8382 r = self->f->pushInt(self, 1); 8383 ck_assert_ptr_ne(r, null); 8384 r = self->f->prependUndefined(self); 8385 ck_assert_ptr_ne(r, null); 8386 ck_assert_int_eq(lenO(r), 2); 8387 char *s = toStringO(r); 8388 ck_assert_str_eq(s, "[null,1]"); 8389 free(s); 8390 // non json array 8391 freeO(self); 8392 setTypeBoolO(self); 8393 ck_assert_ptr_eq(self->f->prependUndefined(self), NULL); 8394 terminateO(self); 8395 8396 } 8397 8398 8399 void prependBoolSmallJsonT(void) { 8400 8401 smallJsont* r; 8402 smallJsont *self = allocSmallJson(); 8403 8404 // add an element to check that push adds the second element 8405 // at the end 8406 r = self->f->pushInt(self, 1); 8407 ck_assert_ptr_ne(r, null); 8408 8409 r = self->f->prependBool(self, TRUE); 8410 ck_assert_ptr_ne(r, null); 8411 ck_assert_int_eq(lenO(r), 2); 8412 char *s = toStringO(r); 8413 ck_assert_str_eq(s, "[true,1]"); 8414 free(s); 8415 // non json array 8416 freeO(self); 8417 setTypeBoolO(self); 8418 ck_assert_ptr_eq(self->f->prependBool(self, true), NULL); 8419 terminateO(self); 8420 8421 } 8422 8423 8424 void prependDoubleSmallJsonT(void) { 8425 8426 smallJsont* r; 8427 smallJsont *self = allocSmallJson(); 8428 8429 // add an element to check that push adds the second element 8430 // at the end 8431 r = self->f->pushInt(self, 1); 8432 ck_assert_ptr_ne(r, null); 8433 r = self->f->prependDouble(self, 1.0); 8434 ck_assert_ptr_ne(r, null); 8435 ck_assert_int_eq(lenO(r), 2); 8436 char *s = toStringO(r); 8437 ck_assert_str_eq(s, "[1.000000e+00,1]"); 8438 free(s); 8439 // non json array 8440 freeO(self); 8441 setTypeBoolO(self); 8442 ck_assert_ptr_eq(self->f->prependDouble(self, 0), NULL); 8443 terminateO(self); 8444 8445 } 8446 8447 8448 void prependIntSmallJsonT(void) { 8449 8450 smallJsont* r; 8451 smallJsont *self = allocSmallJson(); 8452 8453 // add an element to check that push adds the second element 8454 // at the end 8455 r = self->f->prependInt(self, 1); 8456 ck_assert_ptr_ne(r, null); 8457 r = self->f->prependInt(self, 1); 8458 ck_assert_ptr_ne(r, null); 8459 ck_assert_int_eq(lenO(r), 2); 8460 char *s = toStringO(r); 8461 ck_assert_str_eq(s, "[1,1]"); 8462 free(s); 8463 // non json array 8464 freeO(self); 8465 setTypeBoolO(self); 8466 ck_assert_ptr_eq(self->f->prependInt(self, 0), NULL); 8467 terminateO(self); 8468 8469 } 8470 8471 8472 void prependSSmallJsonT(void) { 8473 8474 smallJsont* r; 8475 smallJsont *self = allocSmallJson(); 8476 8477 // add an element to check that push adds the second element 8478 // at the end 8479 r = self->f->pushInt(self, 1); 8480 ck_assert_ptr_ne(r, null); 8481 r = self->f->prependS(self, null); 8482 ck_assert_ptr_eq(r, null); 8483 ck_assert_int_eq(lenO(self), 1); 8484 char *s = toStringO(self); 8485 ck_assert_str_eq(s, "[1]"); 8486 free(s); 8487 char *str = "poi"; 8488 r = self->f->prependS(self, str); 8489 ck_assert_ptr_ne(r, null); 8490 ck_assert_int_eq(lenO(self), 2); 8491 s = toStringO(r); 8492 ck_assert_str_eq(s, "[\"poi\",1]"); 8493 free(s); 8494 // non json array 8495 freeO(self); 8496 setTypeBoolO(self); 8497 ck_assert_ptr_eq(self->f->prependS(self, ""), NULL); 8498 terminateO(self); 8499 // json string 8500 self = allocSmallJson(); 8501 setTopSO(self, "qwe"); 8502 r = prependSO(self, "!@#"); 8503 ck_assert_ptr_ne(r, null); 8504 s = toStringO(r); 8505 ck_assert_str_eq(s, "!@#qwe"); 8506 free(s); 8507 // empty string 8508 r = prependSO(self, ""); 8509 ck_assert_ptr_ne(r, null); 8510 s = toStringO(r); 8511 ck_assert_str_eq(s, "!@#qwe"); 8512 free(s); 8513 // empty self 8514 freeO(self); 8515 setTypeStringO(self); 8516 r = prependSO(self, "asd"); 8517 ck_assert_ptr_ne(r, null); 8518 s = toStringO(r); 8519 ck_assert_str_eq(s, "asd"); 8520 free(s); 8521 // null parameter 8522 r = prependSO(self, null); 8523 ck_assert_ptr_eq(r, null); 8524 terminateO(self); 8525 8526 } 8527 8528 8529 void prependCharSmallJsonT(void) { 8530 8531 smallJsont* r; 8532 smallJsont *self = allocSmallJson(); 8533 8534 // add an element to check that push adds the second element 8535 // at the end 8536 r = self->f->pushInt(self, 1); 8537 ck_assert_ptr_ne(r, null); 8538 r = self->f->prependChar(self, 'a'); 8539 ck_assert_ptr_ne(r, null); 8540 ck_assert_int_eq(lenO(r), 2); 8541 char *s = toStringO(r); 8542 ck_assert_str_eq(s, "[\"a\",1]"); 8543 free(s); 8544 // non json array 8545 freeO(self); 8546 setTypeBoolO(self); 8547 ck_assert_ptr_eq(self->f->prependChar(self, 't'), NULL); 8548 terminateO(self); 8549 8550 } 8551 8552 8553 void prependDictSmallJsonT(void) { 8554 8555 smallJsont* r; 8556 smallJsont *self = allocSmallJson(); 8557 smallDictt *dict = allocG(rtSmallDictt); 8558 8559 // add an element to check that push adds the second element 8560 // at the end 8561 r = self->f->pushInt(self, 1); 8562 ck_assert_ptr_ne(r, null); 8563 // push dict 8564 r = self->f->prependDict(self, dict); 8565 ck_assert_ptr_ne(r, null); 8566 ck_assert_int_eq(lenO(r), 2); 8567 finishO(dict); 8568 ck_assert_ptr_ne(r, null); 8569 char *s = toStringO(r); 8570 ck_assert_str_eq(s, "[{},1]"); 8571 free(s); 8572 // non smallDict object 8573 dict = (smallDictt*) allocSmallInt(2); 8574 r = self->f->prependDict(self, dict); 8575 ck_assert_ptr_eq(r, null); 8576 terminateO(dict); 8577 // null 8578 r = self->f->prependDict(self, null); 8579 ck_assert_ptr_eq(r, null); 8580 ck_assert_int_eq(lenO(self), 2); 8581 s = toStringO(self); 8582 ck_assert_str_eq(s, "[{},1]"); 8583 free(s); 8584 // non json array 8585 freeO(self); 8586 setTypeBoolO(self); 8587 smallDictt *value = allocSmallDict(); 8588 ck_assert_ptr_eq(self->f->prependDict(self, value), NULL); 8589 terminateO(value); 8590 terminateO(self); 8591 8592 } 8593 8594 8595 void prependArraySmallJsonT(void) { 8596 8597 smallJsont* r; 8598 smallJsont *self = allocSmallJson(); 8599 smallArrayt *array = allocG(rtSmallArrayt); 8600 8601 // add an element to check that push adds the second element 8602 // at the end 8603 r = self->f->pushInt(self, 1); 8604 ck_assert_ptr_ne(r, null); 8605 r = self->f->prependArray(self, array); 8606 ck_assert_ptr_ne(r, null); 8607 ck_assert_int_eq(lenO(r), 2); 8608 finishO(array); 8609 char *s = toStringO(r); 8610 ck_assert_str_eq(s, "[[],1]"); 8611 free(s); 8612 // non smallArray object 8613 array = (smallArrayt*) allocSmallInt(2); 8614 r = self->f->prependArray(self, array); 8615 ck_assert_ptr_eq(r, null); 8616 terminateO(array); 8617 // null 8618 r = self->f->prependArray(self, null); 8619 ck_assert_ptr_eq(r, null); 8620 ck_assert_int_eq(lenO(self), 2); 8621 s = toStringO(self); 8622 ck_assert_str_eq(s, "[[],1]"); 8623 free(s); 8624 // non json array 8625 freeO(self); 8626 setTypeBoolO(self); 8627 smallArrayt *value = allocSmallArray(); 8628 ck_assert_ptr_eq(self->f->prependArray(self, value), NULL); 8629 terminateO(value); 8630 terminateO(self); 8631 8632 } 8633 8634 8635 void prependArraycSmallJsonT(void) { 8636 8637 smallJsont* r; 8638 smallJsont *self = allocSmallJson(); 8639 char **array = listCreateS("a","bb"); 8640 8641 // add an element to check that push adds the second element 8642 // at the end 8643 r = self->f->pushInt(self, 1); 8644 ck_assert_ptr_ne(r, null); 8645 r = self->f->prependArrayc(self, array); 8646 ck_assert_ptr_ne(r, null); 8647 ck_assert_int_eq(lenO(r), 2); 8648 listFreeS(array); 8649 char *s = toStringO(r); 8650 ck_assert_str_eq(s, "[[\"a\",\"bb\"],1]"); 8651 free(s); 8652 // null 8653 r = self->f->prependArrayc(self, null); 8654 ck_assert_ptr_eq(r, null); 8655 ck_assert_int_eq(lenO(self), 2); 8656 s = toStringO(self); 8657 ck_assert_str_eq(s, "[[\"a\",\"bb\"],1]"); 8658 free(s); 8659 // non json array 8660 freeO(self); 8661 setTypeBoolO(self); 8662 char **value = listCreateS("a","bb"); 8663 ck_assert_ptr_eq(self->f->prependArrayc(self, value), NULL); 8664 listFreeS(value); 8665 terminateO(self); 8666 8667 } 8668 8669 8670 void prependSmallBoolSmallJsonT(void) { 8671 8672 smallJsont* r; 8673 smallJsont *self = allocSmallJson(); 8674 smallBoolt *value = allocG(TRUE); 8675 8676 // add an element to check that push adds the second element 8677 // at the end 8678 r = self->f->pushInt(self, 1); 8679 ck_assert_ptr_ne(r, null); 8680 r = self->f->prependSmallBool(self, value); 8681 ck_assert_ptr_ne(r, null); 8682 ck_assert_int_eq(lenO(r), 2); 8683 finishO(value); 8684 char *s = toStringO(r); 8685 ck_assert_str_eq(s, "[true,1]"); 8686 free(s); 8687 // bool object with no data 8688 createAllocateSmallBool(b); 8689 r = self->f->prependSmallBool(self, b); 8690 ck_assert_ptr_ne(r, null); 8691 ck_assert_int_eq(lenO(r), 3); 8692 finishO(b); 8693 s = toStringO(r); 8694 ck_assert_str_eq(s, "[false,true,1]"); 8695 free(s); 8696 // non smallBool object 8697 value = (smallBoolt*) allocSmallInt(2); 8698 r = self->f->prependSmallBool(self, value); 8699 ck_assert_ptr_eq(r, null); 8700 terminateO(value); 8701 // null 8702 r = self->f->prependSmallBool(self, null); 8703 ck_assert_ptr_eq(r, null); 8704 ck_assert_int_eq(lenO(self), 3); 8705 s = toStringO(self); 8706 ck_assert_str_eq(s, "[false,true,1]"); 8707 free(s); 8708 // non json array 8709 freeO(self); 8710 setTypeBoolO(self); 8711 value = allocSmallBool(true); 8712 ck_assert_ptr_eq(self->f->prependSmallBool(self, value), NULL); 8713 terminateO(value); 8714 terminateO(self); 8715 8716 } 8717 8718 8719 void prependSmallBytesSmallJsonT(void) { 8720 8721 smallJsont* r; 8722 smallJsont *self = allocSmallJson(); 8723 createAllocateSmallBytes(value); 8724 8725 // add an element to check that push adds the second element 8726 // at the end 8727 r = self->f->pushInt(self, 1); 8728 ck_assert_ptr_ne(r, null); 8729 // the smallBytes container is empty 8730 r = self->f->prependSmallBytes(self, value); 8731 ck_assert_ptr_ne(r, null); 8732 ck_assert_int_eq(lenO(r), 2); 8733 char *s = toStringO(r); 8734 ck_assert_str_eq(s, "[[],1]"); 8735 free(s); 8736 // reuse value 8737 value->B = null; 8738 char *buffer = "poi"; 8739 pushBufferO(value, buffer, strlen(buffer)); 8740 r = self->f->prependSmallBytes(self, value); 8741 finishO(value); 8742 ck_assert_ptr_ne(r, null); 8743 ck_assert_int_eq(lenO(r), 3); 8744 s = toStringO(r); 8745 ck_assert_str_eq(s, "[[0x70,0x6f,0x69],[],1]"); 8746 free(s); 8747 // non smallBytes object 8748 value = (smallBytest*) allocSmallInt(2); 8749 r = self->f->prependSmallBytes(self, value); 8750 ck_assert_ptr_eq(r, null); 8751 terminateO(value); 8752 // null 8753 r = self->f->prependSmallBytes(self, null); 8754 ck_assert_ptr_eq(r, null); 8755 ck_assert_int_eq(lenO(self), 3); 8756 s = toStringO(self); 8757 ck_assert_str_eq(s, "[[0x70,0x6f,0x69],[],1]"); 8758 free(s); 8759 // non json array 8760 freeO(self); 8761 setTypeBoolO(self); 8762 value = allocSmallBytes("", sizeof("")); 8763 ck_assert_ptr_eq(self->f->prependSmallBytes(self, value), NULL); 8764 terminateO(value); 8765 terminateO(self); 8766 8767 } 8768 8769 8770 void prependSmallDoubleSmallJsonT(void) { 8771 8772 smallJsont* r; 8773 smallJsont *self = allocSmallJson(); 8774 smallDoublet *value = allocG(1.0); 8775 8776 // add an element to check that push adds the second element 8777 // at the end 8778 r = self->f->pushInt(self, 1); 8779 ck_assert_ptr_ne(r, null); 8780 r = self->f->prependSmallDouble(self, value); 8781 ck_assert_ptr_ne(r, null); 8782 ck_assert_int_eq(lenO(r), 2); 8783 finishO(value); 8784 char *s = toStringO(r); 8785 ck_assert_str_eq(s, "[1.000000e+00,1]"); 8786 free(s); 8787 // object with no data 8788 createAllocateSmallDouble(b); 8789 r = self->f->prependSmallDouble(self, b); 8790 ck_assert_ptr_ne(r, null); 8791 ck_assert_int_eq(lenO(r), 3); 8792 finishO(b); 8793 s = toStringO(r); 8794 ck_assert_str_eq(s, "[0.000000e+00,1.000000e+00,1]"); 8795 free(s); 8796 // non smallDouble object 8797 value = (smallDoublet*) allocSmallInt(2); 8798 r = self->f->prependSmallDouble(self, value); 8799 ck_assert_ptr_eq(r, null); 8800 terminateO(value); 8801 // null 8802 r = self->f->prependSmallDouble(self, null); 8803 ck_assert_ptr_eq(r, null); 8804 ck_assert_int_eq(lenO(self), 3); 8805 s = toStringO(self); 8806 ck_assert_str_eq(s, "[0.000000e+00,1.000000e+00,1]"); 8807 free(s); 8808 // non json array 8809 freeO(self); 8810 setTypeBoolO(self); 8811 value = allocSmallDouble(2); 8812 ck_assert_ptr_eq(self->f->prependSmallDouble(self, value), NULL); 8813 terminateO(value); 8814 terminateO(self); 8815 8816 } 8817 8818 8819 void prependSmallIntSmallJsonT(void) { 8820 8821 smallJsont* r; 8822 smallJsont *self = allocSmallJson(); 8823 smallIntt *value = allocG(1); 8824 8825 // add an element to check that push adds the second element 8826 // at the end 8827 r = self->f->pushInt(self, 1); 8828 ck_assert_ptr_ne(r, null); 8829 r = self->f->prependSmallInt(self, value); 8830 ck_assert_ptr_ne(r, null); 8831 ck_assert_int_eq(lenO(r), 2); 8832 finishO(value); 8833 char *s = toStringO(r); 8834 ck_assert_str_eq(s, "[1,1]"); 8835 free(s); 8836 // bool object with no data 8837 createAllocateSmallInt(b); 8838 r = self->f->prependSmallInt(self, b); 8839 ck_assert_ptr_ne(r, null); 8840 ck_assert_int_eq(lenO(r), 3); 8841 finishO(b); 8842 s = toStringO(r); 8843 ck_assert_str_eq(s, "[0,1,1]"); 8844 free(s); 8845 // non smallInt object 8846 value = (smallIntt*) allocSmallBool(true); 8847 r = self->f->prependSmallInt(self, value); 8848 ck_assert_ptr_eq(r, null); 8849 terminateO(value); 8850 // null 8851 r = self->f->prependSmallInt(self, null); 8852 ck_assert_ptr_eq(r, null); 8853 ck_assert_int_eq(lenO(self), 3); 8854 s = toStringO(self); 8855 ck_assert_str_eq(s, "[0,1,1]"); 8856 free(s); 8857 // non json array 8858 freeO(self); 8859 setTypeBoolO(self); 8860 value = allocSmallInt(2); 8861 ck_assert_ptr_eq(self->f->prependSmallInt(self, value), NULL); 8862 terminateO(value); 8863 terminateO(self); 8864 8865 } 8866 8867 8868 void prependSmallJsonSmallJsonT(void) { 8869 8870 smallJsont* r; 8871 smallJsont *self = allocSmallJson(); 8872 smallJsont *value = allocG(rtSmallJsont); 8873 8874 // add an element to check that push adds the second element 8875 // at the end 8876 r = self->f->pushInt(self, 1); 8877 ck_assert_ptr_ne(r, null); 8878 // the smallJson container is empty 8879 r = self->f->prependSmallJson(self, value); 8880 ck_assert_ptr_ne(r, null); 8881 ck_assert_int_eq(lenO(r), 2); 8882 char *s = toStringO(r); 8883 ck_assert_str_eq(s, "[{},1]"); 8884 free(s); 8885 resetO(value); 8886 parseO(value, "{}"); 8887 r = self->f->prependSmallJson(self, value); 8888 finishO(value); 8889 ck_assert_ptr_ne(r, null); 8890 ck_assert_int_eq(lenO(r), 3); 8891 s = toStringO(r); 8892 ck_assert_str_eq(s, "[{},{},1]"); 8893 free(s); 8894 // non smallJson object 8895 value = (smallJsont*) allocSmallInt(2); 8896 r = self->f->prependSmallJson(self, value); 8897 ck_assert_ptr_eq(r, null); 8898 terminateO(value); 8899 // null 8900 r = self->f->prependSmallJson(self, null); 8901 ck_assert_ptr_eq(r, null); 8902 ck_assert_int_eq(lenO(self), 3); 8903 s = toStringO(self); 8904 ck_assert_str_eq(s, "[{},{},1]"); 8905 free(s); 8906 // non json array 8907 freeO(self); 8908 setTypeBoolO(self); 8909 value = allocSmallJson(); 8910 ck_assert_ptr_eq(self->f->prependSmallJson(self, value), NULL); 8911 terminateO(value); 8912 terminateO(self); 8913 8914 } 8915 8916 8917 void prependSmallStringSmallJsonT(void) { 8918 8919 smallJsont* r; 8920 smallJsont *self = allocSmallJson(); 8921 createAllocateSmallString(string); 8922 8923 // add an element to check that push adds the second element 8924 // at the end 8925 r = self->f->pushInt(self, 1); 8926 ck_assert_ptr_ne(r, null); 8927 r = self->f->prependSmallString(self, string); 8928 ck_assert_ptr_ne(r, null); 8929 ck_assert_int_eq(lenO(r), 2); 8930 finishO(string); 8931 char *s = toStringO(r); 8932 ck_assert_str_eq(s, "[\"\",1]"); 8933 free(s); 8934 // non smallString object 8935 string = (smallStringt*) allocSmallInt(2); 8936 r = self->f->prependSmallString(self, string); 8937 ck_assert_ptr_eq(r, null); 8938 terminateO(string); 8939 // null 8940 r = self->f->prependSmallString(self, null); 8941 ck_assert_ptr_eq(r, null); 8942 ck_assert_int_eq(lenO(self), 2); 8943 s = toStringO(self); 8944 ck_assert_str_eq(s, "[\"\",1]"); 8945 free(s); 8946 // non json array 8947 freeO(self); 8948 setTypeBoolO(self); 8949 smallStringt *value = allocSmallString(""); 8950 ck_assert_ptr_eq(self->f->prependSmallString(self, value), NULL); 8951 terminateO(value); 8952 terminateO(self); 8953 // json string 8954 self = allocSmallJson(); 8955 setTopSO(self, "qwe"); 8956 string = allocSmallString("!@#"); 8957 r = self->f->prependSmallString(self, string); 8958 ck_assert_ptr_ne(r, null); 8959 s = toStringO(r); 8960 ck_assert_str_eq(s, "!@#qwe"); 8961 free(s); 8962 // empty string 8963 setValO(string, ""); 8964 r = self->f->prependSmallString(self, string); 8965 ck_assert_ptr_ne(r, null); 8966 s = toStringO(r); 8967 ck_assert_str_eq(s, "!@#qwe"); 8968 free(s); 8969 freeO(string); 8970 r = self->f->prependSmallString(self, string); 8971 ck_assert_ptr_ne(r, null); 8972 s = toStringO(r); 8973 ck_assert_str_eq(s, "!@#qwe"); 8974 free(s); 8975 // empty self 8976 freeO(self); 8977 setTypeStringO(self); 8978 setValO(string, "asd"); 8979 r = self->f->prependSmallString(self, string); 8980 ck_assert_ptr_ne(r, null); 8981 s = toStringO(r); 8982 ck_assert_str_eq(s, "asd"); 8983 free(s); 8984 terminateO(string); 8985 // not smallString object 8986 string = (smallStringt*) allocSmallInt(1); 8987 r = self->f->prependSmallString(self, string); 8988 ck_assert_ptr_eq(r, null); 8989 terminateO(string); 8990 // null parameter 8991 r = self->f->prependSmallString(self, null); 8992 ck_assert_ptr_eq(r, null); 8993 terminateO(self); 8994 8995 } 8996 8997 8998 void prependSmallContainerSmallJsonT(void) { 8999 9000 smallJsont* r; 9001 smallJsont *self = allocSmallJson(); 9002 createAllocateSmallContainer(container); 9003 9004 // add an element to check that push adds the second element 9005 // at the end 9006 r = self->f->pushInt(self, 1); 9007 ck_assert_ptr_ne(r, null); 9008 r = self->f->prependSmallContainer(self, container); 9009 ck_assert_ptr_ne(r, null); 9010 ck_assert_int_eq(lenO(r), 2); 9011 finishO(container); 9012 char *s = toStringO(r); 9013 ck_assert_str_eq(s, "[\"<data container>\",1]"); 9014 free(s); 9015 // non smallContainer object 9016 container = (smallContainert*) allocSmallInt(2); 9017 r = self->f->prependSmallContainer(self, container); 9018 ck_assert_ptr_eq(r, null); 9019 terminateO(container); 9020 // null 9021 r = self->f->prependSmallContainer(self, null); 9022 ck_assert_ptr_eq(r, null); 9023 ck_assert_int_eq(lenO(self), 2); 9024 s = toStringO(self); 9025 ck_assert_str_eq(s, "[\"<data container>\",1]"); 9026 free(s); 9027 // non json array 9028 freeO(self); 9029 setTypeBoolO(self); 9030 smallContainert *value = allocSmallContainer(null); 9031 ck_assert_ptr_eq(self->f->prependSmallContainer(self, value), NULL); 9032 terminateO(value); 9033 terminateO(self); 9034 9035 } 9036 9037 9038 void prependNFreeSmallJsonT(void) { 9039 9040 smallJsont* r; 9041 smallJsont *self = allocSmallJson(); 9042 baset *value = (baset*) allocG(2); 9043 9044 // add an element to check that prepend adds the second element 9045 // at the start 9046 r = self->f->pushInt(self, 1); 9047 ck_assert_ptr_ne(r, null); 9048 9049 r = self->f->prependNFree(self, value); 9050 ck_assert_ptr_ne(r, null); 9051 ck_assert_int_eq(lenO(r), 2); 9052 char *s = toStringO(r); 9053 ck_assert_str_eq(s, "[2,1]"); 9054 free(s); 9055 // null 9056 r = self->f->prependNFree(self, null); 9057 ck_assert_ptr_eq(r, null); 9058 ck_assert_int_eq(lenO(self), 2); 9059 s = toStringO(self); 9060 ck_assert_str_eq(s, "[2,1]"); 9061 free(s); 9062 terminateO(self); 9063 9064 } 9065 9066 9067 void prependNFreeUndefinedSmallJsonT(void) { 9068 9069 smallJsont* r; 9070 smallJsont *self = allocSmallJson(); 9071 9072 // add an element to check that push adds the second element 9073 // at the end 9074 r = self->f->pushInt(self, 1); 9075 ck_assert_ptr_ne(r, null); 9076 9077 createAllocateUndefined(value); 9078 r = self->f->prependNFreeUndefined(self, value); 9079 ck_assert_ptr_ne(r, null); 9080 ck_assert_int_eq(lenO(r), 2); 9081 char *s = toStringO(r); 9082 ck_assert_str_eq(s, "[null,1]"); 9083 free(s); 9084 terminateO(self); 9085 9086 } 9087 9088 9089 void prependNFreeSSmallJsonT(void) { 9090 9091 smallJsont* r; 9092 smallJsont *self = allocSmallJson(); 9093 9094 // add an element to check that push adds the second element 9095 // at the end 9096 r = self->f->pushInt(self, 1); 9097 ck_assert_ptr_ne(r, null); 9098 9099 r = self->f->prependNFreeS(self, null); 9100 ck_assert_ptr_eq(r, null); 9101 ck_assert_int_eq(lenO(self), 1); 9102 char *s = toStringO(self); 9103 ck_assert_str_eq(s, "[1]"); 9104 free(s); 9105 9106 char *str = strdup("poi"); 9107 r = self->f->prependNFreeS(self, str); 9108 ck_assert_ptr_ne(r, null); 9109 ck_assert_int_eq(lenO(self), 2); 9110 s = toStringO(r); 9111 ck_assert_str_eq(s, "[\"poi\",1]"); 9112 free(s); 9113 9114 terminateO(self); 9115 9116 } 9117 9118 9119 void prependNFreeDictSmallJsonT(void) { 9120 9121 smallJsont* r; 9122 smallJsont *self = allocSmallJson(); 9123 smallDictt *dict = allocG(rtSmallDictt); 9124 9125 // add an element to check that push adds the second element 9126 // at the end 9127 r = self->f->pushInt(self, 1); 9128 ck_assert_ptr_ne(r, null); 9129 9130 // push dict 9131 r = self->f->prependNFreeDict(self, dict); 9132 ck_assert_ptr_ne(r, null); 9133 ck_assert_int_eq(lenO(r), 2); 9134 ck_assert_ptr_ne(r, null); 9135 char *s = toStringO(r); 9136 ck_assert_str_eq(s, "[{},1]"); 9137 free(s); 9138 // null 9139 r = self->f->prependNFreeDict(self, null); 9140 ck_assert_ptr_eq(r, null); 9141 ck_assert_int_eq(lenO(self), 2); 9142 s = toStringO(self); 9143 ck_assert_str_eq(s, "[{},1]"); 9144 free(s); 9145 terminateO(self); 9146 9147 } 9148 9149 9150 void prependNFreeArraySmallJsonT(void) { 9151 9152 smallJsont* r; 9153 smallJsont *self = allocSmallJson(); 9154 smallArrayt *array = allocG(rtSmallArrayt); 9155 9156 // add an element to check that push adds the second element 9157 // at the end 9158 r = self->f->pushInt(self, 1); 9159 ck_assert_ptr_ne(r, null); 9160 9161 r = self->f->prependNFreeArray(self, array); 9162 ck_assert_ptr_ne(r, null); 9163 ck_assert_int_eq(lenO(r), 2); 9164 char *s = toStringO(r); 9165 ck_assert_str_eq(s, "[[],1]"); 9166 free(s); 9167 // null 9168 r = self->f->prependNFreeArray(self, null); 9169 ck_assert_ptr_eq(r, null); 9170 ck_assert_int_eq(lenO(self), 2); 9171 s = toStringO(self); 9172 ck_assert_str_eq(s, "[[],1]"); 9173 free(s); 9174 terminateO(self); 9175 9176 } 9177 9178 9179 void prependNFreeArraycSmallJsonT(void) { 9180 9181 smallJsont* r; 9182 smallJsont *self = allocSmallJson(); 9183 char **array = listCreateS("a","bb"); 9184 9185 // add an element to check that push adds the second element 9186 // at the end 9187 r = self->f->pushInt(self, 1); 9188 ck_assert_ptr_ne(r, null); 9189 9190 r = self->f->prependNFreeArrayc(self, array); 9191 ck_assert_ptr_ne(r, null); 9192 ck_assert_int_eq(lenO(r), 2); 9193 char *s = toStringO(r); 9194 ck_assert_str_eq(s, "[[\"a\",\"bb\"],1]"); 9195 free(s); 9196 // null 9197 r = self->f->prependNFreeArrayc(self, null); 9198 ck_assert_ptr_eq(r, null); 9199 ck_assert_int_eq(lenO(self), 2); 9200 s = toStringO(self); 9201 ck_assert_str_eq(s, "[[\"a\",\"bb\"],1]"); 9202 free(s); 9203 terminateO(self); 9204 9205 } 9206 9207 9208 void prependNFreeSmallBoolSmallJsonT(void) { 9209 9210 smallJsont* r; 9211 smallJsont *self = allocSmallJson(); 9212 smallBoolt *value = allocG(TRUE); 9213 9214 // add an element to check that push adds the second element 9215 // at the end 9216 r = self->f->pushInt(self, 1); 9217 ck_assert_ptr_ne(r, null); 9218 9219 r = self->f->prependNFreeSmallBool(self, value); 9220 ck_assert_ptr_ne(r, null); 9221 ck_assert_int_eq(lenO(r), 2); 9222 char *s = toStringO(r); 9223 ck_assert_str_eq(s, "[true,1]"); 9224 free(s); 9225 // bool object with no data 9226 createAllocateSmallBool(b); 9227 r = self->f->prependNFreeSmallBool(self, b); 9228 ck_assert_ptr_ne(r, null); 9229 ck_assert_int_eq(lenO(r), 3); 9230 s = toStringO(r); 9231 ck_assert_str_eq(s, "[false,true,1]"); 9232 free(s); 9233 // null 9234 r = self->f->prependNFreeSmallBool(self, null); 9235 ck_assert_ptr_eq(r, null); 9236 ck_assert_int_eq(lenO(self), 3); 9237 s = toStringO(self); 9238 ck_assert_str_eq(s, "[false,true,1]"); 9239 free(s); 9240 terminateO(self); 9241 9242 } 9243 9244 9245 void prependNFreeSmallBytesSmallJsonT(void) { 9246 9247 smallJsont* r; 9248 smallJsont *self = allocSmallJson(); 9249 createAllocateSmallBytes(value); 9250 9251 // add an element to check that push adds the second element 9252 // at the end 9253 r = self->f->pushInt(self, 1); 9254 ck_assert_ptr_ne(r, null); 9255 9256 // the smallBytes container is empty 9257 r = self->f->prependNFreeSmallBytes(self, value); 9258 ck_assert_ptr_ne(r, null); 9259 ck_assert_int_eq(lenO(r), 2); 9260 char *s = toStringO(r); 9261 ck_assert_str_eq(s, "[[],1]"); 9262 free(s); 9263 9264 char *buffer = "poi"; 9265 value = allocSmallBytes(buffer, strlen(buffer)); 9266 r = self->f->prependNFreeSmallBytes(self, value); 9267 ck_assert_ptr_ne(r, null); 9268 ck_assert_int_eq(lenO(r), 3); 9269 s = toStringO(r); 9270 ck_assert_str_eq(s, "[[0x70,0x6f,0x69],[],1]"); 9271 free(s); 9272 // null 9273 r = self->f->prependNFreeSmallBytes(self, null); 9274 ck_assert_ptr_eq(r, null); 9275 ck_assert_int_eq(lenO(self), 3); 9276 s = toStringO(self); 9277 ck_assert_str_eq(s, "[[0x70,0x6f,0x69],[],1]"); 9278 free(s); 9279 terminateO(self); 9280 9281 } 9282 9283 9284 void prependNFreeSmallDoubleSmallJsonT(void) { 9285 9286 smallJsont* r; 9287 smallJsont *self = allocSmallJson(); 9288 smallDoublet *value = allocG(1.0); 9289 9290 // add an element to check that push adds the second element 9291 // at the end 9292 r = self->f->pushInt(self, 1); 9293 ck_assert_ptr_ne(r, null); 9294 9295 r = self->f->prependNFreeSmallDouble(self, value); 9296 ck_assert_ptr_ne(r, null); 9297 ck_assert_int_eq(lenO(r), 2); 9298 char *s = toStringO(r); 9299 ck_assert_str_eq(s, "[1.000000e+00,1]"); 9300 free(s); 9301 // object with no data 9302 createAllocateSmallDouble(b); 9303 r = self->f->prependNFreeSmallDouble(self, b); 9304 ck_assert_ptr_ne(r, null); 9305 ck_assert_int_eq(lenO(r), 3); 9306 s = toStringO(r); 9307 ck_assert_str_eq(s, "[0.000000e+00,1.000000e+00,1]"); 9308 free(s); 9309 // null 9310 r = self->f->prependNFreeSmallDouble(self, null); 9311 ck_assert_ptr_eq(r, null); 9312 ck_assert_int_eq(lenO(self), 3); 9313 s = toStringO(self); 9314 ck_assert_str_eq(s, "[0.000000e+00,1.000000e+00,1]"); 9315 free(s); 9316 terminateO(self); 9317 9318 } 9319 9320 9321 void prependNFreeSmallIntSmallJsonT(void) { 9322 9323 smallJsont* r; 9324 smallJsont *self = allocSmallJson(); 9325 smallIntt *value = allocG(1); 9326 9327 // add an element to check that push adds the second element 9328 // at the end 9329 r = self->f->pushInt(self, 1); 9330 ck_assert_ptr_ne(r, null); 9331 9332 r = self->f->prependNFreeSmallInt(self, value); 9333 ck_assert_ptr_ne(r, null); 9334 ck_assert_int_eq(lenO(r), 2); 9335 char *s = toStringO(r); 9336 ck_assert_str_eq(s, "[1,1]"); 9337 free(s); 9338 // bool object with no data 9339 createAllocateSmallInt(b); 9340 r = self->f->prependNFreeSmallInt(self, b); 9341 ck_assert_ptr_ne(r, null); 9342 ck_assert_int_eq(lenO(r), 3); 9343 s = toStringO(r); 9344 ck_assert_str_eq(s, "[0,1,1]"); 9345 free(s); 9346 // null 9347 r = self->f->prependNFreeSmallInt(self, null); 9348 ck_assert_ptr_eq(r, null); 9349 ck_assert_int_eq(lenO(self), 3); 9350 s = toStringO(self); 9351 ck_assert_str_eq(s, "[0,1,1]"); 9352 free(s); 9353 terminateO(self); 9354 9355 } 9356 9357 9358 void prependNFreeSmallJsonSmallJsonT(void) { 9359 9360 smallJsont* r; 9361 smallJsont *self = allocSmallJson(); 9362 smallJsont *value = allocG(rtSmallJsont); 9363 9364 // add an element to check that push adds the second element 9365 // at the end 9366 r = self->f->pushInt(self, 1); 9367 ck_assert_ptr_ne(r, null); 9368 9369 // the smallJson container is empty 9370 r = self->f->prependNFreeSmallJson(self, value); 9371 ck_assert_ptr_ne(r, null); 9372 ck_assert_int_eq(lenO(r), 2); 9373 char *s = toStringO(r); 9374 ck_assert_str_eq(s, "[{},1]"); 9375 free(s); 9376 9377 value = allocG(rtSmallJsont); 9378 parseO(value, "{}"); 9379 r = self->f->prependNFreeSmallJson(self, value); 9380 ck_assert_ptr_ne(r, null); 9381 ck_assert_int_eq(lenO(r), 3); 9382 s = toStringO(r); 9383 ck_assert_str_eq(s, "[{},{},1]"); 9384 free(s); 9385 // null 9386 r = self->f->prependNFreeSmallJson(self, null); 9387 ck_assert_ptr_eq(r, null); 9388 ck_assert_int_eq(lenO(self), 3); 9389 s = toStringO(self); 9390 ck_assert_str_eq(s, "[{},{},1]"); 9391 free(s); 9392 terminateO(self); 9393 9394 } 9395 9396 9397 void prependNFreeSmallStringSmallJsonT(void) { 9398 9399 smallJsont* r; 9400 smallJsont *self = allocSmallJson(); 9401 createAllocateSmallString(string); 9402 9403 // add an element to check that push adds the second element 9404 // at the end 9405 r = self->f->pushInt(self, 1); 9406 ck_assert_ptr_ne(r, null); 9407 9408 r = self->f->prependNFreeSmallString(self, string); 9409 ck_assert_ptr_ne(r, null); 9410 ck_assert_int_eq(lenO(r), 2); 9411 char *s = toStringO(r); 9412 ck_assert_str_eq(s, "[\"\",1]"); 9413 free(s); 9414 // null 9415 r = self->f->prependNFreeSmallString(self, null); 9416 ck_assert_ptr_eq(r, null); 9417 ck_assert_int_eq(lenO(self), 2); 9418 s = toStringO(self); 9419 ck_assert_str_eq(s, "[\"\",1]"); 9420 free(s); 9421 terminateO(self); 9422 9423 } 9424 9425 9426 void prependNFreeSmallContainerSmallJsonT(void) { 9427 9428 smallJsont* r; 9429 smallJsont *self = allocSmallJson(); 9430 createAllocateSmallContainer(container); 9431 9432 // add an element to check that push adds the second element 9433 // at the end 9434 r = self->f->pushInt(self, 1); 9435 ck_assert_ptr_ne(r, null); 9436 9437 r = self->f->prependNFreeSmallContainer(self, container); 9438 ck_assert_ptr_ne(r, null); 9439 ck_assert_int_eq(lenO(r), 2); 9440 char *s = toStringO(r); 9441 ck_assert_str_eq(s, "[\"<data container>\",1]"); 9442 free(s); 9443 // null 9444 r = self->f->prependNFreeSmallContainer(self, null); 9445 ck_assert_ptr_eq(r, null); 9446 ck_assert_int_eq(lenO(self), 2); 9447 s = toStringO(self); 9448 ck_assert_str_eq(s, "[\"<data container>\",1]"); 9449 free(s); 9450 terminateO(self); 9451 9452 } 9453 9454 9455 void dequeueSmallJsonT(void) { 9456 9457 baset* r; 9458 smallJsont *self = allocSmallJson(); 9459 smallJsont *r2; 9460 9461 // add an element to check that the second element is dequeueed 9462 // at the end 9463 r2 = self->f->prependInt(self, 1); 9464 ck_assert_ptr_ne(r2, null); 9465 // prepend a base object of unknown type 9466 smallIntt *o = allocSmallInt(2); 9467 o->type = "newType"; 9468 r2 = self->f->prependNFree(self, (baset*)o); 9469 ck_assert_ptr_ne(r2, null); 9470 r2 = self->f->prependUndefined(self); 9471 ck_assert_ptr_ne(r2, null); 9472 r = self->f->dequeue(self); 9473 ck_assert_ptr_ne(r, null); 9474 ck_assert(isOUndefined(r)); 9475 terminateO(r); 9476 r = self->f->dequeue(self); 9477 ck_assert_ptr_ne(r, null); 9478 ck_assert_str_eq(r->type, "newType"); 9479 char *s = toStringO(r); 9480 terminateO(r); 9481 ck_assert_str_eq(s, "2"); 9482 free(s); 9483 ck_assert_int_eq(lenO(self), 1); 9484 s = toStringO(self); 9485 ck_assert_str_eq(s, "[1]"); 9486 free(s); 9487 // empty array 9488 r = self->f->dequeue(self); 9489 ck_assert_ptr_ne(r, null); 9490 terminateO(r); 9491 s = toStringO(self); 9492 ck_assert_str_eq(s, "[]"); 9493 free(s); 9494 r = self->f->dequeue(self); 9495 ck_assert_ptr_eq(r, null); 9496 s = toStringO(self); 9497 ck_assert_str_eq(s, "[]"); 9498 free(s); 9499 r2 = self->f->pushUndefined(self); 9500 ck_assert_ptr_ne(r2, null); 9501 delElemIndexO(self,-1); 9502 r = self->f->dequeue(self); 9503 ck_assert_ptr_eq(r, null); 9504 // non json array 9505 freeO(self); 9506 setTypeBoolO(self); 9507 ck_assert_ptr_eq(self->f->dequeue(self), NULL); 9508 terminateO(self); 9509 9510 } 9511 9512 9513 void dequeueUndefinedSmallJsonT(void) { 9514 9515 undefinedt* r; 9516 smallJsont *self = allocSmallJson(); 9517 smallJsont *r2; 9518 baset *r3; 9519 9520 // add an element to check that the second element is poped 9521 // at the end 9522 r2 = self->f->pushInt(self, 1); 9523 ck_assert_ptr_ne(r2, null); 9524 // add second element 9525 r2 = self->f->prependUndefined(self); 9526 ck_assert_ptr_ne(r2, null); 9527 // pop 9528 r = self->f->dequeueUndefined(self); 9529 ck_assert_ptr_ne(r, null); 9530 char *s = toStringO(r); 9531 terminateO(r); 9532 ck_assert_str_eq(s, "null"); 9533 free(s); 9534 ck_assert_int_eq(lenO(self), 1); 9535 s = toStringO(self); 9536 ck_assert_str_eq(s, "[1]"); 9537 free(s); 9538 // pop element of unexpected type 9539 r = self->f->dequeueUndefined(self); 9540 ck_assert_ptr_eq(r, null); 9541 ck_assert_int_eq(lenO(self), 1); 9542 s = toStringO(self); 9543 ck_assert_str_eq(s, "[1]"); 9544 free(s); 9545 // empty array 9546 r3 = self->f->pop(self); 9547 ck_assert_ptr_ne(r3, null); 9548 terminateO(r3); 9549 s = toStringO(self); 9550 ck_assert_str_eq(s, "[]"); 9551 free(s); 9552 r = self->f->dequeueUndefined(self); 9553 ck_assert_ptr_eq(r, null); 9554 s = toStringO(self); 9555 ck_assert_str_eq(s, "[]"); 9556 free(s); 9557 r2 = self->f->pushUndefined(self); 9558 ck_assert_ptr_ne(r2, null); 9559 delElemIndexO(self,-1); 9560 r = self->f->dequeueUndefined(self); 9561 ck_assert_ptr_eq(r, null); 9562 // non json array 9563 freeO(self); 9564 setTypeBoolO(self); 9565 ck_assert_ptr_eq(self->f->dequeueUndefined(self), NULL); 9566 terminateO(self); 9567 9568 } 9569 9570 9571 void dequeueBoolSmallJsonT(void) { 9572 9573 bool r; 9574 smallJsont *self = allocSmallJson(); 9575 smallJsont *r2; 9576 baset *r3; 9577 9578 // add an element to check that the second element is poped 9579 // at the end 9580 r2 = self->f->pushInt(self, 1); 9581 ck_assert_ptr_ne(r2, null); 9582 9583 // add second element 9584 r2 = self->f->prependBool(self, TRUE); 9585 ck_assert_ptr_ne(r2, null); 9586 9587 // pop 9588 r = self->f->dequeueBool(self); 9589 ck_assert(r); 9590 ck_assert_int_eq(lenO(self), 1); 9591 char *s = toStringO(self); 9592 ck_assert_str_eq(s, "[1]"); 9593 free(s); 9594 9595 // pop element of unexpected type 9596 r = self->f->dequeueBool(self); 9597 ck_assert(!r); 9598 ck_assert_int_eq(lenO(self), 1); 9599 s = toStringO(self); 9600 ck_assert_str_eq(s, "[1]"); 9601 free(s); 9602 9603 // empty array 9604 r3 = self->f->pop(self); 9605 ck_assert_ptr_ne(r3, null); 9606 terminateO(r3); 9607 s = toStringO(self); 9608 ck_assert_str_eq(s, "[]"); 9609 free(s); 9610 r = self->f->dequeueBool(self); 9611 ck_assert(!r); 9612 s = toStringO(self); 9613 ck_assert_str_eq(s, "[]"); 9614 free(s); 9615 terminateO(self); 9616 9617 } 9618 9619 9620 void dequeueDoubleSmallJsonT(void) { 9621 9622 double r; 9623 smallJsont *self = allocSmallJson(); 9624 smallJsont *r2; 9625 baset *r3; 9626 9627 // add an element to check that the second element is poped 9628 // at the end 9629 r2 = self->f->pushInt(self, 1); 9630 ck_assert_ptr_ne(r2, null); 9631 9632 // add second element 9633 r2 = self->f->prependDouble(self, 2.0); 9634 ck_assert_ptr_ne(r2, null); 9635 9636 // pop 9637 r = self->f->dequeueDouble(self); 9638 ck_assert(r==2.0); 9639 ck_assert_int_eq(lenO(self), 1); 9640 char *s = toStringO(self); 9641 ck_assert_str_eq(s, "[1]"); 9642 free(s); 9643 9644 // pop element of unexpected type 9645 r = self->f->dequeueDouble(self); 9646 ck_assert(!r); 9647 ck_assert_int_eq(lenO(self), 1); 9648 s = toStringO(self); 9649 ck_assert_str_eq(s, "[1]"); 9650 free(s); 9651 9652 // empty array 9653 r3 = self->f->pop(self); 9654 ck_assert_ptr_ne(r3, null); 9655 terminateO(r3); 9656 s = toStringO(self); 9657 ck_assert_str_eq(s, "[]"); 9658 free(s); 9659 r = self->f->dequeueDouble(self); 9660 ck_assert(!r); 9661 s = toStringO(self); 9662 ck_assert_str_eq(s, "[]"); 9663 free(s); 9664 terminateO(self); 9665 9666 } 9667 9668 9669 void dequeueIntSmallJsonT(void) { 9670 9671 int64_t r; 9672 smallJsont *self = allocSmallJson(); 9673 smallJsont *r2; 9674 baset *r3; 9675 9676 // add an element to check that the second element is poped 9677 // at the end 9678 r2 = self->f->pushBool(self, FALSE); 9679 ck_assert_ptr_ne(r2, null); 9680 9681 // add second element 9682 r2 = self->f->prependInt(self, 2); 9683 ck_assert_ptr_ne(r2, null); 9684 9685 // pop 9686 r = self->f->dequeueInt(self); 9687 ck_assert_int_eq(r, 2); 9688 ck_assert_int_eq(lenO(self), 1); 9689 char *s = toStringO(self); 9690 ck_assert_str_eq(s, "[false]"); 9691 free(s); 9692 9693 // pop element of unexpected type 9694 r = self->f->dequeueInt(self); 9695 ck_assert(!r); 9696 ck_assert_int_eq(lenO(self), 1); 9697 s = toStringO(self); 9698 ck_assert_str_eq(s, "[false]"); 9699 free(s); 9700 9701 // empty array 9702 r3 = self->f->pop(self); 9703 ck_assert_ptr_ne(r3, null); 9704 terminateO(r3); 9705 s = toStringO(self); 9706 ck_assert_str_eq(s, "[]"); 9707 free(s); 9708 r = self->f->dequeueInt(self); 9709 ck_assert(!r); 9710 s = toStringO(self); 9711 ck_assert_str_eq(s, "[]"); 9712 free(s); 9713 terminateO(self); 9714 9715 } 9716 9717 9718 void dequeueInt32SmallJsonT(void) { 9719 9720 int32_t r; 9721 smallJsont *self = allocSmallJson(); 9722 smallJsont *r2; 9723 baset *r3; 9724 9725 // add an element to check that the second element is poped 9726 // at the end 9727 r2 = self->f->pushBool(self, FALSE); 9728 ck_assert_ptr_ne(r2, null); 9729 9730 // add second element 9731 r2 = self->f->prependInt(self, 2); 9732 ck_assert_ptr_ne(r2, null); 9733 9734 // pop 9735 r = self->f->dequeueInt32(self); 9736 ck_assert_int_eq(r, 2); 9737 ck_assert_int_eq(lenO(self), 1); 9738 char *s = toStringO(self); 9739 ck_assert_str_eq(s, "[false]"); 9740 free(s); 9741 9742 // pop element of unexpected type 9743 r = self->f->dequeueInt32(self); 9744 ck_assert(!r); 9745 ck_assert_int_eq(lenO(self), 1); 9746 s = toStringO(self); 9747 ck_assert_str_eq(s, "[false]"); 9748 free(s); 9749 9750 // empty array 9751 r3 = self->f->pop(self); 9752 ck_assert_ptr_ne(r3, null); 9753 terminateO(r3); 9754 s = toStringO(self); 9755 ck_assert_str_eq(s, "[]"); 9756 free(s); 9757 r = self->f->dequeueInt32(self); 9758 ck_assert(!r); 9759 s = toStringO(self); 9760 ck_assert_str_eq(s, "[]"); 9761 free(s); 9762 terminateO(self); 9763 9764 } 9765 9766 9767 void dequeueUintSmallJsonT(void) { 9768 9769 uint64_t r; 9770 smallJsont *self = allocSmallJson(); 9771 smallJsont *r2; 9772 baset *r3; 9773 9774 // add an element to check that the second element is poped 9775 // at the end 9776 r2 = self->f->pushBool(self, FALSE); 9777 ck_assert_ptr_ne(r2, null); 9778 9779 // add second element 9780 r2 = self->f->prependInt(self, 2); 9781 ck_assert_ptr_ne(r2, null); 9782 9783 // pop 9784 r = self->f->dequeueUint(self); 9785 ck_assert_int_eq(r, 2); 9786 ck_assert_int_eq(lenO(self), 1); 9787 char *s = toStringO(self); 9788 ck_assert_str_eq(s, "[false]"); 9789 free(s); 9790 9791 // pop element of unexpected type 9792 r = self->f->dequeueUint(self); 9793 ck_assert(!r); 9794 ck_assert_int_eq(lenO(self), 1); 9795 s = toStringO(self); 9796 ck_assert_str_eq(s, "[false]"); 9797 free(s); 9798 9799 // empty array 9800 r3 = self->f->pop(self); 9801 ck_assert_ptr_ne(r3, null); 9802 terminateO(r3); 9803 s = toStringO(self); 9804 ck_assert_str_eq(s, "[]"); 9805 free(s); 9806 r = self->f->dequeueUint(self); 9807 ck_assert(!r); 9808 s = toStringO(self); 9809 ck_assert_str_eq(s, "[]"); 9810 free(s); 9811 terminateO(self); 9812 9813 } 9814 9815 9816 void dequeueUint32SmallJsonT(void) { 9817 9818 uint32_t r; 9819 smallJsont *self = allocSmallJson(); 9820 smallJsont *r2; 9821 baset *r3; 9822 9823 // add an element to check that the second element is poped 9824 // at the end 9825 r2 = self->f->pushBool(self, FALSE); 9826 ck_assert_ptr_ne(r2, null); 9827 9828 // add second element 9829 r2 = self->f->prependInt(self, 2); 9830 ck_assert_ptr_ne(r2, null); 9831 9832 // pop 9833 r = self->f->dequeueUint32(self); 9834 ck_assert_int_eq(r, 2); 9835 ck_assert_int_eq(lenO(self), 1); 9836 char *s = toStringO(self); 9837 ck_assert_str_eq(s, "[false]"); 9838 free(s); 9839 9840 // pop element of unexpected type 9841 r = self->f->dequeueUint32(self); 9842 ck_assert(!r); 9843 ck_assert_int_eq(lenO(self), 1); 9844 s = toStringO(self); 9845 ck_assert_str_eq(s, "[false]"); 9846 free(s); 9847 9848 // empty array 9849 r3 = self->f->pop(self); 9850 ck_assert_ptr_ne(r3, null); 9851 terminateO(r3); 9852 s = toStringO(self); 9853 ck_assert_str_eq(s, "[]"); 9854 free(s); 9855 r = self->f->dequeueUint32(self); 9856 ck_assert(!r); 9857 s = toStringO(self); 9858 ck_assert_str_eq(s, "[]"); 9859 free(s); 9860 terminateO(self); 9861 9862 } 9863 9864 9865 void dequeueSSmallJsonT(void) { 9866 9867 char* r; 9868 smallJsont *self = allocSmallJson(); 9869 smallJsont *r2; 9870 baset *r3; 9871 9872 // add an element to check that the second element is poped 9873 // at the end 9874 r2 = self->f->pushInt(self, 1); 9875 ck_assert_ptr_ne(r2, null); 9876 9877 // add second element 9878 r2 = self->f->prependS(self, "bb"); 9879 ck_assert_ptr_ne(r2, null); 9880 9881 // pop 9882 r = self->f->dequeueS(self); 9883 ck_assert_str_eq(r, "bb"); 9884 free(r); 9885 ck_assert_int_eq(lenO(self), 1); 9886 char *s = toStringO(self); 9887 ck_assert_str_eq(s, "[1]"); 9888 free(s); 9889 9890 // pop element of unexpected type 9891 r = self->f->dequeueS(self); 9892 ck_assert(!r); 9893 ck_assert_int_eq(lenO(self), 1); 9894 s = toStringO(self); 9895 ck_assert_str_eq(s, "[1]"); 9896 free(s); 9897 9898 // empty array 9899 r3 = self->f->pop(self); 9900 ck_assert_ptr_ne(r3, null); 9901 terminateO(r3); 9902 s = toStringO(self); 9903 ck_assert_str_eq(s, "[]"); 9904 free(s); 9905 r = self->f->dequeueS(self); 9906 ck_assert(!r); 9907 s = toStringO(self); 9908 ck_assert_str_eq(s, "[]"); 9909 free(s); 9910 terminateO(self); 9911 9912 } 9913 9914 9915 void dequeueDictSmallJsonT(void) { 9916 9917 smallDictt* r; 9918 smallJsont *self = allocSmallJson(); 9919 smallJsont *r2; 9920 baset *r3; 9921 9922 // add an element to check that the second element is poped 9923 // at the end 9924 r2 = self->f->pushInt(self, 1); 9925 ck_assert_ptr_ne(r2, null); 9926 // add second element 9927 createSmallDict(e); 9928 r2 = self->f->prependDict(self, &e); 9929 ck_assert_ptr_ne(r2, null); 9930 // pop 9931 r = self->f->dequeueDict(self); 9932 ck_assert_ptr_ne(r, null); 9933 char *s = toStringO(r); 9934 terminateO(r); 9935 ck_assert_str_eq(s, "{}"); 9936 free(s); 9937 ck_assert_int_eq(lenO(self), 1); 9938 s = toStringO(self); 9939 ck_assert_str_eq(s, "[1]"); 9940 free(s); 9941 // pop element of unexpected type 9942 r = self->f->dequeueDict(self); 9943 ck_assert(!r); 9944 ck_assert_int_eq(lenO(self), 1); 9945 s = toStringO(self); 9946 ck_assert_str_eq(s, "[1]"); 9947 free(s); 9948 // empty array 9949 r3 = self->f->pop(self); 9950 ck_assert_ptr_ne(r3, null); 9951 terminateO(r3); 9952 s = toStringO(self); 9953 ck_assert_str_eq(s, "[]"); 9954 free(s); 9955 r = self->f->dequeueDict(self); 9956 ck_assert(!r); 9957 s = toStringO(self); 9958 ck_assert_str_eq(s, "[]"); 9959 free(s); 9960 r2 = self->f->pushUndefined(self); 9961 ck_assert_ptr_ne(r2, null); 9962 delElemIndexO(self,-1); 9963 r = self->f->dequeueDict(self); 9964 ck_assert_ptr_eq(r, null); 9965 // non json array 9966 freeO(self); 9967 setTypeBoolO(self); 9968 ck_assert_ptr_eq(self->f->dequeueDict(self), NULL); 9969 terminateO(self); 9970 9971 } 9972 9973 9974 void dequeueArraySmallJsonT(void) { 9975 9976 smallArrayt* r; 9977 smallJsont *self = allocSmallJson(); 9978 smallJsont *r2; 9979 baset *r3; 9980 9981 // add an element to check that the second element is poped 9982 // at the end 9983 r2 = self->f->pushInt(self, 1); 9984 ck_assert_ptr_ne(r2, null); 9985 // add second element 9986 createSmallArray(e); 9987 r2 = self->f->prependArray(self, &e); 9988 ck_assert_ptr_ne(r2, null); 9989 // pop 9990 r = self->f->dequeueArray(self); 9991 ck_assert_ptr_ne(r, null); 9992 char *s = toStringO(r); 9993 terminateO(r); 9994 ck_assert_str_eq(s, "[]"); 9995 free(s); 9996 ck_assert_int_eq(lenO(self), 1); 9997 s = toStringO(self); 9998 ck_assert_str_eq(s, "[1]"); 9999 free(s); 10000 // pop element of unexpected type 10001 r = self->f->dequeueArray(self); 10002 ck_assert(!r); 10003 ck_assert_int_eq(lenO(self), 1); 10004 s = toStringO(self); 10005 ck_assert_str_eq(s, "[1]"); 10006 free(s); 10007 // empty array 10008 r3 = self->f->pop(self); 10009 ck_assert_ptr_ne(r3, null); 10010 terminateO(r3); 10011 s = toStringO(self); 10012 ck_assert_str_eq(s, "[]"); 10013 free(s); 10014 r = self->f->dequeueArray(self); 10015 ck_assert(!r); 10016 s = toStringO(self); 10017 ck_assert_str_eq(s, "[]"); 10018 free(s); 10019 r2 = self->f->pushUndefined(self); 10020 ck_assert_ptr_ne(r2, null); 10021 delElemIndexO(self,-1); 10022 r = self->f->dequeueArray(self); 10023 ck_assert_ptr_eq(r, null); 10024 // non json array 10025 freeO(self); 10026 setTypeBoolO(self); 10027 ck_assert_ptr_eq(self->f->dequeueArray(self), NULL); 10028 terminateO(self); 10029 10030 } 10031 10032 10033 void dequeueSmallBoolSmallJsonT(void) { 10034 10035 smallBoolt* r; 10036 smallJsont *self = allocSmallJson(); 10037 smallJsont *r2; 10038 baset *r3; 10039 10040 // add an element to check that the second element is poped 10041 // at the end 10042 r2 = self->f->pushInt(self, 1); 10043 ck_assert_ptr_ne(r2, null); 10044 // add second element 10045 createSmallBool(e); 10046 r2 = self->f->prependSmallBool(self, &e); 10047 ck_assert_ptr_ne(r2, null); 10048 // pop 10049 r = self->f->dequeueSmallBool(self); 10050 ck_assert_ptr_ne(r, null); 10051 char *s = toStringO(r); 10052 terminateO(r); 10053 ck_assert_str_eq(s, "false"); 10054 free(s); 10055 ck_assert_int_eq(lenO(self), 1); 10056 s = toStringO(self); 10057 ck_assert_str_eq(s, "[1]"); 10058 free(s); 10059 // pop element of unexpected type 10060 r = self->f->dequeueSmallBool(self); 10061 ck_assert(!r); 10062 ck_assert_int_eq(lenO(self), 1); 10063 s = toStringO(self); 10064 ck_assert_str_eq(s, "[1]"); 10065 free(s); 10066 // empty array 10067 r3 = self->f->pop(self); 10068 ck_assert_ptr_ne(r3, null); 10069 terminateO(r3); 10070 s = toStringO(self); 10071 ck_assert_str_eq(s, "[]"); 10072 free(s); 10073 r = self->f->dequeueSmallBool(self); 10074 ck_assert(!r); 10075 s = toStringO(self); 10076 ck_assert_str_eq(s, "[]"); 10077 free(s); 10078 r2 = self->f->pushUndefined(self); 10079 ck_assert_ptr_ne(r2, null); 10080 delElemIndexO(self,-1); 10081 r = self->f->dequeueSmallBool(self); 10082 ck_assert_ptr_eq(r, null); 10083 // non json array 10084 freeO(self); 10085 setTypeBoolO(self); 10086 ck_assert_ptr_eq(self->f->dequeueSmallBool(self), NULL); 10087 terminateO(self); 10088 10089 } 10090 10091 10092 void dequeueSmallBytesSmallJsonT(void) { 10093 10094 smallBytest* r; 10095 smallJsont *self = allocSmallJson(); 10096 smallJsont *r2; 10097 baset *r3; 10098 10099 // add an element to check that the second element is poped 10100 // at the end 10101 r2 = self->f->pushInt(self, 1); 10102 ck_assert_ptr_ne(r2, null); 10103 // add second element 10104 createSmallBytes(e); 10105 r2 = self->f->prependSmallBytes(self, &e); 10106 ck_assert_ptr_ne(r2, null); 10107 // pop 10108 r = self->f->dequeueSmallBytes(self); 10109 ck_assert_ptr_ne(r, null); 10110 char *s = toStringO(r); 10111 terminateO(r); 10112 ck_assert_str_eq(s, "[]"); 10113 free(s); 10114 ck_assert_int_eq(lenO(self), 1); 10115 s = toStringO(self); 10116 ck_assert_str_eq(s, "[1]"); 10117 free(s); 10118 // pop element of unexpected type 10119 r = self->f->dequeueSmallBytes(self); 10120 ck_assert(!r); 10121 ck_assert_int_eq(lenO(self), 1); 10122 s = toStringO(self); 10123 ck_assert_str_eq(s, "[1]"); 10124 free(s); 10125 // empty array 10126 r3 = self->f->pop(self); 10127 ck_assert_ptr_ne(r3, null); 10128 terminateO(r3); 10129 s = toStringO(self); 10130 ck_assert_str_eq(s, "[]"); 10131 free(s); 10132 r = self->f->dequeueSmallBytes(self); 10133 ck_assert(!r); 10134 s = toStringO(self); 10135 ck_assert_str_eq(s, "[]"); 10136 free(s); 10137 r2 = self->f->pushUndefined(self); 10138 ck_assert_ptr_ne(r2, null); 10139 delElemIndexO(self,-1); 10140 r = self->f->dequeueSmallBytes(self); 10141 ck_assert_ptr_eq(r, null); 10142 // non json array 10143 freeO(self); 10144 setTypeBoolO(self); 10145 ck_assert_ptr_eq(self->f->dequeueSmallBytes(self), NULL); 10146 terminateO(self); 10147 10148 } 10149 10150 10151 void dequeueSmallDoubleSmallJsonT(void) { 10152 10153 smallDoublet* r; 10154 smallJsont *self = allocSmallJson(); 10155 smallJsont *r2; 10156 baset *r3; 10157 10158 // add an element to check that the second element is poped 10159 // at the end 10160 r2 = self->f->pushInt(self, 1); 10161 ck_assert_ptr_ne(r2, null); 10162 // add second element 10163 createSmallDouble(e); 10164 r2 = self->f->prependSmallDouble(self, &e); 10165 ck_assert_ptr_ne(r2, null); 10166 // pop 10167 r = self->f->dequeueSmallDouble(self); 10168 ck_assert_ptr_ne(r, null); 10169 char *s = toStringO(r); 10170 terminateO(r); 10171 ck_assert_str_eq(s, "0.000000e+00"); 10172 free(s); 10173 ck_assert_int_eq(lenO(self), 1); 10174 s = toStringO(self); 10175 ck_assert_str_eq(s, "[1]"); 10176 free(s); 10177 // pop element of unexpected type 10178 r = self->f->dequeueSmallDouble(self); 10179 ck_assert(!r); 10180 ck_assert_int_eq(lenO(self), 1); 10181 s = toStringO(self); 10182 ck_assert_str_eq(s, "[1]"); 10183 free(s); 10184 // empty array 10185 r3 = self->f->pop(self); 10186 ck_assert_ptr_ne(r3, null); 10187 terminateO(r3); 10188 s = toStringO(self); 10189 ck_assert_str_eq(s, "[]"); 10190 free(s); 10191 r = self->f->dequeueSmallDouble(self); 10192 ck_assert(!r); 10193 s = toStringO(self); 10194 ck_assert_str_eq(s, "[]"); 10195 free(s); 10196 r2 = self->f->pushUndefined(self); 10197 ck_assert_ptr_ne(r2, null); 10198 delElemIndexO(self,-1); 10199 r = self->f->dequeueSmallDouble(self); 10200 ck_assert_ptr_eq(r, null); 10201 // non json array 10202 freeO(self); 10203 setTypeBoolO(self); 10204 ck_assert_ptr_eq(self->f->dequeueSmallDouble(self), NULL); 10205 terminateO(self); 10206 10207 } 10208 10209 10210 void dequeueSmallIntSmallJsonT(void) { 10211 10212 smallIntt* r; 10213 smallJsont *self = allocSmallJson(); 10214 smallJsont *r2; 10215 baset *r3; 10216 10217 // add an element to check that the second element is poped 10218 // at the end 10219 r2 = self->f->pushBool(self, TRUE); 10220 ck_assert_ptr_ne(r2, null); 10221 // add second element 10222 createSmallInt(e); 10223 r2 = self->f->prependSmallInt(self, &e); 10224 ck_assert_ptr_ne(r2, null); 10225 // pop 10226 r = self->f->dequeueSmallInt(self); 10227 ck_assert_ptr_ne(r, null); 10228 char *s = toStringO(r); 10229 terminateO(r); 10230 ck_assert_str_eq(s, "0"); 10231 free(s); 10232 ck_assert_int_eq(lenO(self), 1); 10233 s = toStringO(self); 10234 ck_assert_str_eq(s, "[true]"); 10235 free(s); 10236 // pop element of unexpected type 10237 r = self->f->dequeueSmallInt(self); 10238 ck_assert(!r); 10239 ck_assert_int_eq(lenO(self), 1); 10240 s = toStringO(self); 10241 ck_assert_str_eq(s, "[true]"); 10242 free(s); 10243 // empty array 10244 r3 = self->f->pop(self); 10245 ck_assert_ptr_ne(r3, null); 10246 terminateO(r3); 10247 s = toStringO(self); 10248 ck_assert_str_eq(s, "[]"); 10249 free(s); 10250 r = self->f->dequeueSmallInt(self); 10251 ck_assert(!r); 10252 s = toStringO(self); 10253 ck_assert_str_eq(s, "[]"); 10254 free(s); 10255 r2 = self->f->pushUndefined(self); 10256 ck_assert_ptr_ne(r2, null); 10257 delElemIndexO(self,-1); 10258 r = self->f->dequeueSmallInt(self); 10259 ck_assert_ptr_eq(r, null); 10260 r2 = self->f->pushUndefined(self); 10261 ck_assert_ptr_ne(r2, null); 10262 delElemIndexO(self,-1); 10263 r = self->f->dequeueSmallInt(self); 10264 ck_assert_ptr_eq(r, null); 10265 // non json array 10266 freeO(self); 10267 setTypeBoolO(self); 10268 ck_assert_ptr_eq(self->f->dequeueSmallInt(self), NULL); 10269 terminateO(self); 10270 10271 } 10272 10273 10274 void dequeueSmallJsonSmallJsonT(void) { 10275 10276 smallJsont* r; 10277 smallJsont *self = allocSmallJson(); 10278 smallJsont *r2; 10279 baset *r3; 10280 10281 // add an element to check that the second element is poped 10282 // at the end 10283 createSmallBytes(B); 10284 r2 = self->f->pushSmallBytes(self, &B); 10285 ck_assert_ptr_ne(r2, null); 10286 // add second element 10287 createSmallJson(e); 10288 r2 = self->f->prependSmallJson(self, &e); 10289 ck_assert_ptr_ne(r2, null); 10290 // pop 10291 r = self->f->dequeueSmallJson(self); 10292 ck_assert_ptr_ne(r, null); 10293 char *s = toStringO(r); 10294 terminateO(r); 10295 ck_assert_str_eq(s, "{}"); 10296 free(s); 10297 ck_assert_int_eq(lenO(self), 1); 10298 s = toStringO(self); 10299 ck_assert_str_eq(s, "[[]]"); 10300 free(s); 10301 // pop element of unexpected type 10302 r = self->f->dequeueSmallJson(self); 10303 ck_assert(!r); 10304 ck_assert_int_eq(lenO(self), 1); 10305 s = toStringO(self); 10306 ck_assert_str_eq(s, "[[]]"); 10307 free(s); 10308 // empty array 10309 r3 = self->f->pop(self); 10310 ck_assert_ptr_ne(r3, null); 10311 terminateO(r3); 10312 s = toStringO(self); 10313 ck_assert_str_eq(s, "[]"); 10314 free(s); 10315 r = self->f->dequeueSmallJson(self); 10316 ck_assert(!r); 10317 s = toStringO(self); 10318 ck_assert_str_eq(s, "[]"); 10319 free(s); 10320 r2 = self->f->pushUndefined(self); 10321 ck_assert_ptr_ne(r2, null); 10322 delElemIndexO(self,-1); 10323 r = self->f->dequeueSmallJson(self); 10324 ck_assert_ptr_eq(r, null); 10325 // non json array 10326 freeO(self); 10327 setTypeBoolO(self); 10328 ck_assert_ptr_eq(self->f->dequeueSmallJson(self), NULL); 10329 terminateO(self); 10330 10331 } 10332 10333 10334 void dequeueSmallStringSmallJsonT(void) { 10335 10336 smallStringt* r; 10337 smallJsont *self = allocSmallJson(); 10338 smallJsont *r2; 10339 baset *r3; 10340 10341 // add an element to check that the second element is poped 10342 // at the end 10343 r2 = self->f->pushInt(self, 1); 10344 ck_assert_ptr_ne(r2, null); 10345 // add second element 10346 createSmallString(e); 10347 r2 = self->f->prependSmallString(self, &e); 10348 ck_assert_ptr_ne(r2, null); 10349 // pop 10350 r = self->f->dequeueSmallString(self); 10351 ck_assert_ptr_ne(r, null); 10352 char *s = toStringO(r); 10353 terminateO(r); 10354 ck_assert_str_eq(s, ""); 10355 free(s); 10356 ck_assert_int_eq(lenO(self), 1); 10357 s = toStringO(self); 10358 ck_assert_str_eq(s, "[1]"); 10359 free(s); 10360 // pop element of unexpected type 10361 r = self->f->dequeueSmallString(self); 10362 ck_assert(!r); 10363 ck_assert_int_eq(lenO(self), 1); 10364 s = toStringO(self); 10365 ck_assert_str_eq(s, "[1]"); 10366 free(s); 10367 // empty array 10368 r3 = self->f->pop(self); 10369 ck_assert_ptr_ne(r3, null); 10370 terminateO(r3); 10371 s = toStringO(self); 10372 ck_assert_str_eq(s, "[]"); 10373 free(s); 10374 r = self->f->dequeueSmallString(self); 10375 ck_assert(!r); 10376 s = toStringO(self); 10377 ck_assert_str_eq(s, "[]"); 10378 free(s); 10379 r2 = self->f->pushUndefined(self); 10380 ck_assert_ptr_ne(r2, null); 10381 delElemIndexO(self,-1); 10382 r = self->f->dequeueSmallString(self); 10383 ck_assert_ptr_eq(r, null); 10384 // non json array 10385 freeO(self); 10386 setTypeBoolO(self); 10387 ck_assert_ptr_eq(self->f->dequeueSmallString(self), NULL); 10388 terminateO(self); 10389 10390 } 10391 10392 10393 void dequeueVoidSmallJsonT(void) { 10394 10395 void* r; 10396 smallJsont *self = allocSmallJson(); 10397 smallJsont *r2; 10398 baset *r3; 10399 10400 // add an element to check that the second element is poped 10401 // at the end 10402 r2 = self->f->pushInt(self, 1); 10403 ck_assert_ptr_ne(r2, null); 10404 10405 // add second element 10406 createSmallContainer(e); 10407 setValO(&e, &r); 10408 r2 = self->f->prependSmallContainer(self, &e); 10409 ck_assert_ptr_ne(r2, null); 10410 10411 // pop 10412 r = self->f->dequeueVoid(self); 10413 ck_assert_ptr_eq(r, &r); 10414 ck_assert_int_eq(lenO(self), 1); 10415 char *s = toStringO(self); 10416 ck_assert_str_eq(s, "[1]"); 10417 free(s); 10418 10419 // pop element of unexpected type 10420 r = self->f->dequeueVoid(self); 10421 ck_assert(!r); 10422 ck_assert_int_eq(lenO(self), 1); 10423 s = toStringO(self); 10424 ck_assert_str_eq(s, "[1]"); 10425 free(s); 10426 10427 // empty array 10428 r3 = self->f->pop(self); 10429 ck_assert_ptr_ne(r3, null); 10430 terminateO(r3); 10431 s = toStringO(self); 10432 ck_assert_str_eq(s, "[]"); 10433 free(s); 10434 r = self->f->dequeueVoid(self); 10435 ck_assert(!r); 10436 s = toStringO(self); 10437 ck_assert_str_eq(s, "[]"); 10438 free(s); 10439 terminateO(self); 10440 10441 } 10442 10443 10444 void dequeueSmallContainerSmallJsonT(void) { 10445 10446 smallContainert* r; 10447 smallJsont *self = allocSmallJson(); 10448 smallJsont *r2; 10449 baset *r3; 10450 10451 // add an element to check that the second element is poped 10452 // at the end 10453 r2 = self->f->pushInt(self, 1); 10454 ck_assert_ptr_ne(r2, null); 10455 // add second element 10456 createSmallContainer(e); 10457 r2 = self->f->prependSmallContainer(self, &e); 10458 ck_assert_ptr_ne(r2, null); 10459 // pop 10460 r = self->f->dequeueSmallContainer(self); 10461 ck_assert_ptr_ne(r, null); 10462 char *s = toStringO(r); 10463 terminateO(r); 10464 ck_assert_str_eq(s, "<data smallContainer>"); 10465 free(s); 10466 ck_assert_int_eq(lenO(self), 1); 10467 s = toStringO(self); 10468 ck_assert_str_eq(s, "[1]"); 10469 free(s); 10470 // container with baset object 10471 // push a base object of unknown type 10472 smallIntt *o = allocSmallInt(2); 10473 o->type = "newType"; 10474 r2 = self->f->prependNFree(self, (baset*)o); 10475 ck_assert_ptr_ne(r2, null); 10476 r = self->f->dequeueSmallContainer(self); 10477 ck_assert_ptr_eq(r, NULL); 10478 ck_assert_int_eq(lenO(self), 2); 10479 s = toStringO(self); 10480 ck_assert_str_eq(s, "[\"<data container>\",1]"); 10481 free(s); 10482 r3 = self->f->dequeue(self); 10483 ck_assert_ptr_ne(r3, null); 10484 terminateO(r3); 10485 // pop element of unexpected type 10486 r = self->f->dequeueSmallContainer(self); 10487 ck_assert_ptr_eq(r, NULL); 10488 ck_assert_int_eq(lenO(self), 1); 10489 s = toStringO(self); 10490 ck_assert_str_eq(s, "[1]"); 10491 free(s); 10492 // empty array 10493 r3 = self->f->pop(self); 10494 ck_assert_ptr_ne(r3, null); 10495 terminateO(r3); 10496 s = toStringO(self); 10497 ck_assert_str_eq(s, "[]"); 10498 free(s); 10499 r = self->f->dequeueSmallContainer(self); 10500 ck_assert(!r); 10501 s = toStringO(self); 10502 ck_assert_str_eq(s, "[]"); 10503 free(s); 10504 r2 = self->f->pushUndefined(self); 10505 ck_assert_ptr_ne(r2, null); 10506 delElemIndexO(self,-1); 10507 r = self->f->dequeueSmallContainer(self); 10508 ck_assert_ptr_eq(r, null); 10509 // non json array 10510 freeO(self); 10511 setTypeBoolO(self); 10512 ck_assert_ptr_eq(self->f->dequeueSmallContainer(self), NULL); 10513 terminateO(self); 10514 10515 } 10516 10517 10518 void dequeueNumSmallJsonT(void) { 10519 10520 double r; 10521 smallJsont *self = allocSmallJson(); 10522 smallJsont *r2; 10523 baset *r3; 10524 10525 // add an element to check that the second element is poped 10526 // at the end 10527 r2 = self->f->pushBool(self, TRUE); 10528 ck_assert_ptr_ne(r2, null); 10529 // add second element 10530 r2 = self->f->prependInt(self, 2); 10531 ck_assert_ptr_ne(r2, null); 10532 r2 = self->f->prependDouble(self, 2.5); 10533 ck_assert_ptr_ne(r2, null); 10534 // pop 10535 r = self->f->dequeueNum(self); 10536 ck_assert(r==2.5); 10537 ck_assert_int_eq(lenO(self), 2); 10538 char *s = toStringO(self); 10539 ck_assert_str_eq(s, "[2,true]"); 10540 free(s); 10541 r = self->f->dequeueNum(self); 10542 ck_assert_int_eq(r, 2); 10543 ck_assert_int_eq(lenO(self), 1); 10544 s = toStringO(self); 10545 ck_assert_str_eq(s, "[true]"); 10546 free(s); 10547 // pop element of unexpected type 10548 r = self->f->dequeueNum(self); 10549 ck_assert(!r); 10550 ck_assert_int_eq(lenO(self), 1); 10551 s = toStringO(self); 10552 ck_assert_str_eq(s, "[true]"); 10553 free(s); 10554 // empty array 10555 r3 = self->f->pop(self); 10556 ck_assert_ptr_ne(r3, null); 10557 terminateO(r3); 10558 s = toStringO(self); 10559 ck_assert_str_eq(s, "[]"); 10560 free(s); 10561 r = self->f->dequeueNum(self); 10562 ck_assert(!r); 10563 s = toStringO(self); 10564 ck_assert_str_eq(s, "[]"); 10565 free(s); 10566 r2 = self->f->pushUndefined(self); 10567 ck_assert_ptr_ne(r2, null); 10568 delElemIndexO(self,-1); 10569 r = self->f->dequeueNum(self); 10570 ck_assert(!r); 10571 // non json array 10572 freeO(self); 10573 setTypeBoolO(self); 10574 ck_assert(!self->f->dequeueNum(self)); 10575 terminateO(self); 10576 10577 } 10578 10579 10580 void reverseSmallJsonT(void) { 10581 10582 smallJsont* r; 10583 smallJsont *self = allocSmallJson(); 10584 setTypeArrayO(self); 10585 10586 // empty array 10587 r = reverseO(self); 10588 ck_assert_ptr_ne(r, NULL); 10589 char *s = toStringO(r); 10590 ck_assert_str_eq(s, "[]"); 10591 free(s); 10592 // 1 element array 10593 self->f->pushInt(self,1); 10594 r = reverseO(self); 10595 ck_assert_ptr_ne(r, NULL); 10596 s = toStringO(r); 10597 ck_assert_str_eq(s, "[1]"); 10598 free(s); 10599 // 2 elements array 10600 self->f->pushInt(self,2); 10601 r = reverseO(self); 10602 ck_assert_ptr_ne(r, NULL); 10603 s = toStringO(r); 10604 ck_assert_str_eq(s, "[2,1]"); 10605 free(s); 10606 // non json array 10607 freeO(self); 10608 setTypeBoolO(self); 10609 ck_assert_ptr_eq(reverseO(self), NULL); 10610 terminateO(self); 10611 10612 } 10613 10614 10615 void catSmallJsonT(void) { 10616 10617 smallJsont* r; 10618 smallJsont *self = allocSmallJson(); 10619 10620 // cat arrays 10621 self->f->pushInt(self,1); 10622 createAllocateSmallArray(a); 10623 createAllocateSmallArray(a2); 10624 a2->f->pushInt(a2,2); 10625 r = catO(self, a, a2); 10626 ck_assert_ptr_ne(r, null); 10627 char *s = toStringO(r); 10628 ck_assert_str_eq(s, "[1,2]"); 10629 free(s); 10630 smashManyO(a,a2); 10631 emptyO(self); 10632 // null parameter 10633 r = catO(self, null); 10634 ck_assert_ptr_ne(r, null); 10635 s = toStringO(r); 10636 ck_assert_str_eq(s, "[]"); 10637 free(s); 10638 terminateO(self); 10639 // json string 10640 self = allocSmallJson(); 10641 setTopSO(self, "qwe"); 10642 smallStringt *s1 = allocSmallString("123"); 10643 smallStringt *s2 = allocSmallString("456"); 10644 r = catO(self, s1, s2); 10645 ck_assert_ptr_ne(r, null); 10646 s = toStringO(r); 10647 ck_assert_str_eq(s, "qwe123456"); 10648 free(s); 10649 // non smallString object 10650 terminateO(s2); 10651 s2 = (smallStringt*) allocSmallInt(1); 10652 r = catO(self, s1, s2); 10653 ck_assert_ptr_eq(r, null); 10654 s = toStringO(self); 10655 ck_assert_str_eq(s, "qwe123456"); 10656 free(s); 10657 // non json array 10658 freeO(self); 10659 setTypeBoolO(self); 10660 ck_assert_ptr_eq(catO(self, s1), NULL); 10661 terminateO(s1); 10662 terminateO(s2); 10663 terminateO(self); 10664 10665 } 10666 10667 10668 void mergeDictSmallJsonT(void) { 10669 10670 smallJsont* r; 10671 smallJsont *self = allocG(rtSmallJsont); 10672 smallDictt *smallDict = allocSmallDict(); 10673 10674 r = mergeDictO(self, smallDict); 10675 ck_assert_ptr_ne(r, null); 10676 smallDict->f->setInt(smallDict, "a", 1); 10677 r = mergeDictO(self, smallDict); 10678 ck_assert_ptr_ne(r, null); 10679 smashO(smallDict); 10680 char *s = toStringO(r); 10681 ck_assert_str_eq(s, "{\"a\":1}"); 10682 free(s); 10683 // same sObject in json and smallDict 10684 smallDict = allocSmallDict(); 10685 setsoO(smallDict, (sDictt*) getsoO(self)); 10686 r = mergeDictO(self, smallDict); 10687 ck_assert_ptr_eq(r, null); 10688 // non json array 10689 freeO(self); 10690 setTypeBoolO(self); 10691 ck_assert_ptr_eq(mergeDictO(self, smallDict), NULL); 10692 finishO(smallDict); 10693 terminateO(self); 10694 10695 } 10696 10697 10698 void mergeDictNSmashSmallJsonT(void) { 10699 10700 smallJsont* r; 10701 smallJsont *self = allocSmallJson(); 10702 smallDictt *value = allocSmallDict(); 10703 10704 self->f->setS(self, "1", "2"); 10705 self->f->setS(self, "3", "4"); 10706 value->f->setS(value, "3", "#"); 10707 value->f->setInt(value, "4", 0); 10708 r = self->f->mergeDictNSmash(self, value); 10709 ck_assert_ptr_ne(r, null); 10710 char *s = toStringO(r); 10711 ck_assert_str_eq(s, "{\"1\":\"2\",\"3\":\"#\",\"4\":0}"); 10712 free(s); 10713 // empty dict 10714 value = allocSmallDict(); 10715 r = self->f->mergeDictNSmash(self, value); 10716 ck_assert_ptr_eq(r, self); 10717 // non smallDict object 10718 createAllocateSmallInt(i); 10719 r = self->f->mergeDictNSmash(self, (smallDictt*)i); 10720 ck_assert_ptr_eq(r, null); 10721 terminateO(i); 10722 // null 10723 r = self->f->mergeDictNSmash(self, null); 10724 ck_assert_ptr_eq(r, null); 10725 terminateO(self); 10726 10727 } 10728 10729 10730 void mergeSmallJsonT(void) { 10731 10732 smallJsont* r; 10733 smallJsont *self = allocSmallJson(); 10734 createAllocateSmallJson(json); 10735 10736 // add an element to check that the second array is appended 10737 // at the end 10738 r = self->f->pushInt(self, 1); 10739 ck_assert_ptr_ne(r, null); 10740 10741 // append json array 10742 json->f->pushInt(json, 2); 10743 r = mergeO(self, json); 10744 smashO(json); 10745 ck_assert_ptr_ne(r, null); 10746 char *s = toStringO(r); 10747 ck_assert_str_eq(s, "[1,2]"); 10748 free(s); 10749 // length 0 10750 json = allocSmallJson(); 10751 json->f->pushInt(json, 2); 10752 baset *o = json->f->pop(json); 10753 terminateO(o); 10754 r = mergeO(self, json); 10755 smashO(json); 10756 ck_assert_ptr_ne(r, null); 10757 s = toStringO(r); 10758 ck_assert_str_eq(s, "[1,2]"); 10759 free(s); 10760 // same sArray in both self and json 10761 json = allocSmallJson(); 10762 setsoO(json, (smallt*) getsoO(self)); 10763 r = mergeO(self, json); 10764 ck_assert_ptr_eq(r, null); 10765 finishO(json); 10766 s = toStringO(self); 10767 ck_assert_str_eq(s, "[1,2]"); 10768 free(s); 10769 // json of type not array 10770 json = allocSmallJson(); 10771 setTopIntO(json, 1); 10772 r = mergeO(self, json); 10773 ck_assert_ptr_eq(r, null); 10774 terminateO(json); 10775 s = toStringO(self); 10776 ck_assert_str_eq(s, "[1,2]"); 10777 free(s); 10778 // non smallJson object 10779 json = (smallJsont*) allocSmallInt(2); 10780 r = mergeO(self, json); 10781 ck_assert_ptr_eq(r, null); 10782 terminateO(json); 10783 // null 10784 r = mergeO(self, null); 10785 ck_assert_ptr_eq(r, null); 10786 s = toStringO(self); 10787 ck_assert_str_eq(s, "[1,2]"); 10788 free(s); 10789 // json empty json 10790 freeO(self); 10791 json = allocSmallJson(); 10792 json->f->pushInt(json, 2); 10793 r = mergeO(self, json); 10794 smashO(json); 10795 ck_assert_ptr_ne(r, null); 10796 s = toStringO(r); 10797 ck_assert_str_eq(s, "[2]"); 10798 free(s); 10799 freeO(self); 10800 json = allocSmallJson(); 10801 json->f->setInt(json, "a", 1); 10802 r = mergeO(self, json); 10803 smashO(json); 10804 ck_assert_ptr_ne(r, null); 10805 s = toStringO(r); 10806 ck_assert_str_eq(s, "{\"a\":1}"); 10807 free(s); 10808 // same dict in self and json 10809 json = allocSmallJson(); 10810 setsoO(json, getsoO(self)); 10811 r = mergeO(self, json); 10812 ck_assert_ptr_eq(r, null); 10813 finishO(json); 10814 // non json array or dict 10815 freeO(self); 10816 setTypeBoolO(self); 10817 json = allocSmallJson(); 10818 ck_assert_ptr_eq(mergeO(self, json), NULL); 10819 terminateO(json); 10820 terminateO(self); 10821 10822 } 10823 10824 10825 void mergeNSmashSmallJsonT(void) { 10826 10827 smallJsont* r; 10828 smallJsont *self = allocSmallJson(); 10829 createAllocateSmallJson(json); 10830 10831 // add an element to check that the second array is appended 10832 // at the end 10833 r = self->f->pushInt(self, 1); 10834 ck_assert_ptr_ne(r, null); 10835 10836 // append json array 10837 json->f->pushInt(json, 2); 10838 r = mergeNSmashO(self, json); 10839 ck_assert_ptr_ne(r, null); 10840 char *s = toStringO(r); 10841 ck_assert_str_eq(s, "[1,2]"); 10842 free(s); 10843 // null 10844 r = mergeNSmashO(self, null); 10845 ck_assert_ptr_eq(r, null); 10846 s = toStringO(self); 10847 ck_assert_str_eq(s, "[1,2]"); 10848 free(s); 10849 terminateO(self); 10850 10851 } 10852 10853 10854 void appendSmallJsonT(void) { 10855 10856 smallJsont* r; 10857 smallJsont *self = allocG(rtSmallJsont); 10858 smallArrayt *array = allocSmallArray(); 10859 10860 array->f->pushInt(array, 12); 10861 r = appendO(self, array); 10862 ck_assert_ptr_ne(r, null); 10863 smashO(array); 10864 char *s = toStringO(r); 10865 ck_assert_str_eq(s, "[12]"); 10866 free(s); 10867 // non smallArray array 10868 array = (smallArrayt*) allocSmallInt(1); 10869 r = appendO(self, array); 10870 ck_assert_ptr_eq(r, null); 10871 terminateO(array); 10872 // non json array 10873 freeO(self); 10874 setTypeBoolO(self); 10875 array = allocSmallArray(); 10876 ck_assert_ptr_eq(appendO(self, array), NULL); 10877 terminateO(array); 10878 terminateO(self); 10879 10880 } 10881 10882 10883 void appendNSmashSmallJsonT(void) { 10884 10885 smallJsont* r; 10886 smallJsont *self = allocSmallJson(); 10887 createAllocateSmallArray(a); 10888 10889 // add an element to check that the second array is appended 10890 // at the end 10891 r = self->f->pushInt(self, 1); 10892 ck_assert_ptr_ne(r, null); 10893 10894 // append array 10895 a->f->pushInt(a, 2); 10896 r = self->f->appendNSmash(self, a); 10897 ck_assert_ptr_ne(r, null); 10898 char *s = toStringO(r); 10899 ck_assert_str_eq(s, "[1,2]"); 10900 free(s); 10901 // length 0 10902 a = allocSmallArray(); 10903 a->f->pushInt(a, 2); 10904 delElemO(a,0); 10905 r = self->f->appendNSmash(self, a); 10906 ck_assert_ptr_ne(r, null); 10907 s = toStringO(r); 10908 ck_assert_str_eq(s, "[1,2]"); 10909 free(s); 10910 // same sArray in both self and a 10911 a = allocSmallArray(); 10912 setsoO(a, (sArrayt*) getsoO(self)); 10913 r = self->f->appendNSmash(self, a); 10914 ck_assert_ptr_eq(r, null); 10915 finishO(a); 10916 s = toStringO(self); 10917 ck_assert_str_eq(s, "[1,2]"); 10918 free(s); 10919 // null 10920 r = self->f->appendNSmash(self, null); 10921 ck_assert_ptr_eq(r, null); 10922 s = toStringO(self); 10923 ck_assert_str_eq(s, "[1,2]"); 10924 free(s); 10925 terminateO(self); 10926 10927 } 10928 10929 10930 void appendArraySmallJsonT(void) { 10931 10932 smallJsont* r; 10933 smallJsont *self = allocSmallJson(); 10934 char **array; 10935 10936 // add an element to check that the second array is appended 10937 // at the end 10938 r = self->f->pushInt(self, 1); 10939 ck_assert_ptr_ne(r, null); 10940 10941 // append array 10942 array = null; 10943 listPushS(&array, "2"); 10944 r = self->f->appendArray(self, array); 10945 listFreeS(array); 10946 ck_assert_ptr_ne(r, null); 10947 char *s = toStringO(r); 10948 ck_assert_str_eq(s, "[1,\"2\"]"); 10949 free(s); 10950 // length 0 10951 listEmptyS(array); 10952 r = self->f->appendArray(self, array); 10953 free(array); 10954 ck_assert_ptr_ne(r, null); 10955 s = toStringO(r); 10956 ck_assert_str_eq(s, "[1,\"2\"]"); 10957 free(s); 10958 // null 10959 r = self->f->appendArray(self, null); 10960 ck_assert_ptr_eq(r, null); 10961 s = toStringO(self); 10962 ck_assert_str_eq(s, "[1,\"2\"]"); 10963 free(s); 10964 // empty json 10965 freeO(self); 10966 array = null; 10967 listPushS(&array, "2"); 10968 r = self->f->appendArray(self, array); 10969 listFreeS(array); 10970 ck_assert_ptr_ne(r, null); 10971 s = toStringO(r); 10972 ck_assert_str_eq(s, "[\"2\"]"); 10973 free(s); 10974 // non json array 10975 freeO(self); 10976 setTypeBoolO(self); 10977 listEmptyS(array); 10978 ck_assert_ptr_eq(self->f->appendArray(self, array), NULL); 10979 free(array); 10980 terminateO(self); 10981 10982 } 10983 10984 10985 void appendNSmashArraySmallJsonT(void) { 10986 10987 smallJsont* r; 10988 smallJsont *self = allocSmallJson(); 10989 char **array; 10990 10991 // add an element to check that the second array is appended 10992 // at the end 10993 r = self->f->pushInt(self, 1); 10994 ck_assert_ptr_ne(r, null); 10995 10996 // append array 10997 array = null; 10998 listPushS(&array, "2"); 10999 r = self->f->appendNSmashArray(self, array); 11000 ck_assert_ptr_ne(r, null); 11001 char *s = toStringO(r); 11002 ck_assert_str_eq(s, "[1,\"2\"]"); 11003 free(s); 11004 // length 0 11005 listEmptyS(array); 11006 r = self->f->appendNSmashArray(self, array); 11007 ck_assert_ptr_ne(r, null); 11008 s = toStringO(r); 11009 ck_assert_str_eq(s, "[1,\"2\"]"); 11010 free(s); 11011 // null 11012 r = self->f->appendNSmashArray(self, null); 11013 ck_assert_ptr_eq(r, null); 11014 s = toStringO(self); 11015 ck_assert_str_eq(s, "[1,\"2\"]"); 11016 free(s); 11017 // empty json 11018 freeO(self); 11019 array = null; 11020 listPushS(&array, "2"); 11021 r = self->f->appendNSmashArray(self, array); 11022 ck_assert_ptr_ne(r, null); 11023 s = toStringO(r); 11024 ck_assert_str_eq(s, "[\"2\"]"); 11025 free(s); 11026 // non json array 11027 freeO(self); 11028 setTypeBoolO(self); 11029 listEmptyS(array); 11030 ck_assert_ptr_eq(self->f->appendNSmashArray(self, array), NULL); 11031 free(array); 11032 terminateO(self); 11033 11034 } 11035 11036 11037 void shiftSmallJsonT(void) { 11038 11039 smallJsont* r; 11040 smallJsont *self = allocSmallJson(); 11041 createAllocateSmallArray(a); 11042 11043 // add an element to check that the second array is appended 11044 // at the end 11045 r = self->f->pushInt(self, 1); 11046 ck_assert_ptr_ne(r, null); 11047 11048 // append array 11049 a->f->pushInt(a, 2); 11050 r = self->f->shift(self, a); 11051 smashO(a); 11052 ck_assert_ptr_ne(r, null); 11053 char *s = toStringO(r); 11054 ck_assert_str_eq(s, "[2,1]"); 11055 free(s); 11056 // length 0 11057 a = allocSmallArray(); 11058 a->f->pushInt(a, 2); 11059 delElemO(a,0); 11060 r = self->f->shift(self, a); 11061 smashO(a); 11062 ck_assert_ptr_ne(r, null); 11063 s = toStringO(r); 11064 ck_assert_str_eq(s, "[2,1]"); 11065 free(s); 11066 // same sArray in both self and a 11067 a = allocSmallArray(); 11068 setsoO(a, (sArrayt*) getsoO(self)); 11069 r = self->f->shift(self, a); 11070 ck_assert_ptr_eq(r, null); 11071 finishO(a); 11072 s = toStringO(self); 11073 ck_assert_str_eq(s, "[2,1]"); 11074 free(s); 11075 // null 11076 r = self->f->shift(self, null); 11077 ck_assert_ptr_eq(r, null); 11078 s = toStringO(self); 11079 ck_assert_str_eq(s, "[2,1]"); 11080 free(s); 11081 terminateO(self); 11082 11083 } 11084 11085 11086 void shiftNSmashSmallJsonT(void) { 11087 11088 smallJsont* r; 11089 smallJsont *self = allocSmallJson(); 11090 createAllocateSmallArray(a); 11091 11092 // add an element to check that the second array is appended 11093 // at the end 11094 r = self->f->pushInt(self, 1); 11095 ck_assert_ptr_ne(r, null); 11096 11097 // append array 11098 a->f->pushInt(a, 2); 11099 r = self->f->shiftNSmash(self, a); 11100 ck_assert_ptr_ne(r, null); 11101 char *s = toStringO(r); 11102 ck_assert_str_eq(s, "[2,1]"); 11103 free(s); 11104 // length 0 11105 a = allocSmallArray(); 11106 a->f->pushInt(a, 2); 11107 delElemO(a,0); 11108 r = self->f->shiftNSmash(self, a); 11109 ck_assert_ptr_ne(r, null); 11110 s = toStringO(r); 11111 ck_assert_str_eq(s, "[2,1]"); 11112 free(s); 11113 // same sArray in both self and a 11114 a = allocSmallArray(); 11115 setsoO(a, (sArrayt*) getsoO(self)); 11116 r = self->f->shiftNSmash(self, a); 11117 ck_assert_ptr_eq(r, null); 11118 finishO(a); 11119 s = toStringO(self); 11120 ck_assert_str_eq(s, "[2,1]"); 11121 free(s); 11122 // null 11123 r = self->f->shiftNSmash(self, null); 11124 ck_assert_ptr_eq(r, null); 11125 s = toStringO(self); 11126 ck_assert_str_eq(s, "[2,1]"); 11127 free(s); 11128 terminateO(self); 11129 11130 } 11131 11132 11133 void shiftSmallJsonSmallJsonT(void) { 11134 11135 smallJsont* r; 11136 smallJsont *self = allocSmallJson(); 11137 createAllocateSmallJson(json); 11138 11139 // add an element to check that the second array is shifted 11140 // at the end 11141 r = self->f->pushInt(self, 1); 11142 ck_assert_ptr_ne(r, null); 11143 11144 // shift json array 11145 json->f->pushInt(json, 2); 11146 r = self->f->shiftSmallJson(self, json); 11147 smashO(json); 11148 ck_assert_ptr_ne(r, null); 11149 char *s = toStringO(r); 11150 ck_assert_str_eq(s, "[2,1]"); 11151 free(s); 11152 // length 0 11153 json = allocSmallJson(); 11154 json->f->pushInt(json, 2); 11155 baset *o = json->f->pop(json); 11156 terminateO(o); 11157 r = self->f->shiftSmallJson(self, json); 11158 smashO(json); 11159 ck_assert_ptr_ne(r, null); 11160 s = toStringO(r); 11161 ck_assert_str_eq(s, "[2,1]"); 11162 free(s); 11163 // same sArray in both self and json 11164 json = allocSmallJson(); 11165 setsoO(json, (smallt*) getsoO(self)); 11166 r = self->f->shiftSmallJson(self, json); 11167 ck_assert_ptr_eq(r, null); 11168 finishO(json); 11169 s = toStringO(self); 11170 ck_assert_str_eq(s, "[2,1]"); 11171 free(s); 11172 // json of type not array 11173 json = allocSmallJson(); 11174 setTopIntO(json, 1); 11175 r = self->f->shiftSmallJson(self, json); 11176 ck_assert_ptr_eq(r, null); 11177 terminateO(json); 11178 s = toStringO(self); 11179 ck_assert_str_eq(s, "[2,1]"); 11180 free(s); 11181 // null 11182 r = self->f->shiftSmallJson(self, null); 11183 ck_assert_ptr_eq(r, null); 11184 s = toStringO(self); 11185 ck_assert_str_eq(s, "[2,1]"); 11186 free(s); 11187 terminateO(self); 11188 11189 } 11190 11191 11192 void shiftNSmashSmallJsonSmallJsonT(void) { 11193 11194 smallJsont* r; 11195 smallJsont *self = allocSmallJson(); 11196 createAllocateSmallJson(json); 11197 11198 // add an element to check that the second array is shifted 11199 // at the end 11200 r = self->f->pushInt(self, 1); 11201 ck_assert_ptr_ne(r, null); 11202 11203 // shift json array 11204 json->f->pushInt(json, 2); 11205 r = self->f->shiftNSmashSmallJson(self, json); 11206 ck_assert_ptr_ne(r, null); 11207 char *s = toStringO(r); 11208 ck_assert_str_eq(s, "[2,1]"); 11209 free(s); 11210 // length 0 11211 json = allocSmallJson(); 11212 json->f->pushInt(json, 2); 11213 baset *o = json->f->pop(json); 11214 terminateO(o); 11215 r = self->f->shiftNSmashSmallJson(self, json); 11216 ck_assert_ptr_ne(r, null); 11217 s = toStringO(r); 11218 ck_assert_str_eq(s, "[2,1]"); 11219 free(s); 11220 // same sArray in both self and json 11221 json = allocSmallJson(); 11222 setsoO(json, (smallt*) getsoO(self)); 11223 r = self->f->shiftNSmashSmallJson(self, json); 11224 ck_assert_ptr_eq(r, null); 11225 finishO(json); 11226 s = toStringO(self); 11227 ck_assert_str_eq(s, "[2,1]"); 11228 free(s); 11229 // json of type not array 11230 json = allocSmallJson(); 11231 setTopIntO(json, 1); 11232 r = self->f->shiftNSmashSmallJson(self, json); 11233 ck_assert_ptr_eq(r, null); 11234 terminateO(json); 11235 s = toStringO(self); 11236 ck_assert_str_eq(s, "[2,1]"); 11237 free(s); 11238 // null 11239 r = self->f->shiftNSmashSmallJson(self, null); 11240 ck_assert_ptr_eq(r, null); 11241 s = toStringO(self); 11242 ck_assert_str_eq(s, "[2,1]"); 11243 free(s); 11244 terminateO(self); 11245 11246 } 11247 11248 11249 void addSmallJsonT(void) { 11250 11251 smallJsont* r; 11252 smallJsont *self = allocSmallJson(); 11253 createAllocateSmallArray(a); 11254 11255 // add an element to check that the second array is added 11256 // at the end 11257 r = self->f->pushInt(self, 1); 11258 ck_assert_ptr_ne(r, null); 11259 11260 // add array 11261 a->f->pushInt(a, 2); 11262 r = addO(self, a); 11263 smashO(a); 11264 ck_assert_ptr_ne(r, null); 11265 char *s = toStringO(r); 11266 terminateO(r); 11267 ck_assert_str_eq(s, "[1,2]"); 11268 free(s); 11269 // length 0 11270 a = allocSmallArray(); 11271 a->f->pushInt(a, 2); 11272 delElemO(a,0); 11273 r = addO(self, a); 11274 smashO(a); 11275 ck_assert_ptr_ne(r, null); 11276 s = toStringO(r); 11277 terminateO(r); 11278 ck_assert_str_eq(s, "[1]"); 11279 free(s); 11280 a = allocSmallArray(); 11281 r = addO(self, a); 11282 smashO(a); 11283 ck_assert_ptr_ne(r, null); 11284 s = toStringO(r); 11285 terminateO(r); 11286 ck_assert_str_eq(s, "[1]"); 11287 free(s); 11288 // same sArray in both self and a 11289 a = allocSmallArray(); 11290 setsoO(a, (sArrayt*) getsoO(self)); 11291 r = addO(self, a); 11292 ck_assert_ptr_eq(r, null); 11293 finishO(a); 11294 s = toStringO(self); 11295 ck_assert_str_eq(s, "[1]"); 11296 free(s); 11297 // null 11298 r = addO(self, null); 11299 ck_assert_ptr_eq(r, null); 11300 s = toStringO(self); 11301 ck_assert_str_eq(s, "[1]"); 11302 free(s); 11303 // non smallArray a 11304 a = (smallArrayt*) allocSmallInt(1); 11305 ck_assert_ptr_eq(addO(self, a), NULL); 11306 terminateO(a); 11307 // non json array 11308 freeO(self); 11309 setTypeBoolO(self); 11310 a = allocSmallArray(); 11311 ck_assert_ptr_eq(addO(self, a), NULL); 11312 terminateO(a); 11313 terminateO(self); 11314 11315 } 11316 11317 11318 void addJsonSmallJsonT(void) { 11319 11320 smallJsont* r; 11321 smallJsont *self = allocSmallJson(); 11322 smallJsont *a = allocSmallJson(); 11323 11324 // add an element to check that the second array is added 11325 // at the end 11326 r = self->f->pushInt(self, 1); 11327 ck_assert_ptr_ne(r, null); 11328 11329 // add array 11330 a->f->pushInt(a, 2); 11331 r = addJsonO(self, a); 11332 smashO(a); 11333 ck_assert_ptr_ne(r, null); 11334 char *s = toStringO(r); 11335 terminateO(r); 11336 ck_assert_str_eq(s, "[1,2]"); 11337 free(s); 11338 // length 0 11339 a = allocSmallJson(); 11340 a->f->pushInt(a, 2); 11341 delElemIndexO(a,0); 11342 r = addJsonO(self, a); 11343 smashO(a); 11344 ck_assert_ptr_ne(r, null); 11345 s = toStringO(r); 11346 terminateO(r); 11347 ck_assert_str_eq(s, "[1]"); 11348 free(s); 11349 a = allocSmallJson(); 11350 setTypeArrayO(a); 11351 r = addJsonO(self, a); 11352 smashO(a); 11353 ck_assert_ptr_ne(r, null); 11354 s = toStringO(r); 11355 terminateO(r); 11356 ck_assert_str_eq(s, "[1]"); 11357 free(s); 11358 // same sArray in both self and a 11359 a = allocSmallJson(); 11360 setsoO(a, getsoO(self)); 11361 r = addJsonO(self, a); 11362 ck_assert_ptr_eq(r, null); 11363 finishO(a); 11364 s = toStringO(self); 11365 ck_assert_str_eq(s, "[1]"); 11366 free(s); 11367 // non json array a 11368 a = allocSmallJson(); 11369 r = addJsonO(self, a); 11370 ck_assert_ptr_eq(r, null); 11371 finishO(a); 11372 s = toStringO(self); 11373 ck_assert_str_eq(s, "[1]"); 11374 free(s); 11375 // null 11376 r = addJsonO(self, null); 11377 ck_assert_ptr_eq(r, null); 11378 s = toStringO(self); 11379 ck_assert_str_eq(s, "[1]"); 11380 free(s); 11381 // non json a 11382 a = (smallJsont*) allocSmallInt(1); 11383 ck_assert_ptr_eq(addJsonO(self, a), NULL); 11384 terminateO(a); 11385 // non json array 11386 freeO(self); 11387 setTypeBoolO(self); 11388 a = allocSmallJson(); 11389 ck_assert_ptr_eq(addJsonO(self, a), NULL); 11390 terminateO(a); 11391 terminateO(self); 11392 11393 } 11394 11395 11396 void sliceSmallJsonT(void) { 11397 11398 smallJsont* r; 11399 smallJsont *self = allocSmallJson(); 11400 11401 //r = sliceO(self); 11402 // slice 11403 self->f->pushS(self, "asd"); 11404 self->f->pushInt(self, 123); 11405 self->f->pushS(self, "sheepy"); 11406 self->f->pushInt(self, 5345); 11407 r = sliceO(self,1,-1); 11408 ck_assert_ptr_ne(r, null); 11409 char *s = toStringO(r); 11410 ck_assert_str_eq(s, "[123,\"sheepy\"]"); 11411 free(s); 11412 terminateO(self); 11413 // start outside 11414 self = allocSmallJson(); 11415 self->f->pushS(self, "asd"); 11416 self->f->pushInt(self, 123); 11417 self->f->pushS(self, "sheepy"); 11418 self->f->pushInt(self, 5345); 11419 r = sliceO(self,20,-1); 11420 ck_assert_ptr_eq(r, null); 11421 s = toStringO(self); 11422 ck_assert_str_eq(s, "[]"); 11423 free(s); 11424 terminateO(self); 11425 // start negative and outside 11426 self = allocSmallJson(); 11427 self->f->pushUndefined(self); 11428 self->f->pushInt(self, 123); 11429 self->f->pushS(self, "sheepy"); 11430 self->f->pushInt(self, 5345); 11431 r = sliceO(self,-20,1); 11432 ck_assert_ptr_ne(r, null); 11433 s = toStringO(r); 11434 ck_assert_str_eq(s, "[null]"); 11435 free(s); 11436 terminateO(self); 11437 // end outside 11438 self = allocSmallJson(); 11439 self->f->pushUndefined(self); 11440 self->f->pushInt(self, 123); 11441 self->f->pushS(self, "sheepy"); 11442 self->f->pushInt(self, 5345); 11443 r = sliceO(self,2,40); 11444 ck_assert_ptr_ne(r, null); 11445 s = toStringO(self); 11446 ck_assert_str_eq(s, "[\"sheepy\",5345]"); 11447 free(s); 11448 terminateO(self); 11449 // end negative and outside 11450 self = allocSmallJson(); 11451 self->f->pushUndefined(self); 11452 self->f->pushInt(self, 123); 11453 self->f->pushS(self, "sheepy"); 11454 self->f->pushInt(self, 5345); 11455 r = sliceO(self,2,-40); 11456 ck_assert_ptr_eq(r, null); 11457 s = toStringO(self); 11458 ck_assert_str_eq(s, "[]"); 11459 free(s); 11460 terminateO(self); 11461 // end before start 11462 self = allocSmallJson(); 11463 self->f->pushUndefined(self); 11464 self->f->pushInt(self, 123); 11465 self->f->pushS(self, "sheepy"); 11466 self->f->pushInt(self, 5345); 11467 r = sliceO(self,3,2); 11468 ck_assert_ptr_eq(r, null); 11469 s = toStringO(self); 11470 ck_assert_str_eq(s, "[]"); 11471 free(s); 11472 terminateO(self); 11473 // negative start last element 11474 self = allocSmallJson(); 11475 self->f->pushUndefined(self); 11476 self->f->pushInt(self, 123); 11477 self->f->pushS(self, "sheepy"); 11478 self->f->pushInt(self, 5345); 11479 r = sliceO(self,-1,0); 11480 ck_assert_ptr_ne(r, null); 11481 s = toStringO(r); 11482 ck_assert_str_eq(s, "[5345]"); 11483 free(s); 11484 terminateO(self); 11485 // start = end 11486 self = allocSmallJson(); 11487 self->f->pushUndefined(self); 11488 self->f->pushInt(self, 123); 11489 self->f->pushS(self, "sheepy"); 11490 self->f->pushInt(self, 5345); 11491 r = sliceO(self,1,1); 11492 ck_assert_ptr_ne(r, null); 11493 s = toStringO(r); 11494 ck_assert_str_eq(s, "[]"); 11495 free(s); 11496 terminateO(self); 11497 // empty list 11498 initiateAllocateSmallJson(&self); 11499 setTypeArrayO(self); 11500 r = sliceO(self,0,0); 11501 ck_assert_ptr_eq(r, null); 11502 s = toStringO(self); 11503 ck_assert_str_eq(s, "[]"); 11504 free(s); 11505 // non json array 11506 freeO(self); 11507 setTypeBoolO(self); 11508 ck_assert_ptr_eq(sliceO(self, 0, 1), NULL); 11509 terminateO(self); 11510 // json string 11511 self = allocSmallJson(); 11512 // slice 11513 setTopSO(self, "sheepy"); 11514 r = sliceO(self, 0,2); 11515 ck_assert_ptr_ne(r, null); 11516 ck_assert_str_eq(sjGet(self), "sh"); 11517 // negative index 11518 freeO(self); 11519 setTopSO(self, "sheepy"); 11520 r = sliceO(self, -2,0); 11521 ck_assert_ptr_ne(r, null); 11522 ck_assert_str_eq(sjGet(self), "py"); 11523 // positive and negative indexes 11524 freeO(self); 11525 setTopSO(self, "sheepy"); 11526 r = sliceO(self, 2,-2); 11527 ck_assert_ptr_ne(r, null); 11528 ck_assert_str_eq(sjGet(self), "ee"); 11529 // start = end 11530 freeO(self); 11531 setTopSO(self, "sheepy"); 11532 r = sliceO(self, 2,-4); 11533 ck_assert_ptr_ne(r, null); 11534 ck_assert_str_eq(sjGet(self), ""); 11535 // end of string 11536 freeO(self); 11537 setTopSO(self, "sheepy"); 11538 r = sliceO(self, 2,6); 11539 ck_assert_ptr_ne(r, null); 11540 ck_assert_str_eq(sjGet(self), "eepy"); 11541 // NULL string 11542 freeO(self); 11543 ck_assert_ptr_eq(sliceO(self, 2,-4), NULL); 11544 // start outside string 11545 freeO(self); 11546 setTopSO(self, "sheepy"); 11547 ck_assert_ptr_eq(sliceO(self, 20,-4), NULL); 11548 // end outside string 11549 freeO(self); 11550 setTopSO(self, "sheepy"); 11551 r = sliceO(self, 2,40); 11552 ck_assert_ptr_ne(r, null); 11553 ck_assert_str_eq(sjGet(self), "eepy"); 11554 freeO(self); 11555 setTopSO(self, "sheepy"); 11556 r = sliceO(self, -22,3); 11557 ck_assert_ptr_ne(r, null); 11558 ck_assert_str_eq(sjGet(self), "she"); 11559 freeO(self); 11560 setTopSO(self, "sheepy"); 11561 ck_assert_ptr_eq(sliceO(self, 2,-40), NULL); 11562 // end before start 11563 freeO(self); 11564 setTopSO(self, "sheepy"); 11565 ck_assert_ptr_eq(sliceO(self, 4,2), NULL); 11566 terminateO(self); 11567 11568 } 11569 11570 11571 void cropSmallJsonT(void) { 11572 11573 smallJsont* r; 11574 smallJsont *self = allocSmallJson(); 11575 11576 // add elements to self 11577 r = self->f->pushInt(self, 1); 11578 ck_assert_ptr_ne(r, null); 11579 r = self->f->pushInt(self, 2); 11580 ck_assert_ptr_ne(r, null); 11581 r = self->f->pushInt(self, 3); 11582 ck_assert_ptr_ne(r, null); 11583 r = self->f->pushInt(self, 4); 11584 ck_assert_ptr_ne(r, null); 11585 11586 // negative index 11587 r = cropO(self, 1, -1); 11588 ck_assert_ptr_ne(r, null); 11589 ck_assert_int_eq(lenO(r), 2); 11590 char *s = toStringO(r); 11591 terminateO(r); 11592 ck_assert_str_eq(s, "[2,3]"); 11593 free(s); 11594 s = toStringO(self); 11595 ck_assert_str_eq(s, "[1,4]"); 11596 free(s); 11597 // start outside 11598 ck_assert_ptr_eq(cropO(self, 20, -4), NULL); 11599 // end outside 11600 r = cropO(self, 0, 40); 11601 ck_assert_ptr_ne(r, null); 11602 ck_assert_int_eq(lenO(r), 2); 11603 s = toStringO(r); 11604 terminateO(r); 11605 ck_assert_str_eq(s, "[1,4]"); 11606 free(s); 11607 s = toStringO(self); 11608 ck_assert_str_eq(s, "[]"); 11609 free(s); 11610 // end negative and outside 11611 // add elements to self 11612 r = self->f->pushInt(self, 1); 11613 ck_assert_ptr_ne(r, null); 11614 r = self->f->pushInt(self, 2); 11615 ck_assert_ptr_ne(r, null); 11616 r = self->f->pushInt(self, 3); 11617 ck_assert_ptr_ne(r, null); 11618 r = self->f->pushInt(self, 4); 11619 ck_assert_ptr_ne(r, null); 11620 ck_assert_ptr_eq(cropO(self, 2, -40), NULL); 11621 s = toStringO(self); 11622 ck_assert_str_eq(s, "[1,2,3,4]"); 11623 free(s); 11624 // end before start 11625 ck_assert_ptr_eq(cropO(self, 3, 2), NULL); 11626 s = toStringO(self); 11627 ck_assert_str_eq(s, "[1,2,3,4]"); 11628 free(s); 11629 // negative start last element 11630 r = cropO(self, -1, 0); 11631 ck_assert_ptr_ne(r, null); 11632 ck_assert_int_eq(lenO(r), 1); 11633 s = toStringO(r); 11634 terminateO(r); 11635 ck_assert_str_eq(s, "[4]"); 11636 free(s); 11637 s = toStringO(self); 11638 ck_assert_str_eq(s, "[1,2,3]"); 11639 free(s); 11640 // negative start and outside 11641 r = cropO(self, -10, 1); 11642 ck_assert_ptr_ne(r, null); 11643 ck_assert_int_eq(lenO(r), 1); 11644 s = toStringO(r); 11645 terminateO(r); 11646 ck_assert_str_eq(s, "[1]"); 11647 free(s); 11648 s = toStringO(self); 11649 ck_assert_str_eq(s, "[2,3]"); 11650 free(s); 11651 // start = end 11652 r = cropO(self, 1, 1); 11653 ck_assert_ptr_ne(r, null); 11654 ck_assert_int_eq(lenO(r), 0); 11655 terminateO(r); 11656 s = toStringO(self); 11657 ck_assert_str_eq(s, "[2,3]"); 11658 free(s); 11659 // empty list 11660 emptyO(self); 11661 ck_assert_ptr_eq(cropO(self, 0, 0), NULL); 11662 ck_assert_ptr_eq(cropO(self, -1, 0), NULL); 11663 // non json array 11664 freeO(self); 11665 setTypeBoolO(self); 11666 ck_assert_ptr_eq(cropO(self, 0, 1), NULL); 11667 terminateO(self); 11668 // json string 11669 self = allocSmallJson(); 11670 setTopSO(self, ""); 11671 // crop 11672 freeO(self); 11673 setTopSO(self, "sheepy"); 11674 r = cropO(self, 0,2); 11675 ck_assert_ptr_ne(r, null); 11676 ck_assert_str_eq(sjGet(r), "sh"); 11677 ck_assert_str_eq(sjGet(self), "eepy"); 11678 terminateO(r); 11679 // negative index 11680 freeO(self); 11681 setTopSO(self, "sheepy"); 11682 r = cropO(self, -2,0); 11683 ck_assert_ptr_ne(r, null); 11684 ck_assert_str_eq(sjGet(r), "py"); 11685 ck_assert_str_eq(sjGet(self), "shee"); 11686 terminateO(r); 11687 // positive and negative indexes 11688 freeO(self); 11689 setTopSO(self, "sheepy"); 11690 r = cropO(self, 2,-2); 11691 ck_assert_ptr_ne(r, null); 11692 ck_assert_str_eq(sjGet(r), "ee"); 11693 ck_assert_str_eq(sjGet(self), "shpy"); 11694 terminateO(r); 11695 // start = end 11696 freeO(self); 11697 setTopSO(self, "sheepy"); 11698 r = cropO(self, 2,-4); 11699 ck_assert_ptr_ne(r, null); 11700 ck_assert_str_eq(sjGet(r), ""); 11701 ck_assert_str_eq(sjGet(self), "sheepy"); 11702 terminateO(r); 11703 // end of string 11704 freeO(self); 11705 setTopSO(self, "sheepy"); 11706 r = cropO(self, 2,6); 11707 ck_assert_ptr_ne(r, null); 11708 ck_assert_str_eq(sjGet(r), "eepy"); 11709 ck_assert_str_eq(sjGet(self), "sh"); 11710 terminateO(r); 11711 // NULL string 11712 freeO(self); 11713 ck_assert_ptr_eq(cropO(self, 2,-4), NULL); 11714 // start outside string 11715 freeO(self); 11716 setTopSO(self, "sheepy"); 11717 ck_assert_ptr_eq(cropO(self, 20,-4), NULL); 11718 // end outside string 11719 freeO(self); 11720 setTopSO(self, "sheepy"); 11721 r = cropO(self, 2,40); 11722 ck_assert_ptr_ne(r, null); 11723 ck_assert_str_eq(sjGet(r), "eepy"); 11724 ck_assert_str_eq(sjGet(self), "sh"); 11725 terminateO(r); 11726 freeO(self); 11727 setTopSO(self, "sheepy"); 11728 r = cropO(self, -22,3); 11729 ck_assert_ptr_ne(r, null); 11730 ck_assert_str_eq(sjGet(r), "she"); 11731 ck_assert_str_eq(sjGet(self), "epy"); 11732 terminateO(r); 11733 freeO(self); 11734 setTopSO(self, "sheepy"); 11735 ck_assert_ptr_eq(cropO(self, 2,-40), NULL); 11736 // end before start 11737 ck_assert_ptr_eq(cropO(self, 4,2), NULL); 11738 terminateO(self); 11739 11740 } 11741 11742 11743 void cropSSmallJsonT(void) { 11744 11745 char* s; 11746 smallJsont *self = allocSmallJson(); 11747 setTopSO(self, ""); 11748 11749 // crop 11750 freeO(self); 11751 setTopSO(self, "sheepy"); 11752 s = cropSO(self, 0,2); 11753 ck_assert_str_eq(s, "sh"); 11754 ck_assert_str_eq(sjGet(self), "eepy"); 11755 free(s); 11756 // negative index 11757 freeO(self); 11758 setTopSO(self, "sheepy"); 11759 s = cropSO(self, -2,0); 11760 ck_assert_str_eq(s, "py"); 11761 ck_assert_str_eq(sjGet(self), "shee"); 11762 free(s); 11763 // positive and negative indexes 11764 freeO(self); 11765 setTopSO(self, "sheepy"); 11766 s = cropSO(self, 2,-2); 11767 ck_assert_str_eq(s, "ee"); 11768 ck_assert_str_eq(sjGet(self), "shpy"); 11769 free(s); 11770 // start = end 11771 freeO(self); 11772 setTopSO(self, "sheepy"); 11773 s = cropSO(self, 2,-4); 11774 ck_assert_str_eq(s, ""); 11775 ck_assert_str_eq(sjGet(self), "sheepy"); 11776 free(s); 11777 // end of string 11778 freeO(self); 11779 setTopSO(self, "sheepy"); 11780 s = cropSO(self, 2,6); 11781 ck_assert_str_eq(s, "eepy"); 11782 ck_assert_str_eq(sjGet(self), "sh"); 11783 free(s); 11784 // empty string 11785 freeO(self); 11786 setTopSO(self, ""); 11787 ck_assert_ptr_eq(cropSO(self, 0,1), NULL); 11788 // NULL string 11789 freeO(self); 11790 ck_assert_ptr_eq(cropSO(self, 2,-4), NULL); 11791 // start outside string 11792 freeO(self); 11793 setTopSO(self, "sheepy"); 11794 ck_assert_ptr_eq(cropSO(self, 20,-4), NULL); 11795 // end outside string 11796 freeO(self); 11797 setTopSO(self, "sheepy"); 11798 s = cropSO(self, 2,40); 11799 ck_assert_str_eq(s, "eepy"); 11800 ck_assert_str_eq(sjGet(self), "sh"); 11801 free(s); 11802 freeO(self); 11803 setTopSO(self, "sheepy"); 11804 s = cropSO(self, -22,3); 11805 ck_assert_str_eq(s, "she"); 11806 ck_assert_str_eq(sjGet(self), "epy"); 11807 free(s); 11808 freeO(self); 11809 setTopSO(self, "sheepy"); 11810 ck_assert_ptr_eq(cropSO(self, 2,-40), NULL); 11811 // end before start 11812 ck_assert_ptr_eq(cropSO(self, 4,2), NULL); 11813 terminateO(self); 11814 11815 } 11816 11817 11818 void cropSmallStringSmallJsonT(void) { 11819 11820 smallStringt* r; 11821 smallJsont *self = allocSmallJson(); 11822 setTopSO(self, ""); 11823 11824 // crop 11825 freeO(self); 11826 setTopSO(self, "sheepy"); 11827 r = cropSmallStringO(self, 0,2); 11828 ck_assert_ptr_ne(r, null); 11829 ck_assert_str_eq(ssGet(r), "sh"); 11830 ck_assert_str_eq(sjGet(self), "eepy"); 11831 terminateO(r); 11832 // negative index 11833 freeO(self); 11834 setTopSO(self, "sheepy"); 11835 r = cropSmallStringO(self, -2,0); 11836 ck_assert_ptr_ne(r, null); 11837 ck_assert_str_eq(ssGet(r), "py"); 11838 ck_assert_str_eq(sjGet(self), "shee"); 11839 terminateO(r); 11840 // positive and negative indexes 11841 freeO(self); 11842 setTopSO(self, "sheepy"); 11843 r = cropSmallStringO(self, 2,-2); 11844 ck_assert_ptr_ne(r, null); 11845 ck_assert_str_eq(ssGet(r), "ee"); 11846 ck_assert_str_eq(sjGet(self), "shpy"); 11847 terminateO(r); 11848 // start = end 11849 freeO(self); 11850 setTopSO(self, "sheepy"); 11851 r = cropSmallStringO(self, 2,-4); 11852 ck_assert_ptr_ne(r, null); 11853 ck_assert_str_eq(ssGet(r), ""); 11854 ck_assert_str_eq(sjGet(self), "sheepy"); 11855 terminateO(r); 11856 // end of string 11857 freeO(self); 11858 setTopSO(self, "sheepy"); 11859 r = cropSmallStringO(self, 2,6); 11860 ck_assert_ptr_ne(r, null); 11861 ck_assert_str_eq(ssGet(r), "eepy"); 11862 ck_assert_str_eq(sjGet(self), "sh"); 11863 terminateO(r); 11864 // NULL string 11865 freeO(self); 11866 ck_assert_ptr_eq(cropSmallStringO(self, 2,-4), NULL); 11867 // start outside string 11868 freeO(self); 11869 setTopSO(self, "sheepy"); 11870 ck_assert_ptr_eq(cropSmallStringO(self, 20,-4), NULL); 11871 // end outside string 11872 freeO(self); 11873 setTopSO(self, "sheepy"); 11874 r = cropSmallStringO(self, 2,40); 11875 ck_assert_ptr_ne(r, null); 11876 ck_assert_str_eq(ssGet(r), "eepy"); 11877 ck_assert_str_eq(sjGet(self), "sh"); 11878 terminateO(r); 11879 freeO(self); 11880 setTopSO(self, "sheepy"); 11881 r = cropSmallStringO(self, -22,3); 11882 ck_assert_ptr_ne(r, null); 11883 ck_assert_str_eq(ssGet(r), "she"); 11884 ck_assert_str_eq(sjGet(self), "epy"); 11885 terminateO(r); 11886 freeO(self); 11887 setTopSO(self, "sheepy"); 11888 ck_assert_ptr_eq(cropSmallStringO(self, 2,-40), NULL); 11889 // end before start 11890 ck_assert_ptr_eq(cropSmallStringO(self, 4,2), NULL); 11891 terminateO(self); 11892 11893 } 11894 11895 11896 void cropElemAtSmallJsonT(void) { 11897 11898 baset* r; 11899 smallJsont *self = allocSmallJson(); 11900 smallJsont *r2; 11901 11902 // add elements to self 11903 r2 = self->f->pushInt(self, 1); 11904 ck_assert_ptr_ne(r2, null); 11905 r2 = self->f->pushInt(self, 2); 11906 ck_assert_ptr_ne(r2, null); 11907 r2 = self->f->pushInt(self, 3); 11908 ck_assert_ptr_ne(r2, null); 11909 r2 = self->f->pushInt(self, 4); 11910 ck_assert_ptr_ne(r2, null); 11911 11912 // positive index 11913 r = cropElemAtO(self,1); 11914 ck_assert_ptr_ne(r, null); 11915 char *s = toStringO(r); 11916 terminateO(r); 11917 ck_assert_str_eq(s, "2"); 11918 free(s); 11919 s = toStringO(self); 11920 ck_assert_str_eq(s, "[1,3,4]"); 11921 free(s); 11922 // negative index 11923 r = cropElemAtO(self,-1); 11924 ck_assert_ptr_ne(r, null); 11925 s = toStringO(r); 11926 terminateO(r); 11927 ck_assert_str_eq(s, "4"); 11928 free(s); 11929 s = toStringO(self); 11930 ck_assert_str_eq(s, "[1,3]"); 11931 free(s); 11932 // undefined object 11933 r2 = self->f->pushUndefined(self); 11934 ck_assert_ptr_ne(r2, null); 11935 r = cropElemAtO(self,2); 11936 ck_assert_ptr_ne(r, null); 11937 s = toStringO(r); 11938 terminateO(r); 11939 ck_assert_str_eq(s, "null"); 11940 free(s); 11941 s = toStringO(self); 11942 ck_assert_str_eq(s, "[1,3]"); 11943 free(s); 11944 // container 11945 createSmallContainer(c); 11946 r2 = self->f->pushSmallContainer(self, &c); 11947 r = cropElemAtO(self,2); 11948 ck_assert_ptr_ne(r, null); 11949 s = toStringO(r); 11950 terminateO(r); 11951 ck_assert_str_eq(s, "<data smallContainer>"); 11952 free(s); 11953 s = toStringO(self); 11954 ck_assert_str_eq(s, "[1,3]"); 11955 free(s); 11956 // base object in container 11957 createAllocateSmallInt(I); 11958 setValG(I, 11); 11959 I->type = "anothertype"; 11960 r2 = self->f->push(self, (baset*)I); 11961 r = cropElemAtO(self,2); 11962 ck_assert_ptr_ne(r, null); 11963 ck_assert_str_eq(r->type, "anothertype"); 11964 s = toStringO(r); 11965 terminateO(r); 11966 ck_assert_str_eq(s, "11"); 11967 free(s); 11968 s = toStringO(self); 11969 ck_assert_str_eq(s, "[1,3]"); 11970 free(s); 11971 // index outside 11972 ck_assert_ptr_eq(cropElemAtO(self, 20), NULL); 11973 ck_assert_ptr_eq(cropElemAtO(self, -4), NULL); 11974 // empty list 11975 emptyO(self); 11976 ck_assert_ptr_eq(cropElemAtO(self, 0), NULL); 11977 ck_assert_ptr_eq(cropElemAtO(self, -1), NULL); 11978 r2 = self->f->pushUndefined(self); 11979 ck_assert_ptr_ne(r2, null); 11980 delElemIndexO(self,-1); 11981 r = cropElemAtO(self, 0); 11982 ck_assert_ptr_eq(r, null); 11983 // non json array 11984 freeO(self); 11985 setTypeBoolO(self); 11986 ck_assert_ptr_eq(cropElemAtO(self, 0), NULL); 11987 terminateO(self); 11988 11989 } 11990 11991 11992 void cropElemAtUndefinedSmallJsonT(void) { 11993 11994 undefinedt* r; 11995 smallJsont *self = allocSmallJson(); 11996 smallJsont *r2; 11997 11998 // add elements to self 11999 r2 = self->f->pushInt(self, 1); 12000 ck_assert_ptr_ne(r2, null); 12001 r2 = self->f->pushUndefined(self); 12002 ck_assert_ptr_ne(r2, null); 12003 r2 = self->f->pushInt(self, 3); 12004 ck_assert_ptr_ne(r2, null); 12005 r2 = self->f->pushUndefined(self); 12006 ck_assert_ptr_ne(r2, null); 12007 12008 // positive index 12009 r = cropElemAtUndefinedO(self,1); 12010 ck_assert_ptr_ne(r, null); 12011 char *s = toStringO(r); 12012 terminateO(r); 12013 ck_assert_str_eq(s, "null"); 12014 free(s); 12015 s = toStringO(self); 12016 ck_assert_str_eq(s, "[1,3,null]"); 12017 free(s); 12018 // negative index 12019 r = cropElemAtUndefinedO(self,-1); 12020 ck_assert_ptr_ne(r, null); 12021 s = toStringO(r); 12022 terminateO(r); 12023 ck_assert_str_eq(s, "null"); 12024 free(s); 12025 s = toStringO(self); 12026 ck_assert_str_eq(s, "[1,3]"); 12027 free(s); 12028 // wrong object type 12029 createSmallInt(I); 12030 setValG(&I, 11); 12031 r2 = self->f->pushSmallInt(self, &I); 12032 ck_assert_ptr_ne(r2, null); 12033 r = cropElemAtUndefinedO(self,2); 12034 ck_assert_ptr_eq(r, null); 12035 s = toStringO(self); 12036 ck_assert_str_eq(s, "[1,3,11]"); 12037 free(s); 12038 // index outside 12039 ck_assert_ptr_eq(cropElemAtUndefinedO(self, 20), NULL); 12040 ck_assert_ptr_eq(cropElemAtUndefinedO(self, -4), NULL); 12041 // empty list 12042 emptyO(self); 12043 ck_assert_ptr_eq(cropElemAtUndefinedO(self, 0), NULL); 12044 ck_assert_ptr_eq(cropElemAtUndefinedO(self, -1), NULL); 12045 r2 = self->f->pushUndefined(self); 12046 ck_assert_ptr_ne(r2, null); 12047 delElemIndexO(self,-1); 12048 r = cropElemAtUndefinedO(self, 0); 12049 ck_assert_ptr_eq(r, null); 12050 // non json array 12051 freeO(self); 12052 setTypeBoolO(self); 12053 ck_assert_ptr_eq(cropElemAtUndefinedO(self, 0), NULL); 12054 terminateO(self); 12055 12056 } 12057 12058 12059 void cropElemAtBoolSmallJsonT(void) { 12060 12061 bool r; 12062 smallJsont *self = allocSmallJson(); 12063 smallJsont *r2; 12064 12065 // add elements to self 12066 r2 = self->f->pushInt(self, 1); 12067 ck_assert_ptr_ne(r2, null); 12068 r2 = self->f->pushBool(self, TRUE); 12069 ck_assert_ptr_ne(r2, null); 12070 r2 = self->f->pushInt(self, 3); 12071 ck_assert_ptr_ne(r2, null); 12072 r2 = self->f->pushBool(self, TRUE); 12073 ck_assert_ptr_ne(r2, null); 12074 12075 // positive index 12076 r = cropElemAtBoolO(self,1); 12077 ck_assert(r); 12078 char *s = toStringO(self); 12079 ck_assert_str_eq(s, "[1,3,true]"); 12080 free(s); 12081 // negative index 12082 r = cropElemAtBoolO(self,-1); 12083 ck_assert(r); 12084 s = toStringO(self); 12085 ck_assert_str_eq(s, "[1,3]"); 12086 free(s); 12087 // wrong object type 12088 createSmallInt(I); 12089 setValG(&I, 11); 12090 r2 = self->f->pushSmallInt(self, &I); 12091 r = cropElemAtBoolO(self,2); 12092 ck_assert(!r); 12093 s = toStringO(self); 12094 ck_assert_str_eq(s, "[1,3,11]"); 12095 free(s); 12096 // wrong object type of another user class 12097 // User classes are stored in containers transparently 12098 createAllocateSmallInt(ip); 12099 ip->type = "anothertype"; 12100 setValG(ip, 11); 12101 r2 = self->f->push(self, (baset*)ip); 12102 ck_assert_ptr_ne(r2, null); 12103 r = cropElemAtBoolO(self,3); 12104 ck_assert(!r); 12105 s = toStringO(self); 12106 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12107 free(s); 12108 // index outside 12109 ck_assert(!cropElemAtBoolO(self, 20)); 12110 ck_assert(!cropElemAtBoolO(self, -5)); 12111 // empty list 12112 emptyO(self); 12113 ck_assert(!cropElemAtBoolO(self, 0)); 12114 ck_assert(!cropElemAtBoolO(self, -1)); 12115 r2 = self->f->pushUndefined(self); 12116 ck_assert_ptr_ne(r2, null); 12117 delElemIndexO(self,-1); 12118 r = cropElemAtBoolO(self, 0); 12119 ck_assert(!r); 12120 // non json array 12121 freeO(self); 12122 setTypeBoolO(self); 12123 ck_assert(!cropElemAtBoolO(self, 0)); 12124 terminateO(self); 12125 12126 } 12127 12128 12129 void cropElemAtDoubleSmallJsonT(void) { 12130 12131 double r; 12132 smallJsont *self = allocSmallJson(); 12133 smallJsont *r2; 12134 12135 // add elements to self 12136 r2 = self->f->pushInt(self, 1); 12137 ck_assert_ptr_ne(r2, null); 12138 r2 = self->f->pushDouble(self, 2); 12139 ck_assert_ptr_ne(r2, null); 12140 r2 = self->f->pushInt(self, 3); 12141 ck_assert_ptr_ne(r2, null); 12142 r2 = self->f->pushDouble(self, 4); 12143 ck_assert_ptr_ne(r2, null); 12144 12145 // positive index 12146 r = cropElemAtDoubleO(self,1); 12147 ck_assert(r==2); 12148 char *s = toStringO(self); 12149 ck_assert_str_eq(s, "[1,3,4.000000e+00]"); 12150 free(s); 12151 // negative index 12152 r = cropElemAtDoubleO(self,-1); 12153 ck_assert(r==4); 12154 s = toStringO(self); 12155 ck_assert_str_eq(s, "[1,3]"); 12156 free(s); 12157 // wrong object type 12158 createSmallInt(I); 12159 setValG(&I, 11); 12160 r2 = self->f->pushSmallInt(self, &I); 12161 r = cropElemAtDoubleO(self,2); 12162 ck_assert(!r); 12163 s = toStringO(self); 12164 ck_assert_str_eq(s, "[1,3,11]"); 12165 free(s); 12166 // wrong object type of another user class 12167 // User classes are stored in containers transparently 12168 createAllocateSmallInt(ip); 12169 ip->type = "anothertype"; 12170 setValG(ip, 11); 12171 r2 = self->f->push(self, (baset*)ip); 12172 ck_assert_ptr_ne(r2, null); 12173 r = cropElemAtDoubleO(self,3); 12174 ck_assert(!r); 12175 s = toStringO(self); 12176 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12177 free(s); 12178 // index outside 12179 ck_assert(!cropElemAtDoubleO(self, 20)); 12180 ck_assert(!cropElemAtDoubleO(self, -5)); 12181 // empty list 12182 emptyO(self); 12183 ck_assert(!cropElemAtDoubleO(self, 0)); 12184 ck_assert(!cropElemAtDoubleO(self, -1)); 12185 r2 = self->f->pushUndefined(self); 12186 ck_assert_ptr_ne(r2, null); 12187 delElemIndexO(self,-1); 12188 r = cropElemAtDoubleO(self, 0); 12189 ck_assert(!r); 12190 // non json array 12191 freeO(self); 12192 setTypeBoolO(self); 12193 ck_assert(!cropElemAtDoubleO(self, 0)); 12194 terminateO(self); 12195 12196 } 12197 12198 12199 void cropElemAtIntSmallJsonT(void) { 12200 12201 int64_t r; 12202 smallJsont *self = allocSmallJson(); 12203 smallJsont *r2; 12204 12205 // add elements to self 12206 r2 = self->f->pushInt(self, 1); 12207 ck_assert_ptr_ne(r2, null); 12208 r2 = self->f->pushInt(self, 2); 12209 ck_assert_ptr_ne(r2, null); 12210 r2 = self->f->pushInt(self, 3); 12211 ck_assert_ptr_ne(r2, null); 12212 r2 = self->f->pushInt(self, 4); 12213 ck_assert_ptr_ne(r2, null); 12214 12215 // positive index 12216 r = cropElemAtIntO(self,1); 12217 ck_assert(r==2); 12218 char *s = toStringO(self); 12219 ck_assert_str_eq(s, "[1,3,4]"); 12220 free(s); 12221 // negative index 12222 r = cropElemAtIntO(self,-1); 12223 ck_assert(r==4); 12224 s = toStringO(self); 12225 ck_assert_str_eq(s, "[1,3]"); 12226 free(s); 12227 // wrong object type 12228 createSmallDouble(I); 12229 setValG(&I, 11); 12230 r2 = self->f->pushSmallDouble(self, &I); 12231 r = cropElemAtIntO(self,2); 12232 ck_assert(!r); 12233 s = toStringO(self); 12234 ck_assert_str_eq(s, "[1,3,1.100000e+01]"); 12235 free(s); 12236 // wrong object type of another user class 12237 // User classes are stored in containers transparently 12238 createAllocateSmallInt(ip); 12239 ip->type = "anothertype"; 12240 setValG(ip, 11); 12241 r2 = self->f->push(self, (baset*)ip); 12242 ck_assert_ptr_ne(r2, null); 12243 r = cropElemAtIntO(self,3); 12244 ck_assert(!r); 12245 s = toStringO(self); 12246 ck_assert_str_eq(s, "[1,3,1.100000e+01,\"<data container>\"]"); 12247 free(s); 12248 // index outside 12249 ck_assert(!cropElemAtIntO(self, 20)); 12250 ck_assert(!cropElemAtIntO(self, -5)); 12251 // empty list 12252 emptyO(self); 12253 ck_assert(!cropElemAtIntO(self, 0)); 12254 ck_assert(!cropElemAtIntO(self, -1)); 12255 r2 = self->f->pushUndefined(self); 12256 ck_assert_ptr_ne(r2, null); 12257 delElemIndexO(self,-1); 12258 r = cropElemAtIntO(self, 0); 12259 ck_assert(!r); 12260 // non json array 12261 freeO(self); 12262 setTypeBoolO(self); 12263 ck_assert(!cropElemAtO(self, 0)); 12264 terminateO(self); 12265 12266 } 12267 12268 12269 void cropElemAtInt32SmallJsonT(void) { 12270 12271 int32_t r; 12272 smallJsont *self = allocSmallJson(); 12273 smallJsont *r2; 12274 12275 // add elements to self 12276 r2 = self->f->pushInt(self, 1); 12277 ck_assert_ptr_ne(r2, null); 12278 r2 = self->f->pushInt(self, 2); 12279 ck_assert_ptr_ne(r2, null); 12280 r2 = self->f->pushInt(self, 3); 12281 ck_assert_ptr_ne(r2, null); 12282 r2 = self->f->pushInt(self, 4); 12283 ck_assert_ptr_ne(r2, null); 12284 12285 // positive index 12286 r = cropElemAtInt32O(self,1); 12287 ck_assert(r==2); 12288 char *s = toStringO(self); 12289 ck_assert_str_eq(s, "[1,3,4]"); 12290 free(s); 12291 // negative index 12292 r = cropElemAtInt32O(self,-1); 12293 ck_assert(r==4); 12294 s = toStringO(self); 12295 ck_assert_str_eq(s, "[1,3]"); 12296 free(s); 12297 // wrong object type 12298 createSmallDouble(I); 12299 setValG(&I, 11); 12300 r2 = self->f->pushSmallDouble(self, &I); 12301 r = cropElemAtInt32O(self,2); 12302 ck_assert(!r); 12303 s = toStringO(self); 12304 ck_assert_str_eq(s, "[1,3,1.100000e+01]"); 12305 free(s); 12306 // wrong object type of another user class 12307 // User classes are stored in containers transparently 12308 createAllocateSmallInt(ip); 12309 ip->type = "anothertype"; 12310 setValG(ip, 11); 12311 r2 = self->f->push(self, (baset*)ip); 12312 ck_assert_ptr_ne(r2, null); 12313 r = cropElemAtInt32O(self,3); 12314 ck_assert(!r); 12315 s = toStringO(self); 12316 ck_assert_str_eq(s, "[1,3,1.100000e+01,\"<data container>\"]"); 12317 free(s); 12318 // index outside 12319 ck_assert(!cropElemAtInt32O(self, 20)); 12320 ck_assert(!cropElemAtInt32O(self, -5)); 12321 // empty list 12322 emptyO(self); 12323 ck_assert(!cropElemAtInt32O(self, 0)); 12324 ck_assert(!cropElemAtInt32O(self, -1)); 12325 r2 = self->f->pushUndefined(self); 12326 ck_assert_ptr_ne(r2, null); 12327 delElemIndexO(self,-1); 12328 r = cropElemAtInt32O(self, 0); 12329 ck_assert(!r); 12330 // non json array 12331 freeO(self); 12332 setTypeBoolO(self); 12333 ck_assert(!cropElemAtO(self, 0)); 12334 terminateO(self); 12335 12336 } 12337 12338 12339 void cropElemAtUintSmallJsonT(void) { 12340 12341 uint64_t r; 12342 smallJsont *self = allocSmallJson(); 12343 smallJsont *r2; 12344 12345 // add elements to self 12346 r2 = self->f->pushInt(self, 1); 12347 ck_assert_ptr_ne(r2, null); 12348 r2 = self->f->pushInt(self, 2); 12349 ck_assert_ptr_ne(r2, null); 12350 r2 = self->f->pushInt(self, 3); 12351 ck_assert_ptr_ne(r2, null); 12352 r2 = self->f->pushInt(self, 4); 12353 ck_assert_ptr_ne(r2, null); 12354 12355 // positive index 12356 r = cropElemAtUintO(self,1); 12357 ck_assert(r==2); 12358 char *s = toStringO(self); 12359 ck_assert_str_eq(s, "[1,3,4]"); 12360 free(s); 12361 // negative index 12362 r = cropElemAtUintO(self,-1); 12363 ck_assert(r==4); 12364 s = toStringO(self); 12365 ck_assert_str_eq(s, "[1,3]"); 12366 free(s); 12367 // wrong object type 12368 createSmallDouble(I); 12369 setValG(&I, 11); 12370 r2 = self->f->pushSmallDouble(self, &I); 12371 r = cropElemAtUintO(self,2); 12372 ck_assert(!r); 12373 s = toStringO(self); 12374 ck_assert_str_eq(s, "[1,3,1.100000e+01]"); 12375 free(s); 12376 // wrong object type of another user class 12377 // User classes are stored in containers transparently 12378 createAllocateSmallInt(ip); 12379 ip->type = "anothertype"; 12380 setValG(ip, 11); 12381 r2 = self->f->push(self, (baset*)ip); 12382 ck_assert_ptr_ne(r2, null); 12383 r = cropElemAtUintO(self,3); 12384 ck_assert(!r); 12385 s = toStringO(self); 12386 ck_assert_str_eq(s, "[1,3,1.100000e+01,\"<data container>\"]"); 12387 free(s); 12388 // index outside 12389 ck_assert(!cropElemAtUintO(self, 20)); 12390 ck_assert(!cropElemAtUintO(self, -5)); 12391 // empty list 12392 emptyO(self); 12393 ck_assert(!cropElemAtUintO(self, 0)); 12394 ck_assert(!cropElemAtUintO(self, -1)); 12395 r2 = self->f->pushUndefined(self); 12396 ck_assert_ptr_ne(r2, null); 12397 delElemIndexO(self,-1); 12398 r = cropElemAtUintO(self, 0); 12399 ck_assert(!r); 12400 // non json array 12401 freeO(self); 12402 setTypeBoolO(self); 12403 ck_assert(!cropElemAtUintO(self, 0)); 12404 terminateO(self); 12405 12406 } 12407 12408 12409 void cropElemAtUint32SmallJsonT(void) { 12410 12411 uint32_t r; 12412 smallJsont *self = allocSmallJson(); 12413 smallJsont *r2; 12414 12415 // add elements to self 12416 r2 = self->f->pushInt(self, 1); 12417 ck_assert_ptr_ne(r2, null); 12418 r2 = self->f->pushInt(self, 2); 12419 ck_assert_ptr_ne(r2, null); 12420 r2 = self->f->pushInt(self, 3); 12421 ck_assert_ptr_ne(r2, null); 12422 r2 = self->f->pushInt(self, 4); 12423 ck_assert_ptr_ne(r2, null); 12424 12425 // positive index 12426 r = cropElemAtUint32O(self,1); 12427 ck_assert(r==2); 12428 char *s = toStringO(self); 12429 ck_assert_str_eq(s, "[1,3,4]"); 12430 free(s); 12431 // negative index 12432 r = cropElemAtUint32O(self,-1); 12433 ck_assert(r==4); 12434 s = toStringO(self); 12435 ck_assert_str_eq(s, "[1,3]"); 12436 free(s); 12437 // wrong object type 12438 createSmallDouble(I); 12439 setValG(&I, 11); 12440 r2 = self->f->pushSmallDouble(self, &I); 12441 r = cropElemAtUint32O(self,2); 12442 ck_assert(!r); 12443 s = toStringO(self); 12444 ck_assert_str_eq(s, "[1,3,1.100000e+01]"); 12445 free(s); 12446 // wrong object type of another user class 12447 // User classes are stored in containers transparently 12448 createAllocateSmallInt(ip); 12449 ip->type = "anothertype"; 12450 setValG(ip, 11); 12451 r2 = self->f->push(self, (baset*)ip); 12452 ck_assert_ptr_ne(r2, null); 12453 r = cropElemAtUint32O(self,3); 12454 ck_assert(!r); 12455 s = toStringO(self); 12456 ck_assert_str_eq(s, "[1,3,1.100000e+01,\"<data container>\"]"); 12457 free(s); 12458 // index outside 12459 ck_assert(!cropElemAtUint32O(self, 20)); 12460 ck_assert(!cropElemAtUint32O(self, -5)); 12461 // empty list 12462 emptyO(self); 12463 ck_assert(!cropElemAtUint32O(self, 0)); 12464 ck_assert(!cropElemAtUint32O(self, -1)); 12465 r2 = self->f->pushUndefined(self); 12466 ck_assert_ptr_ne(r2, null); 12467 delElemIndexO(self,-1); 12468 r = cropElemAtUint32O(self, 0); 12469 ck_assert(!r); 12470 // non json array 12471 freeO(self); 12472 setTypeBoolO(self); 12473 ck_assert(!cropElemAtUint32O(self, 0)); 12474 terminateO(self); 12475 12476 } 12477 12478 12479 void cropElemAtSSmallJsonT(void) { 12480 12481 char* r; 12482 smallJsont *self = allocSmallJson(); 12483 smallJsont *r2; 12484 12485 // add elements to self 12486 r2 = self->f->pushInt(self, 1); 12487 ck_assert_ptr_ne(r2, null); 12488 r2 = self->f->pushS(self, "2"); 12489 ck_assert_ptr_ne(r2, null); 12490 r2 = self->f->pushInt(self, 3); 12491 ck_assert_ptr_ne(r2, null); 12492 r2 = self->f->pushS(self, "4"); 12493 ck_assert_ptr_ne(r2, null); 12494 12495 // positive index 12496 r = cropElemAtSO(self,1); 12497 ck_assert_ptr_ne(r, null); 12498 ck_assert_str_eq(r, "2"); 12499 free(r); 12500 char *s = toStringO(self); 12501 ck_assert_str_eq(s, "[1,3,\"4\"]"); 12502 free(s); 12503 // negative index 12504 r = cropElemAtSO(self,-1); 12505 ck_assert_ptr_ne(r, null); 12506 ck_assert_str_eq(r, "4"); 12507 free(r); 12508 s = toStringO(self); 12509 ck_assert_str_eq(s, "[1,3]"); 12510 free(s); 12511 // wrong object type 12512 createSmallInt(I); 12513 setValG(&I, 11); 12514 r2 = self->f->pushSmallInt(self, &I); 12515 r = cropElemAtSO(self,2); 12516 ck_assert_ptr_eq(r, NULL); 12517 s = toStringO(self); 12518 ck_assert_str_eq(s, "[1,3,11]"); 12519 free(s); 12520 // wrong object type of another user class 12521 // User classes are stored in containers transparently 12522 createAllocateSmallInt(ip); 12523 ip->type = "anothertype"; 12524 setValG(ip, 11); 12525 r2 = self->f->push(self, (baset*)ip); 12526 ck_assert_ptr_ne(r2, null); 12527 r = cropElemAtSO(self,3); 12528 ck_assert_ptr_eq(r, NULL); 12529 s = toStringO(self); 12530 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12531 free(s); 12532 // index outside 12533 ck_assert_ptr_eq(cropElemAtSO(self, 20), NULL); 12534 ck_assert_ptr_eq(cropElemAtSO(self, -5), NULL); 12535 // empty list 12536 emptyO(self); 12537 ck_assert_ptr_eq(cropElemAtSO(self, 0), NULL); 12538 ck_assert_ptr_eq(cropElemAtSO(self, -1), NULL); 12539 r2 = self->f->pushUndefined(self); 12540 ck_assert_ptr_ne(r2, null); 12541 delElemIndexO(self,-1); 12542 r = cropElemAtSO(self, 0); 12543 ck_assert_ptr_eq(r, null); 12544 // non json array 12545 freeO(self); 12546 setTypeBoolO(self); 12547 ck_assert_ptr_eq(cropElemAtSO(self, 0), NULL); 12548 terminateO(self); 12549 12550 } 12551 12552 12553 void cropElemAtCharSmallJsonT(void) { 12554 12555 char r; 12556 smallJsont *self = allocSmallJson(); 12557 setTopSO(self, ""); 12558 12559 // crop 12560 freeO(self); 12561 setTopSO(self, "sheepy"); 12562 r = cropElemAtCharO(self, 0); 12563 ck_assert_int_eq(r, 's'); 12564 ck_assert_str_eq(sjGet(self), "heepy"); 12565 freeO(self); 12566 setTopSO(self, "sheepy"); 12567 r = cropElemAtCharO(self, 5); 12568 ck_assert_int_eq(r, 'y'); 12569 ck_assert_str_eq(sjGet(self), "sheep"); 12570 // negative index 12571 freeO(self); 12572 setTopSO(self, "sheepy"); 12573 r = cropElemAtCharO(self, -1); 12574 ck_assert_int_eq(r, 'y'); 12575 ck_assert_str_eq(sjGet(self), "sheep"); 12576 freeO(self); 12577 setTopSO(self, "sheepy"); 12578 r = cropElemAtCharO(self, -6); 12579 ck_assert_int_eq(r, 's'); 12580 ck_assert_str_eq(sjGet(self), "heepy"); 12581 // index outside string 12582 freeO(self); 12583 setTopSO(self, "sheepy"); 12584 r = cropElemAtCharO(self, 6); 12585 ck_assert_int_eq(r, 0); 12586 ck_assert_str_eq(sjGet(self), "sheepy"); 12587 freeO(self); 12588 setTopSO(self, "sheepy"); 12589 r = cropElemAtCharO(self, -7); 12590 ck_assert_int_eq(r, 0); 12591 ck_assert_str_eq(sjGet(self), "sheepy"); 12592 // null string 12593 freeO(self); 12594 ck_assert_int_eq(cropElemAtCharO(self, 0), 0); 12595 terminateO(self); 12596 12597 } 12598 12599 12600 void cropElemAtDictSmallJsonT(void) { 12601 12602 smallDictt* r; 12603 smallJsont *self = allocSmallJson(); 12604 smallJsont *r2; 12605 12606 // add elements to self 12607 r2 = self->f->pushInt(self, 1); 12608 ck_assert_ptr_ne(r2, null); 12609 createSmallDict(e2); 12610 r2 = self->f->pushDict(self, &e2); 12611 ck_assert_ptr_ne(r2, null); 12612 r2 = self->f->pushInt(self, 3); 12613 ck_assert_ptr_ne(r2, null); 12614 createSmallDict(e4); 12615 r2 = self->f->pushDict(self, &e4); 12616 ck_assert_ptr_ne(r2, null); 12617 12618 // positive index 12619 r = cropElemAtDictO(self,1); 12620 ck_assert_ptr_ne(r, null); 12621 char *s = toStringO(r); 12622 terminateO(r); 12623 ck_assert_str_eq(s, "{}"); 12624 free(s); 12625 s = toStringO(self); 12626 ck_assert_str_eq(s, "[1,3,{}]"); 12627 free(s); 12628 // negative index 12629 r = cropElemAtDictO(self,-1); 12630 ck_assert_ptr_ne(r, null); 12631 s = toStringO(r); 12632 terminateO(r); 12633 ck_assert_str_eq(s, "{}"); 12634 free(s); 12635 s = toStringO(self); 12636 ck_assert_str_eq(s, "[1,3]"); 12637 free(s); 12638 // wrong object type 12639 createSmallInt(I); 12640 setValG(&I, 11); 12641 r2 = self->f->pushSmallInt(self, &I); 12642 r = cropElemAtDictO(self,2); 12643 ck_assert_ptr_eq(r, NULL); 12644 s = toStringO(self); 12645 ck_assert_str_eq(s, "[1,3,11]"); 12646 free(s); 12647 // wrong object type of another user class 12648 // User classes are stored in containers transparently 12649 createAllocateSmallInt(ip); 12650 ip->type = "anothertype"; 12651 setValG(ip, 11); 12652 r2 = self->f->push(self, (baset*)ip); 12653 ck_assert_ptr_ne(r2, null); 12654 r = cropElemAtDictO(self,3); 12655 ck_assert_ptr_eq(r, NULL); 12656 s = toStringO(self); 12657 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12658 free(s); 12659 // index outside 12660 ck_assert_ptr_eq(cropElemAtDictO(self, 20), NULL); 12661 ck_assert_ptr_eq(cropElemAtDictO(self, -5), NULL); 12662 // empty list 12663 emptyO(self); 12664 ck_assert_ptr_eq(cropElemAtDictO(self, 0), NULL); 12665 ck_assert_ptr_eq(cropElemAtDictO(self, -1), NULL); 12666 r2 = self->f->pushUndefined(self); 12667 ck_assert_ptr_ne(r2, null); 12668 delElemIndexO(self,-1); 12669 r = cropElemAtDictO(self, 0); 12670 ck_assert_ptr_eq(r, null); 12671 // non json array 12672 freeO(self); 12673 setTypeBoolO(self); 12674 ck_assert_ptr_eq(cropElemAtDictO(self, 0), NULL); 12675 terminateO(self); 12676 12677 } 12678 12679 12680 void cropElemAtArraySmallJsonT(void) { 12681 12682 smallArrayt* r; 12683 smallJsont *self = allocSmallJson(); 12684 smallJsont *r2; 12685 12686 // add elements to self 12687 r2 = self->f->pushInt(self, 1); 12688 ck_assert_ptr_ne(r2, null); 12689 createSmallArray(e2); 12690 r2 = self->f->pushArray(self, &e2); 12691 ck_assert_ptr_ne(r2, null); 12692 r2 = self->f->pushInt(self, 3); 12693 ck_assert_ptr_ne(r2, null); 12694 createSmallArray(e4); 12695 r2 = self->f->pushArray(self, &e4); 12696 ck_assert_ptr_ne(r2, null); 12697 12698 // positive index 12699 r = cropElemAtArrayO(self,1); 12700 ck_assert_ptr_ne(r, null); 12701 char *s = toStringO(r); 12702 terminateO(r); 12703 ck_assert_str_eq(s, "[]"); 12704 free(s); 12705 s = toStringO(self); 12706 ck_assert_str_eq(s, "[1,3,[]]"); 12707 free(s); 12708 // negative index 12709 r = cropElemAtArrayO(self,-1); 12710 ck_assert_ptr_ne(r, null); 12711 s = toStringO(r); 12712 terminateO(r); 12713 ck_assert_str_eq(s, "[]"); 12714 free(s); 12715 s = toStringO(self); 12716 ck_assert_str_eq(s, "[1,3]"); 12717 free(s); 12718 // wrong object type 12719 createSmallInt(I); 12720 setValG(&I, 11); 12721 r2 = self->f->pushSmallInt(self, &I); 12722 r = cropElemAtArrayO(self,2); 12723 ck_assert_ptr_eq(r, NULL); 12724 s = toStringO(self); 12725 ck_assert_str_eq(s, "[1,3,11]"); 12726 free(s); 12727 // wrong object type of another user class 12728 // User classes are stored in containers transparently 12729 createAllocateSmallInt(ip); 12730 ip->type = "anothertype"; 12731 setValG(ip, 11); 12732 r2 = self->f->push(self, (baset*)ip); 12733 ck_assert_ptr_ne(r2, null); 12734 r = cropElemAtArrayO(self,3); 12735 ck_assert_ptr_eq(r, NULL); 12736 s = toStringO(self); 12737 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12738 free(s); 12739 // index outside 12740 ck_assert_ptr_eq(cropElemAtArrayO(self, 20), NULL); 12741 ck_assert_ptr_eq(cropElemAtArrayO(self, -5), NULL); 12742 // empty list 12743 emptyO(self); 12744 ck_assert_ptr_eq(cropElemAtArrayO(self, 0), NULL); 12745 ck_assert_ptr_eq(cropElemAtArrayO(self, -1), NULL); 12746 r2 = self->f->pushUndefined(self); 12747 ck_assert_ptr_ne(r2, null); 12748 delElemIndexO(self,-1); 12749 r = cropElemAtArrayO(self, 0); 12750 ck_assert_ptr_eq(r, null); 12751 // non json array 12752 freeO(self); 12753 setTypeBoolO(self); 12754 ck_assert_ptr_eq(cropElemAtArrayO(self, 0), NULL); 12755 terminateO(self); 12756 12757 } 12758 12759 12760 void cropElemAtSmallBoolSmallJsonT(void) { 12761 12762 smallBoolt* r; 12763 smallJsont *self = allocSmallJson(); 12764 smallJsont *r2; 12765 12766 // add elements to self 12767 r2 = self->f->pushInt(self, 1); 12768 ck_assert_ptr_ne(r2, null); 12769 createSmallBool(e2); 12770 r2 = self->f->pushBool(self, true); 12771 ck_assert_ptr_ne(r2, null); 12772 r2 = self->f->pushInt(self, 3); 12773 ck_assert_ptr_ne(r2, null); 12774 createSmallBool(e4); 12775 r2 = self->f->pushBool(self, true); 12776 ck_assert_ptr_ne(r2, null); 12777 12778 // positive index 12779 r = cropElemAtSmallBoolO(self,1); 12780 ck_assert_ptr_ne(r, null); 12781 char *s = toStringO(r); 12782 terminateO(r); 12783 ck_assert_str_eq(s, "true"); 12784 free(s); 12785 s = toStringO(self); 12786 ck_assert_str_eq(s, "[1,3,true]"); 12787 free(s); 12788 // negative index 12789 r = cropElemAtSmallBoolO(self,-1); 12790 ck_assert_ptr_ne(r, null); 12791 s = toStringO(r); 12792 terminateO(r); 12793 ck_assert_str_eq(s, "true"); 12794 free(s); 12795 s = toStringO(self); 12796 ck_assert_str_eq(s, "[1,3]"); 12797 free(s); 12798 // wrong object type 12799 createSmallInt(I); 12800 setValG(&I, 11); 12801 r2 = self->f->pushSmallInt(self, &I); 12802 r = cropElemAtSmallBoolO(self,2); 12803 ck_assert_ptr_eq(r, NULL); 12804 s = toStringO(self); 12805 ck_assert_str_eq(s, "[1,3,11]"); 12806 free(s); 12807 // wrong object type of another user class 12808 // User classes are stored in containers transparently 12809 createAllocateSmallInt(ip); 12810 ip->type = "anothertype"; 12811 setValG(ip, 11); 12812 r2 = self->f->push(self, (baset*)ip); 12813 ck_assert_ptr_ne(r2, null); 12814 r = cropElemAtSmallBoolO(self,3); 12815 ck_assert_ptr_eq(r, NULL); 12816 s = toStringO(self); 12817 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12818 free(s); 12819 // index outside 12820 ck_assert_ptr_eq(cropElemAtSmallBoolO(self, 20), NULL); 12821 ck_assert_ptr_eq(cropElemAtSmallBoolO(self, -5), NULL); 12822 // empty list 12823 emptyO(self); 12824 ck_assert_ptr_eq(cropElemAtSmallBoolO(self, 0), NULL); 12825 ck_assert_ptr_eq(cropElemAtSmallBoolO(self, -1), NULL); 12826 r2 = self->f->pushUndefined(self); 12827 ck_assert_ptr_ne(r2, null); 12828 delElemIndexO(self,-1); 12829 r = cropElemAtSmallBoolO(self, 0); 12830 ck_assert_ptr_eq(r, null); 12831 // non json array 12832 freeO(self); 12833 setTypeBoolO(self); 12834 ck_assert_ptr_eq(cropElemAtSmallBoolO(self, 0), NULL); 12835 terminateO(self); 12836 12837 } 12838 12839 12840 void cropElemAtSmallBytesSmallJsonT(void) { 12841 12842 smallBytest* r; 12843 smallJsont *self = allocSmallJson(); 12844 smallJsont *r2; 12845 12846 // add elements to self 12847 r2 = self->f->pushInt(self, 1); 12848 ck_assert_ptr_ne(r2, null); 12849 createSmallBytes(e2); 12850 r2 = self->f->pushSmallBytes(self, &e2); 12851 ck_assert_ptr_ne(r2, null); 12852 r2 = self->f->pushInt(self, 3); 12853 ck_assert_ptr_ne(r2, null); 12854 createSmallBytes(e4); 12855 r2 = self->f->pushSmallBytes(self, &e4); 12856 ck_assert_ptr_ne(r2, null); 12857 12858 // positive index 12859 r = cropElemAtSmallBytesO(self,1); 12860 ck_assert_ptr_ne(r, null); 12861 char *s = toStringO(r); 12862 terminateO(r); 12863 ck_assert_str_eq(s, "[]"); 12864 free(s); 12865 s = toStringO(self); 12866 ck_assert_str_eq(s, "[1,3,[]]"); 12867 free(s); 12868 // negative index 12869 r = cropElemAtSmallBytesO(self,-1); 12870 ck_assert_ptr_ne(r, null); 12871 s = toStringO(r); 12872 terminateO(r); 12873 ck_assert_str_eq(s, "[]"); 12874 free(s); 12875 s = toStringO(self); 12876 ck_assert_str_eq(s, "[1,3]"); 12877 free(s); 12878 // wrong object type 12879 createSmallInt(I); 12880 setValG(&I, 11); 12881 r2 = self->f->pushSmallInt(self, &I); 12882 r = cropElemAtSmallBytesO(self,2); 12883 ck_assert_ptr_eq(r, NULL); 12884 s = toStringO(self); 12885 ck_assert_str_eq(s, "[1,3,11]"); 12886 free(s); 12887 // wrong object type of another user class 12888 // User classes are stored in containers transparently 12889 createAllocateSmallInt(ip); 12890 ip->type = "anothertype"; 12891 setValG(ip, 11); 12892 r2 = self->f->push(self, (baset*)ip); 12893 ck_assert_ptr_ne(r2, null); 12894 r = cropElemAtSmallBytesO(self,3); 12895 ck_assert_ptr_eq(r, NULL); 12896 s = toStringO(self); 12897 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12898 free(s); 12899 // index outside 12900 ck_assert_ptr_eq(cropElemAtSmallBytesO(self, 20), NULL); 12901 ck_assert_ptr_eq(cropElemAtSmallBytesO(self, -5), NULL); 12902 // empty list 12903 emptyO(self); 12904 ck_assert_ptr_eq(cropElemAtSmallBytesO(self, 0), NULL); 12905 ck_assert_ptr_eq(cropElemAtSmallBytesO(self, -1), NULL); 12906 r2 = self->f->pushUndefined(self); 12907 ck_assert_ptr_ne(r2, null); 12908 delElemIndexO(self,-1); 12909 r = cropElemAtSmallBytesO(self, 0); 12910 ck_assert_ptr_eq(r, null); 12911 // non json array 12912 freeO(self); 12913 setTypeBoolO(self); 12914 ck_assert_ptr_eq(cropElemAtSmallBytesO(self, 0), NULL); 12915 terminateO(self); 12916 12917 } 12918 12919 12920 void cropElemAtSmallDoubleSmallJsonT(void) { 12921 12922 smallDoublet* r; 12923 smallJsont *self = allocSmallJson(); 12924 smallJsont *r2; 12925 12926 // add elements to self 12927 r2 = self->f->pushInt(self, 1); 12928 ck_assert_ptr_ne(r2, null); 12929 createSmallDouble(e2); 12930 r2 = self->f->pushSmallDouble(self, &e2); 12931 ck_assert_ptr_ne(r2, null); 12932 r2 = self->f->pushInt(self, 3); 12933 ck_assert_ptr_ne(r2, null); 12934 createSmallDouble(e4); 12935 r2 = self->f->pushSmallDouble(self, &e4); 12936 ck_assert_ptr_ne(r2, null); 12937 12938 // positive index 12939 r = cropElemAtSmallDoubleO(self,1); 12940 ck_assert_ptr_ne(r, null); 12941 char *s = toStringO(r); 12942 terminateO(r); 12943 ck_assert_str_eq(s, "0.000000e+00"); 12944 free(s); 12945 s = toStringO(self); 12946 ck_assert_str_eq(s, "[1,3,0.000000e+00]"); 12947 free(s); 12948 // negative index 12949 r = cropElemAtSmallDoubleO(self,-1); 12950 ck_assert_ptr_ne(r, null); 12951 s = toStringO(r); 12952 terminateO(r); 12953 ck_assert_str_eq(s, "0.000000e+00"); 12954 free(s); 12955 s = toStringO(self); 12956 ck_assert_str_eq(s, "[1,3]"); 12957 free(s); 12958 // wrong object type 12959 createSmallInt(I); 12960 setValG(&I, 11); 12961 r2 = self->f->pushSmallInt(self, &I); 12962 r = cropElemAtSmallDoubleO(self,2); 12963 ck_assert_ptr_eq(r, NULL); 12964 s = toStringO(self); 12965 ck_assert_str_eq(s, "[1,3,11]"); 12966 free(s); 12967 // wrong object type of another user class 12968 // User classes are stored in containers transparently 12969 createAllocateSmallInt(ip); 12970 ip->type = "anothertype"; 12971 setValG(ip, 11); 12972 r2 = self->f->push(self, (baset*)ip); 12973 ck_assert_ptr_ne(r2, null); 12974 r = cropElemAtSmallDoubleO(self,3); 12975 ck_assert_ptr_eq(r, NULL); 12976 s = toStringO(self); 12977 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 12978 free(s); 12979 // index outside 12980 ck_assert_ptr_eq(cropElemAtSmallDoubleO(self, 20), NULL); 12981 ck_assert_ptr_eq(cropElemAtSmallDoubleO(self, -5), NULL); 12982 // empty list 12983 emptyO(self); 12984 ck_assert_ptr_eq(cropElemAtSmallDoubleO(self, 0), NULL); 12985 ck_assert_ptr_eq(cropElemAtSmallDoubleO(self, -1), NULL); 12986 r2 = self->f->pushUndefined(self); 12987 ck_assert_ptr_ne(r2, null); 12988 delElemIndexO(self,-1); 12989 r = cropElemAtSmallDoubleO(self, 0); 12990 ck_assert_ptr_eq(r, null); 12991 // non json array 12992 freeO(self); 12993 setTypeBoolO(self); 12994 ck_assert_ptr_eq(cropElemAtSmallDoubleO(self, 0), NULL); 12995 terminateO(self); 12996 12997 } 12998 12999 13000 void cropElemAtSmallIntSmallJsonT(void) { 13001 13002 smallIntt* r; 13003 smallJsont *self = allocSmallJson(); 13004 smallJsont *r2; 13005 13006 // add elements to self 13007 r2 = self->f->pushBool(self, true); 13008 ck_assert_ptr_ne(r2, null); 13009 createSmallInt(e2); 13010 r2 = self->f->pushSmallInt(self, &e2); 13011 ck_assert_ptr_ne(r2, null); 13012 r2 = self->f->pushBool(self, true); 13013 ck_assert_ptr_ne(r2, null); 13014 createSmallInt(e4); 13015 r2 = self->f->pushSmallInt(self, &e4); 13016 ck_assert_ptr_ne(r2, null); 13017 13018 // positive index 13019 r = cropElemAtSmallIntO(self,1); 13020 ck_assert_ptr_ne(r, null); 13021 char *s = toStringO(r); 13022 terminateO(r); 13023 ck_assert_str_eq(s, "0"); 13024 free(s); 13025 s = toStringO(self); 13026 ck_assert_str_eq(s, "[true,true,0]"); 13027 free(s); 13028 // negative index 13029 r = cropElemAtSmallIntO(self,-1); 13030 ck_assert_ptr_ne(r, null); 13031 s = toStringO(r); 13032 terminateO(r); 13033 ck_assert_str_eq(s, "0"); 13034 free(s); 13035 s = toStringO(self); 13036 ck_assert_str_eq(s, "[true,true]"); 13037 free(s); 13038 // wrong object type 13039 createSmallDouble(I); 13040 setValG(&I, 11); 13041 r2 = self->f->pushSmallDouble(self, &I); 13042 r = cropElemAtSmallIntO(self,2); 13043 ck_assert_ptr_eq(r, NULL); 13044 s = toStringO(self); 13045 ck_assert_str_eq(s, "[true,true,1.100000e+01]"); 13046 free(s); 13047 // wrong object type of another user class 13048 // User classes are stored in containers transparently 13049 createAllocateSmallInt(ip); 13050 ip->type = "anothertype"; 13051 setValG(ip, 11); 13052 r2 = self->f->push(self, (baset*)ip); 13053 ck_assert_ptr_ne(r2, null); 13054 r = cropElemAtSmallIntO(self,3); 13055 ck_assert_ptr_eq(r, NULL); 13056 s = toStringO(self); 13057 ck_assert_str_eq(s, "[true,true,1.100000e+01,\"<data container>\"]"); 13058 free(s); 13059 // index outside 13060 ck_assert_ptr_eq(cropElemAtSmallIntO(self, 20), NULL); 13061 ck_assert_ptr_eq(cropElemAtSmallIntO(self, -5), NULL); 13062 // empty list 13063 emptyO(self); 13064 ck_assert_ptr_eq(cropElemAtSmallIntO(self, 0), NULL); 13065 ck_assert_ptr_eq(cropElemAtSmallIntO(self, -1), NULL); 13066 r2 = self->f->pushUndefined(self); 13067 ck_assert_ptr_ne(r2, null); 13068 delElemIndexO(self,-1); 13069 r = cropElemAtSmallIntO(self, 0); 13070 ck_assert_ptr_eq(r, null); 13071 // non json array 13072 freeO(self); 13073 setTypeBoolO(self); 13074 ck_assert_ptr_eq(cropElemAtSmallIntO(self, 0), NULL); 13075 terminateO(self); 13076 13077 } 13078 13079 13080 void cropElemAtSmallJsonSmallJsonT(void) { 13081 13082 smallJsont* r; 13083 smallJsont *self = allocSmallJson(); 13084 smallJsont *r2; 13085 13086 // add elements to self 13087 r2 = self->f->pushInt(self, 1); 13088 ck_assert_ptr_ne(r2, null); 13089 createSmallJson(e2); 13090 r2 = self->f->pushSmallJson(self, &e2); 13091 ck_assert_ptr_ne(r2, null); 13092 r2 = self->f->pushInt(self, 3); 13093 ck_assert_ptr_ne(r2, null); 13094 createSmallJson(e4); 13095 r2 = self->f->pushSmallJson(self, &e4); 13096 ck_assert_ptr_ne(r2, null); 13097 13098 // positive index 13099 r = cropElemAtSmallJsonO(self,1); 13100 ck_assert_ptr_ne(r, null); 13101 char *s = toStringO(r); 13102 terminateO(r); 13103 ck_assert_str_eq(s, "{}"); 13104 free(s); 13105 s = toStringO(self); 13106 ck_assert_str_eq(s, "[1,3,{}]"); 13107 free(s); 13108 // negative index 13109 r = cropElemAtSmallJsonO(self,-1); 13110 ck_assert_ptr_ne(r, null); 13111 s = toStringO(r); 13112 terminateO(r); 13113 ck_assert_str_eq(s, "{}"); 13114 free(s); 13115 s = toStringO(self); 13116 ck_assert_str_eq(s, "[1,3]"); 13117 free(s); 13118 // wrong object type 13119 createSmallBytes(I); 13120 r2 = self->f->pushSmallBytes(self, &I); 13121 r = cropElemAtSmallJsonO(self,2); 13122 ck_assert_ptr_eq(r, NULL); 13123 s = toStringO(self); 13124 ck_assert_str_eq(s, "[1,3,[]]"); 13125 free(s); 13126 // wrong object type of another user class 13127 // User classes are stored in containers transparently 13128 createAllocateSmallInt(ip); 13129 ip->type = "anothertype"; 13130 setValG(ip, 11); 13131 r2 = self->f->push(self, (baset*)ip); 13132 ck_assert_ptr_ne(r2, null); 13133 r = cropElemAtSmallJsonO(self,3); 13134 ck_assert_ptr_eq(r, NULL); 13135 s = toStringO(self); 13136 ck_assert_str_eq(s, "[1,3,[],\"<data container>\"]"); 13137 free(s); 13138 // index outside 13139 ck_assert_ptr_eq(cropElemAtSmallJsonO(self, 20), NULL); 13140 ck_assert_ptr_eq(cropElemAtSmallJsonO(self, -5), NULL); 13141 // empty list 13142 emptyO(self); 13143 ck_assert_ptr_eq(cropElemAtSmallJsonO(self, 0), NULL); 13144 ck_assert_ptr_eq(cropElemAtSmallJsonO(self, -1), NULL); 13145 r2 = self->f->pushUndefined(self); 13146 ck_assert_ptr_ne(r2, null); 13147 delElemIndexO(self,-1); 13148 r = cropElemAtSmallJsonO(self, 0); 13149 ck_assert_ptr_eq(r, null); 13150 // non json array 13151 freeO(self); 13152 setTypeBoolO(self); 13153 ck_assert_ptr_eq(cropElemAtSmallJsonO(self, 0), NULL); 13154 terminateO(self); 13155 13156 } 13157 13158 13159 void cropElemAtSmallStringSmallJsonT(void) { 13160 13161 smallStringt* r; 13162 smallJsont *self = allocSmallJson(); 13163 smallJsont *r2; 13164 13165 // add elements to self 13166 r2 = self->f->pushInt(self, 1); 13167 ck_assert_ptr_ne(r2, null); 13168 createSmallString(e2); 13169 r2 = self->f->pushSmallString(self, &e2); 13170 ck_assert_ptr_ne(r2, null); 13171 r2 = self->f->pushInt(self, 3); 13172 ck_assert_ptr_ne(r2, null); 13173 createSmallString(e4); 13174 r2 = self->f->pushSmallString(self, &e4); 13175 ck_assert_ptr_ne(r2, null); 13176 13177 // positive index 13178 r = cropElemAtSmallStringO(self,1); 13179 ck_assert_ptr_ne(r, null); 13180 char *s = toStringO(r); 13181 terminateO(r); 13182 ck_assert_str_eq(s, ""); 13183 free(s); 13184 s = toStringO(self); 13185 ck_assert_str_eq(s, "[1,3,\"\"]"); 13186 free(s); 13187 // negative index 13188 r = cropElemAtSmallStringO(self,-1); 13189 ck_assert_ptr_ne(r, null); 13190 s = toStringO(r); 13191 terminateO(r); 13192 ck_assert_str_eq(s, ""); 13193 free(s); 13194 s = toStringO(self); 13195 ck_assert_str_eq(s, "[1,3]"); 13196 free(s); 13197 // wrong object type 13198 createSmallInt(I); 13199 setValG(&I, 11); 13200 r2 = self->f->pushSmallInt(self, &I); 13201 r = cropElemAtSmallStringO(self,2); 13202 ck_assert_ptr_eq(r, NULL); 13203 s = toStringO(self); 13204 ck_assert_str_eq(s, "[1,3,11]"); 13205 free(s); 13206 // wrong object type of another user class 13207 // User classes are stored in containers transparently 13208 createAllocateSmallInt(ip); 13209 ip->type = "anothertype"; 13210 setValG(ip, 11); 13211 r2 = self->f->push(self, (baset*)ip); 13212 ck_assert_ptr_ne(r2, null); 13213 r = cropElemAtSmallStringO(self,3); 13214 ck_assert_ptr_eq(r, NULL); 13215 s = toStringO(self); 13216 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 13217 free(s); 13218 // index outside 13219 ck_assert_ptr_eq(cropElemAtSmallStringO(self, 20), NULL); 13220 ck_assert_ptr_eq(cropElemAtSmallStringO(self, -5), NULL); 13221 // empty list 13222 emptyO(self); 13223 ck_assert_ptr_eq(cropElemAtSmallStringO(self, 0), NULL); 13224 ck_assert_ptr_eq(cropElemAtSmallStringO(self, -1), NULL); 13225 r2 = self->f->pushUndefined(self); 13226 ck_assert_ptr_ne(r2, null); 13227 delElemIndexO(self,-1); 13228 r = cropElemAtSmallStringO(self, 0); 13229 ck_assert_ptr_eq(r, null); 13230 // non json array 13231 freeO(self); 13232 setTypeBoolO(self); 13233 ck_assert_ptr_eq(cropElemAtSmallStringO(self, 0), NULL); 13234 terminateO(self); 13235 13236 } 13237 13238 13239 void cropElemAtVoidSmallJsonT(void) { 13240 13241 void* r; 13242 smallJsont *self = allocSmallJson(); 13243 smallJsont *r2; 13244 13245 // add elements to self 13246 r2 = self->f->pushInt(self, 1); 13247 ck_assert_ptr_ne(r2, null); 13248 r2 = pushVoidSmallJsonG(self, &r); 13249 ck_assert_ptr_ne(r2, null); 13250 r2 = self->f->pushInt(self, 3); 13251 ck_assert_ptr_ne(r2, null); 13252 r2 = pushVoidSmallJsonG(self, &self); 13253 ck_assert_ptr_ne(r2, null); 13254 13255 // positive index 13256 r = cropElemAtVoidO(self,1); 13257 ck_assert_ptr_eq(r, &r); 13258 char *s = toStringO(self); 13259 ck_assert_str_eq(s, "[1,3,\"<data container>\"]"); 13260 free(s); 13261 // negative index 13262 r = cropElemAtVoidO(self,-1); 13263 ck_assert_ptr_eq(r, &self); 13264 s = toStringO(self); 13265 ck_assert_str_eq(s, "[1,3]"); 13266 free(s); 13267 // wrong object type 13268 createSmallInt(I); 13269 setValG(&I, 11); 13270 r2 = self->f->pushSmallInt(self, &I); 13271 r = cropElemAtVoidO(self,2); 13272 ck_assert_ptr_eq(r, NULL); 13273 s = toStringO(self); 13274 ck_assert_str_eq(s, "[1,3,11]"); 13275 free(s); 13276 // wrong object type of another user class 13277 // User classes are stored in containers transparently 13278 createAllocateSmallInt(ip); 13279 ip->type = "anothertype"; 13280 setValG(ip, 11); 13281 r2 = self->f->push(self, (baset*)ip); 13282 ck_assert_ptr_ne(r2, null); 13283 r = cropElemAtVoidO(self,3); 13284 ck_assert_ptr_eq(r, NULL); 13285 s = toStringO(self); 13286 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 13287 free(s); 13288 // index outside 13289 ck_assert_ptr_eq(cropElemAtVoidO(self, 20), NULL); 13290 ck_assert_ptr_eq(cropElemAtVoidO(self, -5), NULL); 13291 // empty list 13292 emptyO(self); 13293 ck_assert_ptr_eq(cropElemAtVoidO(self, 0), NULL); 13294 ck_assert_ptr_eq(cropElemAtVoidO(self, -1), NULL); 13295 r2 = self->f->pushUndefined(self); 13296 ck_assert_ptr_ne(r2, null); 13297 delElemIndexO(self,-1); 13298 r = cropElemAtVoidO(self, 0); 13299 ck_assert_ptr_eq(r, null); 13300 // non json array 13301 freeO(self); 13302 setTypeBoolO(self); 13303 ck_assert_ptr_eq(cropElemAtVoidO(self, 0), NULL); 13304 terminateO(self); 13305 13306 } 13307 13308 13309 void cropElemAtSmallContainerSmallJsonT(void) { 13310 13311 smallContainert* r; 13312 smallJsont *self = allocSmallJson(); 13313 smallJsont *r2; 13314 13315 // add elements to self 13316 r2 = self->f->pushInt(self, 1); 13317 ck_assert_ptr_ne(r2, null); 13318 createSmallContainer(e2); 13319 r2 = self->f->pushSmallContainer(self, &e2); 13320 ck_assert_ptr_ne(r2, null); 13321 r2 = self->f->pushInt(self, 3); 13322 ck_assert_ptr_ne(r2, null); 13323 createSmallContainer(e4); 13324 r2 = self->f->pushSmallContainer(self, &e4); 13325 ck_assert_ptr_ne(r2, null); 13326 13327 // positive index 13328 r = cropElemAtSmallContainerO(self,1); 13329 ck_assert_ptr_ne(r, null); 13330 char *s = toStringO(r); 13331 terminateO(r); 13332 ck_assert_str_eq(s, "<data smallContainer>"); 13333 free(s); 13334 s = toStringO(self); 13335 ck_assert_str_eq(s, "[1,3,\"<data container>\"]"); 13336 free(s); 13337 // negative index 13338 r = cropElemAtSmallContainerO(self,-1); 13339 ck_assert_ptr_ne(r, null); 13340 s = toStringO(r); 13341 terminateO(r); 13342 ck_assert_str_eq(s, "<data smallContainer>"); 13343 free(s); 13344 s = toStringO(self); 13345 ck_assert_str_eq(s, "[1,3]"); 13346 free(s); 13347 // wrong object type 13348 createSmallInt(I); 13349 setValG(&I, 11); 13350 r2 = self->f->pushSmallInt(self, &I); 13351 r = cropElemAtSmallContainerO(self,2); 13352 ck_assert_ptr_eq(r, NULL); 13353 s = toStringO(self); 13354 ck_assert_str_eq(s, "[1,3,11]"); 13355 free(s); 13356 // wrong object type of another user class 13357 // User classes are stored in containers transparently 13358 createAllocateSmallInt(ip); 13359 ip->type = "anothertype"; 13360 setValG(ip, 11); 13361 r2 = self->f->push(self, (baset*)ip); 13362 ck_assert_ptr_ne(r2, null); 13363 r = cropElemAtSmallContainerO(self,3); 13364 ck_assert_ptr_eq(r, NULL); 13365 s = toStringO(self); 13366 ck_assert_str_eq(s, "[1,3,11,\"<data container>\"]"); 13367 free(s); 13368 // index outside 13369 ck_assert_ptr_eq(cropElemAtSmallContainerO(self, 20), NULL); 13370 ck_assert_ptr_eq(cropElemAtSmallContainerO(self, -5), NULL); 13371 // empty list 13372 emptyO(self); 13373 ck_assert_ptr_eq(cropElemAtSmallContainerO(self, 0), NULL); 13374 ck_assert_ptr_eq(cropElemAtSmallContainerO(self, -1), NULL); 13375 r2 = self->f->pushUndefined(self); 13376 ck_assert_ptr_ne(r2, null); 13377 delElemIndexO(self,-1); 13378 r = cropElemAtSmallContainerO(self, 0); 13379 ck_assert_ptr_eq(r, null); 13380 // non json array 13381 freeO(self); 13382 setTypeBoolO(self); 13383 ck_assert_ptr_eq(cropElemAtSmallContainerO(self, 0), NULL); 13384 terminateO(self); 13385 13386 } 13387 13388 13389 void cropElemKeySmallJsonT(void) { 13390 13391 baset* r; 13392 smallJsont *self = allocSmallJson(); 13393 smallJsont *r2; 13394 13395 r2 = self->f->setInt(self, "1", 1); 13396 ck_assert_ptr_ne(r2, null); 13397 r2 = self->f->setDouble(self, "2", 2.2); 13398 ck_assert_ptr_ne(r2, null); 13399 r2 = self->f->setS(self, "3", "2"); 13400 ck_assert_ptr_ne(r2, null); 13401 r2 = self->f->setUndefined(self, "u"); 13402 ck_assert_ptr_ne(r2, null); 13403 createSmallContainer(c); 13404 r2 = self->f->setSmallContainer(self, "c", &c); 13405 ck_assert_ptr_ne(r2, null); 13406 createAllocateSmallInt(I); 13407 setValG(I, 11); 13408 I->type = "anothertype"; 13409 r2 = self->f->set(self, "b", (baset*)I); 13410 ck_assert_ptr_ne(r2, null); 13411 // get int 13412 r = cropElemKeyO(self, "3"); 13413 ck_assert_ptr_ne(r, null); 13414 char *s = toStringO(r); 13415 terminateO(r); 13416 ck_assert_str_eq(s, "2"); 13417 free(s); 13418 s = toStringO(self); 13419 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"u\":null,\"c\":\"<data container>\",\"b\":\"<data container>\"}"); 13420 free(s); 13421 // undefined object 13422 r = cropElemKeyO(self, "u"); 13423 ck_assert_ptr_ne(r, null); 13424 s = toStringO(r); 13425 terminateO(r); 13426 ck_assert_str_eq(s, "null"); 13427 free(s); 13428 s = toStringO(self); 13429 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"c\":\"<data container>\",\"b\":\"<data container>\"}"); 13430 free(s); 13431 // container 13432 r = cropElemKeyO(self, "c"); 13433 ck_assert_ptr_ne(r, null); 13434 s = toStringO(r); 13435 terminateO(r); 13436 ck_assert_str_eq(s, "<data smallContainer>"); 13437 free(s); 13438 s = toStringO(self); 13439 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"b\":\"<data container>\"}"); 13440 free(s); 13441 // base object in container 13442 r = cropElemKeyO(self, "b"); 13443 ck_assert_ptr_ne(r, null); 13444 s = toStringO(r); 13445 terminateO(r); 13446 ck_assert_str_eq(s, "11"); 13447 free(s); 13448 s = toStringO(self); 13449 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00}"); 13450 free(s); 13451 // non existing key 13452 r = cropElemKeyO(self, "qwe"); 13453 ck_assert_ptr_eq(r, null); 13454 // null key 13455 r = cropElemKeyO(self, null); 13456 ck_assert_ptr_eq(r, null); 13457 // empty self 13458 freeO(self); 13459 r = cropElemKeyO(self, "1"); 13460 ck_assert_ptr_eq(r, null); 13461 terminateO(self); 13462 13463 } 13464 13465 13466 void cropElemKeyUndefinedSmallJsonT(void) { 13467 13468 undefinedt* r; 13469 smallJsont *self = allocSmallJson(); 13470 smallJsont *r2; 13471 13472 r2 = self->f->setInt(self, "1", 1); 13473 ck_assert_ptr_ne(r2, null); 13474 r2 = self->f->setDouble(self, "2", 2.2); 13475 ck_assert_ptr_ne(r2, null); 13476 r2 = self->f->setUndefined(self, "u"); 13477 ck_assert_ptr_ne(r2, null); 13478 r = cropElemKeyUndefinedO(self, "u"); 13479 ck_assert_ptr_ne(r, null); 13480 char *s = toStringO(r); 13481 terminateO(r); 13482 ck_assert_str_eq(s, "null"); 13483 free(s); 13484 s = toStringO(self); 13485 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00}"); 13486 free(s); 13487 // wrong object type 13488 r = cropElemKeyUndefinedO(self, "1"); 13489 ck_assert_ptr_eq(r, null); 13490 s = toStringO(self); 13491 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00}"); 13492 free(s); 13493 // non existing key 13494 r = cropElemKeyUndefinedO(self, "qwe"); 13495 ck_assert_ptr_eq(r, null); 13496 // null key 13497 r = cropElemKeyUndefinedO(self, null); 13498 ck_assert_ptr_eq(r, null); 13499 // empty self 13500 freeO(self); 13501 r = cropElemKeyUndefinedO(self, "1"); 13502 ck_assert_ptr_eq(r, null); 13503 terminateO(self); 13504 13505 } 13506 13507 13508 void cropElemKeyBoolSmallJsonT(void) { 13509 13510 bool r; 13511 smallJsont *self = allocSmallJson(); 13512 smallJsont *r2; 13513 13514 r2 = self->f->setInt(self, "1", 1); 13515 ck_assert_ptr_ne(r2, null); 13516 r2 = self->f->setDouble(self, "2", 2.2); 13517 ck_assert_ptr_ne(r2, null); 13518 r2 = self->f->setBool(self, "b", true); 13519 ck_assert_ptr_ne(r2, null); 13520 createAllocateSmallInt(I); 13521 setValG(I, 11); 13522 I->type = "anothertype"; 13523 r2 = self->f->set(self, "B", (baset*)I); 13524 ck_assert_ptr_ne(r2, null); 13525 r = cropElemKeyBoolO(self, "b"); 13526 ck_assert(r); 13527 char *s = toStringO(self); 13528 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13529 free(s); 13530 // wrong object type 13531 r = cropElemKeyBoolO(self, "1"); 13532 ck_assert(!r); 13533 s = toStringO(self); 13534 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13535 free(s); 13536 r = cropElemKeyBoolO(self, "B"); 13537 ck_assert(!r); 13538 s = toStringO(self); 13539 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13540 free(s); 13541 // non existing key 13542 r = cropElemKeyBoolO(self, "qwe"); 13543 ck_assert(!r); 13544 // null key 13545 r = cropElemKeyBoolO(self, null); 13546 ck_assert(!r); 13547 // empty self 13548 freeO(self); 13549 r = cropElemKeyBoolO(self, "1"); 13550 ck_assert(!r); 13551 terminateO(self); 13552 13553 } 13554 13555 13556 void cropElemKeyDoubleSmallJsonT(void) { 13557 13558 double r; 13559 smallJsont *self = allocSmallJson(); 13560 smallJsont *r2; 13561 13562 r2 = self->f->setInt(self, "1", 1); 13563 ck_assert_ptr_ne(r2, null); 13564 r2 = self->f->setDouble(self, "2", 2.2); 13565 ck_assert_ptr_ne(r2, null); 13566 r2 = self->f->setDouble(self, "b", 3.3); 13567 ck_assert_ptr_ne(r2, null); 13568 createAllocateSmallInt(I); 13569 setValG(I, 11); 13570 I->type = "anothertype"; 13571 r2 = self->f->set(self, "B", (baset*)I); 13572 ck_assert_ptr_ne(r2, null); 13573 r = cropElemKeyDoubleO(self, "b"); 13574 ck_assert(r == 3.3); 13575 char *s = toStringO(self); 13576 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13577 free(s); 13578 // wrong object type 13579 r = cropElemKeyDoubleO(self, "1"); 13580 ck_assert(!r); 13581 s = toStringO(self); 13582 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13583 free(s); 13584 r = cropElemKeyDoubleO(self, "B"); 13585 ck_assert(!r); 13586 s = toStringO(self); 13587 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13588 free(s); 13589 // non existing key 13590 r = cropElemKeyDoubleO(self, "qwe"); 13591 ck_assert(!r); 13592 // null key 13593 r = cropElemKeyDoubleO(self, null); 13594 ck_assert(r == 0); 13595 // empty self 13596 freeO(self); 13597 r = cropElemKeyDoubleO(self, "1"); 13598 ck_assert(r == 0); 13599 terminateO(self); 13600 13601 } 13602 13603 13604 void cropElemKeyIntSmallJsonT(void) { 13605 13606 int64_t r; 13607 smallJsont *self = allocSmallJson(); 13608 smallJsont *r2; 13609 13610 r2 = self->f->setInt(self, "1", 1); 13611 ck_assert_ptr_ne(r2, null); 13612 r2 = self->f->setDouble(self, "2", 2.2); 13613 ck_assert_ptr_ne(r2, null); 13614 r2 = self->f->setInt(self, "b", 2); 13615 ck_assert_ptr_ne(r2, null); 13616 createAllocateSmallInt(I); 13617 setValG(I, 11); 13618 I->type = "anothertype"; 13619 r2 = self->f->set(self, "B", (baset*)I); 13620 ck_assert_ptr_ne(r2, null); 13621 r = cropElemKeyIntO(self, "b"); 13622 ck_assert_int_eq(r, 2); 13623 char *s = toStringO(self); 13624 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13625 free(s); 13626 // wrong object type 13627 r = cropElemKeyIntO(self, "2"); 13628 ck_assert(!r); 13629 s = toStringO(self); 13630 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13631 free(s); 13632 r = cropElemKeyIntO(self, "B"); 13633 ck_assert(!r); 13634 s = toStringO(self); 13635 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13636 free(s); 13637 // non existing key 13638 r = cropElemKeyIntO(self, "qwe"); 13639 ck_assert(!r); 13640 // null key 13641 r = cropElemKeyIntO(self, null); 13642 ck_assert_int_eq(r, 0); 13643 // empty self 13644 freeO(self); 13645 r = cropElemKeyIntO(self, "1"); 13646 ck_assert_int_eq(r, 0); 13647 terminateO(self); 13648 13649 } 13650 13651 13652 void cropElemKeyInt32SmallJsonT(void) { 13653 13654 int32_t r; 13655 smallJsont *self = allocSmallJson(); 13656 smallJsont *r2; 13657 13658 r2 = self->f->setInt(self, "1", 1); 13659 ck_assert_ptr_ne(r2, null); 13660 r2 = self->f->setDouble(self, "2", 2.2); 13661 ck_assert_ptr_ne(r2, null); 13662 r2 = self->f->setInt(self, "b", 2); 13663 ck_assert_ptr_ne(r2, null); 13664 createAllocateSmallInt(I); 13665 setValG(I, 11); 13666 I->type = "anothertype"; 13667 r2 = self->f->set(self, "B", (baset*)I); 13668 ck_assert_ptr_ne(r2, null); 13669 r = cropElemKeyInt32O(self, "b"); 13670 ck_assert_int_eq(r, 2); 13671 char *s = toStringO(self); 13672 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13673 free(s); 13674 // wrong object type 13675 r = cropElemKeyInt32O(self, "2"); 13676 ck_assert(!r); 13677 s = toStringO(self); 13678 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13679 free(s); 13680 r = cropElemKeyInt32O(self, "B"); 13681 ck_assert(!r); 13682 s = toStringO(self); 13683 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13684 free(s); 13685 // non existing key 13686 r = cropElemKeyInt32O(self, "qwe"); 13687 ck_assert(!r); 13688 // null key 13689 r = cropElemKeyInt32O(self, null); 13690 ck_assert_int_eq(r, 0); 13691 // empty self 13692 freeO(self); 13693 r = cropElemKeyInt32O(self, "1"); 13694 ck_assert_int_eq(r, 0); 13695 terminateO(self); 13696 13697 } 13698 13699 13700 void cropElemKeyUintSmallJsonT(void) { 13701 13702 uint64_t r; 13703 smallJsont *self = allocSmallJson(); 13704 smallJsont *r2; 13705 13706 r2 = self->f->setInt(self, "1", 1); 13707 ck_assert_ptr_ne(r2, null); 13708 r2 = self->f->setDouble(self, "2", 2.2); 13709 ck_assert_ptr_ne(r2, null); 13710 r2 = self->f->setInt(self, "b", 2); 13711 ck_assert_ptr_ne(r2, null); 13712 createAllocateSmallInt(I); 13713 setValG(I, 11); 13714 I->type = "anothertype"; 13715 r2 = self->f->set(self, "B", (baset*)I); 13716 ck_assert_ptr_ne(r2, null); 13717 r = cropElemKeyUintO(self, "b"); 13718 ck_assert_int_eq(r, 2); 13719 char *s = toStringO(self); 13720 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13721 free(s); 13722 // wrong object type 13723 r = cropElemKeyUintO(self, "2"); 13724 ck_assert(!r); 13725 s = toStringO(self); 13726 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13727 free(s); 13728 r = cropElemKeyUintO(self, "B"); 13729 ck_assert(!r); 13730 s = toStringO(self); 13731 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13732 free(s); 13733 // non existing key 13734 r = cropElemKeyUintO(self, "qwe"); 13735 ck_assert(!r); 13736 // null key 13737 r = cropElemKeyUintO(self, null); 13738 ck_assert_int_eq(r, 0); 13739 // empty self 13740 freeO(self); 13741 r = cropElemKeyUintO(self, "1"); 13742 ck_assert_int_eq(r, 0); 13743 terminateO(self); 13744 13745 } 13746 13747 13748 void cropElemKeyUint32SmallJsonT(void) { 13749 13750 uint32_t r; 13751 smallJsont *self = allocSmallJson(); 13752 smallJsont *r2; 13753 13754 r2 = self->f->setInt(self, "1", 1); 13755 ck_assert_ptr_ne(r2, null); 13756 r2 = self->f->setDouble(self, "2", 2.2); 13757 ck_assert_ptr_ne(r2, null); 13758 r2 = self->f->setInt(self, "b", 2); 13759 ck_assert_ptr_ne(r2, null); 13760 createAllocateSmallInt(I); 13761 setValG(I, 11); 13762 I->type = "anothertype"; 13763 r2 = self->f->set(self, "B", (baset*)I); 13764 ck_assert_ptr_ne(r2, null); 13765 r = cropElemKeyUint32O(self, "b"); 13766 ck_assert_int_eq(r, 2); 13767 char *s = toStringO(self); 13768 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13769 free(s); 13770 // wrong object type 13771 r = cropElemKeyUint32O(self, "2"); 13772 ck_assert(!r); 13773 s = toStringO(self); 13774 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13775 free(s); 13776 r = cropElemKeyUint32O(self, "B"); 13777 ck_assert(!r); 13778 s = toStringO(self); 13779 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13780 free(s); 13781 // non existing key 13782 r = cropElemKeyUint32O(self, "qwe"); 13783 ck_assert(!r); 13784 // null key 13785 r = cropElemKeyUint32O(self, null); 13786 ck_assert_int_eq(r, 0); 13787 // empty self 13788 freeO(self); 13789 r = cropElemKeyUint32O(self, "1"); 13790 ck_assert_int_eq(r, 0); 13791 terminateO(self); 13792 13793 } 13794 13795 13796 void cropElemKeySSmallJsonT(void) { 13797 13798 char* r; 13799 smallJsont *self = allocSmallJson(); 13800 smallJsont *r2; 13801 13802 r2 = self->f->setInt(self, "1", 1); 13803 ck_assert_ptr_ne(r2, null); 13804 r2 = self->f->setDouble(self, "2", 2.2); 13805 ck_assert_ptr_ne(r2, null); 13806 r2 = self->f->setS(self, "b", "qwe"); 13807 ck_assert_ptr_ne(r2, null); 13808 createAllocateSmallInt(I); 13809 setValG(I, 11); 13810 I->type = "anothertype"; 13811 r2 = self->f->set(self, "B", (baset*)I); 13812 ck_assert_ptr_ne(r2, null); 13813 r = cropElemKeySO(self, "b"); 13814 ck_assert_str_eq(r, "qwe"); 13815 free(r); 13816 char *s = toStringO(self); 13817 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13818 free(s); 13819 // wrong object type 13820 r = cropElemKeySO(self, "2"); 13821 ck_assert_ptr_eq(r, null); 13822 s = toStringO(self); 13823 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13824 free(s); 13825 r = cropElemKeySO(self, "B"); 13826 ck_assert_ptr_eq(r, null); 13827 s = toStringO(self); 13828 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13829 free(s); 13830 // non existing key 13831 r = cropElemKeySO(self, "qwe"); 13832 ck_assert_ptr_eq(r, null); 13833 // null key 13834 r = cropElemKeySO(self, null); 13835 ck_assert_ptr_eq(r, null); 13836 // empty self 13837 freeO(self); 13838 r = cropElemKeySO(self, "1"); 13839 ck_assert_ptr_eq(r, null); 13840 terminateO(self); 13841 13842 } 13843 13844 13845 void cropElemKeyDictSmallJsonT(void) { 13846 13847 smallDictt* r; 13848 smallJsont *self = allocSmallJson(); 13849 smallJsont *r2; 13850 13851 r2 = self->f->setInt(self, "1", 1); 13852 ck_assert_ptr_ne(r2, null); 13853 r2 = self->f->setDouble(self, "2", 2.2); 13854 ck_assert_ptr_ne(r2, null); 13855 createAllocateSmallDict(d); 13856 r2 = self->f->setNFreeDict(self, "b", d); 13857 ck_assert_ptr_ne(r2, null); 13858 createAllocateSmallInt(I); 13859 setValG(I, 11); 13860 I->type = "anothertype"; 13861 r2 = self->f->set(self, "B", (baset*)I); 13862 ck_assert_ptr_ne(r2, null); 13863 r = cropElemKeyDictO(self, "b"); 13864 ck_assert_ptr_ne(r, null); 13865 char *s = toStringO(r); 13866 terminateO(r); 13867 ck_assert_str_eq(s, "{}"); 13868 free(s); 13869 s = toStringO(self); 13870 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13871 free(s); 13872 // wrong object type 13873 r = cropElemKeyDictO(self, "2"); 13874 ck_assert_ptr_eq(r, null); 13875 s = toStringO(self); 13876 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13877 free(s); 13878 r = cropElemKeyDictO(self, "B"); 13879 ck_assert_ptr_eq(r, null); 13880 s = toStringO(self); 13881 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13882 free(s); 13883 // non existing key 13884 r = cropElemKeyDictO(self, "qwe"); 13885 ck_assert_ptr_eq(r, null); 13886 // null key 13887 r = cropElemKeyDictO(self, null); 13888 ck_assert_ptr_eq(r, null); 13889 // empty self 13890 freeO(self); 13891 r = cropElemKeyDictO(self, "1"); 13892 ck_assert_ptr_eq(r, null); 13893 terminateO(self); 13894 13895 } 13896 13897 13898 void cropElemKeyArraySmallJsonT(void) { 13899 13900 smallArrayt* r; 13901 smallJsont *self = allocSmallJson(); 13902 smallJsont *r2; 13903 13904 r2 = self->f->setInt(self, "1", 1); 13905 ck_assert_ptr_ne(r2, null); 13906 r2 = self->f->setDouble(self, "2", 2.2); 13907 ck_assert_ptr_ne(r2, null); 13908 createAllocateSmallArray(d); 13909 r2 = self->f->setNFreeArray(self, "b", d); 13910 ck_assert_ptr_ne(r2, null); 13911 createAllocateSmallInt(I); 13912 setValG(I, 11); 13913 I->type = "anothertype"; 13914 r2 = self->f->set(self, "B", (baset*)I); 13915 ck_assert_ptr_ne(r2, null); 13916 r = cropElemKeyArrayO(self, "b"); 13917 ck_assert_ptr_ne(r, null); 13918 char *s = toStringO(r); 13919 terminateO(r); 13920 ck_assert_str_eq(s, "[]"); 13921 free(s); 13922 s = toStringO(self); 13923 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13924 free(s); 13925 // wrong object type 13926 r = cropElemKeyArrayO(self, "2"); 13927 ck_assert_ptr_eq(r, null); 13928 s = toStringO(self); 13929 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13930 free(s); 13931 r = cropElemKeyArrayO(self, "B"); 13932 ck_assert_ptr_eq(r, null); 13933 s = toStringO(self); 13934 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13935 free(s); 13936 // non existing key 13937 r = cropElemKeyArrayO(self, "qwe"); 13938 ck_assert_ptr_eq(r, null); 13939 // null key 13940 r = cropElemKeyArrayO(self, null); 13941 ck_assert_ptr_eq(r, null); 13942 // empty self 13943 freeO(self); 13944 r = cropElemKeyArrayO(self, "1"); 13945 ck_assert_ptr_eq(r, null); 13946 terminateO(self); 13947 13948 } 13949 13950 13951 void cropElemKeySmallBoolSmallJsonT(void) { 13952 13953 smallBoolt* r; 13954 smallJsont *self = allocSmallJson(); 13955 smallJsont *r2; 13956 13957 r2 = self->f->setInt(self, "1", 1); 13958 ck_assert_ptr_ne(r2, null); 13959 r2 = self->f->setDouble(self, "2", 2.2); 13960 ck_assert_ptr_ne(r2, null); 13961 r2 = self->f->setBool(self, "b", true); 13962 ck_assert_ptr_ne(r2, null); 13963 createAllocateSmallInt(I); 13964 setValG(I, 11); 13965 I->type = "anothertype"; 13966 r2 = self->f->set(self, "B", (baset*)I); 13967 ck_assert_ptr_ne(r2, null); 13968 r = cropElemKeySmallBoolO(self, "b"); 13969 ck_assert_ptr_ne(r, null); 13970 char *s = toStringO(r); 13971 terminateO(r); 13972 ck_assert_str_eq(s, "true"); 13973 free(s); 13974 s = toStringO(self); 13975 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13976 free(s); 13977 // wrong object type 13978 r = cropElemKeySmallBoolO(self, "2"); 13979 ck_assert_ptr_eq(r, null); 13980 s = toStringO(self); 13981 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13982 free(s); 13983 r = cropElemKeySmallBoolO(self, "B"); 13984 ck_assert_ptr_eq(r, null); 13985 s = toStringO(self); 13986 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 13987 free(s); 13988 // non existing key 13989 r = cropElemKeySmallBoolO(self, "qwe"); 13990 ck_assert_ptr_eq(r, null); 13991 // null key 13992 r = cropElemKeySmallBoolO(self, null); 13993 ck_assert_ptr_eq(r, null); 13994 // empty self 13995 freeO(self); 13996 r = cropElemKeySmallBoolO(self, "1"); 13997 ck_assert_ptr_eq(r, null); 13998 terminateO(self); 13999 14000 } 14001 14002 14003 void cropElemKeySmallBytesSmallJsonT(void) { 14004 14005 smallBytest* r; 14006 smallJsont *self = allocSmallJson(); 14007 smallJsont *r2; 14008 14009 r2 = self->f->setInt(self, "1", 1); 14010 ck_assert_ptr_ne(r2, null); 14011 r2 = self->f->setDouble(self, "2", 2.2); 14012 ck_assert_ptr_ne(r2, null); 14013 createAllocateSmallBytes(d); 14014 r2 = self->f->setNFreeSmallBytes(self, "b", d); 14015 ck_assert_ptr_ne(r2, null); 14016 createAllocateSmallInt(I); 14017 setValG(I, 11); 14018 I->type = "anothertype"; 14019 r2 = self->f->set(self, "B", (baset*)I); 14020 ck_assert_ptr_ne(r2, null); 14021 r = cropElemKeySmallBytesO(self, "b"); 14022 ck_assert_ptr_ne(r, null); 14023 char *s = toStringO(r); 14024 terminateO(r); 14025 ck_assert_str_eq(s, "[]"); 14026 free(s); 14027 s = toStringO(self); 14028 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14029 free(s); 14030 // wrong object type 14031 r = cropElemKeySmallBytesO(self, "2"); 14032 ck_assert_ptr_eq(r, null); 14033 s = toStringO(self); 14034 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14035 free(s); 14036 r = cropElemKeySmallBytesO(self, "B"); 14037 ck_assert_ptr_eq(r, null); 14038 s = toStringO(self); 14039 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14040 free(s); 14041 // non existing key 14042 r = cropElemKeySmallBytesO(self, "qwe"); 14043 ck_assert_ptr_eq(r, null); 14044 // null key 14045 r = cropElemKeySmallBytesO(self, null); 14046 ck_assert_ptr_eq(r, null); 14047 // empty self 14048 freeO(self); 14049 r = cropElemKeySmallBytesO(self, "1"); 14050 ck_assert_ptr_eq(r, null); 14051 terminateO(self); 14052 14053 } 14054 14055 14056 void cropElemKeySmallDoubleSmallJsonT(void) { 14057 14058 smallDoublet* r; 14059 smallJsont *self = allocSmallJson(); 14060 smallJsont *r2; 14061 14062 r2 = self->f->setInt(self, "1", 1); 14063 ck_assert_ptr_ne(r2, null); 14064 r2 = self->f->setDouble(self, "2", 2.2); 14065 ck_assert_ptr_ne(r2, null); 14066 r2 = self->f->setDouble(self, "b", 3.3); 14067 ck_assert_ptr_ne(r2, null); 14068 createAllocateSmallInt(I); 14069 setValG(I, 11); 14070 I->type = "anothertype"; 14071 r2 = self->f->set(self, "B", (baset*)I); 14072 ck_assert_ptr_ne(r2, null); 14073 r = cropElemKeySmallDoubleO(self, "b"); 14074 ck_assert_ptr_ne(r, null); 14075 char *s = toStringO(r); 14076 terminateO(r); 14077 ck_assert_str_eq(s, "3.300000e+00"); 14078 free(s); 14079 s = toStringO(self); 14080 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14081 free(s); 14082 // wrong object type 14083 r = cropElemKeySmallDoubleO(self, "1"); 14084 ck_assert_ptr_eq(r, null); 14085 s = toStringO(self); 14086 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14087 free(s); 14088 r = cropElemKeySmallDoubleO(self, "B"); 14089 ck_assert_ptr_eq(r, null); 14090 s = toStringO(self); 14091 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14092 free(s); 14093 // non existing key 14094 r = cropElemKeySmallDoubleO(self, "qwe"); 14095 ck_assert_ptr_eq(r, null); 14096 // null key 14097 r = cropElemKeySmallDoubleO(self, null); 14098 ck_assert_ptr_eq(r, null); 14099 // empty self 14100 freeO(self); 14101 r = cropElemKeySmallDoubleO(self, "1"); 14102 ck_assert_ptr_eq(r, null); 14103 terminateO(self); 14104 14105 } 14106 14107 14108 void cropElemKeySmallIntSmallJsonT(void) { 14109 14110 smallIntt* r; 14111 smallJsont *self = allocSmallJson(); 14112 smallJsont *r2; 14113 14114 r2 = self->f->setInt(self, "1", 1); 14115 ck_assert_ptr_ne(r2, null); 14116 r2 = self->f->setDouble(self, "2", 2.2); 14117 ck_assert_ptr_ne(r2, null); 14118 r2 = self->f->setInt(self, "b", 2); 14119 ck_assert_ptr_ne(r2, null); 14120 createAllocateSmallInt(I); 14121 setValG(I, 11); 14122 I->type = "anothertype"; 14123 r2 = self->f->set(self, "B", (baset*)I); 14124 ck_assert_ptr_ne(r2, null); 14125 r = cropElemKeySmallIntO(self, "b"); 14126 ck_assert_ptr_ne(r, null); 14127 char *s = toStringO(r); 14128 terminateO(r); 14129 ck_assert_str_eq(s, "2"); 14130 free(s); 14131 s = toStringO(self); 14132 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14133 free(s); 14134 // wrong object type 14135 r = cropElemKeySmallIntO(self, "2"); 14136 ck_assert_ptr_eq(r, null); 14137 s = toStringO(self); 14138 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14139 free(s); 14140 r = cropElemKeySmallIntO(self, "B"); 14141 ck_assert_ptr_eq(r, null); 14142 s = toStringO(self); 14143 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14144 free(s); 14145 // non existing key 14146 r = cropElemKeySmallIntO(self, "qwe"); 14147 ck_assert_ptr_eq(r, null); 14148 // null key 14149 r = cropElemKeySmallIntO(self, null); 14150 ck_assert_ptr_eq(r, null); 14151 // empty self 14152 freeO(self); 14153 r = cropElemKeySmallIntO(self, "1"); 14154 ck_assert_ptr_eq(r, null); 14155 terminateO(self); 14156 14157 } 14158 14159 14160 void cropElemKeySmallJsonSmallJsonT(void) { 14161 14162 smallJsont* r; 14163 smallJsont *self = allocSmallJson(); 14164 smallJsont *r2; 14165 14166 r2 = self->f->setInt(self, "1", 1); 14167 ck_assert_ptr_ne(r2, null); 14168 createAllocateSmallBytes(b); 14169 r2 = self->f->setNFreeSmallBytes(self, "2", b); 14170 ck_assert_ptr_ne(r2, null); 14171 createAllocateSmallJson(d); 14172 r2 = self->f->setNFreeSmallJson(self, "b", d); 14173 ck_assert_ptr_ne(r2, null); 14174 createAllocateSmallInt(I); 14175 setValG(I, 11); 14176 I->type = "anothertype"; 14177 r2 = self->f->set(self, "B", (baset*)I); 14178 ck_assert_ptr_ne(r2, null); 14179 r = cropElemKeySmallJsonO(self, "b"); 14180 ck_assert_ptr_ne(r, null); 14181 char *s = toStringO(r); 14182 terminateO(r); 14183 ck_assert_str_eq(s, "{}"); 14184 free(s); 14185 s = toStringO(self); 14186 ck_assert_str_eq(s, "{\"1\":1,\"2\":[],\"B\":\"<data container>\"}"); 14187 free(s); 14188 // wrong object type 14189 r = cropElemKeySmallJsonO(self, "2"); 14190 ck_assert_ptr_eq(r, null); 14191 s = toStringO(self); 14192 ck_assert_str_eq(s, "{\"1\":1,\"2\":[],\"B\":\"<data container>\"}"); 14193 free(s); 14194 r = cropElemKeySmallJsonO(self, "B"); 14195 ck_assert_ptr_eq(r, null); 14196 s = toStringO(self); 14197 ck_assert_str_eq(s, "{\"1\":1,\"2\":[],\"B\":\"<data container>\"}"); 14198 free(s); 14199 // non existing key 14200 r = cropElemKeySmallJsonO(self, "qwe"); 14201 ck_assert_ptr_eq(r, null); 14202 // null key 14203 r = cropElemKeySmallJsonO(self, null); 14204 ck_assert_ptr_eq(r, null); 14205 // empty self 14206 freeO(self); 14207 r = cropElemKeySmallJsonO(self, "1"); 14208 ck_assert_ptr_eq(r, null); 14209 terminateO(self); 14210 14211 } 14212 14213 14214 void cropElemKeySmallStringSmallJsonT(void) { 14215 14216 smallStringt* r; 14217 smallJsont *self = allocSmallJson(); 14218 smallJsont *r2; 14219 14220 r2 = self->f->setInt(self, "1", 1); 14221 ck_assert_ptr_ne(r2, null); 14222 r2 = self->f->setDouble(self, "2", 2.2); 14223 ck_assert_ptr_ne(r2, null); 14224 r2 = self->f->setS(self, "b", "qwe"); 14225 ck_assert_ptr_ne(r2, null); 14226 createAllocateSmallInt(I); 14227 setValG(I, 11); 14228 I->type = "anothertype"; 14229 r2 = self->f->set(self, "B", (baset*)I); 14230 ck_assert_ptr_ne(r2, null); 14231 r = cropElemKeySmallStringO(self, "b"); 14232 ck_assert_ptr_ne(r, null); 14233 char *s = toStringO(r); 14234 terminateO(r); 14235 ck_assert_str_eq(s, "qwe"); 14236 free(s); 14237 s = toStringO(self); 14238 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14239 free(s); 14240 // wrong object type 14241 r = cropElemKeySmallStringO(self, "2"); 14242 ck_assert_ptr_eq(r, null); 14243 s = toStringO(self); 14244 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14245 free(s); 14246 r = cropElemKeySmallStringO(self, "B"); 14247 ck_assert_ptr_eq(r, null); 14248 s = toStringO(self); 14249 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14250 free(s); 14251 // non existing key 14252 r = cropElemKeySmallStringO(self, "qwe"); 14253 ck_assert_ptr_eq(r, null); 14254 // null key 14255 r = cropElemKeySmallStringO(self, null); 14256 ck_assert_ptr_eq(r, null); 14257 // empty self 14258 freeO(self); 14259 r = cropElemKeySmallStringO(self, "1"); 14260 ck_assert_ptr_eq(r, null); 14261 terminateO(self); 14262 14263 } 14264 14265 14266 void cropElemKeyVoidSmallJsonT(void) { 14267 14268 void* r; 14269 smallJsont *self = allocSmallJson(); 14270 smallJsont *r2; 14271 14272 r2 = self->f->setInt(self, "1", 1); 14273 ck_assert_ptr_ne(r2, null); 14274 r2 = self->f->setDouble(self, "2", 2.2); 14275 ck_assert_ptr_ne(r2, null); 14276 smallContainert *c = allocSmallContainer(&r); 14277 r2 = self->f->setNFreeSmallContainer(self, "b", c); 14278 ck_assert_ptr_ne(r2, null); 14279 createAllocateSmallInt(I); 14280 setValG(I, 11); 14281 I->type = "anothertype"; 14282 r2 = self->f->set(self, "B", (baset*)I); 14283 ck_assert_ptr_ne(r2, null); 14284 r = cropElemKeyVoidO(self, "b"); 14285 ck_assert_ptr_eq(r, &r); 14286 char *s = toStringO(self); 14287 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14288 free(s); 14289 // wrong object type 14290 r = cropElemKeyVoidO(self, "2"); 14291 ck_assert_ptr_eq(r, null); 14292 s = toStringO(self); 14293 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14294 free(s); 14295 r = cropElemKeyVoidO(self, "B"); 14296 ck_assert_ptr_eq(r, null); 14297 s = toStringO(self); 14298 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14299 free(s); 14300 // non existing key 14301 r = cropElemKeyVoidO(self, "qwe"); 14302 ck_assert_ptr_eq(r, null); 14303 // null key 14304 r = cropElemKeyVoidO(self, null); 14305 ck_assert_ptr_eq(r, null); 14306 // empty self 14307 freeO(self); 14308 r = cropElemKeyVoidO(self, "1"); 14309 ck_assert_ptr_eq(r, null); 14310 terminateO(self); 14311 14312 } 14313 14314 14315 void cropElemKeySmallContainerSmallJsonT(void) { 14316 14317 smallContainert* r; 14318 smallJsont *self = allocSmallJson(); 14319 smallJsont *r2; 14320 14321 r2 = self->f->setInt(self, "1", 1); 14322 ck_assert_ptr_ne(r2, null); 14323 r2 = self->f->setDouble(self, "2", 2.2); 14324 ck_assert_ptr_ne(r2, null); 14325 smallContainert *c = allocSmallContainer(&r); 14326 r2 = self->f->setNFreeSmallContainer(self, "b", c); 14327 ck_assert_ptr_ne(r2, null); 14328 createAllocateSmallInt(I); 14329 setValG(I, 11); 14330 I->type = "anothertype"; 14331 r2 = self->f->set(self, "B", (baset*)I); 14332 ck_assert_ptr_ne(r2, null); 14333 r = cropElemKeySmallContainerO(self, "b"); 14334 ck_assert_ptr_ne(r, null); 14335 char *s = toStringO(r); 14336 terminateO(r); 14337 ck_assert_str_eq(s, "<data smallContainer>"); 14338 free(s); 14339 s = toStringO(self); 14340 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14341 free(s); 14342 // wrong object type 14343 r = cropElemKeySmallContainerO(self, "2"); 14344 ck_assert_ptr_eq(r, null); 14345 s = toStringO(self); 14346 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14347 free(s); 14348 r = cropElemKeySmallContainerO(self, "B"); 14349 ck_assert_ptr_eq(r, null); 14350 s = toStringO(self); 14351 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 14352 free(s); 14353 // non existing key 14354 r = cropElemKeySmallContainerO(self, "qwe"); 14355 ck_assert_ptr_eq(r, null); 14356 // null key 14357 r = cropElemKeySmallContainerO(self, null); 14358 ck_assert_ptr_eq(r, null); 14359 // empty self 14360 freeO(self); 14361 r = cropElemKeySmallContainerO(self, "1"); 14362 ck_assert_ptr_eq(r, null); 14363 terminateO(self); 14364 14365 } 14366 14367 14368 void copySmallJsonT(void) { 14369 14370 smallJsont* r; 14371 smallJsont *self = allocSmallJson(); 14372 14373 // add elements to self 14374 r = self->f->pushInt(self, 1); 14375 ck_assert_ptr_ne(r, null); 14376 r = self->f->pushInt(self, 2); 14377 ck_assert_ptr_ne(r, null); 14378 r = self->f->pushInt(self, 3); 14379 ck_assert_ptr_ne(r, null); 14380 r = self->f->pushInt(self, 4); 14381 ck_assert_ptr_ne(r, null); 14382 14383 // negative index 14384 r = copyRngO(self, 1, -1); 14385 ck_assert_ptr_ne(r, null); 14386 ck_assert_int_eq(lenO(r), 2); 14387 char *s = toStringO(r); 14388 terminateO(r); 14389 ck_assert_str_eq(s, "[2,3]"); 14390 free(s); 14391 s = toStringO(self); 14392 ck_assert_str_eq(s, "[1,2,3,4]"); 14393 free(s); 14394 // start outside 14395 ck_assert_ptr_eq(copyRngO(self, 20, -3), NULL); 14396 // end outside 14397 r = copyRngO(self, 0, 40); 14398 ck_assert_ptr_ne(r, null); 14399 ck_assert_int_eq(lenO(r), 4); 14400 s = toStringO(r); 14401 terminateO(r); 14402 ck_assert_str_eq(s, "[1,2,3,4]"); 14403 free(s); 14404 s = toStringO(self); 14405 ck_assert_str_eq(s, "[1,2,3,4]"); 14406 free(s); 14407 // end negative and outside 14408 ck_assert_ptr_eq(copyRngO(self, 2, -40), NULL); 14409 s = toStringO(self); 14410 ck_assert_str_eq(s, "[1,2,3,4]"); 14411 free(s); 14412 // end before start 14413 ck_assert_ptr_eq(copyRngO(self, 3, 2), NULL); 14414 s = toStringO(self); 14415 ck_assert_str_eq(s, "[1,2,3,4]"); 14416 free(s); 14417 // negative start last element 14418 r = copyRngO(self, -1, 0); 14419 ck_assert_ptr_ne(r, null); 14420 ck_assert_int_eq(lenO(r), 1); 14421 s = toStringO(r); 14422 terminateO(r); 14423 ck_assert_str_eq(s, "[4]"); 14424 free(s); 14425 s = toStringO(self); 14426 ck_assert_str_eq(s, "[1,2,3,4]"); 14427 free(s); 14428 // negative start and outside 14429 r = copyRngO(self, -10, 1); 14430 ck_assert_ptr_ne(r, null); 14431 ck_assert_int_eq(lenO(r), 1); 14432 s = toStringO(r); 14433 terminateO(r); 14434 ck_assert_str_eq(s, "[1]"); 14435 free(s); 14436 s = toStringO(self); 14437 ck_assert_str_eq(s, "[1,2,3,4]"); 14438 free(s); 14439 // start = end 14440 r = copyRngO(self, 1, 1); 14441 ck_assert_ptr_ne(r, null); 14442 ck_assert_int_eq(lenO(r), 0); 14443 terminateO(r); 14444 s = toStringO(self); 14445 ck_assert_str_eq(s, "[1,2,3,4]"); 14446 free(s); 14447 // empty list 14448 emptyO(self); 14449 ck_assert_ptr_eq(copyRngO(self, 0, 0), NULL); 14450 ck_assert_ptr_eq(copyRngO(self, -1, 0), NULL); 14451 // non json array 14452 freeO(self); 14453 setTypeBoolO(self); 14454 ck_assert_ptr_eq(copyRngO(self, 0, 1), NULL); 14455 terminateO(self); 14456 // json string 14457 self = allocSmallJson(); 14458 // copy range 14459 setTopSO(self, "sheepy"); 14460 r = copyRngO(self, 0,2); 14461 ck_assert_ptr_ne(r, null); 14462 ck_assert_str_eq(sjGet(r), "sh"); 14463 ck_assert_str_eq(sjGet(self), "sheepy"); 14464 terminateO(r); 14465 // negative index 14466 r = copyRngO(self, -2,0); 14467 ck_assert_ptr_ne(r, null); 14468 ck_assert_str_eq(sjGet(r), "py"); 14469 ck_assert_str_eq(sjGet(self), "sheepy"); 14470 terminateO(r); 14471 // positive and negative indexes 14472 r = copyRngO(self, 2,-2); 14473 ck_assert_ptr_ne(r, null); 14474 ck_assert_str_eq(sjGet(r), "ee"); 14475 ck_assert_str_eq(sjGet(self), "sheepy"); 14476 terminateO(r); 14477 // start = end 14478 r = copyRngO(self, 2,-4); 14479 ck_assert_ptr_ne(r, null); 14480 ck_assert_str_eq(sjGet(r), ""); 14481 ck_assert_str_eq(sjGet(self), "sheepy"); 14482 terminateO(r); 14483 // end of string 14484 r = copyRngO(self, 2,6); 14485 ck_assert_ptr_ne(r, null); 14486 ck_assert_str_eq(sjGet(r), "eepy"); 14487 ck_assert_str_eq(sjGet(self), "sheepy"); 14488 terminateO(r); 14489 // NULL string 14490 freeO(self); 14491 ck_assert_ptr_eq(copyRngO(self, 2,-4), NULL); 14492 // start outside string 14493 setTopSO(self, "sheepy"); 14494 ck_assert_ptr_eq(copyRngO(self, 20,-4), NULL); 14495 // end outside string 14496 r = copyRngO(self, 2,40); 14497 ck_assert_ptr_ne(r, null); 14498 ck_assert_str_eq(sjGet(r), "eepy"); 14499 ck_assert_str_eq(sjGet(self), "sheepy"); 14500 terminateO(r); 14501 r = copyRngO(self, -22,3); 14502 ck_assert_ptr_ne(r, null); 14503 ck_assert_str_eq(sjGet(r), "she"); 14504 ck_assert_str_eq(sjGet(self), "sheepy"); 14505 terminateO(r); 14506 ck_assert_ptr_eq(copyRngO(self, 2,-40), NULL); 14507 // end before start 14508 ck_assert_ptr_eq(copyRngO(self, 4,2), NULL); 14509 terminateO(self); 14510 14511 } 14512 14513 14514 void insertSmallJsonT(void) { 14515 14516 smallJsont* r; 14517 smallJsont *self = allocSmallJson(); 14518 smallArrayt *toInsert; 14519 14520 // add elements to self 14521 r = self->f->pushInt(self, 1); 14522 ck_assert_ptr_ne(r, null); 14523 r = self->f->pushInt(self, 2); 14524 ck_assert_ptr_ne(r, null); 14525 14526 // positive index 14527 toInsert = allocSmallArray(); 14528 toInsert->f->pushInt(toInsert, 3); 14529 r = self->f->insert(self, 1, toInsert); 14530 smashO(toInsert); 14531 ck_assert_ptr_ne(r, null); 14532 char *s = toStringO(r); 14533 ck_assert_str_eq(s, "[1,3,2]"); 14534 free(s); 14535 // negative index 14536 toInsert = allocSmallArray(); 14537 toInsert->f->pushInt(toInsert, 4); 14538 r = self->f->insert(self, -1, toInsert); 14539 smashO(toInsert); 14540 ck_assert_ptr_ne(r, null); 14541 s = toStringO(r); 14542 ck_assert_str_eq(s, "[1,3,2,4]"); 14543 free(s); 14544 // empty list 14545 emptyO(self); 14546 toInsert = allocSmallArray(); 14547 toInsert->f->pushInt(toInsert, 3); 14548 r = self->f->insert(self, 0, toInsert); 14549 smashO(toInsert); 14550 ck_assert_ptr_ne(r, null); 14551 s = toStringO(r); 14552 ck_assert_str_eq(s, "[3]"); 14553 free(s); 14554 emptyO(self); 14555 toInsert = allocSmallArray(); 14556 toInsert->f->pushInt(toInsert, 3); 14557 r = self->f->insert(self, -1, toInsert); 14558 smashO(toInsert); 14559 ck_assert_ptr_ne(r, null); 14560 s = toStringO(r); 14561 ck_assert_str_eq(s, "[3]"); 14562 free(s); 14563 // Array array length 0 14564 toInsert = allocSmallArray(); 14565 r = self->f->insert(self, -1, toInsert); 14566 smashO(toInsert); 14567 ck_assert_ptr_ne(r, null); 14568 s = toStringO(r); 14569 ck_assert_str_eq(s, "[3]"); 14570 free(s); 14571 // index outside 14572 toInsert = allocSmallArray(); 14573 ck_assert_ptr_eq(self->f->insert(self, 20, toInsert), NULL); 14574 ck_assert_ptr_eq(self->f->insert(self, -5, toInsert), NULL); 14575 smashO(toInsert); 14576 // non smallArray toInsert 14577 toInsert = (smallArrayt*) allocSmallInt(1); 14578 ck_assert_ptr_eq(self->f->insert(self, 0, toInsert), NULL); 14579 terminateO(toInsert); 14580 // insert NULL 14581 ck_assert_ptr_eq(self->f->insert(self, 0, NULL), NULL); 14582 // non json array 14583 freeO(self); 14584 setTypeBoolO(self); 14585 toInsert = allocSmallArray(); 14586 ck_assert_ptr_eq(self->f->insert(self, 0, toInsert), NULL); 14587 terminateO(toInsert); 14588 terminateO(self); 14589 14590 } 14591 14592 14593 void insertNSmashSmallJsonT(void) { 14594 14595 smallJsont* r; 14596 smallJsont *self = allocSmallJson(); 14597 smallArrayt *toInsert; 14598 14599 // add elements to self 14600 r = self->f->pushInt(self, 1); 14601 ck_assert_ptr_ne(r, null); 14602 r = self->f->pushInt(self, 2); 14603 ck_assert_ptr_ne(r, null); 14604 14605 // positive index 14606 toInsert = allocSmallArray(); 14607 toInsert->f->pushInt(toInsert, 3); 14608 r = self->f->insertNSmash(self, 1, toInsert); 14609 ck_assert_ptr_ne(r, null); 14610 char *s = toStringO(r); 14611 ck_assert_str_eq(s, "[1,3,2]"); 14612 free(s); 14613 // negative index 14614 toInsert = allocSmallArray(); 14615 toInsert->f->pushInt(toInsert, 4); 14616 r = self->f->insertNSmash(self, -1, toInsert); 14617 ck_assert_ptr_ne(r, null); 14618 s = toStringO(r); 14619 ck_assert_str_eq(s, "[1,3,2,4]"); 14620 free(s); 14621 // empty list 14622 emptyO(self); 14623 toInsert = allocSmallArray(); 14624 toInsert->f->pushInt(toInsert, 3); 14625 r = self->f->insertNSmash(self, 0, toInsert); 14626 ck_assert_ptr_ne(r, null); 14627 s = toStringO(r); 14628 ck_assert_str_eq(s, "[3]"); 14629 free(s); 14630 emptyO(self); 14631 toInsert = allocSmallArray(); 14632 toInsert->f->pushInt(toInsert, 3); 14633 r = self->f->insertNSmash(self, -1, toInsert); 14634 ck_assert_ptr_ne(r, null); 14635 s = toStringO(r); 14636 ck_assert_str_eq(s, "[3]"); 14637 free(s); 14638 // Array array length 0 14639 toInsert = allocSmallArray(); 14640 r = self->f->insertNSmash(self, -1, toInsert); 14641 ck_assert_ptr_ne(r, null); 14642 s = toStringO(r); 14643 ck_assert_str_eq(s, "[3]"); 14644 free(s); 14645 // index outside 14646 toInsert = allocSmallArray(); 14647 ck_assert_ptr_eq(self->f->insertNSmash(self, 20, toInsert), NULL); 14648 ck_assert_ptr_eq(self->f->insertNSmash(self, -5, toInsert), NULL); 14649 smashO(toInsert); 14650 // insert NULL 14651 ck_assert_ptr_eq(self->f->insertNSmash(self, 0, NULL), NULL); 14652 terminateO(self); 14653 14654 } 14655 14656 14657 void insertSmallJsonSmallJsonT(void) { 14658 14659 smallJsont* r; 14660 smallJsont *self = allocSmallJson(); 14661 smallJsont *toInsert; 14662 14663 // add elements to self 14664 r = self->f->pushInt(self, 1); 14665 ck_assert_ptr_ne(r, null); 14666 r = self->f->pushInt(self, 2); 14667 ck_assert_ptr_ne(r, null); 14668 14669 // positive index 14670 toInsert = allocSmallJson(); 14671 toInsert->f->pushInt(toInsert, 3); 14672 r = self->f->insertSmallJson(self, 1, toInsert); 14673 smashO(toInsert); 14674 ck_assert_ptr_ne(r, null); 14675 char *s = toStringO(r); 14676 ck_assert_str_eq(s, "[1,3,2]"); 14677 free(s); 14678 // negative index 14679 toInsert = allocSmallJson(); 14680 toInsert->f->pushInt(toInsert, 4); 14681 r = self->f->insertSmallJson(self, -1, toInsert); 14682 smashO(toInsert); 14683 ck_assert_ptr_ne(r, null); 14684 s = toStringO(r); 14685 ck_assert_str_eq(s, "[1,3,2,4]"); 14686 free(s); 14687 // empty list 14688 emptyO(self); 14689 toInsert = allocSmallJson(); 14690 toInsert->f->pushInt(toInsert, 3); 14691 r = self->f->insertSmallJson(self, 0, toInsert); 14692 smashO(toInsert); 14693 ck_assert_ptr_ne(r, null); 14694 s = toStringO(r); 14695 ck_assert_str_eq(s, "[3]"); 14696 free(s); 14697 emptyO(self); 14698 toInsert = allocSmallJson(); 14699 toInsert->f->pushInt(toInsert, 3); 14700 r = self->f->insertSmallJson(self, -1, toInsert); 14701 smashO(toInsert); 14702 ck_assert_ptr_ne(r, null); 14703 s = toStringO(r); 14704 ck_assert_str_eq(s, "[3]"); 14705 free(s); 14706 // json array length 0 14707 toInsert = allocSmallJson(); 14708 setTypeArrayG(toInsert); 14709 r = self->f->insertSmallJson(self, -1, toInsert); 14710 smashO(toInsert); 14711 ck_assert_ptr_ne(r, null); 14712 s = toStringO(r); 14713 ck_assert_str_eq(s, "[3]"); 14714 free(s); 14715 // json with no type 14716 toInsert = allocSmallJson(); 14717 r = self->f->insertSmallJson(self, -1, toInsert); 14718 smashO(toInsert); 14719 ck_assert_ptr_eq(r, null); 14720 s = toStringO(self); 14721 ck_assert_str_eq(s, "[3]"); 14722 free(s); 14723 // non smallJson object 14724 toInsert = (smallJsont*) allocSmallInt(2); 14725 r = self->f->insertSmallJson(self, -1, toInsert); 14726 ck_assert_ptr_eq(r, null); 14727 terminateO(toInsert); 14728 // index outside 14729 toInsert = allocSmallJson(); 14730 ck_assert_ptr_eq(self->f->insertSmallJson(self, 20, toInsert), NULL); 14731 ck_assert_ptr_eq(self->f->insertSmallJson(self, -5, toInsert), NULL); 14732 smashO(toInsert); 14733 // insert NULL 14734 ck_assert_ptr_eq(self->f->insertSmallJson(self, 0, NULL), NULL); 14735 terminateO(self); 14736 14737 } 14738 14739 14740 void insertNSmashSmallJsonSmallJsonT(void) { 14741 14742 smallJsont* r; 14743 smallJsont *self = allocSmallJson(); 14744 smallJsont *toInsert; 14745 14746 // add elements to self 14747 r = self->f->pushInt(self, 1); 14748 ck_assert_ptr_ne(r, null); 14749 r = self->f->pushInt(self, 2); 14750 ck_assert_ptr_ne(r, null); 14751 14752 // positive index 14753 toInsert = allocSmallJson(); 14754 toInsert->f->pushInt(toInsert, 3); 14755 r = self->f->insertNSmashSmallJson(self, 1, toInsert); 14756 ck_assert_ptr_ne(r, null); 14757 char *s = toStringO(r); 14758 ck_assert_str_eq(s, "[1,3,2]"); 14759 free(s); 14760 // negative index 14761 toInsert = allocSmallJson(); 14762 toInsert->f->pushInt(toInsert, 4); 14763 r = self->f->insertNSmashSmallJson(self, -1, toInsert); 14764 ck_assert_ptr_ne(r, null); 14765 s = toStringO(r); 14766 ck_assert_str_eq(s, "[1,3,2,4]"); 14767 free(s); 14768 // empty list 14769 emptyO(self); 14770 toInsert = allocSmallJson(); 14771 toInsert->f->pushInt(toInsert, 3); 14772 r = self->f->insertNSmashSmallJson(self, 0, toInsert); 14773 ck_assert_ptr_ne(r, null); 14774 s = toStringO(r); 14775 ck_assert_str_eq(s, "[3]"); 14776 free(s); 14777 emptyO(self); 14778 toInsert = allocSmallJson(); 14779 toInsert->f->pushInt(toInsert, 3); 14780 r = self->f->insertNSmashSmallJson(self, -1, toInsert); 14781 ck_assert_ptr_ne(r, null); 14782 s = toStringO(r); 14783 ck_assert_str_eq(s, "[3]"); 14784 free(s); 14785 // json array length 0 14786 toInsert = allocSmallJson(); 14787 setTypeArrayG(toInsert); 14788 r = self->f->insertNSmashSmallJson(self, -1, toInsert); 14789 ck_assert_ptr_ne(r, null); 14790 s = toStringO(r); 14791 ck_assert_str_eq(s, "[3]"); 14792 free(s); 14793 // json with no type 14794 toInsert = allocSmallJson(); 14795 r = self->f->insertNSmashSmallJson(self, -1, toInsert); 14796 smashO(toInsert); 14797 ck_assert_ptr_eq(r, null); 14798 s = toStringO(self); 14799 ck_assert_str_eq(s, "[3]"); 14800 free(s); 14801 // index outside 14802 toInsert = allocSmallJson(); 14803 ck_assert_ptr_eq(self->f->insertNSmashSmallJson(self, 20, toInsert), NULL); 14804 ck_assert_ptr_eq(self->f->insertNSmashSmallJson(self, -5, toInsert), NULL); 14805 smashO(toInsert); 14806 // insert NULL 14807 ck_assert_ptr_eq(self->f->insertNSmashSmallJson(self, 0, NULL), NULL); 14808 terminateO(self); 14809 14810 } 14811 14812 14813 void insertStringSmallJsonT(void) { 14814 14815 smallJsont* r; 14816 smallJsont *self = allocSmallJson(); 14817 setTopSO(self, ""); 14818 smallStringt *toInsert = allocSmallString(""); 14819 14820 // insert 14821 freeO(self); 14822 setTopSO(self, "sheepy"); 14823 setValO(toInsert, "lib"); 14824 r = insertStringO(self, 0, toInsert); 14825 ck_assert_ptr_ne(r, null); 14826 char *s = toStringO(r); 14827 ck_assert_str_eq(s, "libsheepy"); 14828 free(s); 14829 // negative index 14830 setValO(toInsert, "P"); 14831 r = insertStringO(self, -2, toInsert); 14832 ck_assert_ptr_ne(r, null); 14833 s = toStringO(r); 14834 ck_assert_str_eq(s, "libsheepPy"); 14835 free(s); 14836 // edge 14837 freeO(self); 14838 setTopSO(self, "qwe"); 14839 setValO(toInsert, "C"); 14840 r = insertStringO(self, 3, toInsert); 14841 ck_assert_ptr_ne(r, null); 14842 s = toStringO(r); 14843 ck_assert_str_eq(s, "qweC"); 14844 free(s); 14845 // outside string 14846 freeO(self); 14847 setTopSO(self, "qwe"); 14848 r = insertStringO(self, 4, toInsert); 14849 ck_assert_ptr_eq(r, NULL); 14850 r = insertStringO(self, -5, toInsert); 14851 ck_assert_ptr_eq(r, NULL); 14852 // negative index in a one char string 14853 freeO(self); 14854 setTopSO(self, "s"); 14855 setValO(toInsert, "S"); 14856 r = insertStringO(self, -1, toInsert); 14857 ck_assert_ptr_ne(r, null); 14858 s = toStringO(r); 14859 ck_assert_str_eq(s, "sS"); 14860 free(s); 14861 // empty string 14862 freeO(self); 14863 setTopSO(self, ""); 14864 setValO(toInsert, "s"); 14865 r = insertStringO(self, 0, toInsert); 14866 ck_assert_ptr_ne(r, null); 14867 s = toStringO(r); 14868 ck_assert_str_eq(s, "s"); 14869 free(s); 14870 freeO(self); 14871 setTopSO(self, ""); 14872 r = insertStringO(self, -1, toInsert); 14873 ck_assert_ptr_ne(r, null); 14874 s = toStringO(r); 14875 ck_assert_str_eq(s, "s"); 14876 free(s); 14877 // empty insert string 14878 freeO(self); 14879 setTopSO(self, "a"); 14880 setValO(toInsert, ""); 14881 r = insertStringO(self, 0, toInsert); 14882 ck_assert_ptr_ne(r, null); 14883 s = toStringO(r); 14884 ck_assert_str_eq(s, "a"); 14885 free(s); 14886 freeO(toInsert); 14887 r = insertStringO(self, 0, toInsert); 14888 ck_assert_ptr_ne(r, null); 14889 s = toStringO(r); 14890 ck_assert_str_eq(s, "a"); 14891 free(s); 14892 // non smallString toInsert 14893 terminateO(toInsert); 14894 toInsert = (smallStringt*) allocSmallInt(1); 14895 r = insertStringO(self, 0, toInsert); 14896 ck_assert_ptr_eq(r, null); 14897 terminateO(toInsert); 14898 toInsert = allocSmallString(""); 14899 // NULL insert string 14900 r = insertStringO(self, 0, NULL); 14901 ck_assert_ptr_eq(r, null); 14902 // NULL string 14903 freeO(self); 14904 setValO(toInsert, "s"); 14905 r = insertStringO(self, 1, toInsert); 14906 ck_assert_ptr_eq(r, null); 14907 r = insertStringO(self, 0, toInsert); 14908 ck_assert_ptr_ne(r, null); 14909 s = toStringO(r); 14910 ck_assert_str_eq(s, "s"); 14911 free(s); 14912 terminateO(toInsert); 14913 terminateO(self); 14914 14915 } 14916 14917 14918 void insertSSmallJsonT(void) { 14919 14920 smallJsont* r; 14921 smallJsont *self = allocSmallJson(); 14922 setTopSO(self, ""); 14923 14924 // insert 14925 freeO(self); 14926 setTopSO(self, "sheepy"); 14927 r = insertSO(self, 0, "lib"); 14928 ck_assert_ptr_ne(r, null); 14929 char *s = toStringO(r); 14930 ck_assert_str_eq(s, "libsheepy"); 14931 free(s); 14932 // negative index 14933 r = insertSO(self, -2, "P"); 14934 ck_assert_ptr_ne(r, null); 14935 s = toStringO(r); 14936 ck_assert_str_eq(s, "libsheepPy"); 14937 free(s); 14938 // edge 14939 freeO(self); 14940 setTopSO(self, "qwe"); 14941 r = insertSO(self, 3, "C"); 14942 ck_assert_ptr_ne(r, null); 14943 s = toStringO(r); 14944 ck_assert_str_eq(s, "qweC"); 14945 free(s); 14946 // outside string 14947 freeO(self); 14948 setTopSO(self, "qwe"); 14949 r = insertSO(self, 4, "C"); 14950 ck_assert_ptr_eq(r, NULL); 14951 r = insertSO(self, -5, "C"); 14952 ck_assert_ptr_eq(r, NULL); 14953 // negative index in a one char string 14954 freeO(self); 14955 setTopSO(self, "s"); 14956 r = insertSO(self, -1, "S"); 14957 ck_assert_ptr_ne(r, null); 14958 s = toStringO(r); 14959 ck_assert_str_eq(s, "sS"); 14960 free(s); 14961 // empty string 14962 freeO(self); 14963 setTopSO(self, ""); 14964 r = insertSO(self, 0, "s"); 14965 ck_assert_ptr_ne(r, null); 14966 s = toStringO(r); 14967 ck_assert_str_eq(s, "s"); 14968 free(s); 14969 freeO(self); 14970 setTopSO(self, ""); 14971 r = insertSO(self, -1, "s"); 14972 ck_assert_ptr_ne(r, null); 14973 s = toStringO(r); 14974 ck_assert_str_eq(s, "s"); 14975 free(s); 14976 // empty insert string 14977 freeO(self); 14978 setTopSO(self, "a"); 14979 r = insertSO(self, 0, ""); 14980 ck_assert_ptr_ne(r, null); 14981 s = toStringO(r); 14982 ck_assert_str_eq(s, "a"); 14983 free(s); 14984 // NULL insert string 14985 r = insertSO(self, 0, NULL); 14986 ck_assert_ptr_ne(r, null); 14987 s = toStringO(r); 14988 ck_assert_str_eq(s, "a"); 14989 free(s); 14990 // NULL string 14991 freeO(self); 14992 r = insertSO(self, 0, "s"); 14993 ck_assert_ptr_ne(r, null); 14994 s = toStringO(r); 14995 ck_assert_str_eq(s, "s"); 14996 free(s); 14997 // non json array 14998 freeO(self); 14999 setTypeBoolO(self); 15000 ck_assert_ptr_eq(insertSO(self, 0, "asd"), NULL); 15001 terminateO(self); 15002 15003 } 15004 15005 15006 void insertNFreeStringSmallJsonT(void) { 15007 15008 smallJsont* r; 15009 smallJsont *self = allocSmallJson(); 15010 setTopSO(self, ""); 15011 smallStringt *toInsert = allocSmallString(""); 15012 15013 // insert 15014 freeO(self); 15015 setTopSO(self, "sheepy"); 15016 setValO(toInsert, "lib"); 15017 r = self->f->insertNFreeString(self, 0, toInsert); 15018 ck_assert_ptr_ne(r, null); 15019 char *s = toStringO(r); 15020 ck_assert_str_eq(s, "libsheepy"); 15021 free(s); 15022 // negative index 15023 toInsert = allocSmallString("P"); 15024 r = self->f->insertNFreeString(self, -2, toInsert); 15025 ck_assert_ptr_ne(r, null); 15026 s = toStringO(r); 15027 ck_assert_str_eq(s, "libsheepPy"); 15028 free(s); 15029 // edge 15030 freeO(self); 15031 setTopSO(self, "qwe"); 15032 toInsert = allocSmallString("C"); 15033 r = self->f->insertNFreeString(self, 3, toInsert); 15034 ck_assert_ptr_ne(r, null); 15035 s = toStringO(r); 15036 ck_assert_str_eq(s, "qweC"); 15037 free(s); 15038 // outside string 15039 freeO(self); 15040 setTopSO(self, "qwe"); 15041 toInsert = allocSmallString("S"); 15042 r = self->f->insertNFreeString(self, 4, toInsert); 15043 ck_assert_ptr_eq(r, NULL); 15044 r = self->f->insertNFreeString(self, -5, toInsert); 15045 ck_assert_ptr_eq(r, NULL); 15046 // negative index in a one char string 15047 freeO(self); 15048 setTopSO(self, "s"); 15049 r = self->f->insertNFreeString(self, -1, toInsert); 15050 ck_assert_ptr_ne(r, null); 15051 s = toStringO(r); 15052 ck_assert_str_eq(s, "sS"); 15053 free(s); 15054 // empty string 15055 freeO(self); 15056 setTopSO(self, ""); 15057 toInsert = allocSmallString("s"); 15058 r = self->f->insertNFreeString(self, 0, toInsert); 15059 ck_assert_ptr_ne(r, null); 15060 s = toStringO(r); 15061 ck_assert_str_eq(s, "s"); 15062 free(s); 15063 freeO(self); 15064 setTopSO(self, ""); 15065 toInsert = allocSmallString("s"); 15066 r = self->f->insertNFreeString(self, -1, toInsert); 15067 ck_assert_ptr_ne(r, null); 15068 s = toStringO(r); 15069 ck_assert_str_eq(s, "s"); 15070 free(s); 15071 // empty insert string 15072 freeO(self); 15073 setTopSO(self, "a"); 15074 toInsert = allocSmallString(""); 15075 r = self->f->insertNFreeString(self, 0, toInsert); 15076 ck_assert_ptr_ne(r, null); 15077 s = toStringO(r); 15078 ck_assert_str_eq(s, "a"); 15079 free(s); 15080 toInsert = allocSmallString(""); 15081 freeO(toInsert); 15082 r = self->f->insertNFreeString(self, 0, toInsert); 15083 ck_assert_ptr_ne(r, null); 15084 s = toStringO(r); 15085 ck_assert_str_eq(s, "a"); 15086 free(s); 15087 // non smallString toInsert 15088 toInsert = (smallStringt*) allocSmallInt(1); 15089 r = self->f->insertNFreeString(self, 0, toInsert); 15090 ck_assert_ptr_eq(r, null); 15091 terminateO(toInsert); 15092 toInsert = allocSmallString("s"); 15093 // NULL insert string 15094 r = self->f->insertNFreeString(self, 0, NULL); 15095 ck_assert_ptr_eq(r, null); 15096 // NULL string 15097 freeO(self); 15098 r = self->f->insertNFreeString(self, 1, toInsert); 15099 ck_assert_ptr_eq(r, null); 15100 r = self->f->insertNFreeString(self, 0, toInsert); 15101 ck_assert_ptr_ne(r, null); 15102 s = toStringO(r); 15103 ck_assert_str_eq(s, "s"); 15104 free(s); 15105 terminateO(self); 15106 15107 } 15108 15109 15110 void insertSNFreeSmallJsonT(void) { 15111 15112 smallJsont* r; 15113 smallJsont *self = allocSmallJson(); 15114 setTopSO(self, ""); 15115 15116 // insert 15117 freeO(self); 15118 setTopSO(self, "sheepy"); 15119 r = insertSNFreeO(self, 0, strdup("lib")); 15120 ck_assert_ptr_ne(r, null); 15121 char *s = toStringO(r); 15122 ck_assert_str_eq(s, "libsheepy"); 15123 free(s); 15124 // negative index 15125 r = insertSNFreeO(self, -2, strdup("P")); 15126 ck_assert_ptr_ne(r, null); 15127 s = toStringO(r); 15128 ck_assert_str_eq(s, "libsheepPy"); 15129 free(s); 15130 // edge 15131 freeO(self); 15132 setTopSO(self, "qwe"); 15133 r = insertSNFreeO(self, 3, strdup("C")); 15134 ck_assert_ptr_ne(r, null); 15135 s = toStringO(r); 15136 ck_assert_str_eq(s, "qweC"); 15137 free(s); 15138 // outside string 15139 freeO(self); 15140 setTopSO(self, "qwe"); 15141 r = insertSNFreeO(self, 4, "C"); 15142 ck_assert_ptr_eq(r, NULL); 15143 r = insertSNFreeO(self, -5, "C"); 15144 ck_assert_ptr_eq(r, NULL); 15145 // negative index in a one char string 15146 freeO(self); 15147 setTopSO(self, "s"); 15148 r = insertSNFreeO(self, -1, strdup("S")); 15149 ck_assert_ptr_ne(r, null); 15150 s = toStringO(r); 15151 ck_assert_str_eq(s, "sS"); 15152 free(s); 15153 // empty string 15154 freeO(self); 15155 setTopSO(self, ""); 15156 r = insertSNFreeO(self, 0, strdup("s")); 15157 ck_assert_ptr_ne(r, null); 15158 s = toStringO(r); 15159 ck_assert_str_eq(s, "s"); 15160 free(s); 15161 freeO(self); 15162 setTopSO(self, ""); 15163 r = insertSNFreeO(self, -1, strdup("s")); 15164 ck_assert_ptr_ne(r, null); 15165 s = toStringO(r); 15166 ck_assert_str_eq(s, "s"); 15167 free(s); 15168 // empty insert string 15169 freeO(self); 15170 setTopSO(self, "a"); 15171 r = insertSNFreeO(self, 0, strdup("")); 15172 ck_assert_ptr_ne(r, null); 15173 s = toStringO(r); 15174 ck_assert_str_eq(s, "a"); 15175 free(s); 15176 // NULL insert string 15177 r = insertSNFreeO(self, 0, NULL); 15178 ck_assert_ptr_ne(r, null); 15179 s = toStringO(r); 15180 ck_assert_str_eq(s, "a"); 15181 free(s); 15182 // NULL string 15183 freeO(self); 15184 r = insertSNFreeO(self, 0, strdup("s")); 15185 ck_assert_ptr_ne(r, null); 15186 s = toStringO(r); 15187 ck_assert_str_eq(s, "s"); 15188 free(s); 15189 terminateO(self); 15190 15191 } 15192 15193 15194 void injectSmallJsonT(void) { 15195 15196 smallJsont* r; 15197 smallJsont *self = allocSmallJson(); 15198 baset *toInject; 15199 15200 // add elements to self 15201 r = self->f->pushInt(self, 1); 15202 ck_assert_ptr_ne(r, null); 15203 r = self->f->pushInt(self, 2); 15204 ck_assert_ptr_ne(r, null); 15205 r = self->f->pushInt(self, 3); 15206 ck_assert_ptr_ne(r, null); 15207 r = self->f->pushInt(self, 4); 15208 ck_assert_ptr_ne(r, null); 15209 15210 // positive index 15211 toInject = (baset*) allocSmallInt(8); 15212 r = self->f->inject(self, 1, toInject); 15213 ck_assert_ptr_ne(r, null); 15214 finishO(toInject); 15215 char *s = toStringO(r); 15216 ck_assert_str_eq(s, "[1,8,2,3,4]"); 15217 free(s); 15218 // negative index 15219 toInject = (baset*) allocSmallInt(9); 15220 r = self->f->inject(self,-1, toInject); 15221 ck_assert_ptr_ne(r, null); 15222 finishO(toInject); 15223 s = toStringO(r); 15224 ck_assert_str_eq(s, "[1,8,2,3,4,9]"); 15225 free(s); 15226 // index 0 15227 toInject = (baset*) allocSmallInt(6); 15228 r = self->f->inject(self,0, toInject); 15229 ck_assert_ptr_ne(r, null); 15230 finishO(toInject); 15231 s = toStringO(r); 15232 ck_assert_str_eq(s, "[6,1,8,2,3,4,9]"); 15233 free(s); 15234 // index outside 15235 toInject = (baset*) allocSmallInt(7); 15236 ck_assert_ptr_eq(self->f->inject(self, 20, toInject), NULL); 15237 ck_assert_ptr_eq(self->f->inject(self, -9, toInject), NULL); 15238 terminateO(toInject); 15239 // empty list 15240 emptyO(self); 15241 toInject = (baset*) allocSmallInt(7); 15242 ck_assert_ptr_ne(self->f->inject(self, 0, toInject), NULL); 15243 finishO(toInject); 15244 s = toStringO(r); 15245 ck_assert_str_eq(s, "[7]"); 15246 free(s); 15247 emptyO(self); 15248 toInject = (baset*) allocSmallInt(7); 15249 ck_assert_ptr_ne(self->f->inject(self, -1, toInject), NULL); 15250 finishO(toInject); 15251 s = toStringO(r); 15252 ck_assert_str_eq(s, "[7]"); 15253 free(s); 15254 // null toInject 15255 ck_assert_ptr_eq(self->f->inject(self, 0, NULL), NULL); 15256 // non json array 15257 freeO(self); 15258 setTypeBoolO(self); 15259 toInject = (baset*) allocSmallInt(7); 15260 ck_assert_ptr_eq(self->f->inject(self, 0, toInject), NULL); 15261 terminateO(toInject); 15262 terminateO(self); 15263 15264 } 15265 15266 15267 void injectUndefinedSmallJsonT(void) { 15268 15269 smallJsont* r; 15270 smallJsont *self = allocSmallJson(); 15271 15272 // add elements to self 15273 r = self->f->pushInt(self, 1); 15274 ck_assert_ptr_ne(r, null); 15275 r = self->f->pushInt(self, 2); 15276 ck_assert_ptr_ne(r, null); 15277 r = self->f->pushInt(self, 3); 15278 ck_assert_ptr_ne(r, null); 15279 r = self->f->pushInt(self, 4); 15280 ck_assert_ptr_ne(r, null); 15281 15282 // positive index 15283 r = self->f->injectUndefined(self, 1); 15284 ck_assert_ptr_ne(r, null); 15285 char *s = toStringO(r); 15286 ck_assert_str_eq(s, "[1,null,2,3,4]"); 15287 free(s); 15288 // negative index 15289 r = self->f->injectUndefined(self,-1); 15290 ck_assert_ptr_ne(r, null); 15291 s = toStringO(r); 15292 ck_assert_str_eq(s, "[1,null,2,3,4,null]"); 15293 free(s); 15294 // index 0 15295 r = self->f->injectUndefined(self,0); 15296 ck_assert_ptr_ne(r, null); 15297 s = toStringO(r); 15298 ck_assert_str_eq(s, "[null,1,null,2,3,4,null]"); 15299 free(s); 15300 // index outside 15301 ck_assert_ptr_eq(self->f->injectUndefined(self, 20), NULL); 15302 ck_assert_ptr_eq(self->f->injectUndefined(self, -9), NULL); 15303 // empty list 15304 emptyO(self); 15305 ck_assert_ptr_ne(self->f->injectUndefined(self, 0), NULL); 15306 s = toStringO(r); 15307 ck_assert_str_eq(s, "[null]"); 15308 free(s); 15309 emptyO(self); 15310 ck_assert_ptr_ne(self->f->injectUndefined(self, -1), NULL); 15311 s = toStringO(r); 15312 ck_assert_str_eq(s, "[null]"); 15313 free(s); 15314 terminateO(self); 15315 15316 } 15317 15318 15319 void injectBoolSmallJsonT(void) { 15320 15321 smallJsont* r; 15322 smallJsont *self = allocSmallJson(); 15323 15324 // add elements to self 15325 r = self->f->pushInt(self, 1); 15326 ck_assert_ptr_ne(r, null); 15327 r = self->f->pushInt(self, 2); 15328 ck_assert_ptr_ne(r, null); 15329 r = self->f->pushInt(self, 3); 15330 ck_assert_ptr_ne(r, null); 15331 r = self->f->pushInt(self, 4); 15332 ck_assert_ptr_ne(r, null); 15333 15334 // positive index 15335 r = self->f->injectBool(self, 1, true); 15336 ck_assert_ptr_ne(r, null); 15337 char *s = toStringO(r); 15338 ck_assert_str_eq(s, "[1,true,2,3,4]"); 15339 free(s); 15340 // negative index 15341 r = self->f->injectBool(self,-1, true); 15342 ck_assert_ptr_ne(r, null); 15343 s = toStringO(r); 15344 ck_assert_str_eq(s, "[1,true,2,3,4,true]"); 15345 free(s); 15346 // index 0 15347 r = self->f->injectBool(self,0, true); 15348 ck_assert_ptr_ne(r, null); 15349 s = toStringO(r); 15350 ck_assert_str_eq(s, "[true,1,true,2,3,4,true]"); 15351 free(s); 15352 // index outside 15353 ck_assert_ptr_eq(self->f->injectBool(self, 20, true), NULL); 15354 ck_assert_ptr_eq(self->f->injectBool(self, -9, true), NULL); 15355 // empty list 15356 emptyO(self); 15357 ck_assert_ptr_ne(self->f->injectBool(self, 0, true), NULL); 15358 s = toStringO(r); 15359 ck_assert_str_eq(s, "[true]"); 15360 free(s); 15361 emptyO(self); 15362 ck_assert_ptr_ne(self->f->injectBool(self, -1, true), NULL); 15363 s = toStringO(r); 15364 ck_assert_str_eq(s, "[true]"); 15365 free(s); 15366 // non json array 15367 freeO(self); 15368 setTypeBoolO(self); 15369 ck_assert_ptr_eq(self->f->injectBool(self, 0, true), NULL); 15370 terminateO(self); 15371 15372 } 15373 15374 15375 void injectDoubleSmallJsonT(void) { 15376 15377 smallJsont* r; 15378 smallJsont *self = allocSmallJson(); 15379 15380 // add elements to self 15381 r = self->f->pushInt(self, 1); 15382 ck_assert_ptr_ne(r, null); 15383 r = self->f->pushInt(self, 2); 15384 ck_assert_ptr_ne(r, null); 15385 r = self->f->pushInt(self, 3); 15386 ck_assert_ptr_ne(r, null); 15387 r = self->f->pushInt(self, 4); 15388 ck_assert_ptr_ne(r, null); 15389 15390 // positive index 15391 r = self->f->injectDouble(self, 1, 7); 15392 ck_assert_ptr_ne(r, null); 15393 char *s = toStringO(r); 15394 ck_assert_str_eq(s, "[1,7.000000e+00,2,3,4]"); 15395 free(s); 15396 // negative index 15397 r = self->f->injectDouble(self,-1, 8); 15398 ck_assert_ptr_ne(r, null); 15399 s = toStringO(r); 15400 ck_assert_str_eq(s, "[1,7.000000e+00,2,3,4,8.000000e+00]"); 15401 free(s); 15402 // index 0 15403 r = self->f->injectDouble(self,0, 9); 15404 ck_assert_ptr_ne(r, null); 15405 s = toStringO(r); 15406 ck_assert_str_eq(s, "[9.000000e+00,1,7.000000e+00,2,3,4,8.000000e+00]"); 15407 free(s); 15408 // index outside 15409 ck_assert_ptr_eq(self->f->injectDouble(self, 20, 7.000000e+00), NULL); 15410 ck_assert_ptr_eq(self->f->injectDouble(self, -9, 7.000000e+00), NULL); 15411 // empty list 15412 emptyO(self); 15413 ck_assert_ptr_ne(self->f->injectDouble(self, 0, 9), NULL); 15414 s = toStringO(r); 15415 ck_assert_str_eq(s, "[9.000000e+00]"); 15416 free(s); 15417 emptyO(self); 15418 ck_assert_ptr_ne(self->f->injectDouble(self, -1, 9), NULL); 15419 s = toStringO(r); 15420 ck_assert_str_eq(s, "[9.000000e+00]"); 15421 free(s); 15422 // non json array 15423 freeO(self); 15424 setTypeBoolO(self); 15425 ck_assert_ptr_eq(self->f->injectDouble(self, 0, 0), NULL); 15426 terminateO(self); 15427 15428 } 15429 15430 15431 void injectIntSmallJsonT(void) { 15432 15433 smallJsont* r; 15434 smallJsont *self = allocSmallJson(); 15435 15436 // add elements to self 15437 r = self->f->pushInt(self, 1); 15438 ck_assert_ptr_ne(r, null); 15439 r = self->f->pushInt(self, 2); 15440 ck_assert_ptr_ne(r, null); 15441 r = self->f->pushInt(self, 3); 15442 ck_assert_ptr_ne(r, null); 15443 r = self->f->pushInt(self, 4); 15444 ck_assert_ptr_ne(r, null); 15445 15446 // positive index 15447 r = self->f->injectInt(self, 1, 5); 15448 ck_assert_ptr_ne(r, null); 15449 char *s = toStringO(r); 15450 ck_assert_str_eq(s, "[1,5,2,3,4]"); 15451 free(s); 15452 // negative index 15453 r = self->f->injectInt(self,-1, 6); 15454 ck_assert_ptr_ne(r, null); 15455 s = toStringO(r); 15456 ck_assert_str_eq(s, "[1,5,2,3,4,6]"); 15457 free(s); 15458 // index 0 15459 r = self->f->injectInt(self,0, 7); 15460 ck_assert_ptr_ne(r, null); 15461 s = toStringO(r); 15462 ck_assert_str_eq(s, "[7,1,5,2,3,4,6]"); 15463 free(s); 15464 // index outside 15465 ck_assert_ptr_eq(self->f->injectInt(self, 20, true), NULL); 15466 ck_assert_ptr_eq(self->f->injectInt(self, -9, true), NULL); 15467 // empty list 15468 emptyO(self); 15469 ck_assert_ptr_ne(self->f->injectInt(self, 0, 7), NULL); 15470 s = toStringO(r); 15471 ck_assert_str_eq(s, "[7]"); 15472 free(s); 15473 emptyO(self); 15474 ck_assert_ptr_ne(self->f->injectInt(self, -1, 7), NULL); 15475 s = toStringO(r); 15476 ck_assert_str_eq(s, "[7]"); 15477 free(s); 15478 // non json array 15479 freeO(self); 15480 setTypeBoolO(self); 15481 ck_assert_ptr_eq(self->f->injectInt(self, 0, 0), NULL); 15482 terminateO(self); 15483 15484 } 15485 15486 15487 void injectSSmallJsonT(void) { 15488 15489 smallJsont* r; 15490 smallJsont *self = allocSmallJson(); 15491 15492 // add elements to self 15493 r = self->f->pushInt(self, 1); 15494 ck_assert_ptr_ne(r, null); 15495 r = self->f->pushInt(self, 2); 15496 ck_assert_ptr_ne(r, null); 15497 r = self->f->pushInt(self, 3); 15498 ck_assert_ptr_ne(r, null); 15499 r = self->f->pushInt(self, 4); 15500 ck_assert_ptr_ne(r, null); 15501 // positive index 15502 r = self->f->injectS(self, 1, "5"); 15503 ck_assert_ptr_ne(r, null); 15504 char *s = toStringO(r); 15505 ck_assert_str_eq(s, "[1,\"5\",2,3,4]"); 15506 free(s); 15507 // negative index 15508 r = self->f->injectS(self,-1, "6"); 15509 ck_assert_ptr_ne(r, null); 15510 s = toStringO(r); 15511 ck_assert_str_eq(s, "[1,\"5\",2,3,4,\"6\"]"); 15512 free(s); 15513 // index 0 15514 r = self->f->injectS(self,0, "7"); 15515 ck_assert_ptr_ne(r, null); 15516 s = toStringO(r); 15517 ck_assert_str_eq(s, "[\"7\",1,\"5\",2,3,4,\"6\"]"); 15518 free(s); 15519 // null toInject 15520 r = self->f->injectS(self,0, null); 15521 ck_assert_ptr_eq(r, null); 15522 s = toStringO(self); 15523 ck_assert_str_eq(s, "[\"7\",1,\"5\",2,3,4,\"6\"]"); 15524 free(s); 15525 // index outside 15526 ck_assert_ptr_eq(self->f->injectS(self, 20, ""), NULL); 15527 ck_assert_ptr_eq(self->f->injectS(self, -9, ""), NULL); 15528 // empty list 15529 emptyO(self); 15530 ck_assert_ptr_ne(self->f->injectS(self, 0, "7"), NULL); 15531 s = toStringO(self); 15532 ck_assert_str_eq(s, "[\"7\"]"); 15533 free(s); 15534 emptyO(self); 15535 ck_assert_ptr_ne(self->f->injectS(self, -1, "7"), NULL); 15536 s = toStringO(self); 15537 ck_assert_str_eq(s, "[\"7\"]"); 15538 free(s); 15539 // non json array 15540 freeO(self); 15541 setTypeBoolO(self); 15542 ck_assert_ptr_eq(self->f->injectS(self, 0, "7"), NULL); 15543 terminateO(self); 15544 // json string 15545 self = allocSmallJson(); 15546 setTopSO(self, "s"); 15547 r = self->f->injectS(self,1, "heepy"); 15548 ck_assert_ptr_ne(r, null); 15549 s = toStringO(r); 15550 ck_assert_str_eq(s, "sheepy"); 15551 free(s); 15552 terminateO(self); 15553 15554 } 15555 15556 15557 void injectCharSmallJsonT(void) { 15558 15559 smallJsont* r; 15560 smallJsont *self = allocSmallJson(); 15561 15562 // add elements to self 15563 r = self->f->pushInt(self, 1); 15564 ck_assert_ptr_ne(r, null); 15565 r = self->f->pushInt(self, 2); 15566 ck_assert_ptr_ne(r, null); 15567 r = self->f->pushInt(self, 3); 15568 ck_assert_ptr_ne(r, null); 15569 r = self->f->pushInt(self, 4); 15570 ck_assert_ptr_ne(r, null); 15571 15572 // positive index 15573 r = self->f->injectChar(self, 1, '5'); 15574 ck_assert_ptr_ne(r, null); 15575 char *s = toStringO(r); 15576 ck_assert_str_eq(s, "[1,\"5\",2,3,4]"); 15577 free(s); 15578 // negative index 15579 r = self->f->injectChar(self,-1, '6'); 15580 ck_assert_ptr_ne(r, null); 15581 s = toStringO(r); 15582 ck_assert_str_eq(s, "[1,\"5\",2,3,4,\"6\"]"); 15583 free(s); 15584 // index 0 15585 r = self->f->injectChar(self,0, '7'); 15586 ck_assert_ptr_ne(r, null); 15587 s = toStringO(r); 15588 ck_assert_str_eq(s, "[\"7\",1,\"5\",2,3,4,\"6\"]"); 15589 free(s); 15590 // index outside 15591 ck_assert_ptr_eq(self->f->injectChar(self, 20, 'y'), NULL); 15592 ck_assert_ptr_eq(self->f->injectChar(self, -9, 'y'), NULL); 15593 // empty list 15594 emptyO(self); 15595 ck_assert_ptr_ne(self->f->injectChar(self, 0, '7'), NULL); 15596 s = toStringO(r); 15597 ck_assert_str_eq(s, "[\"7\"]"); 15598 free(s); 15599 emptyO(self); 15600 ck_assert_ptr_ne(self->f->injectChar(self, -1, '7'), NULL); 15601 s = toStringO(r); 15602 ck_assert_str_eq(s, "[\"7\"]"); 15603 free(s); 15604 terminateO(self); 15605 15606 } 15607 15608 15609 void injectDictSmallJsonT(void) { 15610 15611 smallJsont* r; 15612 smallJsont *self = allocSmallJson(); 15613 smallDictt *toInject; 15614 15615 // add elements to self 15616 r = self->f->pushInt(self, 1); 15617 ck_assert_ptr_ne(r, null); 15618 r = self->f->pushInt(self, 2); 15619 ck_assert_ptr_ne(r, null); 15620 r = self->f->pushInt(self, 3); 15621 ck_assert_ptr_ne(r, null); 15622 r = self->f->pushInt(self, 4); 15623 ck_assert_ptr_ne(r, null); 15624 15625 // positive index 15626 toInject = allocSmallDict(); 15627 r = self->f->injectDict(self, 1, toInject); 15628 ck_assert_ptr_ne(r, null); 15629 finishO(toInject); 15630 char *s = toStringO(r); 15631 ck_assert_str_eq(s, "[1,{},2,3,4]"); 15632 free(s); 15633 // negative index 15634 toInject = allocSmallDict(); 15635 r = self->f->injectDict(self,-1, toInject); 15636 ck_assert_ptr_ne(r, null); 15637 finishO(toInject); 15638 s = toStringO(r); 15639 ck_assert_str_eq(s, "[1,{},2,3,4,{}]"); 15640 free(s); 15641 // index 0 15642 toInject = allocSmallDict(); 15643 r = self->f->injectDict(self,0, toInject); 15644 ck_assert_ptr_ne(r, null); 15645 finishO(toInject); 15646 s = toStringO(r); 15647 ck_assert_str_eq(s, "[{},1,{},2,3,4,{}]"); 15648 free(s); 15649 // index outside 15650 toInject = allocSmallDict(); 15651 ck_assert_ptr_eq(self->f->injectDict(self, 20, toInject), NULL); 15652 ck_assert_ptr_eq(self->f->injectDict(self, -9, toInject), NULL); 15653 terminateO(toInject); 15654 // empty list 15655 emptyO(self); 15656 toInject = allocSmallDict(); 15657 ck_assert_ptr_ne(self->f->injectDict(self, 0, toInject), NULL); 15658 finishO(toInject); 15659 s = toStringO(r); 15660 ck_assert_str_eq(s, "[{}]"); 15661 free(s); 15662 emptyO(self); 15663 toInject = allocSmallDict(); 15664 ck_assert_ptr_ne(self->f->injectDict(self, -1, toInject), NULL); 15665 finishO(toInject); 15666 s = toStringO(r); 15667 ck_assert_str_eq(s, "[{}]"); 15668 free(s); 15669 // non smallDict object 15670 toInject = (smallDictt*) allocSmallInt(2); 15671 r = self->f->injectDict(self, 0, toInject); 15672 ck_assert_ptr_eq(r, null); 15673 terminateO(toInject); 15674 // null toInsert 15675 ck_assert_ptr_eq(self->f->injectDict(self, 0, NULL), NULL); 15676 // non json array 15677 freeO(self); 15678 setTypeBoolO(self); 15679 toInject = allocSmallDict(); 15680 ck_assert_ptr_eq(self->f->injectDict(self, 0, toInject), NULL); 15681 terminateO(toInject); 15682 terminateO(self); 15683 15684 } 15685 15686 15687 void injectArraySmallJsonT(void) { 15688 15689 smallJsont* r; 15690 smallJsont *self = allocSmallJson(); 15691 smallArrayt *toInject; 15692 15693 // add elements to self 15694 r = self->f->pushInt(self, 1); 15695 ck_assert_ptr_ne(r, null); 15696 r = self->f->pushInt(self, 2); 15697 ck_assert_ptr_ne(r, null); 15698 r = self->f->pushInt(self, 3); 15699 ck_assert_ptr_ne(r, null); 15700 r = self->f->pushInt(self, 4); 15701 ck_assert_ptr_ne(r, null); 15702 15703 // positive index 15704 toInject = allocSmallArray(); 15705 r = self->f->injectArray(self, 1, toInject); 15706 ck_assert_ptr_ne(r, null); 15707 finishO(toInject); 15708 char *s = toStringO(r); 15709 ck_assert_str_eq(s, "[1,[],2,3,4]"); 15710 free(s); 15711 // negative index 15712 toInject = allocSmallArray(); 15713 r = self->f->injectArray(self,-1, toInject); 15714 ck_assert_ptr_ne(r, null); 15715 finishO(toInject); 15716 s = toStringO(r); 15717 ck_assert_str_eq(s, "[1,[],2,3,4,[]]"); 15718 free(s); 15719 // index 0 15720 toInject = allocSmallArray(); 15721 r = self->f->injectArray(self,0, toInject); 15722 ck_assert_ptr_ne(r, null); 15723 finishO(toInject); 15724 s = toStringO(r); 15725 ck_assert_str_eq(s, "[[],1,[],2,3,4,[]]"); 15726 free(s); 15727 // index outside 15728 toInject = allocSmallArray(); 15729 ck_assert_ptr_eq(self->f->injectArray(self, 20, toInject), NULL); 15730 ck_assert_ptr_eq(self->f->injectArray(self, -9, toInject), NULL); 15731 terminateO(toInject); 15732 // empty list 15733 emptyO(self); 15734 toInject = allocSmallArray(); 15735 ck_assert_ptr_ne(self->f->injectArray(self, 0, toInject), NULL); 15736 finishO(toInject); 15737 s = toStringO(r); 15738 ck_assert_str_eq(s, "[[]]"); 15739 free(s); 15740 emptyO(self); 15741 toInject = allocSmallArray(); 15742 ck_assert_ptr_ne(self->f->injectArray(self, -1, toInject), NULL); 15743 finishO(toInject); 15744 s = toStringO(r); 15745 ck_assert_str_eq(s, "[[]]"); 15746 free(s); 15747 // non smallArray object 15748 toInject = (smallArrayt*) allocSmallInt(2); 15749 r = self->f->injectArray(self, 0, toInject); 15750 ck_assert_ptr_eq(r, null); 15751 terminateO(toInject); 15752 // null toInsert 15753 ck_assert_ptr_eq(self->f->injectArray(self, 0, NULL), NULL); 15754 // non json array 15755 freeO(self); 15756 setTypeBoolO(self); 15757 toInject = allocSmallArray(); 15758 ck_assert_ptr_eq(self->f->injectArray(self, 0, toInject), NULL); 15759 terminateO(toInject); 15760 terminateO(self); 15761 15762 } 15763 15764 15765 void injectArraycSmallJsonT(void) { 15766 15767 smallJsont* r; 15768 smallJsont *self = allocSmallJson(); 15769 char **toInject; 15770 15771 // add elements to self 15772 r = self->f->pushInt(self, 1); 15773 ck_assert_ptr_ne(r, null); 15774 r = self->f->pushInt(self, 2); 15775 ck_assert_ptr_ne(r, null); 15776 r = self->f->pushInt(self, 3); 15777 ck_assert_ptr_ne(r, null); 15778 r = self->f->pushInt(self, 4); 15779 ck_assert_ptr_ne(r, null); 15780 15781 // positive index 15782 toInject = listCreateS("a","b"); 15783 r = self->f->injectArrayc(self, 1, toInject); 15784 listFreeS(toInject); 15785 ck_assert_ptr_ne(r, null); 15786 char *s = toStringO(r); 15787 ck_assert_str_eq(s, "[1,[\"a\",\"b\"],2,3,4]"); 15788 free(s); 15789 // negative index 15790 toInject = listCreateS("c","d"); 15791 r = self->f->injectArrayc(self,-1, toInject); 15792 listFreeS(toInject); 15793 ck_assert_ptr_ne(r, null); 15794 s = toStringO(r); 15795 ck_assert_str_eq(s, "[1,[\"a\",\"b\"],2,3,4,[\"c\",\"d\"]]"); 15796 free(s); 15797 // index 0 15798 toInject = listCreateS("e","ff"); 15799 r = self->f->injectArrayc(self,0, toInject); 15800 listFreeS(toInject); 15801 ck_assert_ptr_ne(r, null); 15802 s = toStringO(r); 15803 ck_assert_str_eq(s, "[[\"e\",\"ff\"],1,[\"a\",\"b\"],2,3,4,[\"c\",\"d\"]]"); 15804 free(s); 15805 // index outside 15806 toInject = listCreateS("a","b"); 15807 ck_assert_ptr_eq(self->f->injectArrayc(self, 20, toInject), NULL); 15808 ck_assert_ptr_eq(self->f->injectArrayc(self, -9, toInject), NULL); 15809 listFreeS(toInject); 15810 // empty list 15811 emptyO(self); 15812 toInject = listCreateS("a","b"); 15813 ck_assert_ptr_ne(self->f->injectArrayc(self, 0, toInject), NULL); 15814 listFreeS(toInject); 15815 s = toStringO(r); 15816 ck_assert_str_eq(s, "[[\"a\",\"b\"]]"); 15817 free(s); 15818 emptyO(self); 15819 toInject = listCreateS("a","b"); 15820 ck_assert_ptr_ne(self->f->injectArrayc(self, -1, toInject), NULL); 15821 listFreeS(toInject); 15822 s = toStringO(r); 15823 ck_assert_str_eq(s, "[[\"a\",\"b\"]]"); 15824 free(s); 15825 // null toInsert 15826 ck_assert_ptr_eq(self->f->injectArrayc(self, 0, NULL), NULL); 15827 // non json array 15828 freeO(self); 15829 setTypeBoolO(self); 15830 toInject = listCreateS("e","ff"); 15831 ck_assert_ptr_eq(self->f->injectArrayc(self, 0, toInject), NULL); 15832 listFreeS(toInject); 15833 terminateO(self); 15834 15835 } 15836 15837 15838 void injectSmallBoolSmallJsonT(void) { 15839 15840 smallJsont* r; 15841 smallJsont *self = allocSmallJson(); 15842 smallBoolt *toInject; 15843 15844 // add elements to self 15845 r = self->f->pushInt(self, 1); 15846 ck_assert_ptr_ne(r, null); 15847 r = self->f->pushInt(self, 2); 15848 ck_assert_ptr_ne(r, null); 15849 r = self->f->pushInt(self, 3); 15850 ck_assert_ptr_ne(r, null); 15851 r = self->f->pushInt(self, 4); 15852 ck_assert_ptr_ne(r, null); 15853 15854 // positive index 15855 toInject = allocSmallBool(true); 15856 r = self->f->injectSmallBool(self, 1, toInject); 15857 ck_assert_ptr_ne(r, null); 15858 finishO(toInject); 15859 char *s = toStringO(r); 15860 ck_assert_str_eq(s, "[1,true,2,3,4]"); 15861 free(s); 15862 // negative index 15863 toInject = allocSmallBool(true); 15864 r = self->f->injectSmallBool(self,-1, toInject); 15865 ck_assert_ptr_ne(r, null); 15866 finishO(toInject); 15867 s = toStringO(r); 15868 ck_assert_str_eq(s, "[1,true,2,3,4,true]"); 15869 free(s); 15870 // index 0 15871 toInject = allocSmallBool(true); 15872 r = self->f->injectSmallBool(self,0, toInject); 15873 ck_assert_ptr_ne(r, null); 15874 finishO(toInject); 15875 s = toStringO(r); 15876 ck_assert_str_eq(s, "[true,1,true,2,3,4,true]"); 15877 free(s); 15878 // index outside 15879 toInject = allocSmallBool(true); 15880 ck_assert_ptr_eq(self->f->injectSmallBool(self, 20, toInject), NULL); 15881 ck_assert_ptr_eq(self->f->injectSmallBool(self, -9, toInject), NULL); 15882 terminateO(toInject); 15883 // empty object 15884 emptyO(self); 15885 toInject = allocSmallBool(true); 15886 freeO(toInject); 15887 ck_assert_ptr_ne(self->f->injectSmallBool(self, 0, toInject), NULL); 15888 finishO(toInject); 15889 s = toStringO(r); 15890 ck_assert_str_eq(s, "[false]"); 15891 free(s); 15892 // empty list 15893 emptyO(self); 15894 toInject = allocSmallBool(true); 15895 ck_assert_ptr_ne(self->f->injectSmallBool(self, 0, toInject), NULL); 15896 finishO(toInject); 15897 s = toStringO(r); 15898 ck_assert_str_eq(s, "[true]"); 15899 free(s); 15900 emptyO(self); 15901 toInject = allocSmallBool(true); 15902 ck_assert_ptr_ne(self->f->injectSmallBool(self, -1, toInject), NULL); 15903 finishO(toInject); 15904 s = toStringO(r); 15905 ck_assert_str_eq(s, "[true]"); 15906 free(s); 15907 // non smallBool object 15908 toInject = (smallBoolt*) allocSmallInt(2); 15909 r = self->f->injectSmallBool(self, 0, toInject); 15910 ck_assert_ptr_eq(r, null); 15911 terminateO(toInject); 15912 // null toInsert 15913 ck_assert_ptr_eq(self->f->injectSmallBool(self, 0, NULL), NULL); 15914 terminateO(self); 15915 15916 } 15917 15918 15919 void injectSmallBytesSmallJsonT(void) { 15920 15921 smallJsont* r; 15922 smallJsont *self = allocSmallJson(); 15923 smallBytest *toInject; 15924 15925 // add elements to self 15926 r = self->f->pushInt(self, 1); 15927 ck_assert_ptr_ne(r, null); 15928 r = self->f->pushInt(self, 2); 15929 ck_assert_ptr_ne(r, null); 15930 r = self->f->pushInt(self, 3); 15931 ck_assert_ptr_ne(r, null); 15932 r = self->f->pushInt(self, 4); 15933 ck_assert_ptr_ne(r, null); 15934 15935 // positive index 15936 toInject = allocSmallBytes(null, 0); 15937 r = self->f->injectSmallBytes(self, 1, toInject); 15938 ck_assert_ptr_ne(r, null); 15939 finishO(toInject); 15940 char *s = toStringO(r); 15941 ck_assert_str_eq(s, "[1,[],2,3,4]"); 15942 free(s); 15943 // negative index 15944 toInject = allocSmallBytes(null, 0); 15945 r = self->f->injectSmallBytes(self,-1, toInject); 15946 ck_assert_ptr_ne(r, null); 15947 finishO(toInject); 15948 s = toStringO(r); 15949 ck_assert_str_eq(s, "[1,[],2,3,4,[]]"); 15950 free(s); 15951 // index 0 15952 toInject = allocSmallBytes(null, 0); 15953 r = self->f->injectSmallBytes(self,0, toInject); 15954 ck_assert_ptr_ne(r, null); 15955 finishO(toInject); 15956 s = toStringO(r); 15957 ck_assert_str_eq(s, "[[],1,[],2,3,4,[]]"); 15958 free(s); 15959 // index outside 15960 toInject = allocSmallBytes(null, 0); 15961 ck_assert_ptr_eq(self->f->injectSmallBytes(self, 20, toInject), NULL); 15962 ck_assert_ptr_eq(self->f->injectSmallBytes(self, -9, toInject), NULL); 15963 terminateO(toInject); 15964 // empty object 15965 emptyO(self); 15966 toInject = allocSmallBytes(null, 0); 15967 freeO(toInject); 15968 ck_assert_ptr_ne(self->f->injectSmallBytes(self, 0, toInject), NULL); 15969 finishO(toInject); 15970 s = toStringO(r); 15971 ck_assert_str_eq(s, "[[]]"); 15972 free(s); 15973 // empty list 15974 emptyO(self); 15975 toInject = allocSmallBytes(null, 0); 15976 ck_assert_ptr_ne(self->f->injectSmallBytes(self, 0, toInject), NULL); 15977 finishO(toInject); 15978 s = toStringO(r); 15979 ck_assert_str_eq(s, "[[]]"); 15980 free(s); 15981 emptyO(self); 15982 toInject = allocSmallBytes(null, 0); 15983 ck_assert_ptr_ne(self->f->injectSmallBytes(self, -1, toInject), NULL); 15984 finishO(toInject); 15985 s = toStringO(r); 15986 ck_assert_str_eq(s, "[[]]"); 15987 free(s); 15988 // non smallBytes object 15989 toInject = (smallBytest*) allocSmallInt(2); 15990 r = self->f->injectSmallBytes(self, 0, toInject); 15991 ck_assert_ptr_eq(r, null); 15992 terminateO(toInject); 15993 // null toInsert 15994 ck_assert_ptr_eq(self->f->injectSmallBytes(self, 0, NULL), NULL); 15995 terminateO(self); 15996 15997 } 15998 15999 16000 void injectSmallDoubleSmallJsonT(void) { 16001 16002 smallJsont* r; 16003 smallJsont *self = allocSmallJson(); 16004 smallDoublet *toInject; 16005 16006 // add elements to self 16007 r = self->f->pushInt(self, 1); 16008 ck_assert_ptr_ne(r, null); 16009 r = self->f->pushInt(self, 2); 16010 ck_assert_ptr_ne(r, null); 16011 r = self->f->pushInt(self, 3); 16012 ck_assert_ptr_ne(r, null); 16013 r = self->f->pushInt(self, 4); 16014 ck_assert_ptr_ne(r, null); 16015 16016 // positive index 16017 toInject = allocSmallDouble(2); 16018 r = self->f->injectSmallDouble(self, 1, toInject); 16019 ck_assert_ptr_ne(r, null); 16020 finishO(toInject); 16021 char *s = toStringO(r); 16022 ck_assert_str_eq(s, "[1,2.000000e+00,2,3,4]"); 16023 free(s); 16024 // negative index 16025 toInject = allocSmallDouble(3); 16026 r = self->f->injectSmallDouble(self,-1, toInject); 16027 ck_assert_ptr_ne(r, null); 16028 finishO(toInject); 16029 s = toStringO(r); 16030 ck_assert_str_eq(s, "[1,2.000000e+00,2,3,4,3.000000e+00]"); 16031 free(s); 16032 // index 0 16033 toInject = allocSmallDouble(1); 16034 r = self->f->injectSmallDouble(self,0, toInject); 16035 ck_assert_ptr_ne(r, null); 16036 finishO(toInject); 16037 s = toStringO(r); 16038 ck_assert_str_eq(s, "[1.000000e+00,1,2.000000e+00,2,3,4,3.000000e+00]"); 16039 free(s); 16040 // index outside 16041 toInject = allocSmallDouble(1); 16042 ck_assert_ptr_eq(self->f->injectSmallDouble(self, 20, toInject), NULL); 16043 ck_assert_ptr_eq(self->f->injectSmallDouble(self, -9, toInject), NULL); 16044 terminateO(toInject); 16045 // empty object 16046 emptyO(self); 16047 toInject = allocSmallDouble(1); 16048 freeO(toInject); 16049 ck_assert_ptr_ne(self->f->injectSmallDouble(self, 0, toInject), NULL); 16050 finishO(toInject); 16051 s = toStringO(r); 16052 ck_assert_str_eq(s, "[0.000000e+00]"); 16053 free(s); 16054 // empty list 16055 emptyO(self); 16056 toInject = allocSmallDouble(1); 16057 ck_assert_ptr_ne(self->f->injectSmallDouble(self, 0, toInject), NULL); 16058 finishO(toInject); 16059 s = toStringO(r); 16060 ck_assert_str_eq(s, "[1.000000e+00]"); 16061 free(s); 16062 emptyO(self); 16063 toInject = allocSmallDouble(1); 16064 ck_assert_ptr_ne(self->f->injectSmallDouble(self, -1, toInject), NULL); 16065 finishO(toInject); 16066 s = toStringO(r); 16067 ck_assert_str_eq(s, "[1.000000e+00]"); 16068 free(s); 16069 // non smallDouble object 16070 toInject = (smallDoublet*) allocSmallInt(2); 16071 r = self->f->injectSmallDouble(self, 0, toInject); 16072 ck_assert_ptr_eq(r, null); 16073 terminateO(toInject); 16074 // null toInsert 16075 ck_assert_ptr_eq(self->f->injectSmallDouble(self, 0, NULL), NULL); 16076 terminateO(self); 16077 16078 } 16079 16080 16081 void injectSmallIntSmallJsonT(void) { 16082 16083 smallJsont* r; 16084 smallJsont *self = allocSmallJson(); 16085 smallIntt *toInject; 16086 16087 // add elements to self 16088 r = self->f->pushInt(self, 1); 16089 ck_assert_ptr_ne(r, null); 16090 r = self->f->pushInt(self, 2); 16091 ck_assert_ptr_ne(r, null); 16092 r = self->f->pushInt(self, 3); 16093 ck_assert_ptr_ne(r, null); 16094 r = self->f->pushInt(self, 4); 16095 ck_assert_ptr_ne(r, null); 16096 16097 // positive index 16098 toInject = allocSmallInt(10); 16099 r = self->f->injectSmallInt(self, 1, toInject); 16100 ck_assert_ptr_ne(r, null); 16101 finishO(toInject); 16102 char *s = toStringO(r); 16103 ck_assert_str_eq(s, "[1,10,2,3,4]"); 16104 free(s); 16105 // negative index 16106 toInject = allocSmallInt(11); 16107 r = self->f->injectSmallInt(self,-1, toInject); 16108 ck_assert_ptr_ne(r, null); 16109 finishO(toInject); 16110 s = toStringO(r); 16111 ck_assert_str_eq(s, "[1,10,2,3,4,11]"); 16112 free(s); 16113 // index 0 16114 toInject = allocSmallInt(12); 16115 r = self->f->injectSmallInt(self,0, toInject); 16116 ck_assert_ptr_ne(r, null); 16117 finishO(toInject); 16118 s = toStringO(r); 16119 ck_assert_str_eq(s, "[12,1,10,2,3,4,11]"); 16120 free(s); 16121 // index outside 16122 toInject = allocSmallInt(10); 16123 ck_assert_ptr_eq(self->f->injectSmallInt(self, 20, toInject), NULL); 16124 ck_assert_ptr_eq(self->f->injectSmallInt(self, -9, toInject), NULL); 16125 terminateO(toInject); 16126 // empty object 16127 emptyO(self); 16128 toInject = allocSmallInt(10); 16129 freeO(toInject); 16130 ck_assert_ptr_ne(self->f->injectSmallInt(self, 0, toInject), NULL); 16131 finishO(toInject); 16132 s = toStringO(r); 16133 ck_assert_str_eq(s, "[0]"); 16134 free(s); 16135 // empty list 16136 emptyO(self); 16137 toInject = allocSmallInt(10); 16138 ck_assert_ptr_ne(self->f->injectSmallInt(self, 0, toInject), NULL); 16139 finishO(toInject); 16140 s = toStringO(r); 16141 ck_assert_str_eq(s, "[10]"); 16142 free(s); 16143 emptyO(self); 16144 toInject = allocSmallInt(10); 16145 ck_assert_ptr_ne(self->f->injectSmallInt(self, -1, toInject), NULL); 16146 finishO(toInject); 16147 s = toStringO(r); 16148 ck_assert_str_eq(s, "[10]"); 16149 free(s); 16150 // non smallInt object 16151 toInject = (smallIntt*) allocSmallBool(true); 16152 r = self->f->injectSmallInt(self, 0, toInject); 16153 ck_assert_ptr_eq(r, null); 16154 terminateO(toInject); 16155 // null toInsert 16156 ck_assert_ptr_eq(self->f->injectSmallInt(self, 0, NULL), NULL); 16157 terminateO(self); 16158 16159 } 16160 16161 16162 void injectSmallJsonSmallJsonT(void) { 16163 16164 smallJsont* r; 16165 smallJsont *self = allocSmallJson(); 16166 smallJsont *toInject; 16167 16168 // add elements to self 16169 r = self->f->pushInt(self, 1); 16170 ck_assert_ptr_ne(r, null); 16171 r = self->f->pushInt(self, 2); 16172 ck_assert_ptr_ne(r, null); 16173 r = self->f->pushInt(self, 3); 16174 ck_assert_ptr_ne(r, null); 16175 r = self->f->pushInt(self, 4); 16176 ck_assert_ptr_ne(r, null); 16177 16178 // positive index 16179 toInject = allocSmallJson(); 16180 r = self->f->injectSmallJson(self, 1, toInject); 16181 ck_assert_ptr_ne(r, null); 16182 finishO(toInject); 16183 char *s = toStringO(r); 16184 ck_assert_str_eq(s, "[1,{},2,3,4]"); 16185 free(s); 16186 // negative index 16187 toInject = allocSmallJson(); 16188 r = self->f->injectSmallJson(self,-1, toInject); 16189 ck_assert_ptr_ne(r, null); 16190 finishO(toInject); 16191 s = toStringO(r); 16192 ck_assert_str_eq(s, "[1,{},2,3,4,{}]"); 16193 free(s); 16194 // index 0 16195 toInject = allocSmallJson(); 16196 toInject->f->setS(toInject, "key", "value"); 16197 r = self->f->injectSmallJson(self,0, toInject); 16198 ck_assert_ptr_ne(r, null); 16199 finishO(toInject); 16200 s = toStringO(r); 16201 ck_assert_str_eq(s, "[{\"key\":\"value\"},1,{},2,3,4,{}]"); 16202 free(s); 16203 // index outside 16204 toInject = allocSmallJson(); 16205 ck_assert_ptr_eq(self->f->injectSmallJson(self, 20, toInject), NULL); 16206 ck_assert_ptr_eq(self->f->injectSmallJson(self, -9, toInject), NULL); 16207 terminateO(toInject); 16208 // empty object 16209 emptyO(self); 16210 toInject = allocSmallJson(); 16211 freeO(toInject); 16212 ck_assert_ptr_ne(self->f->injectSmallJson(self, 0, toInject), NULL); 16213 finishO(toInject); 16214 s = toStringO(r); 16215 ck_assert_str_eq(s, "[{}]"); 16216 free(s); 16217 // empty list 16218 emptyO(self); 16219 toInject = allocSmallJson(); 16220 ck_assert_ptr_ne(self->f->injectSmallJson(self, 0, toInject), NULL); 16221 finishO(toInject); 16222 s = toStringO(r); 16223 ck_assert_str_eq(s, "[{}]"); 16224 free(s); 16225 emptyO(self); 16226 toInject = allocSmallJson(); 16227 ck_assert_ptr_ne(self->f->injectSmallJson(self, -1, toInject), NULL); 16228 finishO(toInject); 16229 s = toStringO(r); 16230 ck_assert_str_eq(s, "[{}]"); 16231 free(s); 16232 // non smallJson object 16233 toInject = (smallJsont*) allocSmallInt(2); 16234 r = self->f->injectSmallJson(self, 0, toInject); 16235 ck_assert_ptr_eq(r, null); 16236 terminateO(toInject); 16237 // null toInsert 16238 ck_assert_ptr_eq(self->f->injectSmallJson(self, 0, NULL), NULL); 16239 terminateO(self); 16240 16241 } 16242 16243 16244 void injectSmallStringSmallJsonT(void) { 16245 16246 smallJsont* r; 16247 smallJsont *self = allocSmallJson(); 16248 smallStringt *toInject; 16249 16250 // add elements to self 16251 r = self->f->pushInt(self, 1); 16252 ck_assert_ptr_ne(r, null); 16253 r = self->f->pushInt(self, 2); 16254 ck_assert_ptr_ne(r, null); 16255 r = self->f->pushInt(self, 3); 16256 ck_assert_ptr_ne(r, null); 16257 r = self->f->pushInt(self, 4); 16258 ck_assert_ptr_ne(r, null); 16259 16260 // positive index 16261 toInject = allocSmallString("1"); 16262 r = self->f->injectSmallString(self, 1, toInject); 16263 ck_assert_ptr_ne(r, null); 16264 finishO(toInject); 16265 char *s = toStringO(r); 16266 ck_assert_str_eq(s, "[1,\"1\",2,3,4]"); 16267 free(s); 16268 // negative index 16269 toInject = allocSmallString("2"); 16270 r = self->f->injectSmallString(self,-1, toInject); 16271 ck_assert_ptr_ne(r, null); 16272 finishO(toInject); 16273 s = toStringO(r); 16274 ck_assert_str_eq(s, "[1,\"1\",2,3,4,\"2\"]"); 16275 free(s); 16276 // index 0 16277 toInject = allocSmallString("3"); 16278 r = self->f->injectSmallString(self,0, toInject); 16279 ck_assert_ptr_ne(r, null); 16280 finishO(toInject); 16281 s = toStringO(r); 16282 ck_assert_str_eq(s, "[\"3\",1,\"1\",2,3,4,\"2\"]"); 16283 free(s); 16284 // index outside 16285 toInject = allocSmallString("1"); 16286 ck_assert_ptr_eq(self->f->injectSmallString(self, 20, toInject), NULL); 16287 ck_assert_ptr_eq(self->f->injectSmallString(self, -9, toInject), NULL); 16288 terminateO(toInject); 16289 // empty object 16290 emptyO(self); 16291 toInject = allocSmallString("1"); 16292 freeO(toInject); 16293 r = self->f->injectSmallString(self, 0, toInject); 16294 ck_assert_ptr_ne(r, NULL); 16295 finishO(toInject); 16296 s = toStringO(r); 16297 ck_assert_str_eq(s, "[\"\"]"); 16298 free(s); 16299 // empty list 16300 emptyO(self); 16301 toInject = allocSmallString("1"); 16302 r = self->f->injectSmallString(self, 0, toInject); 16303 ck_assert_ptr_ne(r, NULL); 16304 finishO(toInject); 16305 s = toStringO(r); 16306 ck_assert_str_eq(s, "[\"1\"]"); 16307 free(s); 16308 emptyO(self); 16309 toInject = allocSmallString("1"); 16310 r = self->f->injectSmallString(self, -1, toInject); 16311 ck_assert_ptr_ne(r, NULL); 16312 finishO(toInject); 16313 s = toStringO(r); 16314 ck_assert_str_eq(s, "[\"1\"]"); 16315 free(s); 16316 // non smallString object 16317 toInject = (smallStringt*) allocSmallInt(2); 16318 r = self->f->injectSmallString(self, 0, toInject); 16319 ck_assert_ptr_eq(r, null); 16320 terminateO(toInject); 16321 // null toInsert 16322 ck_assert_ptr_eq(self->f->injectSmallString(self, 0, NULL), NULL); 16323 terminateO(self); 16324 // json string 16325 self = allocSmallJson(); 16326 setTopSO(self, "s"); 16327 toInject = allocSmallString("heepy"); 16328 r = self->f->injectSmallString(self, 1, toInject); 16329 ck_assert_ptr_ne(r, NULL); 16330 terminateO(toInject); 16331 s = toStringO(r); 16332 ck_assert_str_eq(s, "sheepy"); 16333 free(s); 16334 terminateO(self); 16335 16336 16337 } 16338 16339 16340 void injectSmallContainerSmallJsonT(void) { 16341 16342 smallJsont* r; 16343 smallJsont *self = allocSmallJson(); 16344 smallContainert *toInject; 16345 16346 // add elements to self 16347 r = self->f->pushInt(self, 1); 16348 ck_assert_ptr_ne(r, null); 16349 r = self->f->pushInt(self, 2); 16350 ck_assert_ptr_ne(r, null); 16351 r = self->f->pushInt(self, 3); 16352 ck_assert_ptr_ne(r, null); 16353 r = self->f->pushInt(self, 4); 16354 ck_assert_ptr_ne(r, null); 16355 16356 // positive index 16357 toInject = allocSmallContainer(NULL); 16358 r = self->f->injectSmallContainer(self, 1, toInject); 16359 ck_assert_ptr_ne(r, null); 16360 finishO(toInject); 16361 char *s = toStringO(r); 16362 ck_assert_str_eq(s, "[1,\"<data container>\",2,3,4]"); 16363 free(s); 16364 // negative index 16365 toInject = allocSmallContainer(NULL); 16366 r = self->f->injectSmallContainer(self,-1, toInject); 16367 ck_assert_ptr_ne(r, null); 16368 finishO(toInject); 16369 s = toStringO(r); 16370 ck_assert_str_eq(s, "[1,\"<data container>\",2,3,4,\"<data container>\"]"); 16371 free(s); 16372 // index 0 16373 toInject = allocSmallContainer(NULL); 16374 r = self->f->injectSmallContainer(self,0, toInject); 16375 ck_assert_ptr_ne(r, null); 16376 finishO(toInject); 16377 s = toStringO(r); 16378 ck_assert_str_eq(s, "[\"<data container>\",1,\"<data container>\",2,3,4,\"<data container>\"]"); 16379 free(s); 16380 // index outside 16381 toInject = allocSmallContainer(NULL); 16382 ck_assert_ptr_eq(self->f->injectSmallContainer(self, 20, toInject), NULL); 16383 ck_assert_ptr_eq(self->f->injectSmallContainer(self, -9, toInject), NULL); 16384 terminateO(toInject); 16385 // empty object 16386 emptyO(self); 16387 toInject = allocSmallContainer(NULL); 16388 freeO(toInject); 16389 ck_assert_ptr_ne(self->f->injectSmallContainer(self, 0, toInject), NULL); 16390 finishO(toInject); 16391 s = toStringO(r); 16392 ck_assert_str_eq(s, "[\"<data container>\"]"); 16393 free(s); 16394 // empty list 16395 emptyO(self); 16396 toInject = allocSmallContainer(NULL); 16397 ck_assert_ptr_ne(self->f->injectSmallContainer(self, 0, toInject), NULL); 16398 finishO(toInject); 16399 s = toStringO(r); 16400 ck_assert_str_eq(s, "[\"<data container>\"]"); 16401 free(s); 16402 emptyO(self); 16403 toInject = allocSmallContainer(NULL); 16404 ck_assert_ptr_ne(self->f->injectSmallContainer(self, -1, toInject), NULL); 16405 finishO(toInject); 16406 s = toStringO(r); 16407 ck_assert_str_eq(s, "[\"<data container>\"]"); 16408 free(s); 16409 // non smallContainer object 16410 toInject = (smallContainert*) allocSmallInt(2); 16411 r = self->f->injectSmallContainer(self, 0, toInject); 16412 ck_assert_ptr_eq(r, null); 16413 terminateO(toInject); 16414 // null toInsert 16415 ck_assert_ptr_eq(self->f->injectSmallContainer(self, 0, NULL), NULL); 16416 terminateO(self); 16417 16418 } 16419 16420 16421 void injectNFreeSmallJsonT(void) { 16422 16423 smallJsont* r; 16424 smallJsont *self = allocSmallJson(); 16425 baset *toInject; 16426 16427 // add elements to self 16428 r = self->f->pushInt(self, 1); 16429 ck_assert_ptr_ne(r, null); 16430 r = self->f->pushInt(self, 2); 16431 ck_assert_ptr_ne(r, null); 16432 r = self->f->pushInt(self, 3); 16433 ck_assert_ptr_ne(r, null); 16434 r = self->f->pushInt(self, 4); 16435 ck_assert_ptr_ne(r, null); 16436 16437 // positive index 16438 toInject = (baset*) allocSmallInt(8); 16439 r = self->f->injectNFree(self, 1, toInject); 16440 ck_assert_ptr_ne(r, null); 16441 char *s = toStringO(r); 16442 ck_assert_str_eq(s, "[1,8,2,3,4]"); 16443 free(s); 16444 // negative index 16445 toInject = (baset*) allocSmallInt(9); 16446 r = self->f->injectNFree(self,-1, toInject); 16447 ck_assert_ptr_ne(r, null); 16448 s = toStringO(r); 16449 ck_assert_str_eq(s, "[1,8,2,3,4,9]"); 16450 free(s); 16451 // index 0 16452 toInject = (baset*) allocSmallInt(6); 16453 r = self->f->injectNFree(self,0, toInject); 16454 ck_assert_ptr_ne(r, null); 16455 s = toStringO(r); 16456 ck_assert_str_eq(s, "[6,1,8,2,3,4,9]"); 16457 free(s); 16458 // index outside 16459 toInject = (baset*) allocSmallInt(7); 16460 ck_assert_ptr_eq(self->f->injectNFree(self, 20, toInject), NULL); 16461 ck_assert_ptr_eq(self->f->injectNFree(self, -9, toInject), NULL); 16462 terminateO(toInject); 16463 // empty list 16464 emptyO(self); 16465 toInject = (baset*) allocSmallInt(7); 16466 ck_assert_ptr_ne(self->f->injectNFree(self, 0, toInject), NULL); 16467 s = toStringO(r); 16468 ck_assert_str_eq(s, "[7]"); 16469 free(s); 16470 emptyO(self); 16471 toInject = (baset*) allocSmallInt(7); 16472 ck_assert_ptr_ne(self->f->injectNFree(self, -1, toInject), NULL); 16473 s = toStringO(r); 16474 ck_assert_str_eq(s, "[7]"); 16475 free(s); 16476 // null toInsert 16477 ck_assert_ptr_eq(self->f->injectNFree(self, 0, NULL), NULL); 16478 // non json array 16479 freeO(self); 16480 setTypeBoolO(self); 16481 toInject = (baset*) allocSmallInt(7); 16482 ck_assert_ptr_eq(self->f->injectNFree(self, 0, toInject), NULL); 16483 terminateO(toInject); 16484 terminateO(self); 16485 16486 } 16487 16488 16489 void injectNFreeUndefinedSmallJsonT(void) { 16490 16491 smallJsont* r; 16492 smallJsont *self = allocSmallJson(); 16493 undefinedt *value = NULL; 16494 16495 16496 // add elements to self 16497 r = self->f->pushInt(self, 1); 16498 ck_assert_ptr_ne(r, null); 16499 r = self->f->pushInt(self, 2); 16500 ck_assert_ptr_ne(r, null); 16501 r = self->f->pushInt(self, 3); 16502 ck_assert_ptr_ne(r, null); 16503 r = self->f->pushInt(self, 4); 16504 ck_assert_ptr_ne(r, null); 16505 16506 // positive index 16507 value = allocUndefined(); 16508 r = self->f->injectNFreeUndefined(self, 1, value); 16509 ck_assert_ptr_ne(r, null); 16510 char *s = toStringO(r); 16511 ck_assert_str_eq(s, "[1,null,2,3,4]"); 16512 free(s); 16513 // negative index 16514 value = allocUndefined(); 16515 r = self->f->injectNFreeUndefined(self,-1, value); 16516 ck_assert_ptr_ne(r, null); 16517 s = toStringO(r); 16518 ck_assert_str_eq(s, "[1,null,2,3,4,null]"); 16519 free(s); 16520 // index 0 16521 value = allocUndefined(); 16522 r = self->f->injectNFreeUndefined(self,0, value); 16523 ck_assert_ptr_ne(r, null); 16524 s = toStringO(r); 16525 ck_assert_str_eq(s, "[null,1,null,2,3,4,null]"); 16526 free(s); 16527 // index outside 16528 value = allocUndefined(); 16529 ck_assert_ptr_eq(self->f->injectNFreeUndefined(self, 20, value), NULL); 16530 terminateO(value); 16531 16532 value = allocUndefined(); 16533 ck_assert_ptr_eq(self->f->injectNFreeUndefined(self, -9, value), NULL); 16534 terminateO(value); 16535 16536 // empty list 16537 emptyO(self); 16538 value = allocUndefined(); 16539 ck_assert_ptr_ne(self->f->injectNFreeUndefined(self, 0, value), NULL); 16540 s = toStringO(r); 16541 ck_assert_str_eq(s, "[null]"); 16542 free(s); 16543 emptyO(self); 16544 value = allocUndefined(); 16545 ck_assert_ptr_ne(self->f->injectNFreeUndefined(self, -1, value), NULL); 16546 s = toStringO(r); 16547 ck_assert_str_eq(s, "[null]"); 16548 free(s); 16549 terminateO(self); 16550 16551 } 16552 16553 16554 void injectNFreeSSmallJsonT(void) { 16555 16556 smallJsont* r; 16557 smallJsont *self = allocSmallJson(); 16558 16559 // add elements to self 16560 r = self->f->pushInt(self, 1); 16561 ck_assert_ptr_ne(r, null); 16562 r = self->f->pushInt(self, 2); 16563 ck_assert_ptr_ne(r, null); 16564 r = self->f->pushInt(self, 3); 16565 ck_assert_ptr_ne(r, null); 16566 r = self->f->pushInt(self, 4); 16567 ck_assert_ptr_ne(r, null); 16568 16569 // positive index 16570 r = self->f->injectNFreeS(self, 1, strdup("5")); 16571 ck_assert_ptr_ne(r, null); 16572 char *s = toStringO(r); 16573 ck_assert_str_eq(s, "[1,\"5\",2,3,4]"); 16574 free(s); 16575 // negative index 16576 r = self->f->injectNFreeS(self,-1, strdup("6")); 16577 ck_assert_ptr_ne(r, null); 16578 s = toStringO(r); 16579 ck_assert_str_eq(s, "[1,\"5\",2,3,4,\"6\"]"); 16580 free(s); 16581 // index 0 16582 r = self->f->injectNFreeS(self,0, strdup("7")); 16583 ck_assert_ptr_ne(r, null); 16584 s = toStringO(r); 16585 ck_assert_str_eq(s, "[\"7\",1,\"5\",2,3,4,\"6\"]"); 16586 free(s); 16587 // index outside 16588 ck_assert_ptr_eq(self->f->injectNFreeS(self, 20, ""), NULL); 16589 ck_assert_ptr_eq(self->f->injectNFreeS(self, -9, ""), NULL); 16590 // empty list 16591 emptyO(self); 16592 r = self->f->injectNFreeS(self, 0, strdup("7")); 16593 ck_assert_ptr_ne(r, NULL); 16594 s = toStringO(r); 16595 ck_assert_str_eq(s, "[\"7\"]"); 16596 free(s); 16597 emptyO(self); 16598 r = self->f->injectNFreeS(self, -1, strdup("7")); 16599 ck_assert_ptr_ne(r, NULL); 16600 s = toStringO(r); 16601 ck_assert_str_eq(s, "[\"7\"]"); 16602 free(s); 16603 // null 16604 ck_assert_ptr_eq(self->f->injectNFreeS(self, -1, null), NULL); 16605 terminateO(self); 16606 16607 } 16608 16609 16610 void injectNFreeDictSmallJsonT(void) { 16611 16612 smallJsont* r; 16613 smallJsont *self = allocSmallJson(); 16614 smallDictt *toInject; 16615 16616 // add elements to self 16617 r = self->f->pushInt(self, 1); 16618 ck_assert_ptr_ne(r, null); 16619 r = self->f->pushInt(self, 2); 16620 ck_assert_ptr_ne(r, null); 16621 r = self->f->pushInt(self, 3); 16622 ck_assert_ptr_ne(r, null); 16623 r = self->f->pushInt(self, 4); 16624 ck_assert_ptr_ne(r, null); 16625 16626 // positive index 16627 toInject = allocSmallDict(); 16628 r = self->f->injectNFreeDict(self, 1, toInject); 16629 ck_assert_ptr_ne(r, null); 16630 char *s = toStringO(r); 16631 ck_assert_str_eq(s, "[1,{},2,3,4]"); 16632 free(s); 16633 // negative index 16634 toInject = allocSmallDict(); 16635 r = self->f->injectNFreeDict(self,-1, toInject); 16636 ck_assert_ptr_ne(r, null); 16637 s = toStringO(r); 16638 ck_assert_str_eq(s, "[1,{},2,3,4,{}]"); 16639 free(s); 16640 // index 0 16641 toInject = allocSmallDict(); 16642 r = self->f->injectNFreeDict(self,0, toInject); 16643 ck_assert_ptr_ne(r, null); 16644 s = toStringO(r); 16645 ck_assert_str_eq(s, "[{},1,{},2,3,4,{}]"); 16646 free(s); 16647 // index outside 16648 toInject = allocSmallDict(); 16649 ck_assert_ptr_eq(self->f->injectNFreeDict(self, 20, toInject), NULL); 16650 ck_assert_ptr_eq(self->f->injectNFreeDict(self, -9, toInject), NULL); 16651 terminateO(toInject); 16652 // empty list 16653 emptyO(self); 16654 toInject = allocSmallDict(); 16655 ck_assert_ptr_ne(self->f->injectNFreeDict(self, 0, toInject), NULL); 16656 s = toStringO(r); 16657 ck_assert_str_eq(s, "[{}]"); 16658 free(s); 16659 emptyO(self); 16660 toInject = allocSmallDict(); 16661 ck_assert_ptr_ne(self->f->injectNFreeDict(self, -1, toInject), NULL); 16662 s = toStringO(r); 16663 ck_assert_str_eq(s, "[{}]"); 16664 free(s); 16665 // null toInsert 16666 ck_assert_ptr_eq(self->f->injectNFreeDict(self, 0, NULL), NULL); 16667 terminateO(self); 16668 16669 } 16670 16671 16672 void injectNFreeArraySmallJsonT(void) { 16673 16674 smallJsont* r; 16675 smallJsont *self = allocSmallJson(); 16676 smallArrayt *toInject; 16677 16678 // add elements to self 16679 r = self->f->pushInt(self, 1); 16680 ck_assert_ptr_ne(r, null); 16681 r = self->f->pushInt(self, 2); 16682 ck_assert_ptr_ne(r, null); 16683 r = self->f->pushInt(self, 3); 16684 ck_assert_ptr_ne(r, null); 16685 r = self->f->pushInt(self, 4); 16686 ck_assert_ptr_ne(r, null); 16687 16688 // positive index 16689 toInject = allocSmallArray(); 16690 r = self->f->injectNFreeArray(self, 1, toInject); 16691 ck_assert_ptr_ne(r, null); 16692 char *s = toStringO(r); 16693 ck_assert_str_eq(s, "[1,[],2,3,4]"); 16694 free(s); 16695 // negative index 16696 toInject = allocSmallArray(); 16697 r = self->f->injectNFreeArray(self,-1, toInject); 16698 ck_assert_ptr_ne(r, null); 16699 s = toStringO(r); 16700 ck_assert_str_eq(s, "[1,[],2,3,4,[]]"); 16701 free(s); 16702 // index 0 16703 toInject = allocSmallArray(); 16704 r = self->f->injectNFreeArray(self,0, toInject); 16705 ck_assert_ptr_ne(r, null); 16706 s = toStringO(r); 16707 ck_assert_str_eq(s, "[[],1,[],2,3,4,[]]"); 16708 free(s); 16709 // index outside 16710 toInject = allocSmallArray(); 16711 ck_assert_ptr_eq(self->f->injectNFreeArray(self, 20, toInject), NULL); 16712 ck_assert_ptr_eq(self->f->injectNFreeArray(self, -9, toInject), NULL); 16713 terminateO(toInject); 16714 // empty list 16715 emptyO(self); 16716 toInject = allocSmallArray(); 16717 ck_assert_ptr_ne(self->f->injectNFreeArray(self, 0, toInject), NULL); 16718 s = toStringO(r); 16719 ck_assert_str_eq(s, "[[]]"); 16720 free(s); 16721 emptyO(self); 16722 toInject = allocSmallArray(); 16723 ck_assert_ptr_ne(self->f->injectNFreeArray(self, -1, toInject), NULL); 16724 s = toStringO(r); 16725 ck_assert_str_eq(s, "[[]]"); 16726 free(s); 16727 // null toInsert 16728 ck_assert_ptr_eq(self->f->injectNFreeArray(self, 0, NULL), NULL); 16729 terminateO(self); 16730 16731 } 16732 16733 16734 void injectNFreeArraycSmallJsonT(void) { 16735 16736 smallJsont* r; 16737 smallJsont *self = allocSmallJson(); 16738 char **toInject; 16739 16740 // add elements to self 16741 r = self->f->pushInt(self, 1); 16742 ck_assert_ptr_ne(r, null); 16743 r = self->f->pushInt(self, 2); 16744 ck_assert_ptr_ne(r, null); 16745 r = self->f->pushInt(self, 3); 16746 ck_assert_ptr_ne(r, null); 16747 r = self->f->pushInt(self, 4); 16748 ck_assert_ptr_ne(r, null); 16749 16750 // positive index 16751 toInject = listCreateS("a","b"); 16752 r = self->f->injectNFreeArrayc(self, 1, toInject); 16753 ck_assert_ptr_ne(r, null); 16754 char *s = toStringO(r); 16755 ck_assert_str_eq(s, "[1,[\"a\",\"b\"],2,3,4]"); 16756 free(s); 16757 // negative index 16758 toInject = listCreateS("c","d"); 16759 r = self->f->injectNFreeArrayc(self,-1, toInject); 16760 ck_assert_ptr_ne(r, null); 16761 s = toStringO(r); 16762 ck_assert_str_eq(s, "[1,[\"a\",\"b\"],2,3,4,[\"c\",\"d\"]]"); 16763 free(s); 16764 // index 0 16765 toInject = listCreateS("e","ff"); 16766 r = self->f->injectNFreeArrayc(self,0, toInject); 16767 ck_assert_ptr_ne(r, null); 16768 s = toStringO(r); 16769 ck_assert_str_eq(s, "[[\"e\",\"ff\"],1,[\"a\",\"b\"],2,3,4,[\"c\",\"d\"]]"); 16770 free(s); 16771 // index outside 16772 toInject = listCreateS("a","b"); 16773 ck_assert_ptr_eq(self->f->injectNFreeArrayc(self, 20, toInject), NULL); 16774 ck_assert_ptr_eq(self->f->injectNFreeArrayc(self, -9, toInject), NULL); 16775 listFreeS(toInject); 16776 // empty list 16777 emptyO(self); 16778 toInject = listCreateS("a","b"); 16779 ck_assert_ptr_ne(self->f->injectNFreeArrayc(self, 0, toInject), NULL); 16780 s = toStringO(r); 16781 ck_assert_str_eq(s, "[[\"a\",\"b\"]]"); 16782 free(s); 16783 emptyO(self); 16784 toInject = listCreateS("a","b"); 16785 ck_assert_ptr_ne(self->f->injectNFreeArrayc(self, -1, toInject), NULL); 16786 s = toStringO(r); 16787 ck_assert_str_eq(s, "[[\"a\",\"b\"]]"); 16788 free(s); 16789 // null toInsert 16790 ck_assert_ptr_eq(self->f->injectNFreeArrayc(self, 0, NULL), NULL); 16791 terminateO(self); 16792 16793 } 16794 16795 16796 void injectNFreeSmallBoolSmallJsonT(void) { 16797 16798 smallJsont* r; 16799 smallJsont *self = allocSmallJson(); 16800 smallBoolt *toInject; 16801 16802 // add elements to self 16803 r = self->f->pushInt(self, 1); 16804 ck_assert_ptr_ne(r, null); 16805 r = self->f->pushInt(self, 2); 16806 ck_assert_ptr_ne(r, null); 16807 r = self->f->pushInt(self, 3); 16808 ck_assert_ptr_ne(r, null); 16809 r = self->f->pushInt(self, 4); 16810 ck_assert_ptr_ne(r, null); 16811 16812 // positive index 16813 toInject = allocSmallBool(true); 16814 r = self->f->injectNFreeSmallBool(self, 1, toInject); 16815 ck_assert_ptr_ne(r, null); 16816 char *s = toStringO(r); 16817 ck_assert_str_eq(s, "[1,true,2,3,4]"); 16818 free(s); 16819 // negative index 16820 toInject = allocSmallBool(true); 16821 r = self->f->injectNFreeSmallBool(self,-1, toInject); 16822 ck_assert_ptr_ne(r, null); 16823 s = toStringO(r); 16824 ck_assert_str_eq(s, "[1,true,2,3,4,true]"); 16825 free(s); 16826 // index 0 16827 toInject = allocSmallBool(true); 16828 r = self->f->injectNFreeSmallBool(self,0, toInject); 16829 ck_assert_ptr_ne(r, null); 16830 s = toStringO(r); 16831 ck_assert_str_eq(s, "[true,1,true,2,3,4,true]"); 16832 free(s); 16833 // index outside 16834 toInject = allocSmallBool(true); 16835 ck_assert_ptr_eq(self->f->injectNFreeSmallBool(self, 20, toInject), NULL); 16836 ck_assert_ptr_eq(self->f->injectNFreeSmallBool(self, -9, toInject), NULL); 16837 terminateO(toInject); 16838 // empty object 16839 emptyO(self); 16840 toInject = allocSmallBool(true); 16841 freeO(toInject); 16842 ck_assert_ptr_ne(self->f->injectNFreeSmallBool(self, 0, toInject), NULL); 16843 s = toStringO(r); 16844 ck_assert_str_eq(s, "[false]"); 16845 free(s); 16846 // empty list 16847 emptyO(self); 16848 toInject = allocSmallBool(true); 16849 ck_assert_ptr_ne(self->f->injectNFreeSmallBool(self, 0, toInject), NULL); 16850 s = toStringO(r); 16851 ck_assert_str_eq(s, "[true]"); 16852 free(s); 16853 emptyO(self); 16854 toInject = allocSmallBool(true); 16855 ck_assert_ptr_ne(self->f->injectNFreeSmallBool(self, -1, toInject), NULL); 16856 s = toStringO(r); 16857 ck_assert_str_eq(s, "[true]"); 16858 free(s); 16859 // null toInsert 16860 ck_assert_ptr_eq(self->f->injectNFreeSmallBool(self, 0, NULL), NULL); 16861 terminateO(self); 16862 16863 } 16864 16865 16866 void injectNFreeSmallBytesSmallJsonT(void) { 16867 16868 smallJsont* r; 16869 smallJsont *self = allocSmallJson(); 16870 smallBytest *toInject; 16871 16872 // add elements to self 16873 r = self->f->pushInt(self, 1); 16874 ck_assert_ptr_ne(r, null); 16875 r = self->f->pushInt(self, 2); 16876 ck_assert_ptr_ne(r, null); 16877 r = self->f->pushInt(self, 3); 16878 ck_assert_ptr_ne(r, null); 16879 r = self->f->pushInt(self, 4); 16880 ck_assert_ptr_ne(r, null); 16881 16882 // positive index 16883 toInject = allocSmallBytes(null, 0); 16884 r = self->f->injectNFreeSmallBytes(self, 1, toInject); 16885 ck_assert_ptr_ne(r, null); 16886 char *s = toStringO(r); 16887 ck_assert_str_eq(s, "[1,[],2,3,4]"); 16888 free(s); 16889 // negative index 16890 toInject = allocSmallBytes(null, 0); 16891 r = self->f->injectNFreeSmallBytes(self,-1, toInject); 16892 ck_assert_ptr_ne(r, null); 16893 s = toStringO(r); 16894 ck_assert_str_eq(s, "[1,[],2,3,4,[]]"); 16895 free(s); 16896 // index 0 16897 toInject = allocSmallBytes(null, 0); 16898 r = self->f->injectNFreeSmallBytes(self,0, toInject); 16899 ck_assert_ptr_ne(r, null); 16900 s = toStringO(r); 16901 ck_assert_str_eq(s, "[[],1,[],2,3,4,[]]"); 16902 free(s); 16903 // index outside 16904 toInject = allocSmallBytes(null, 0); 16905 ck_assert_ptr_eq(self->f->injectNFreeSmallBytes(self, 20, toInject), NULL); 16906 ck_assert_ptr_eq(self->f->injectNFreeSmallBytes(self, -9, toInject), NULL); 16907 terminateO(toInject); 16908 // empty object 16909 emptyO(self); 16910 toInject = allocSmallBytes(null, 0); 16911 freeO(toInject); 16912 ck_assert_ptr_ne(self->f->injectNFreeSmallBytes(self, 0, toInject), NULL); 16913 s = toStringO(r); 16914 ck_assert_str_eq(s, "[[]]"); 16915 free(s); 16916 // empty list 16917 emptyO(self); 16918 toInject = allocSmallBytes(null, 0); 16919 ck_assert_ptr_ne(self->f->injectNFreeSmallBytes(self, 0, toInject), NULL); 16920 s = toStringO(r); 16921 ck_assert_str_eq(s, "[[]]"); 16922 free(s); 16923 emptyO(self); 16924 toInject = allocSmallBytes(null, 0); 16925 ck_assert_ptr_ne(self->f->injectNFreeSmallBytes(self, -1, toInject), NULL); 16926 s = toStringO(r); 16927 ck_assert_str_eq(s, "[[]]"); 16928 free(s); 16929 // null toInsert 16930 ck_assert_ptr_eq(self->f->injectNFreeSmallBytes(self, 0, NULL), NULL); 16931 terminateO(self); 16932 16933 } 16934 16935 16936 void injectNFreeSmallDoubleSmallJsonT(void) { 16937 16938 smallJsont* r; 16939 smallJsont *self = allocSmallJson(); 16940 smallDoublet *toInject; 16941 16942 // add elements to self 16943 r = self->f->pushInt(self, 1); 16944 ck_assert_ptr_ne(r, null); 16945 r = self->f->pushInt(self, 2); 16946 ck_assert_ptr_ne(r, null); 16947 r = self->f->pushInt(self, 3); 16948 ck_assert_ptr_ne(r, null); 16949 r = self->f->pushInt(self, 4); 16950 ck_assert_ptr_ne(r, null); 16951 16952 // positive index 16953 toInject = allocSmallDouble(2); 16954 r = self->f->injectNFreeSmallDouble(self, 1, toInject); 16955 ck_assert_ptr_ne(r, null); 16956 char *s = toStringO(r); 16957 ck_assert_str_eq(s, "[1,2.000000e+00,2,3,4]"); 16958 free(s); 16959 // negative index 16960 toInject = allocSmallDouble(3); 16961 r = self->f->injectNFreeSmallDouble(self,-1, toInject); 16962 ck_assert_ptr_ne(r, null); 16963 s = toStringO(r); 16964 ck_assert_str_eq(s, "[1,2.000000e+00,2,3,4,3.000000e+00]"); 16965 free(s); 16966 // index 0 16967 toInject = allocSmallDouble(1); 16968 r = self->f->injectNFreeSmallDouble(self,0, toInject); 16969 ck_assert_ptr_ne(r, null); 16970 s = toStringO(r); 16971 ck_assert_str_eq(s, "[1.000000e+00,1,2.000000e+00,2,3,4,3.000000e+00]"); 16972 free(s); 16973 // index outside 16974 toInject = allocSmallDouble(1); 16975 ck_assert_ptr_eq(self->f->injectNFreeSmallDouble(self, 20, toInject), NULL); 16976 ck_assert_ptr_eq(self->f->injectNFreeSmallDouble(self, -9, toInject), NULL); 16977 terminateO(toInject); 16978 // empty object 16979 emptyO(self); 16980 toInject = allocSmallDouble(1); 16981 freeO(toInject); 16982 ck_assert_ptr_ne(self->f->injectNFreeSmallDouble(self, 0, toInject), NULL); 16983 s = toStringO(r); 16984 ck_assert_str_eq(s, "[0.000000e+00]"); 16985 free(s); 16986 // empty list 16987 emptyO(self); 16988 toInject = allocSmallDouble(1); 16989 ck_assert_ptr_ne(self->f->injectNFreeSmallDouble(self, 0, toInject), NULL); 16990 s = toStringO(r); 16991 ck_assert_str_eq(s, "[1.000000e+00]"); 16992 free(s); 16993 emptyO(self); 16994 toInject = allocSmallDouble(1); 16995 ck_assert_ptr_ne(self->f->injectNFreeSmallDouble(self, -1, toInject), NULL); 16996 s = toStringO(r); 16997 ck_assert_str_eq(s, "[1.000000e+00]"); 16998 free(s); 16999 // null toInsert 17000 ck_assert_ptr_eq(self->f->injectNFreeSmallDouble(self, 0, NULL), NULL); 17001 terminateO(self); 17002 17003 } 17004 17005 17006 void injectNFreeSmallIntSmallJsonT(void) { 17007 17008 smallJsont* r; 17009 smallJsont *self = allocSmallJson(); 17010 smallIntt *toInject; 17011 17012 // add elements to self 17013 r = self->f->pushInt(self, 1); 17014 ck_assert_ptr_ne(r, null); 17015 r = self->f->pushInt(self, 2); 17016 ck_assert_ptr_ne(r, null); 17017 r = self->f->pushInt(self, 3); 17018 ck_assert_ptr_ne(r, null); 17019 r = self->f->pushInt(self, 4); 17020 ck_assert_ptr_ne(r, null); 17021 17022 // positive index 17023 toInject = allocSmallInt(10); 17024 r = self->f->injectNFreeSmallInt(self, 1, toInject); 17025 ck_assert_ptr_ne(r, null); 17026 char *s = toStringO(r); 17027 ck_assert_str_eq(s, "[1,10,2,3,4]"); 17028 free(s); 17029 // negative index 17030 toInject = allocSmallInt(11); 17031 r = self->f->injectNFreeSmallInt(self,-1, toInject); 17032 ck_assert_ptr_ne(r, null); 17033 s = toStringO(r); 17034 ck_assert_str_eq(s, "[1,10,2,3,4,11]"); 17035 free(s); 17036 // index 0 17037 toInject = allocSmallInt(12); 17038 r = self->f->injectNFreeSmallInt(self,0, toInject); 17039 ck_assert_ptr_ne(r, null); 17040 s = toStringO(r); 17041 ck_assert_str_eq(s, "[12,1,10,2,3,4,11]"); 17042 free(s); 17043 // index outside 17044 toInject = allocSmallInt(10); 17045 ck_assert_ptr_eq(self->f->injectNFreeSmallInt(self, 20, toInject), NULL); 17046 ck_assert_ptr_eq(self->f->injectNFreeSmallInt(self, -9, toInject), NULL); 17047 terminateO(toInject); 17048 // empty object 17049 emptyO(self); 17050 toInject = allocSmallInt(10); 17051 freeO(toInject); 17052 ck_assert_ptr_ne(self->f->injectNFreeSmallInt(self, 0, toInject), NULL); 17053 s = toStringO(r); 17054 ck_assert_str_eq(s, "[0]"); 17055 free(s); 17056 // empty list 17057 emptyO(self); 17058 toInject = allocSmallInt(10); 17059 ck_assert_ptr_ne(self->f->injectNFreeSmallInt(self, 0, toInject), NULL); 17060 s = toStringO(r); 17061 ck_assert_str_eq(s, "[10]"); 17062 free(s); 17063 emptyO(self); 17064 toInject = allocSmallInt(10); 17065 ck_assert_ptr_ne(self->f->injectNFreeSmallInt(self, -1, toInject), NULL); 17066 s = toStringO(r); 17067 ck_assert_str_eq(s, "[10]"); 17068 free(s); 17069 // null toInsert 17070 ck_assert_ptr_eq(self->f->injectNFreeSmallInt(self, 0, NULL), NULL); 17071 terminateO(self); 17072 17073 } 17074 17075 17076 void injectNFreeSmallJsonSmallJsonT(void) { 17077 17078 smallJsont* r; 17079 smallJsont *self = allocSmallJson(); 17080 smallJsont *toInject; 17081 17082 // add elements to self 17083 r = self->f->pushInt(self, 1); 17084 ck_assert_ptr_ne(r, null); 17085 r = self->f->pushInt(self, 2); 17086 ck_assert_ptr_ne(r, null); 17087 r = self->f->pushInt(self, 3); 17088 ck_assert_ptr_ne(r, null); 17089 r = self->f->pushInt(self, 4); 17090 ck_assert_ptr_ne(r, null); 17091 17092 // positive index 17093 toInject = allocSmallJson(); 17094 r = self->f->injectNFreeSmallJson(self, 1, toInject); 17095 ck_assert_ptr_ne(r, null); 17096 char *s = toStringO(r); 17097 ck_assert_str_eq(s, "[1,{},2,3,4]"); 17098 free(s); 17099 // negative index 17100 toInject = allocSmallJson(); 17101 r = self->f->injectNFreeSmallJson(self,-1, toInject); 17102 ck_assert_ptr_ne(r, null); 17103 s = toStringO(r); 17104 ck_assert_str_eq(s, "[1,{},2,3,4,{}]"); 17105 free(s); 17106 // index 0 17107 toInject = allocSmallJson(); 17108 toInject->f->setS(toInject, "key", "value"); 17109 r = self->f->injectNFreeSmallJson(self,0, toInject); 17110 ck_assert_ptr_ne(r, null); 17111 s = toStringO(r); 17112 ck_assert_str_eq(s, "[{\"key\":\"value\"},1,{},2,3,4,{}]"); 17113 free(s); 17114 // index outside 17115 toInject = allocSmallJson(); 17116 ck_assert_ptr_eq(self->f->injectNFreeSmallJson(self, 20, toInject), NULL); 17117 ck_assert_ptr_eq(self->f->injectNFreeSmallJson(self, -9, toInject), NULL); 17118 terminateO(toInject); 17119 // empty object 17120 emptyO(self); 17121 toInject = allocSmallJson(); 17122 freeO(toInject); 17123 ck_assert_ptr_ne(self->f->injectNFreeSmallJson(self, 0, toInject), NULL); 17124 s = toStringO(r); 17125 ck_assert_str_eq(s, "[{}]"); 17126 free(s); 17127 // empty list 17128 emptyO(self); 17129 toInject = allocSmallJson(); 17130 ck_assert_ptr_ne(self->f->injectNFreeSmallJson(self, 0, toInject), NULL); 17131 s = toStringO(r); 17132 ck_assert_str_eq(s, "[{}]"); 17133 free(s); 17134 emptyO(self); 17135 toInject = allocSmallJson(); 17136 ck_assert_ptr_ne(self->f->injectNFreeSmallJson(self, -1, toInject), NULL); 17137 s = toStringO(r); 17138 ck_assert_str_eq(s, "[{}]"); 17139 free(s); 17140 // null toInsert 17141 ck_assert_ptr_eq(self->f->injectNFreeSmallJson(self, 0, NULL), NULL); 17142 terminateO(self); 17143 17144 } 17145 17146 17147 void injectNFreeSmallStringSmallJsonT(void) { 17148 17149 smallJsont* r; 17150 smallJsont *self = allocSmallJson(); 17151 smallStringt *toInject; 17152 17153 // add elements to self 17154 r = self->f->pushInt(self, 1); 17155 ck_assert_ptr_ne(r, null); 17156 r = self->f->pushInt(self, 2); 17157 ck_assert_ptr_ne(r, null); 17158 r = self->f->pushInt(self, 3); 17159 ck_assert_ptr_ne(r, null); 17160 r = self->f->pushInt(self, 4); 17161 ck_assert_ptr_ne(r, null); 17162 17163 // positive index 17164 toInject = allocSmallString("1"); 17165 r = self->f->injectNFreeSmallString(self, 1, toInject); 17166 ck_assert_ptr_ne(r, null); 17167 char *s = toStringO(r); 17168 ck_assert_str_eq(s, "[1,\"1\",2,3,4]"); 17169 free(s); 17170 // negative index 17171 toInject = allocSmallString("2"); 17172 r = self->f->injectNFreeSmallString(self,-1, toInject); 17173 ck_assert_ptr_ne(r, null); 17174 s = toStringO(r); 17175 ck_assert_str_eq(s, "[1,\"1\",2,3,4,\"2\"]"); 17176 free(s); 17177 // index 0 17178 toInject = allocSmallString("3"); 17179 r = self->f->injectNFreeSmallString(self,0, toInject); 17180 ck_assert_ptr_ne(r, null); 17181 s = toStringO(r); 17182 ck_assert_str_eq(s, "[\"3\",1,\"1\",2,3,4,\"2\"]"); 17183 free(s); 17184 // index outside 17185 toInject = allocSmallString("1"); 17186 ck_assert_ptr_eq(self->f->injectNFreeSmallString(self, 20, toInject), NULL); 17187 ck_assert_ptr_eq(self->f->injectNFreeSmallString(self, -9, toInject), NULL); 17188 terminateO(toInject); 17189 // empty object 17190 emptyO(self); 17191 toInject = allocSmallString("1"); 17192 freeO(toInject); 17193 ck_assert_ptr_ne(self->f->injectNFreeSmallString(self, 0, toInject), NULL); 17194 s = toStringO(r); 17195 ck_assert_str_eq(s, "[\"\"]"); 17196 free(s); 17197 // empty list 17198 emptyO(self); 17199 toInject = allocSmallString("1"); 17200 ck_assert_ptr_ne(self->f->injectNFreeSmallString(self, 0, toInject), NULL); 17201 s = toStringO(r); 17202 ck_assert_str_eq(s, "[\"1\"]"); 17203 free(s); 17204 emptyO(self); 17205 toInject = allocSmallString("1"); 17206 ck_assert_ptr_ne(self->f->injectNFreeSmallString(self, -1, toInject), NULL); 17207 s = toStringO(r); 17208 ck_assert_str_eq(s, "[\"1\"]"); 17209 free(s); 17210 // null toInsert 17211 ck_assert_ptr_eq(self->f->injectNFreeSmallString(self, 0, NULL), NULL); 17212 terminateO(self); 17213 17214 } 17215 17216 17217 void injectNFreeSmallContainerSmallJsonT(void) { 17218 17219 smallJsont* r; 17220 smallJsont *self = allocSmallJson(); 17221 smallContainert *toInject; 17222 17223 // add elements to self 17224 r = self->f->pushInt(self, 1); 17225 ck_assert_ptr_ne(r, null); 17226 r = self->f->pushInt(self, 2); 17227 ck_assert_ptr_ne(r, null); 17228 r = self->f->pushInt(self, 3); 17229 ck_assert_ptr_ne(r, null); 17230 r = self->f->pushInt(self, 4); 17231 ck_assert_ptr_ne(r, null); 17232 17233 // positive index 17234 toInject = allocSmallContainer(NULL); 17235 r = self->f->injectNFreeSmallContainer(self, 1, toInject); 17236 ck_assert_ptr_ne(r, null); 17237 char *s = toStringO(r); 17238 ck_assert_str_eq(s, "[1,\"<data container>\",2,3,4]"); 17239 free(s); 17240 // negative index 17241 toInject = allocSmallContainer(NULL); 17242 r = self->f->injectNFreeSmallContainer(self,-1, toInject); 17243 ck_assert_ptr_ne(r, null); 17244 s = toStringO(r); 17245 ck_assert_str_eq(s, "[1,\"<data container>\",2,3,4,\"<data container>\"]"); 17246 free(s); 17247 // index 0 17248 toInject = allocSmallContainer(NULL); 17249 r = self->f->injectNFreeSmallContainer(self,0, toInject); 17250 ck_assert_ptr_ne(r, null); 17251 s = toStringO(r); 17252 ck_assert_str_eq(s, "[\"<data container>\",1,\"<data container>\",2,3,4,\"<data container>\"]"); 17253 free(s); 17254 // index outside 17255 toInject = allocSmallContainer(NULL); 17256 ck_assert_ptr_eq(self->f->injectNFreeSmallContainer(self, 20, toInject), NULL); 17257 ck_assert_ptr_eq(self->f->injectNFreeSmallContainer(self, -9, toInject), NULL); 17258 terminateO(toInject); 17259 // empty object 17260 emptyO(self); 17261 toInject = allocSmallContainer(NULL); 17262 freeO(toInject); 17263 ck_assert_ptr_ne(self->f->injectNFreeSmallContainer(self, 0, toInject), NULL); 17264 s = toStringO(r); 17265 ck_assert_str_eq(s, "[\"<data container>\"]"); 17266 free(s); 17267 // empty list 17268 emptyO(self); 17269 toInject = allocSmallContainer(NULL); 17270 ck_assert_ptr_ne(self->f->injectNFreeSmallContainer(self, 0, toInject), NULL); 17271 s = toStringO(r); 17272 ck_assert_str_eq(s, "[\"<data container>\"]"); 17273 free(s); 17274 emptyO(self); 17275 toInject = allocSmallContainer(NULL); 17276 ck_assert_ptr_ne(self->f->injectNFreeSmallContainer(self, -1, toInject), NULL); 17277 s = toStringO(r); 17278 ck_assert_str_eq(s, "[\"<data container>\"]"); 17279 free(s); 17280 // null toInsert 17281 ck_assert_ptr_eq(self->f->injectNFreeSmallContainer(self, 0, NULL), NULL); 17282 terminateO(self); 17283 17284 } 17285 17286 17287 void uniqSmallJsonT(void) { 17288 17289 smallJsont* r; 17290 smallJsont *self = allocSmallJson(); 17291 17292 // empty array 17293 r = self->f->uniq(self); 17294 ck_assert_ptr_eq(r, NULL); 17295 setTypeArrayO(self); 17296 r = self->f->uniq(self); 17297 ck_assert_ptr_eq(r, NULL); 17298 // one element 17299 self->f->pushUndefined(self); 17300 r = self->f->uniq(self); 17301 ck_assert_ptr_eq(r, self); 17302 // uniq elements 17303 self->f->pushUndefined(self); 17304 self->f->pushBool(self, true); 17305 self->f->pushNFreeDict(self, allocSmallDict()); 17306 self->f->pushDouble(self, 1); 17307 self->f->pushInt(self, 2); 17308 self->f->pushS(self, ""); 17309 self->f->pushNFreeArray(self, allocSmallArray()); 17310 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 17311 self->f->pushUndefined(self); 17312 self->f->pushBool(self, true); 17313 self->f->pushNFreeDict(self, allocSmallDict()); 17314 self->f->pushDouble(self, 1); 17315 self->f->pushInt(self, 2); 17316 self->f->pushS(self, ""); 17317 self->f->pushNFreeArray(self, allocSmallArray()); 17318 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 17319 r = self->f->uniq(self); 17320 ck_assert_ptr_ne(r, NULL); 17321 char *s = toStringO(r); 17322 ck_assert_str_eq(s, "[null,true,{},1.000000e+00,2,\"\",[],[0x71,0x77,0x65,0x00]]"); 17323 free(s); 17324 terminateO(self); 17325 17326 } 17327 17328 17329 void sortSmallJsonT(void) { 17330 17331 smallJsont* r; 17332 smallJsont *self = allocSmallJson(); 17333 17334 // sort undefined 17335 self->f->pushInt(self, 0); 17336 self->f->pushUndefined(self); 17337 self->f->pushUndefined(self); 17338 self->f->pushUndefined(self); 17339 self->f->pushUndefined(self); 17340 r = sortO(self); 17341 ck_assert_ptr_ne(r, null); 17342 char *s = toStringO(r); 17343 ck_assert_str_eq(s, "[null,null,null,null,0]"); 17344 free(s); 17345 // sort bool 17346 emptyO(self); 17347 self->f->pushBool(self, false); 17348 self->f->pushBool(self, true); 17349 r = sortO(self); 17350 ck_assert_ptr_ne(r, null); 17351 s = toStringO(r); 17352 ck_assert_str_eq(s, "[false,true]"); 17353 free(s); 17354 // sort container 17355 emptyO(self); 17356 pushVoidSmallJsonG(self, &r); 17357 pushVoidSmallJsonG(self, &r); 17358 r = sortO(self); 17359 ck_assert_ptr_ne(r, null); 17360 s = toStringO(r); 17361 ck_assert_str_eq(s, "[\"<data container>\",\"<data container>\"]"); 17362 free(s); 17363 // sort dict 17364 emptyO(self); 17365 smallDictt *d[4]; 17366 arange(i,d) d[i] = allocSmallDict(); 17367 d[0]->f->setInt(d[0], "a", 1); 17368 d[1]->f->setInt(d[1], "a", 0); 17369 d[3]->f->setInt(d[3], "a", 0); 17370 d[3]->f->setInt(d[3], "b", 0); 17371 arange(i,d) self->f->pushNFreeDict(self, d[i]); 17372 r = sortO(self); 17373 ck_assert_ptr_ne(r, null); 17374 s = toStringO(r); 17375 ck_assert_str_eq(s, "[{},{\"a\":0},{\"a\":1},{\"a\":0,\"b\":0}]"); 17376 free(s); 17377 // sort double 17378 emptyO(self); 17379 self->f->pushDouble(self, 0); 17380 self->f->pushDouble(self, 0); 17381 self->f->pushDouble(self, 1); 17382 self->f->pushDouble(self, -1); 17383 r = sortO(self); 17384 ck_assert_ptr_ne(r, null); 17385 s = toStringO(r); 17386 ck_assert_str_eq(s, "[-1.000000e+00,0.000000e+00,0.000000e+00,1.000000e+00]"); 17387 free(s); 17388 // sort Int 17389 emptyO(self); 17390 self->f->pushInt(self, 0); 17391 self->f->pushInt(self, 0); 17392 self->f->pushInt(self, 1); 17393 self->f->pushInt(self, -1); 17394 r = sortO(self); 17395 ck_assert_ptr_ne(r, null); 17396 s = toStringO(r); 17397 ck_assert_str_eq(s, "[-1,0,0,1]"); 17398 free(s); 17399 // sort strings 17400 emptyO(self); 17401 self->f->pushS(self, "bb"); 17402 self->f->pushS(self, "a"); 17403 r = sortO(self); 17404 ck_assert_ptr_ne(r, null); 17405 s = toStringO(r); 17406 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 17407 free(s); 17408 // sort Array 17409 emptyO(self); 17410 smallArrayt *a[4]; 17411 arange(i,a) a[i] = allocSmallArray(); 17412 a[0]->f->pushInt(a[0], 1); 17413 a[1]->f->pushInt(a[1], 0); 17414 a[3]->f->pushInt(a[3], 0); 17415 a[3]->f->pushInt(a[3], 0); 17416 arange(i,a) self->f->pushNFreeArray(self, a[i]); 17417 r = sortO(self); 17418 ck_assert_ptr_ne(r, null); 17419 s = toStringO(r); 17420 ck_assert_str_eq(s, "[[],[0],[1],[0,0]]"); 17421 free(s); 17422 // sort bytes 17423 emptyO(self); 17424 smallBytest *B[4]; 17425 range(i,3) B[i] = allocSmallBytes("12345678", i); 17426 B[3] = allocSmallBytes("0", 1); 17427 arange(i,B) self->f->pushNFreeSmallBytes(self, B[i]); 17428 r = sortO(self); 17429 ck_assert_ptr_ne(r, null); 17430 s = toStringO(r); 17431 ck_assert_str_eq(s, "[[],[0x30],[0x31],[0x31,0x32]]"); 17432 free(s); 17433 // TODO add element and remove some elements 17434 emptyO(self); 17435 self->f->pushInt(self, 0); 17436 self->f->pushInt(self, 0); 17437 self->f->pushInt(self, 1); 17438 self->f->pushInt(self, -1); 17439 smallIntt *i1 = self->f->getAtSmallInt(self, 1); 17440 smallIntt *i2 = self->f->getAtSmallInt(self, 2); 17441 removeO(self, 1, 3); 17442 terminateO(i1); 17443 terminateO(i2); 17444 r = sortO(self); 17445 ck_assert_ptr_ne(r, null); 17446 s = toStringO(r); 17447 ck_assert_str_eq(s, "[-1,0]"); 17448 free(s); 17449 // length 0 17450 emptyO(self); 17451 r = sortO(self); 17452 ck_assert_ptr_eq(r, null); 17453 // non json array 17454 freeO(self); 17455 setTypeBoolO(self); 17456 ck_assert_ptr_eq(sortO(self), NULL); 17457 terminateO(self); 17458 17459 } 17460 17461 17462 void icSortSmallJsonT(void) { 17463 17464 smallJsont* r; 17465 smallJsont *self = allocSmallJson(); 17466 17467 // sort undefined 17468 self->f->pushInt(self, 0); 17469 self->f->pushUndefined(self); 17470 self->f->pushUndefined(self); 17471 self->f->pushUndefined(self); 17472 self->f->pushUndefined(self); 17473 r = icSortO(self); 17474 ck_assert_ptr_ne(r, null); 17475 char *s = toStringO(r); 17476 ck_assert_str_eq(s, "[null,null,null,null,0]"); 17477 free(s); 17478 // sort bool 17479 emptyO(self); 17480 self->f->pushBool(self, false); 17481 self->f->pushBool(self, true); 17482 r = icSortO(self); 17483 ck_assert_ptr_ne(r, null); 17484 s = toStringO(r); 17485 ck_assert_str_eq(s, "[false,true]"); 17486 free(s); 17487 // sort container 17488 emptyO(self); 17489 pushVoidSmallJsonG(self, &r); 17490 pushVoidSmallJsonG(self, &r); 17491 r = icSortO(self); 17492 ck_assert_ptr_ne(r, null); 17493 s = toStringO(r); 17494 ck_assert_str_eq(s, "[\"<data container>\",\"<data container>\"]"); 17495 free(s); 17496 // sort dict 17497 emptyO(self); 17498 smallDictt *d[4]; 17499 arange(i,d) d[i] = allocSmallDict(); 17500 d[0]->f->setInt(d[0], "a", 1); 17501 d[1]->f->setInt(d[1], "A", 0); 17502 d[3]->f->setInt(d[3], "a", 0); 17503 d[3]->f->setInt(d[3], "b", 0); 17504 arange(i,d) self->f->pushNFreeDict(self, d[i]); 17505 r = icSortO(self); 17506 ck_assert_ptr_ne(r, null); 17507 s = toStringO(r); 17508 ck_assert_str_eq(s, "[{},{\"A\":0},{\"a\":1},{\"a\":0,\"b\":0}]"); 17509 free(s); 17510 // sort double 17511 emptyO(self); 17512 self->f->pushDouble(self, 0); 17513 self->f->pushDouble(self, 0); 17514 self->f->pushDouble(self, 1); 17515 self->f->pushDouble(self, -1); 17516 r = icSortO(self); 17517 ck_assert_ptr_ne(r, null); 17518 s = toStringO(r); 17519 ck_assert_str_eq(s, "[-1.000000e+00,0.000000e+00,0.000000e+00,1.000000e+00]"); 17520 free(s); 17521 // sort Int 17522 emptyO(self); 17523 self->f->pushInt(self, 0); 17524 self->f->pushInt(self, 0); 17525 self->f->pushInt(self, 1); 17526 self->f->pushInt(self, -1); 17527 r = icSortO(self); 17528 ck_assert_ptr_ne(r, null); 17529 s = toStringO(r); 17530 ck_assert_str_eq(s, "[-1,0,0,1]"); 17531 free(s); 17532 // sort strings 17533 emptyO(self); 17534 self->f->pushS(self, "bb"); 17535 self->f->pushS(self, "B"); 17536 r = icSortO(self); 17537 ck_assert_ptr_ne(r, null); 17538 s = toStringO(r); 17539 ck_assert_str_eq(s, "[\"B\",\"bb\"]"); 17540 free(s); 17541 // sort Array 17542 emptyO(self); 17543 smallArrayt *a[4]; 17544 arange(i,a) a[i] = allocSmallArray(); 17545 a[0]->f->pushInt(a[0], 1); 17546 a[1]->f->pushInt(a[1], 0); 17547 a[3]->f->pushInt(a[3], 0); 17548 a[3]->f->pushInt(a[3], 0); 17549 arange(i,a) self->f->pushNFreeArray(self, a[i]); 17550 r = icSortO(self); 17551 ck_assert_ptr_ne(r, null); 17552 s = toStringO(r); 17553 ck_assert_str_eq(s, "[[],[0],[1],[0,0]]"); 17554 free(s); 17555 // sort bytes 17556 emptyO(self); 17557 smallBytest *B[4]; 17558 range(i,3) B[i] = allocSmallBytes("12345678", i); 17559 B[3] = allocSmallBytes("0", 1); 17560 arange(i,B) self->f->pushNFreeSmallBytes(self, B[i]); 17561 r = icSortO(self); 17562 ck_assert_ptr_ne(r, null); 17563 s = toStringO(r); 17564 ck_assert_str_eq(s, "[[],[0x30],[0x31],[0x31,0x32]]"); 17565 free(s); 17566 // TODO add element and remove some elements 17567 emptyO(self); 17568 self->f->pushInt(self, 0); 17569 self->f->pushInt(self, 0); 17570 self->f->pushInt(self, 1); 17571 self->f->pushInt(self, -1); 17572 smallIntt *i1 = self->f->getAtSmallInt(self, 1); 17573 smallIntt *i2 = self->f->getAtSmallInt(self, 2); 17574 removeO(self, 1, 3); 17575 terminateO(i1); 17576 terminateO(i2); 17577 r = icSortO(self); 17578 ck_assert_ptr_ne(r, null); 17579 s = toStringO(r); 17580 ck_assert_str_eq(s, "[-1,0]"); 17581 free(s); 17582 // length 0 17583 emptyO(self); 17584 r = icSortO(self); 17585 ck_assert_ptr_eq(r, null); 17586 // non json array 17587 freeO(self); 17588 setTypeBoolO(self); 17589 ck_assert_ptr_eq(icSortO(self), NULL); 17590 terminateO(self); 17591 17592 } 17593 17594 17595 int sortFOCmp(const void *A, const void *B) { 17596 cast(smallDictt*, a, A); 17597 cast(smallDictt*, b, B); 17598 17599 if (lenO(a) < lenO(b)) 17600 return -1; 17601 else if (lenO(a) == lenO(b)) { 17602 var As = toStringO(a); 17603 var Bs = toStringO(b); 17604 int r = strcmp(As,Bs); 17605 freeManyS(As,Bs); 17606 return r; 17607 } 17608 else 17609 return 1; 17610 } 17611 17612 void sortFSmallJsonT(void) { 17613 17614 smallJsont* r; 17615 smallJsont *self = allocSmallJson(); 17616 17617 // sort dict 17618 smallDictt *d[4]; 17619 arange(i,d) d[i] = allocSmallDict(); 17620 d[0]->f->setInt(d[0], "a", 1); 17621 d[1]->f->setInt(d[1], "a", 0); 17622 d[3]->f->setInt(d[3], "a", 0); 17623 d[3]->f->setInt(d[3], "b", 0); 17624 arange(i,d) self->f->pushNFreeDict(self, d[i]); 17625 r = sortFO(self, sortFOCmp); 17626 ck_assert_ptr_ne(r, null); 17627 char *s = toStringO(r); 17628 ck_assert_str_eq(s, "[{},{\"a\":0},{\"a\":1},{\"a\":0,\"b\":0}]"); 17629 free(s); 17630 // no compare function 17631 r = sortFO(self, NULL); 17632 ck_assert_ptr_eq(r, null); 17633 // empty array 17634 emptyO(self); 17635 r = sortFO(self, sortFOCmp); 17636 ck_assert_ptr_eq(r, null); 17637 // non json array 17638 freeO(self); 17639 setTypeBoolO(self); 17640 ck_assert_ptr_eq(sortFO(self, sortFOCmp), NULL); 17641 terminateO(self); 17642 17643 } 17644 17645 17646 void icUniqSmallJsonT(void) { 17647 17648 smallJsont* r; 17649 smallJsont *self = allocSmallJson(); 17650 17651 // empty array 17652 r = self->f->icUniq(self); 17653 ck_assert_ptr_eq(r, NULL); 17654 setTypeArrayO(self); 17655 r = self->f->icUniq(self); 17656 ck_assert_ptr_eq(r, NULL); 17657 // one element 17658 self->f->pushUndefined(self); 17659 r = self->f->icUniq(self); 17660 ck_assert_ptr_eq(r, self); 17661 // uniq elements 17662 self->f->pushUndefined(self); 17663 self->f->pushBool(self, true); 17664 self->f->pushNFreeDict(self, allocSmallDict()); 17665 self->f->pushDouble(self, 1); 17666 self->f->pushInt(self, 2); 17667 self->f->pushS(self, "ASD"); 17668 self->f->pushNFreeArray(self, allocSmallArray()); 17669 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 17670 self->f->pushUndefined(self); 17671 self->f->pushBool(self, true); 17672 self->f->pushNFreeDict(self, allocSmallDict()); 17673 self->f->pushDouble(self, 1); 17674 self->f->pushInt(self, 2); 17675 self->f->pushS(self, "asd"); 17676 self->f->pushNFreeArray(self, allocSmallArray()); 17677 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 17678 r = self->f->icUniq(self); 17679 ck_assert_ptr_ne(r, NULL); 17680 char *s = toStringO(r); 17681 ck_assert_str_eq(s, "[null,true,{},1.000000e+00,2,\"ASD\",[],[0x71,0x77,0x65,0x00]]"); 17682 free(s); 17683 terminateO(self); 17684 17685 } 17686 17687 17688 void uniqCharSmallJsonT(void) { 17689 17690 smallJsont* r; 17691 smallJsont *self = allocSmallJson(); 17692 setTopSO(self, ""); 17693 17694 // uniquify 17695 freeO(self); 17696 setTopSO(self, "/qwd///"); 17697 r = uniqCharO(self, '/'); 17698 ck_assert_ptr_ne(r, null); 17699 char *s = toStringO(r); 17700 ck_assert_str_eq(s, "/qwd/"); 17701 free(s); 17702 // short string 17703 freeO(self); 17704 setTopSO(self, "?"); 17705 r = uniqCharO(self, '/'); 17706 ck_assert_ptr_ne(r, null); 17707 s = toStringO(r); 17708 ck_assert_str_eq(s, "?"); 17709 free(s); 17710 // NULL 17711 freeO(self); 17712 ck_assert_ptr_eq(uniqCharO(self, '/'), NULL); 17713 terminateO(self); 17714 17715 } 17716 17717 17718 void icUniqCharSmallJsonT(void) { 17719 17720 smallJsont* r; 17721 smallJsont *self = allocSmallJson(); 17722 setTopSO(self, ""); 17723 17724 // uniquify 17725 freeO(self); 17726 setTopSO(self, "/qQwd///"); 17727 r = icUniqCharO(self, 'q'); 17728 ck_assert_ptr_ne(r, null); 17729 char *s = toStringO(r); 17730 ck_assert_str_eq(s, "/qwd///"); 17731 free(s); 17732 // short string 17733 freeO(self); 17734 setTopSO(self, "?"); 17735 r = icUniqCharO(self, '/'); 17736 ck_assert_ptr_ne(r, null); 17737 s = toStringO(r); 17738 ck_assert_str_eq(s, "?"); 17739 free(s); 17740 // NULL 17741 freeO(self); 17742 ck_assert_ptr_eq(icUniqCharO(self, '/'), NULL); 17743 terminateO(self); 17744 17745 } 17746 17747 17748 void hasSmallJsonT(void) { 17749 17750 bool r; 17751 smallJsont *self = allocSmallJson(); 17752 baset *value = (baset*)allocSmallInt(1); 17753 17754 // has 17755 self->f->pushInt(self, 1); 17756 r = hasO(self, value); 17757 ck_assert(r); 17758 // not has 17759 emptyO(self); 17760 r = hasO(self, value); 17761 ck_assert(!r); 17762 // NULL value 17763 r = hasO(self, NULL); 17764 ck_assert(!r); 17765 terminateO(self); 17766 terminateO(value); 17767 17768 } 17769 17770 17771 void hasUndefinedSmallJsonT(void) { 17772 17773 bool r; 17774 smallJsont *self = allocSmallJson(); 17775 undefinedt *value = allocUndefined(); 17776 17777 // has 17778 self->f->pushUndefined(self); 17779 r = hasUndefinedO(self, value); 17780 ck_assert(r); 17781 // not has 17782 emptyO(self); 17783 r = hasUndefinedO(self, value); 17784 ck_assert(!r); 17785 // non undefined object 17786 terminateO(value); 17787 value = (undefinedt*) allocSmallInt(2); 17788 r = hasUndefinedO(self, value); 17789 ck_assert(!r); 17790 // NULL value 17791 r = hasUndefinedO(self, NULL); 17792 ck_assert(!r); 17793 terminateO(self); 17794 terminateO(value); 17795 17796 } 17797 17798 17799 void hasBoolSmallJsonT(void) { 17800 17801 bool r; 17802 smallJsont *self = allocSmallJson(); 17803 bool value = true; 17804 17805 // has 17806 self->f->pushBool(self, true); 17807 r = hasBoolO(self, value); 17808 ck_assert(r); 17809 // not has 17810 emptyO(self); 17811 r = hasBoolO(self, value); 17812 ck_assert(!r); 17813 terminateO(self); 17814 17815 } 17816 17817 17818 void hasDoubleSmallJsonT(void) { 17819 17820 bool r; 17821 smallJsont *self = allocSmallJson(); 17822 double value = 2; 17823 17824 // has 17825 self->f->pushDouble(self, 2); 17826 r = hasDoubleO(self, value); 17827 ck_assert(r); 17828 // not has 17829 emptyO(self); 17830 r = hasDoubleO(self, value); 17831 ck_assert(!r); 17832 terminateO(self); 17833 17834 } 17835 17836 17837 void hasIntSmallJsonT(void) { 17838 17839 bool r; 17840 smallJsont *self = allocSmallJson(); 17841 int64_t value = 1000; 17842 17843 // has 17844 self->f->pushInt(self, 1000); 17845 r = hasIntO(self, value); 17846 ck_assert(r); 17847 // not has 17848 emptyO(self); 17849 r = hasIntO(self, value); 17850 ck_assert(!r); 17851 terminateO(self); 17852 17853 } 17854 17855 17856 void hasSSmallJsonT(void) { 17857 17858 bool r; 17859 smallJsont *self = allocSmallJson(); 17860 const char *value = "asd"; 17861 17862 // has 17863 self->f->pushS(self, "asd"); 17864 r = hasSO(self, value); 17865 ck_assert(r); 17866 // not has 17867 emptyO(self); 17868 r = hasSO(self, value); 17869 ck_assert(!r); 17870 // NULL value 17871 r = hasSO(self, NULL); 17872 ck_assert(!r); 17873 terminateO(self); 17874 // json dict 17875 self = allocSmallJson(); 17876 self->f->setInt(self, "u", 0); 17877 ck_assert(!hasSO(self, "qwe")); 17878 ck_assert(hasSO(self, "u")); 17879 terminateO(self); 17880 17881 } 17882 17883 17884 void hasCharSmallJsonT(void) { 17885 17886 bool r; 17887 smallJsont *self = allocSmallJson(); 17888 char value = 'a'; 17889 17890 // has 17891 self->f->pushS(self, "a"); 17892 r = hasCharO(self, value); 17893 ck_assert(r); 17894 // not has 17895 emptyO(self); 17896 r = hasCharO(self, value); 17897 ck_assert(!r); 17898 terminateO(self); 17899 17900 } 17901 17902 17903 void hasDictSmallJsonT(void) { 17904 17905 bool r; 17906 smallJsont *self = allocSmallJson(); 17907 smallDictt *value = allocSmallDict(); 17908 17909 // has 17910 self->f->pushNFreeDict(self, allocSmallDict()); 17911 r = hasDictO(self, value); 17912 ck_assert(r); 17913 // not has 17914 emptyO(self); 17915 r = hasDictO(self, value); 17916 ck_assert(!r); 17917 // non smallDict object 17918 terminateO(value); 17919 value = (smallDictt*) allocSmallInt(2); 17920 r = hasDictO(self, value); 17921 ck_assert(!r); 17922 // NULL value 17923 r = hasDictO(self, NULL); 17924 ck_assert(!r); 17925 terminateO(self); 17926 terminateO(value); 17927 17928 } 17929 17930 17931 void hasArraySmallJsonT(void) { 17932 17933 bool r; 17934 smallJsont *self = allocSmallJson(); 17935 smallArrayt *value = allocSmallArray(); 17936 17937 // has 17938 self->f->pushNFreeArray(self, allocSmallArray()); 17939 r = hasArrayO(self, value); 17940 ck_assert(r); 17941 // not has 17942 emptyO(self); 17943 r = hasArrayO(self, value); 17944 ck_assert(!r); 17945 // non smallArray object 17946 terminateO(value); 17947 value = (smallArrayt*) allocSmallInt(2); 17948 r = hasArrayO(self, value); 17949 ck_assert(!r); 17950 // NULL value 17951 r = hasArrayO(self, NULL); 17952 ck_assert(!r); 17953 terminateO(self); 17954 terminateO(value); 17955 17956 } 17957 17958 17959 void hasArraycSmallJsonT(void) { 17960 17961 bool r; 17962 smallJsont *self = allocSmallJson(); 17963 char **value = listCreateS("a","bb"); 17964 17965 // has 17966 self->f->pushNFreeArrayc(self, listCreateS("a","bb")); 17967 r = hasArraycO(self, value); 17968 ck_assert(r); 17969 // not has 17970 emptyO(self); 17971 r = hasArraycO(self, value); 17972 ck_assert(!r); 17973 // NULL value 17974 r = hasArraycO(self, NULL); 17975 ck_assert(!r); 17976 terminateO(self); 17977 listFreeS(value); 17978 17979 } 17980 17981 17982 void hasSmallBoolSmallJsonT(void) { 17983 17984 bool r; 17985 smallJsont *self = allocSmallJson(); 17986 smallBoolt *value = allocSmallBool(true); 17987 17988 // has 17989 self->f->pushBool(self, true); 17990 r = hasSmallBoolO(self, value); 17991 ck_assert(r); 17992 // not has 17993 emptyO(self); 17994 r = hasSmallBoolO(self, value); 17995 ck_assert(!r); 17996 // non smallBool object 17997 terminateO(value); 17998 value = (smallBoolt*) allocSmallInt(2); 17999 r = hasSmallBoolO(self, value); 18000 ck_assert(!r); 18001 // NULL value 18002 r = hasSmallBoolO(self, NULL); 18003 ck_assert(!r); 18004 terminateO(self); 18005 terminateO(value); 18006 18007 } 18008 18009 18010 void hasSmallBytesSmallJsonT(void) { 18011 18012 bool r; 18013 smallJsont *self = allocSmallJson(); 18014 createAllocateSmallBytes(value); 18015 pushBufferO(value, &self, 8); 18016 18017 // has 18018 createAllocateSmallBytes(elem); 18019 pushBufferO(elem, &self, 8); 18020 self->f->pushNFreeSmallBytes(self, elem); 18021 r = hasSmallBytesO(self, value); 18022 ck_assert(r); 18023 // not has 18024 emptyO(self); 18025 r = hasSmallBytesO(self, value); 18026 ck_assert(!r); 18027 // non smallBytes object 18028 terminateO(value); 18029 value = (smallBytest*) allocSmallInt(2); 18030 r = hasSmallBytesO(self, value); 18031 ck_assert(!r); 18032 // NULL value 18033 r = hasSmallBytesO(self, NULL); 18034 ck_assert(!r); 18035 terminateO(self); 18036 terminateO(value); 18037 18038 } 18039 18040 18041 void hasSmallDoubleSmallJsonT(void) { 18042 18043 bool r; 18044 smallJsont *self = allocSmallJson(); 18045 smallDoublet *value = allocSmallDouble(2); 18046 18047 // has 18048 self->f->pushDouble(self, 2); 18049 r = hasSmallDoubleO(self, value); 18050 ck_assert(r); 18051 // not has 18052 emptyO(self); 18053 r = hasSmallDoubleO(self, value); 18054 ck_assert(!r); 18055 // non smallDouble object 18056 terminateO(value); 18057 value = (smallDoublet*) allocSmallInt(2); 18058 r = hasSmallDoubleO(self, value); 18059 ck_assert(!r); 18060 // NULL value 18061 r = hasSmallDoubleO(self, NULL); 18062 ck_assert(!r); 18063 terminateO(self); 18064 terminateO(value); 18065 18066 } 18067 18068 18069 void hasSmallIntSmallJsonT(void) { 18070 18071 bool r; 18072 smallJsont *self = allocSmallJson(); 18073 smallIntt *value = allocSmallInt(12); 18074 18075 // has 18076 self->f->pushInt(self, 12); 18077 r = hasSmallIntO(self, value); 18078 ck_assert(r); 18079 // not has 18080 emptyO(self); 18081 r = hasSmallIntO(self, value); 18082 ck_assert(!r); 18083 // non smallInt object 18084 terminateO(value); 18085 value = (smallIntt*) allocSmallBool(true); 18086 r = hasSmallIntO(self, value); 18087 ck_assert(!r); 18088 // NULL value 18089 r = hasSmallIntO(self, NULL); 18090 ck_assert(!r); 18091 terminateO(self); 18092 terminateO(value); 18093 18094 } 18095 18096 18097 void hasSmallJsonSmallJsonT(void) { 18098 18099 bool r; 18100 smallJsont *self = allocSmallJson(); 18101 smallJsont *value = allocSmallJson(); 18102 value->f->pushInt(value, 1); 18103 18104 // has 18105 createAllocateSmallJson(elem); 18106 elem->f->pushInt(elem, 1); 18107 self->f->pushNFreeSmallJson(self, elem); 18108 r = self->f->hasSmallJson(self, value); 18109 ck_assert(r); 18110 // not has 18111 emptyO(self); 18112 r = self->f->hasSmallJson(self, value); 18113 ck_assert(!r); 18114 // non smallJson object 18115 terminateO(value); 18116 value = (smallJsont*) allocSmallInt(2); 18117 r = self->f->hasSmallJson(self, value); 18118 ck_assert(!r); 18119 // NULL value 18120 r = self->f->hasSmallJson(self, NULL); 18121 ck_assert(!r); 18122 terminateO(self); 18123 terminateO(value); 18124 18125 } 18126 18127 18128 void hasSmallStringSmallJsonT(void) { 18129 18130 bool r; 18131 smallJsont *self = allocSmallJson(); 18132 smallStringt *value = allocSmallString("qwe"); 18133 18134 // has 18135 self->f->pushS(self, "qwe"); 18136 r = self->f->hasSmallString(self, value); 18137 ck_assert(r); 18138 // not has 18139 emptyO(self); 18140 r = self->f->hasSmallString(self, value); 18141 ck_assert(!r); 18142 // non smallString object 18143 terminateO(value); 18144 value = (smallStringt*) allocSmallInt(2); 18145 r = self->f->hasSmallString(self, value); 18146 ck_assert(!r); 18147 // NULL value 18148 r = self->f->hasSmallString(self, NULL); 18149 ck_assert(!r); 18150 terminateO(self); 18151 terminateO(value); 18152 18153 } 18154 18155 18156 void hasSmallContainerSmallJsonT(void) { 18157 18158 bool r; 18159 smallJsont *self = allocSmallJson(); 18160 createAllocateSmallContainer(value); 18161 18162 // has 18163 createAllocateSmallContainer(elem); 18164 self->f->pushNFreeSmallContainer(self, elem); 18165 r = hasSmallContainerO(self, value); 18166 ck_assert(!r); 18167 // not has 18168 emptyO(self); 18169 r = hasSmallContainerO(self, value); 18170 ck_assert(!r); 18171 // non smallContainer object 18172 terminateO(value); 18173 value = (smallContainert*) allocSmallInt(2); 18174 r = self->f->hasSmallContainer(self, value); 18175 ck_assert(!r); 18176 // NULL value 18177 r = hasSmallContainerO(self, NULL); 18178 ck_assert(!r); 18179 terminateO(self); 18180 terminateO(value); 18181 18182 } 18183 18184 18185 void findSmallJsonT(void) { 18186 18187 smallJsont* r; 18188 smallJsont *self = allocSmallJson(); 18189 setTopSO(self, ""); 18190 18191 // find string in the middle 18192 freeO(self); 18193 setTopSO(self, "sheepy"); 18194 r = findO(self, "ee"); 18195 ck_assert_ptr_ne(r, null); 18196 ck_assert_str_eq(sjGet(r), "eepy"); 18197 terminateO(r); 18198 // find non existing string 18199 ck_assert_ptr_eq(findO(self, "$"), NULL); 18200 // find NULL 18201 ck_assert_ptr_eq(findO(self, NULL), NULL); 18202 // empty string 18203 freeO(self); 18204 setTopSO(self, ""); 18205 ck_assert_ptr_eq(findO(self, "$"), NULL); 18206 // NULL string 18207 freeO(self); 18208 ck_assert_ptr_eq(findO(self, "$"), NULL); 18209 terminateO(self); 18210 18211 } 18212 18213 18214 void findCharSmallJsonT(void) { 18215 18216 smallJsont* r; 18217 smallJsont *self = allocSmallJson(); 18218 setTopSO(self, ""); 18219 18220 // find string in the middle 18221 freeO(self); 18222 setTopSO(self, "sheepy"); 18223 r = findCharO(self, 'e'); 18224 ck_assert_ptr_ne(r, null); 18225 ck_assert_str_eq(sjGet(r), "eepy"); 18226 terminateO(r); 18227 // find non existing string 18228 ck_assert_ptr_eq(findCharO(self, '$'), NULL); 18229 // find 0 18230 r = findCharO(self, 0); 18231 ck_assert_ptr_ne(r, null); 18232 ck_assert_str_eq(sjGet(r), ""); 18233 terminateO(r); 18234 // empty string 18235 freeO(self); 18236 setTopSO(self, ""); 18237 ck_assert_ptr_eq(findCharO(self, '$'), NULL); 18238 // NULL string 18239 freeO(self); 18240 ck_assert_ptr_eq(findCharO(self, '$'), NULL); 18241 terminateO(self); 18242 18243 } 18244 18245 18246 void findSmallStringSmallJsonT(void) { 18247 18248 smallJsont* r; 18249 smallJsont *self = allocSmallJson(); 18250 setTopSO(self, ""); 18251 smallStringt *needle = allocSmallString("ee"); 18252 18253 // find string in the middle 18254 freeO(self); 18255 setTopSO(self, "sheepy"); 18256 r = self->f->findSmallString(self, needle); 18257 ck_assert_ptr_ne(r, null); 18258 ck_assert_str_eq(sjGet(r), "eepy"); 18259 terminateO(r); 18260 // find non existing string 18261 setValO(needle, "$"); 18262 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 18263 // non smallString object 18264 terminateO(needle); 18265 needle = (smallStringt*) allocSmallInt(1); 18266 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 18267 terminateO(needle); 18268 // find NULL 18269 ck_assert_ptr_eq(self->f->findSmallString(self, NULL), NULL); 18270 // empty string 18271 freeO(self); 18272 setTopSO(self, ""); 18273 needle = allocSmallString("$"); 18274 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 18275 // NULL string 18276 freeO(self); 18277 ck_assert_ptr_eq(self->f->findSmallString(self, needle), NULL); 18278 terminateO(needle); 18279 terminateO(self); 18280 18281 } 18282 18283 18284 void findJsonSmallJsonT(void) { 18285 18286 smallJsont* r; 18287 smallJsont *self = allocSmallJson(); 18288 setTopSO(self, ""); 18289 smallJsont *needle = allocSmallJson(); 18290 18291 // find string in the middle 18292 freeO(self); 18293 setTopSO(self, "sheepy"); 18294 setTopSO(needle, "ee"); 18295 r = self->f->findJson(self, needle); 18296 ck_assert_ptr_ne(r, null); 18297 ck_assert_str_eq(sjGet(r), "eepy"); 18298 terminateO(r); 18299 // find non existing string 18300 freeO(needle); 18301 setTopSO(needle, "$"); 18302 ck_assert_ptr_eq(self->f->findJson(self, needle), NULL); 18303 // non json string 18304 freeO(needle); 18305 ck_assert_ptr_eq(self->f->findJson(self, needle), NULL); 18306 // non json object 18307 terminateO(needle); 18308 needle = (smallJsont*) allocSmallInt(1); 18309 ck_assert_ptr_eq(self->f->findJson(self, needle), NULL); 18310 terminateO(needle); 18311 // find NULL 18312 ck_assert_ptr_eq(self->f->findJson(self, NULL), NULL); 18313 // empty string 18314 freeO(self); 18315 setTopSO(self, ""); 18316 needle = allocSmallJson(); 18317 setTopSO(needle, "$"); 18318 ck_assert_ptr_eq(self->f->findJson(self, needle), NULL); 18319 // NULL string 18320 freeO(self); 18321 ck_assert_ptr_eq(self->f->findJson(self, needle), NULL); 18322 terminateO(needle); 18323 terminateO(self); 18324 18325 } 18326 18327 18328 void indexOfSmallJsonT(void) { 18329 18330 ssize_t r; 18331 smallJsont *self = allocSmallJson(); 18332 baset *value = (baset*)allocSmallInt(1); 18333 18334 // index 18335 self->f->pushInt(self, 2); 18336 self->f->pushInt(self, 0); 18337 delElemIndexO(self, 1); 18338 self->f->pushInt(self, 1); 18339 r = indexOfO(self, value); 18340 ck_assert_int_eq(r, 2); 18341 // not index 18342 smallIntt *v = (smallIntt*) value; 18343 setValO(v, 0); 18344 r = indexOfO(self, value); 18345 ck_assert_int_eq(r, -1); 18346 // NULL value 18347 r = indexOfO(self, NULL); 18348 ck_assert_int_eq(r, -1); 18349 terminateO(self); 18350 terminateO(value); 18351 18352 } 18353 18354 18355 void indexOfUndefinedSmallJsonT(void) { 18356 18357 ssize_t r; 18358 smallJsont *self = allocSmallJson(); 18359 undefinedt *value = allocUndefined(); 18360 18361 // indexOf 18362 self->f->pushInt(self, 1); 18363 self->f->pushUndefined(self); 18364 delElemIndexO(self, 1); 18365 self->f->pushUndefined(self); 18366 r = indexOfUndefinedO(self, value); 18367 ck_assert_int_eq(r, 2); 18368 // not indexOf 18369 delElemIndexO(self, 2); 18370 r = indexOfUndefinedO(self, value); 18371 ck_assert_int_eq(r, -1); 18372 // non undefined object 18373 terminateO(value); 18374 value = (undefinedt*) allocSmallInt(2); 18375 r = indexOfUndefinedO(self, value); 18376 ck_assert_int_eq(r, -1); 18377 // NULL value 18378 r = indexOfUndefinedO(self, NULL); 18379 ck_assert_int_eq(r, -1); 18380 terminateO(self); 18381 terminateO(value); 18382 18383 } 18384 18385 18386 void indexOfBoolSmallJsonT(void) { 18387 18388 ssize_t r; 18389 smallJsont *self = allocSmallJson(); 18390 bool value = true; 18391 18392 // indexOf 18393 self->f->pushInt(self, 1); 18394 self->f->pushUndefined(self); 18395 delElemIndexO(self, 1); 18396 self->f->pushBool(self, true); 18397 r = indexOfBoolO(self, value); 18398 ck_assert_int_eq(r, 2); 18399 // not indexOf 18400 delElemIndexO(self, 2); 18401 r = indexOfBoolO(self, value); 18402 ck_assert_int_eq(r, -1); 18403 terminateO(self); 18404 18405 } 18406 18407 18408 void indexOfDoubleSmallJsonT(void) { 18409 18410 ssize_t r; 18411 smallJsont *self = allocSmallJson(); 18412 double value = 2; 18413 18414 // indexOf 18415 self->f->pushInt(self, 1); 18416 self->f->pushUndefined(self); 18417 delElemIndexO(self, 1); 18418 self->f->pushDouble(self, 2); 18419 r = indexOfDoubleO(self, value); 18420 ck_assert_int_eq(r, 2); 18421 // not indexOf 18422 delElemIndexO(self, 2); 18423 r = indexOfDoubleO(self, value); 18424 ck_assert_int_eq(r, -1); 18425 terminateO(self); 18426 18427 } 18428 18429 18430 void indexOfIntSmallJsonT(void) { 18431 18432 ssize_t r; 18433 smallJsont *self = allocSmallJson(); 18434 int64_t value = 1000; 18435 18436 // indexOf 18437 self->f->pushUndefined(self); 18438 self->f->pushUndefined(self); 18439 delElemIndexO(self, 1); 18440 self->f->pushInt(self, 1000); 18441 r = indexOfIntO(self, value); 18442 ck_assert_int_eq(r, 2); 18443 // not indexOf 18444 delElemIndexO(self, 2); 18445 r = indexOfIntO(self, value); 18446 ck_assert_int_eq(r, -1); 18447 terminateO(self); 18448 18449 } 18450 18451 18452 void indexOfSSmallJsonT(void) { 18453 18454 ssize_t r; 18455 smallJsont *self = allocSmallJson(); 18456 const char *value = "asd"; 18457 18458 // indexOf 18459 self->f->pushUndefined(self); 18460 self->f->pushUndefined(self); 18461 delElemIndexO(self, 1); 18462 self->f->pushS(self, "asd"); 18463 r = indexOfSO(self, value); 18464 ck_assert_int_eq(r, 2); 18465 // not indexOf 18466 delElemIndexO(self, 2); 18467 r = indexOfSO(self, value); 18468 ck_assert_int_eq(r, -1); 18469 // NULL value 18470 r = indexOfSO(self, NULL); 18471 ck_assert_int_eq(r, -1); 18472 terminateO(self); 18473 // json string 18474 self = allocSmallJson(); 18475 // indexOf string in the middle 18476 setTopSO(self, "sheepy"); 18477 ck_assert_int_eq(indexOfSO(self, "ee"), 2); 18478 // indexOf non existing string 18479 ck_assert_int_eq(indexOfSO(self, "$"), -1); 18480 terminateO(self); 18481 18482 } 18483 18484 18485 void indexOfCharSmallJsonT(void) { 18486 18487 ssize_t r; 18488 smallJsont *self = allocSmallJson(); 18489 char value = 'a'; 18490 18491 // indexOf 18492 self->f->pushUndefined(self); 18493 self->f->pushUndefined(self); 18494 delElemIndexO(self, 1); 18495 self->f->pushS(self, "a"); 18496 r = indexOfCharO(self, value); 18497 ck_assert_int_eq(r, 2); 18498 // not indexOf 18499 delElemIndexO(self, 2); 18500 r = indexOfCharO(self, value); 18501 ck_assert_int_eq(r, -1); 18502 terminateO(self); 18503 18504 } 18505 18506 18507 void indexOfDictSmallJsonT(void) { 18508 18509 ssize_t r; 18510 smallJsont *self = allocSmallJson(); 18511 smallDictt *value = allocSmallDict(); 18512 18513 // indexOf 18514 createAllocateSmallDict(elem); 18515 elem->f->setInt(elem, "a", 1); 18516 self->f->pushNFreeDict(self, elem); 18517 self->f->pushUndefined(self); 18518 delElemIndexO(self, 1); 18519 self->f->pushNFreeDict(self, allocSmallDict()); 18520 r = indexOfDictO(self, value); 18521 ck_assert_int_eq(r, 2); 18522 // not indexOf 18523 delElemIndexO(self, 2); 18524 r = indexOfDictO(self, value); 18525 ck_assert_int_eq(r, -1); 18526 // non smallDict object 18527 terminateO(value); 18528 value = (smallDictt*) allocSmallInt(2); 18529 r = indexOfDictO(self, value); 18530 ck_assert_int_eq(r, -1); 18531 // NULL value 18532 r = indexOfDictO(self, NULL); 18533 ck_assert_int_eq(r, -1); 18534 terminateO(self); 18535 terminateO(value); 18536 18537 } 18538 18539 18540 void indexOfArraySmallJsonT(void) { 18541 18542 ssize_t r; 18543 smallJsont *self = allocSmallJson(); 18544 smallArrayt *value = allocSmallArray(); 18545 18546 // indexOf 18547 createAllocateSmallArray(elem); 18548 elem->f->pushInt(elem, 1); 18549 self->f->pushNFreeArray(self, elem); 18550 self->f->pushUndefined(self); 18551 delElemIndexO(self, 1); 18552 self->f->pushNFreeArray(self, allocSmallArray()); 18553 r = indexOfArrayO(self, value); 18554 ck_assert_int_eq(r, 2); 18555 // non smallArray object 18556 terminateO(value); 18557 value = (smallArrayt*) allocSmallInt(2); 18558 r = indexOfArrayO(self, value); 18559 ck_assert_int_eq(r, -1); 18560 // not indexOf 18561 emptyO(self); 18562 r = indexOfArrayO(self, value); 18563 ck_assert_int_eq(r, -1); 18564 // NULL value 18565 r = indexOfArrayO(self, NULL); 18566 ck_assert_int_eq(r, -1); 18567 terminateO(self); 18568 terminateO(value); 18569 18570 } 18571 18572 18573 void indexOfArraycSmallJsonT(void) { 18574 18575 ssize_t r; 18576 smallJsont *self = allocSmallJson(); 18577 char **value = listCreateS("a","bb"); 18578 18579 // indexOf 18580 char **elem = listCreateS("!!","@@@"); 18581 self->f->pushNFreeArrayc(self, elem); 18582 self->f->pushUndefined(self); 18583 delElemIndexO(self, 1); 18584 self->f->pushNFreeArrayc(self, listCreateS("a","bb")); 18585 r = indexOfArraycO(self, value); 18586 ck_assert_int_eq(r, 2); 18587 // not indexOf 18588 delElemIndexO(self, 2); 18589 r = indexOfArraycO(self, value); 18590 ck_assert_int_eq(r, -1); 18591 // NULL value 18592 r = indexOfArraycO(self, NULL); 18593 ck_assert_int_eq(r, -1); 18594 terminateO(self); 18595 listFreeS(value); 18596 18597 } 18598 18599 18600 void indexOfSmallBoolSmallJsonT(void) { 18601 18602 ssize_t r; 18603 smallJsont *self = allocSmallJson(); 18604 smallBoolt *value = allocSmallBool(true); 18605 18606 // indexOf 18607 self->f->pushUndefined(self); 18608 self->f->pushUndefined(self); 18609 delElemIndexO(self, 1); 18610 self->f->pushBool(self, true); 18611 r = indexOfSmallBoolO(self, value); 18612 ck_assert_int_eq(r, 2); 18613 // not indexOf 18614 delElemIndexO(self, 2); 18615 r = indexOfSmallBoolO(self, value); 18616 ck_assert_int_eq(r, -1); 18617 // non smallBool object 18618 terminateO(value); 18619 value = (smallBoolt*) allocSmallInt(2); 18620 r = indexOfSmallBoolO(self, value); 18621 ck_assert_int_eq(r, -1); 18622 // NULL value 18623 r = indexOfSmallBoolO(self, NULL); 18624 ck_assert_int_eq(r, -1); 18625 terminateO(self); 18626 terminateO(value); 18627 18628 } 18629 18630 18631 void indexOfSmallBytesSmallJsonT(void) { 18632 18633 ssize_t r; 18634 smallJsont *self = allocSmallJson(); 18635 createAllocateSmallBytes(value); 18636 pushBufferO(value, &self, 8); 18637 18638 // indexOf 18639 self->f->pushUndefined(self); 18640 self->f->pushUndefined(self); 18641 delElemIndexO(self, 1); 18642 createAllocateSmallBytes(elem); 18643 pushBufferO(elem, &self, 8); 18644 self->f->pushNFreeSmallBytes(self, elem); 18645 r = indexOfSmallBytesO(self, value); 18646 ck_assert_int_eq(r, 2); 18647 // not indexOf 18648 delElemIndexO(self, 2); 18649 r = indexOfSmallBytesO(self, value); 18650 ck_assert_int_eq(r, -1); 18651 // non smallBytes object 18652 terminateO(value); 18653 value = (smallBytest*) allocSmallInt(2); 18654 r = indexOfSmallBytesO(self, value); 18655 ck_assert_int_eq(r, -1); 18656 // NULL value 18657 r = indexOfSmallBytesO(self, NULL); 18658 ck_assert_int_eq(r, -1); 18659 terminateO(self); 18660 terminateO(value); 18661 18662 } 18663 18664 18665 void indexOfSmallDoubleSmallJsonT(void) { 18666 18667 ssize_t r; 18668 smallJsont *self = allocSmallJson(); 18669 smallDoublet *value = allocSmallDouble(2); 18670 18671 // indexOf 18672 self->f->pushUndefined(self); 18673 self->f->pushUndefined(self); 18674 delElemIndexO(self, 1); 18675 self->f->pushDouble(self, 2); 18676 r = indexOfSmallDoubleO(self, value); 18677 ck_assert_int_eq(r, 2); 18678 // not indexOf 18679 delElemIndexO(self, 2); 18680 r = indexOfSmallDoubleO(self, value); 18681 ck_assert_int_eq(r, -1); 18682 // non smallDouble object 18683 terminateO(value); 18684 value = (smallDoublet*) allocSmallInt(2); 18685 r = indexOfSmallDoubleO(self, value); 18686 ck_assert_int_eq(r, -1); 18687 // NULL value 18688 r = indexOfSmallDoubleO(self, NULL); 18689 ck_assert_int_eq(r, -1); 18690 terminateO(self); 18691 terminateO(value); 18692 18693 } 18694 18695 18696 void indexOfSmallIntSmallJsonT(void) { 18697 18698 ssize_t r; 18699 smallJsont *self = allocSmallJson(); 18700 smallIntt *value = allocSmallInt(12); 18701 18702 // indexOf 18703 self->f->pushUndefined(self); 18704 self->f->pushUndefined(self); 18705 delElemIndexO(self, 1); 18706 self->f->pushInt(self, 12); 18707 r = indexOfSmallIntO(self, value); 18708 ck_assert_int_eq(r, 2); 18709 // not indexOf 18710 delElemIndexO(self, 2); 18711 r = indexOfSmallIntO(self, value); 18712 ck_assert_int_eq(r, -1); 18713 // non smallInt object 18714 terminateO(value); 18715 value = (smallIntt*) allocSmallBool(true); 18716 r = indexOfSmallIntO(self, value); 18717 ck_assert_int_eq(r, -1); 18718 // NULL value 18719 r = indexOfSmallIntO(self, NULL); 18720 ck_assert_int_eq(r, -1); 18721 terminateO(self); 18722 terminateO(value); 18723 18724 } 18725 18726 18727 void indexOfSmallJsonSmallJsonT(void) { 18728 18729 ssize_t r; 18730 smallJsont *self = allocSmallJson(); 18731 smallJsont *value = allocSmallJson(); 18732 18733 // indexOf json undefined 18734 createUndefined(u); 18735 setTopO(value, (baset*)&u); 18736 self->f->pushUndefined(self); 18737 r = self->f->indexOfSmallJson(self, value); 18738 ck_assert_int_eq(r, 0); 18739 freeO(value); 18740 // indexOf json bool 18741 smallBoolt *b = allocSmallBool(true); 18742 setTopNFreeSmallBoolO(value, b); 18743 self->f->pushBool(self, true); 18744 r = self->f->indexOfSmallJson(self, value); 18745 ck_assert_int_eq(r, 1); 18746 freeO(value); 18747 // indexOf json double 18748 smallDoublet *d = allocSmallDouble(1); 18749 setTopNFreeSmallDoubleO(value, d); 18750 self->f->pushDouble(self, 1); 18751 r = self->f->indexOfSmallJson(self, value); 18752 ck_assert_int_eq(r, 2); 18753 freeO(value); 18754 // indexOf json int 18755 smallIntt *i = allocSmallInt(1); 18756 setTopNFreeSmallIntO(value, i); 18757 self->f->pushInt(self, 1); 18758 r = self->f->indexOfSmallJson(self, value); 18759 ck_assert_int_eq(r, 3); 18760 freeO(value); 18761 // indexOf json string 18762 smallStringt *s = allocSmallString("asd"); 18763 setTopNFreeSmallStringO(value, s); 18764 self->f->pushS(self, "asd"); 18765 r = self->f->indexOfSmallJson(self, value); 18766 ck_assert_int_eq(r, 4); 18767 freeO(value); 18768 // indexOf json dict 18769 smallDictt *D = allocSmallDict(); 18770 setTopNFreeDictO(value, D); 18771 self->f->pushNFreeDict(self, allocSmallDict()); 18772 r = self->f->indexOfSmallJson(self, value); 18773 ck_assert_int_eq(r, 5); 18774 freeO(value); 18775 // indexOf json array 18776 value->f->pushInt(value, 1); 18777 delElemIndexO(self, 1); 18778 createAllocateSmallJson(elem); 18779 elem->f->pushInt(elem, 1); 18780 self->f->pushNFreeSmallJson(self, elem); 18781 r = self->f->indexOfSmallJson(self, value); 18782 ck_assert_int_eq(r, 6); 18783 // not indexOf 18784 delElemIndexO(self, 6); 18785 r = self->f->indexOfSmallJson(self, value); 18786 ck_assert_int_eq(r, -1); 18787 // empty json object 18788 freeO(value); 18789 r = self->f->indexOfSmallJson(self, value); 18790 ck_assert_int_eq(r, -1); 18791 // non smallJson object 18792 terminateO(value); 18793 value = (smallJsont*) allocSmallInt(2); 18794 r = self->f->indexOfSmallJson(self, value); 18795 ck_assert_int_eq(r, -1); 18796 // NULL value 18797 r = self->f->indexOfSmallJson(self, NULL); 18798 ck_assert_int_eq(r, -1); 18799 terminateO(self); 18800 terminateO(value); 18801 18802 } 18803 18804 18805 void indexOfSmallStringSmallJsonT(void) { 18806 18807 ssize_t r; 18808 smallJsont *self = allocSmallJson(); 18809 smallStringt *value = allocSmallString("qwe"); 18810 18811 // indexOf 18812 self->f->pushUndefined(self); 18813 self->f->pushUndefined(self); 18814 delElemIndexO(self, 1); 18815 self->f->pushS(self, "qwe"); 18816 r = self->f->indexOfSmallString(self, value); 18817 ck_assert_int_eq(r, 2); 18818 // not indexOf 18819 delElemIndexO(self, 2); 18820 r = self->f->indexOfSmallString(self, value); 18821 ck_assert_int_eq(r, -1); 18822 // empty string 18823 freeO(value); 18824 r = self->f->indexOfSmallString(self, value); 18825 ck_assert_int_eq(r, -1); 18826 // non smallString object 18827 terminateO(value); 18828 value = (smallStringt*) allocSmallInt(2); 18829 r = self->f->indexOfSmallString(self, value); 18830 ck_assert_int_eq(r, -1); 18831 // NULL value 18832 r = self->f->indexOfSmallString(self, NULL); 18833 ck_assert_int_eq(r, -1); 18834 terminateO(self); 18835 terminateO(value); 18836 // json string 18837 self = allocSmallJson(); 18838 smallStringt *needle = allocSmallString("ee"); 18839 // indexOf string in the middle 18840 setTopSO(self, "sheepy"); 18841 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), 2); 18842 // indexOf non existing string 18843 setValO(needle, "$"); 18844 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), -1); 18845 // non smallString object 18846 terminateO(needle); 18847 needle = (smallStringt*) allocSmallInt(1); 18848 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), -1); 18849 terminateO(needle); 18850 // indexOf NULL 18851 ck_assert_int_eq(self->f->indexOfSmallString(self, NULL), -1); 18852 // empty string 18853 freeO(self); 18854 setTopSO(self, ""); 18855 needle = allocSmallString("$"); 18856 ck_assert_int_eq(self->f->indexOfSmallString(self, needle), -1); 18857 terminateO(needle); 18858 terminateO(self); 18859 18860 } 18861 18862 18863 void indexOfSmallContainerSmallJsonT(void) { 18864 18865 ssize_t r; 18866 smallJsont *self = allocSmallJson(); 18867 createAllocateSmallContainer(value); 18868 18869 // indexOf 18870 self->f->pushUndefined(self); 18871 self->f->pushUndefined(self); 18872 delElemIndexO(self, 1); 18873 createAllocateSmallContainer(elem); 18874 self->f->pushNFreeSmallContainer(self, elem); 18875 r = self->f->indexOfSmallContainer(self, value); 18876 ck_assert_int_eq(r, -1); 18877 // not indexOf 18878 delElemIndexO(self, 2); 18879 r = self->f->indexOfSmallContainer(self, value); 18880 ck_assert_int_eq(r, -1); 18881 // non smallContainer object 18882 terminateO(value); 18883 value = (smallContainert*) allocSmallInt(2); 18884 r = self->f->indexOfSmallContainer(self, value); 18885 ck_assert_int_eq(r, -1); 18886 // NULL value 18887 r = self->f->indexOfSmallContainer(self, NULL); 18888 ck_assert_int_eq(r, -1); 18889 terminateO(self); 18890 terminateO(value); 18891 18892 } 18893 18894 18895 void binarySearchSmallJsonT(void) { 18896 18897 ssize_t r; 18898 smallJsont *self = allocSmallJson(); 18899 baset *value = (baset*)allocSmallString("4"); 18900 18901 // index not trimmed (an element is NULL) 18902 self->f->pushS(self, "0"); 18903 self->f->pushS(self, "1"); 18904 self->f->pushS(self, "2"); 18905 delElemIndexO(self, 2); 18906 self->f->pushS(self, "3"); 18907 self->f->pushS(self, "4"); 18908 self->f->pushS(self, "5"); 18909 r = binarySearchO(self, value); 18910 ck_assert_int_eq(r, -1); 18911 // index 18912 trimO(self); 18913 r = binarySearchO(self, value); 18914 ck_assert_int_eq(r, 3); 18915 smallStringt *v = (smallStringt*) value; 18916 // index in the lower half of the array 18917 setValO(v, "1"); 18918 r = binarySearchO(self, value); 18919 ck_assert_int_eq(r, 1); 18920 // not index 18921 setValO(v, "asd"); 18922 r = binarySearchO(self, value); 18923 ck_assert_int_eq(r, -1); 18924 // NULL value 18925 r = binarySearchO(self, NULL); 18926 ck_assert_int_eq(r, -1); 18927 // empty array 18928 emptyO(self); 18929 r = binarySearchO(self, value); 18930 ck_assert_int_eq(r, -1); 18931 terminateO(self); 18932 terminateO(value); 18933 18934 } 18935 18936 18937 void binarySearchUndefinedSmallJsonT(void) { 18938 18939 ssize_t r; 18940 smallJsont *self = allocSmallJson(); 18941 undefinedt *undefined = (undefinedt*) 1234; 18942 18943 r = binarySearchUndefinedO(self, undefined); 18944 ck_assert_int_eq(r, -1); 18945 terminateO(self); 18946 18947 } 18948 18949 18950 void binarySearchBoolSmallJsonT(void) { 18951 18952 ssize_t r; 18953 smallJsont *self = allocSmallJson(); 18954 bool value = true; 18955 18956 // index not trimmed (an element is NULL) 18957 self->f->pushUndefined(self); 18958 self->f->pushBool(self, false); 18959 self->f->pushUndefined(self); 18960 delElemIndexO(self, 2); 18961 self->f->pushBool(self, true); 18962 self->f->pushS(self, "4"); 18963 self->f->pushS(self, "5"); 18964 r = binarySearchBoolO(self, value); 18965 ck_assert_int_eq(r, -1); 18966 // index 18967 trimO(self); 18968 r = binarySearchBoolO(self, value); 18969 ck_assert_int_eq(r, 2); 18970 // index in the lower half of the array 18971 value = false; 18972 r = binarySearchBoolO(self, value); 18973 ck_assert_int_eq(r, 1); 18974 // not index 18975 delElemIndexO(self, 1); 18976 trimO(self); 18977 r = binarySearchBoolO(self, value); 18978 ck_assert_int_eq(r, -1); 18979 // empty array 18980 emptyO(self); 18981 r = binarySearchBoolO(self, value); 18982 ck_assert_int_eq(r, -1); 18983 terminateO(self); 18984 18985 } 18986 18987 18988 void binarySearchDoubleSmallJsonT(void) { 18989 18990 ssize_t r; 18991 smallJsont *self = allocSmallJson(); 18992 double value = 2; 18993 18994 // index not trimmed (an element is NULL) 18995 self->f->pushUndefined(self); 18996 self->f->pushDouble(self, 1); 18997 self->f->pushUndefined(self); 18998 delElemIndexO(self, 2); 18999 self->f->pushDouble(self, 2); 19000 self->f->pushS(self, "4"); 19001 self->f->pushS(self, "5"); 19002 r = binarySearchDoubleO(self, value); 19003 ck_assert_int_eq(r, -1); 19004 // index 19005 trimO(self); 19006 r = binarySearchDoubleO(self, value); 19007 ck_assert_int_eq(r, 2); 19008 // index in the lower half of the array 19009 value = 1; 19010 r = binarySearchDoubleO(self, value); 19011 ck_assert_int_eq(r, 1); 19012 // not index 19013 delElemIndexO(self, 1); 19014 trimO(self); 19015 r = binarySearchDoubleO(self, value); 19016 ck_assert_int_eq(r, -1); 19017 // empty array 19018 emptyO(self); 19019 r = binarySearchDoubleO(self, value); 19020 ck_assert_int_eq(r, -1); 19021 terminateO(self); 19022 19023 } 19024 19025 19026 void binarySearchIntSmallJsonT(void) { 19027 19028 ssize_t r; 19029 smallJsont *self = allocSmallJson(); 19030 int64_t value = 2; 19031 19032 // index not trimmed (an element is NULL) 19033 self->f->pushUndefined(self); 19034 self->f->pushInt(self, 1); 19035 self->f->pushUndefined(self); 19036 delElemIndexO(self, 2); 19037 self->f->pushInt(self, 2); 19038 self->f->pushS(self, "4"); 19039 self->f->pushS(self, "5"); 19040 r = binarySearchIntO(self, value); 19041 ck_assert_int_eq(r, -1); 19042 // index 19043 trimO(self); 19044 r = binarySearchIntO(self, value); 19045 ck_assert_int_eq(r, 2); 19046 // index in the lower half of the array 19047 value = 1; 19048 r = binarySearchIntO(self, value); 19049 ck_assert_int_eq(r, 1); 19050 // not index 19051 delElemIndexO(self, 1); 19052 trimO(self); 19053 r = binarySearchIntO(self, value); 19054 ck_assert_int_eq(r, -1); 19055 // empty array 19056 emptyO(self); 19057 r = binarySearchIntO(self, value); 19058 ck_assert_int_eq(r, -1); 19059 terminateO(self); 19060 19061 } 19062 19063 19064 void binarySearchSSmallJsonT(void) { 19065 19066 ssize_t r; 19067 smallJsont *self = allocSmallJson(); 19068 const char *value = "4"; 19069 19070 // index not trimmed (an element is NULL) 19071 self->f->pushS(self, "0"); 19072 self->f->pushS(self, "1"); 19073 self->f->pushS(self, "2"); 19074 delElemIndexO(self, 2); 19075 self->f->pushS(self, "3"); 19076 self->f->pushS(self, "4"); 19077 self->f->pushS(self, "5"); 19078 r = binarySearchSO(self, value); 19079 ck_assert_int_eq(r, -1); 19080 // index 19081 trimO(self); 19082 r = binarySearchSO(self, value); 19083 ck_assert_int_eq(r, 3); 19084 // index in the lower half of the array 19085 value = "1"; 19086 r = binarySearchSO(self, value); 19087 ck_assert_int_eq(r, 1); 19088 // not index 19089 value = "asd"; 19090 r = binarySearchSO(self, value); 19091 ck_assert_int_eq(r, -1); 19092 // NULL value 19093 r = binarySearchSO(self, NULL); 19094 ck_assert_int_eq(r, -1); 19095 // empty array 19096 emptyO(self); 19097 r = binarySearchSO(self, value); 19098 ck_assert_int_eq(r, -1); 19099 terminateO(self); 19100 19101 } 19102 19103 19104 void binarySearchCharSmallJsonT(void) { 19105 19106 ssize_t r; 19107 smallJsont *self = allocSmallJson(); 19108 char value = '4'; 19109 19110 // index not trimmed (an element is NULL) 19111 self->f->pushS(self, "0"); 19112 self->f->pushS(self, "1"); 19113 self->f->pushS(self, "2"); 19114 delElemIndexO(self, 2); 19115 self->f->pushS(self, "3"); 19116 self->f->pushS(self, "4"); 19117 self->f->pushS(self, "5"); 19118 r = binarySearchCharO(self, value); 19119 ck_assert_int_eq(r, -1); 19120 // index 19121 trimO(self); 19122 r = binarySearchCharO(self, value); 19123 ck_assert_int_eq(r, 3); 19124 // index in the lower half of the array 19125 value = '1'; 19126 r = binarySearchCharO(self, value); 19127 ck_assert_int_eq(r, 1); 19128 // not index 19129 value = 'a'; 19130 r = binarySearchCharO(self, value); 19131 ck_assert_int_eq(r, -1); 19132 // empty array 19133 emptyO(self); 19134 r = binarySearchCharO(self, value); 19135 ck_assert_int_eq(r, -1); 19136 terminateO(self); 19137 19138 } 19139 19140 19141 void binarySearchDictSmallJsonT(void) { 19142 19143 ssize_t r; 19144 smallJsont *self = allocSmallJson(); 19145 smallDictt *value = allocSmallDict(); 19146 value->f->setInt(value, "b", 2); 19147 19148 // index not trimmed (an element is NULL) 19149 createAllocateSmallDict(elem); 19150 elem->f->setInt(elem, "a", 1); 19151 self->f->pushUndefined(self); 19152 self->f->pushDict(self, elem); 19153 resetO(elem); 19154 self->f->pushUndefined(self); 19155 delElemIndexO(self, 2); 19156 elem->f->setInt(elem, "b", 2); 19157 self->f->pushNFreeDict(self, elem); 19158 self->f->pushS(self, "4"); 19159 self->f->pushS(self, "5"); 19160 r = binarySearchDictO(self, value); 19161 ck_assert_int_eq(r, -1); 19162 // index 19163 trimO(self); 19164 r = binarySearchDictO(self, value); 19165 ck_assert_int_eq(r, 2); 19166 // index in the lower half of the array 19167 freeO(value); 19168 value->f->setInt(value, "a", 1); 19169 r = binarySearchDictO(self, value); 19170 ck_assert_int_eq(r, 1); 19171 // not index 19172 freeO(value); 19173 r = binarySearchDictO(self, value); 19174 ck_assert_int_eq(r, -1); 19175 // non smallDict object 19176 terminateO(value); 19177 value = (smallDictt*) allocSmallInt(2); 19178 r = binarySearchDictO(self, value); 19179 ck_assert_int_eq(r, -1); 19180 // NULL value 19181 r = binarySearchDictO(self, NULL); 19182 ck_assert_int_eq(r, -1); 19183 // empty array 19184 emptyO(self); 19185 r = binarySearchDictO(self, value); 19186 ck_assert_int_eq(r, -1); 19187 terminateO(self); 19188 terminateO(value); 19189 19190 } 19191 19192 19193 void binarySearchArraySmallJsonT(void) { 19194 19195 ssize_t r; 19196 smallJsont *self = allocSmallJson(); 19197 smallArrayt *value = allocSmallArray(); 19198 value->f->pushInt(value, 2); 19199 19200 // index not trimmed (an element is NULL) 19201 createAllocateSmallArray(elem); 19202 elem->f->pushInt(elem, 1); 19203 self->f->pushUndefined(self); 19204 self->f->pushArray(self, elem); 19205 resetO(elem); 19206 self->f->pushUndefined(self); 19207 delElemIndexO(self, 2); 19208 elem->f->pushInt(elem, 2); 19209 self->f->pushNFreeArray(self, elem); 19210 self->f->pushS(self, "4"); 19211 self->f->pushS(self, "5"); 19212 r = binarySearchArrayO(self, value); 19213 ck_assert_int_eq(r, -1); 19214 // index 19215 trimO(self); 19216 r = binarySearchArrayO(self, value); 19217 ck_assert_int_eq(r, 2); 19218 // index in the lower half of the array 19219 freeO(value); 19220 value->f->pushInt(value, 1); 19221 r = binarySearchArrayO(self, value); 19222 ck_assert_int_eq(r, 1); 19223 // not index 19224 freeO(value); 19225 r = binarySearchArrayO(self, value); 19226 ck_assert_int_eq(r, -1); 19227 // non smallArray object 19228 terminateO(value); 19229 value = (smallArrayt*) allocSmallInt(2); 19230 r = binarySearchArrayO(self, value); 19231 ck_assert_int_eq(r, -1); 19232 // NULL value 19233 r = binarySearchArrayO(self, NULL); 19234 ck_assert_int_eq(r, -1); 19235 // empty array 19236 emptyO(self); 19237 r = binarySearchArrayO(self, value); 19238 ck_assert_int_eq(r, -1); 19239 terminateO(self); 19240 terminateO(value); 19241 19242 } 19243 19244 19245 void binarySearchArraycSmallJsonT(void) { 19246 19247 ssize_t r; 19248 smallJsont *self = allocSmallJson(); 19249 char **value = listCreateS("b"); 19250 19251 // index not trimmed (an element is NULL) 19252 char **elem = listCreateS("a"); 19253 self->f->pushUndefined(self); 19254 self->f->pushNFreeArrayc(self, elem); 19255 self->f->pushUndefined(self); 19256 delElemIndexO(self, 2); 19257 elem = listCreateS("b"); 19258 self->f->pushNFreeArrayc(self, elem); 19259 self->f->pushS(self, "4"); 19260 self->f->pushS(self, "5"); 19261 r = binarySearchArraycO(self, value); 19262 ck_assert_int_eq(r, -1); 19263 // index 19264 trimO(self); 19265 r = binarySearchArraycO(self, value); 19266 ck_assert_int_eq(r, 2); 19267 // index in the lower half of the array 19268 free(value[0]); 19269 value[0] = strdup("a"); 19270 r = binarySearchArraycO(self, value); 19271 ck_assert_int_eq(r, 1); 19272 // not index 19273 free(value[0]); 19274 value[0] = strdup("asd"); 19275 r = binarySearchArraycO(self, value); 19276 ck_assert_int_eq(r, -1); 19277 // NULL value 19278 r = binarySearchArraycO(self, NULL); 19279 ck_assert_int_eq(r, -1); 19280 // empty array 19281 emptyO(self); 19282 r = binarySearchArraycO(self, value); 19283 ck_assert_int_eq(r, -1); 19284 terminateO(self); 19285 listFreeS(value); 19286 19287 } 19288 19289 19290 void binarySearchSmallBoolSmallJsonT(void) { 19291 19292 ssize_t r; 19293 smallJsont *self = allocSmallJson(); 19294 smallBoolt *value = allocSmallBool(true); 19295 19296 // index not trimmed (an element is NULL) 19297 self->f->pushUndefined(self); 19298 self->f->pushBool(self, false); 19299 self->f->pushUndefined(self); 19300 delElemIndexO(self, 2); 19301 self->f->pushBool(self, true); 19302 self->f->pushS(self, "4"); 19303 self->f->pushS(self, "5"); 19304 r = binarySearchSmallBoolO(self, value); 19305 ck_assert_int_eq(r, -1); 19306 // index 19307 trimO(self); 19308 r = binarySearchSmallBoolO(self, value); 19309 ck_assert_int_eq(r, 2); 19310 // index in the lower half of the array 19311 setValO(value, false); 19312 r = binarySearchSmallBoolO(self, value); 19313 ck_assert_int_eq(r, 1); 19314 // not index 19315 delElemIndexO(self, 1); 19316 trimO(self); 19317 r = binarySearchSmallBoolO(self, value); 19318 ck_assert_int_eq(r, -1); 19319 // non smallBool object 19320 terminateO(value); 19321 value = (smallBoolt*) allocSmallInt(2); 19322 r = binarySearchSmallBoolO(self, value); 19323 ck_assert_int_eq(r, -1); 19324 // NULL value 19325 r = binarySearchArraycO(self, NULL); 19326 ck_assert_int_eq(r, -1); 19327 // empty array 19328 emptyO(self); 19329 r = binarySearchSmallBoolO(self, value); 19330 ck_assert_int_eq(r, -1); 19331 terminateO(self); 19332 terminateO(value); 19333 19334 } 19335 19336 19337 void binarySearchSmallBytesSmallJsonT(void) { 19338 19339 ssize_t r; 19340 smallJsont *self = allocSmallJson(); 19341 createAllocateSmallBytes(value); 19342 pushBufferO(value, "bbc", 4); 19343 19344 // index not trimmed (an element is NULL) 19345 createAllocateSmallBytes(elem); 19346 pushBufferO(elem, "abc", 4); 19347 self->f->pushUndefined(self); 19348 self->f->pushNFreeSmallBytes(self, elem); 19349 self->f->pushUndefined(self); 19350 delElemIndexO(self, 2); 19351 elem = allocSmallBytes("bbc", 4); 19352 self->f->pushNFreeSmallBytes(self, elem); 19353 self->f->pushS(self, "4"); 19354 self->f->pushS(self, "5"); 19355 r = binarySearchSmallBytesO(self, value); 19356 ck_assert_int_eq(r, -1); 19357 // index 19358 trimO(self); 19359 r = binarySearchSmallBytesO(self, value); 19360 ck_assert_int_eq(r, 2); 19361 // index in the lower half of the array 19362 freeO(value); 19363 pushBufferO(value, "abc", 4); 19364 r = binarySearchSmallBytesO(self, value); 19365 ck_assert_int_eq(r, 1); 19366 // not index 19367 freeO(value); 19368 pushBufferO(value, "###", 4); 19369 r = binarySearchSmallBytesO(self, value); 19370 ck_assert_int_eq(r, -1); 19371 // non smallBytes object 19372 terminateO(value); 19373 value = (smallBytest*) allocSmallInt(2); 19374 r = binarySearchSmallBytesO(self, value); 19375 ck_assert_int_eq(r, -1); 19376 // NULL value 19377 r = binarySearchSmallBytesO(self, NULL); 19378 ck_assert_int_eq(r, -1); 19379 // empty array 19380 emptyO(self); 19381 r = binarySearchSmallBytesO(self, value); 19382 ck_assert_int_eq(r, -1); 19383 terminateO(self); 19384 terminateO(value); 19385 19386 } 19387 19388 19389 void binarySearchSmallDoubleSmallJsonT(void) { 19390 19391 ssize_t r; 19392 smallJsont *self = allocSmallJson(); 19393 smallDoublet *value = allocSmallDouble(2); 19394 19395 // index not trimmed (an element is NULL) 19396 self->f->pushUndefined(self); 19397 self->f->pushDouble(self, 1); 19398 self->f->pushUndefined(self); 19399 delElemIndexO(self, 2); 19400 self->f->pushDouble(self, 2); 19401 self->f->pushS(self, "4"); 19402 self->f->pushS(self, "5"); 19403 r = binarySearchSmallDoubleO(self, value); 19404 ck_assert_int_eq(r, -1); 19405 // index 19406 trimO(self); 19407 r = binarySearchSmallDoubleO(self, value); 19408 ck_assert_int_eq(r, 2); 19409 // index in the lower half of the array 19410 setValO(value, 1); 19411 r = binarySearchSmallDoubleO(self, value); 19412 ck_assert_int_eq(r, 1); 19413 // not index 19414 delElemIndexO(self, 1); 19415 trimO(self); 19416 r = binarySearchSmallDoubleO(self, value); 19417 ck_assert_int_eq(r, -1); 19418 // non smallDouble object 19419 terminateO(value); 19420 value = (smallDoublet*) allocSmallInt(2); 19421 r = binarySearchSmallDoubleO(self, value); 19422 ck_assert_int_eq(r, -1); 19423 // NULL value 19424 r = binarySearchArraycO(self, NULL); 19425 ck_assert_int_eq(r, -1); 19426 // empty array 19427 emptyO(self); 19428 r = binarySearchSmallDoubleO(self, value); 19429 ck_assert_int_eq(r, -1); 19430 terminateO(self); 19431 terminateO(value); 19432 19433 } 19434 19435 19436 void binarySearchSmallIntSmallJsonT(void) { 19437 19438 ssize_t r; 19439 smallJsont *self = allocSmallJson(); 19440 smallIntt *value = allocSmallInt(2); 19441 19442 // index not trimmed (an element is NULL) 19443 self->f->pushUndefined(self); 19444 self->f->pushInt(self, 1); 19445 self->f->pushUndefined(self); 19446 delElemIndexO(self, 2); 19447 self->f->pushInt(self, 2); 19448 self->f->pushS(self, "4"); 19449 self->f->pushS(self, "5"); 19450 r = binarySearchSmallIntO(self, value); 19451 ck_assert_int_eq(r, -1); 19452 // index 19453 trimO(self); 19454 r = binarySearchSmallIntO(self, value); 19455 ck_assert_int_eq(r, 2); 19456 // index in the lower half of the array 19457 setValO(value, 1); 19458 r = binarySearchSmallIntO(self, value); 19459 ck_assert_int_eq(r, 1); 19460 // not index 19461 delElemIndexO(self, 1); 19462 trimO(self); 19463 r = binarySearchSmallIntO(self, value); 19464 ck_assert_int_eq(r, -1); 19465 // non smallInt object 19466 terminateO(value); 19467 value = (smallIntt*) allocSmallBool(true); 19468 r = binarySearchSmallIntO(self, value); 19469 ck_assert_int_eq(r, -1); 19470 // NULL value 19471 r = binarySearchArraycO(self, NULL); 19472 ck_assert_int_eq(r, -1); 19473 // empty array 19474 emptyO(self); 19475 r = binarySearchSmallIntO(self, value); 19476 ck_assert_int_eq(r, -1); 19477 terminateO(self); 19478 terminateO(value); 19479 19480 } 19481 19482 19483 void binarySearchSmallJsonSmallJsonT(void) { 19484 19485 ssize_t r; 19486 smallJsont *self = allocSmallJson(); 19487 smallJsont *value = allocSmallJson(); 19488 value->f->pushInt(value, 2); 19489 19490 // index not trimmed (an element is NULL) 19491 self->f->pushUndefined(self); 19492 createAllocateSmallArray(elem); 19493 elem->f->pushInt(elem, 1); 19494 self->f->pushArray(self, elem); 19495 resetO(elem); 19496 self->f->pushUndefined(self); 19497 delElemIndexO(self, 2); 19498 elem->f->pushInt(elem, 2); 19499 self->f->pushNFreeArray(self, elem); 19500 self->f->pushS(self, "4"); 19501 self->f->pushS(self, "5"); 19502 r = self->f->binarySearchSmallJson(self, value); 19503 ck_assert_int_eq(r, -1); 19504 // index 19505 trimO(self); 19506 r = self->f->binarySearchSmallJson(self, value); 19507 ck_assert_int_eq(r, 2); 19508 // index in the lower half of the array 19509 freeO(value); 19510 value->f->pushInt(value, 1); 19511 r = self->f->binarySearchSmallJson(self, value); 19512 ck_assert_int_eq(r, 1); 19513 // not index (json array) 19514 delElemIndexO(self, 1); 19515 trimO(self); 19516 r = self->f->binarySearchSmallJson(self, value); 19517 ck_assert_int_eq(r, -1); 19518 // not index json undefined 19519 createUndefined(u); 19520 freeO(value); 19521 setTopO(value, (baset*)&u); 19522 r = self->f->binarySearchSmallJson(self, value); 19523 ck_assert_int_eq(r, -1); 19524 // not index json bool 19525 createSmallBool(b); 19526 freeO(value); 19527 setTopO(value, (baset*)&b); 19528 r = self->f->binarySearchSmallJson(self, value); 19529 ck_assert_int_eq(r, -1); 19530 // not index json double 19531 createSmallDouble(d); 19532 freeO(value); 19533 setTopO(value, (baset*)&d); 19534 r = self->f->binarySearchSmallJson(self, value); 19535 ck_assert_int_eq(r, -1); 19536 // not index json int 19537 createSmallInt(i); 19538 freeO(value); 19539 setTopO(value, (baset*)&i); 19540 r = self->f->binarySearchSmallJson(self, value); 19541 ck_assert_int_eq(r, -1); 19542 // not index json string 19543 createSmallString(s); 19544 freeO(value); 19545 setTopO(value, (baset*)&s); 19546 r = self->f->binarySearchSmallJson(self, value); 19547 ck_assert_int_eq(r, -1); 19548 // not index json dict 19549 createSmallDict(D); 19550 freeO(value); 19551 setTopO(value, (baset*)&D); 19552 r = self->f->binarySearchSmallJson(self, value); 19553 ck_assert_int_eq(r, -1); 19554 // empty json object 19555 freeO(value); 19556 r = self->f->binarySearchSmallJson(self, value); 19557 ck_assert_int_eq(r, -1); 19558 // non smallJson object 19559 terminateO(value); 19560 value = (smallJsont*) allocSmallInt(2); 19561 r = self->f->binarySearchSmallJson(self, value); 19562 ck_assert_int_eq(r, -1); 19563 // NULL value 19564 r = self->f->binarySearchSmallJson(self, NULL); 19565 ck_assert_int_eq(r, -1); 19566 // empty array 19567 emptyO(self); 19568 r = self->f->binarySearchSmallJson(self, value); 19569 ck_assert_int_eq(r, -1); 19570 terminateO(self); 19571 terminateO(value); 19572 19573 } 19574 19575 19576 void binarySearchSmallStringSmallJsonT(void) { 19577 19578 ssize_t r; 19579 smallJsont *self = allocSmallJson(); 19580 smallStringt *value = allocSmallString("4"); 19581 19582 // index not trimmed (an element is NULL) 19583 self->f->pushS(self, "0"); 19584 self->f->pushS(self, "1"); 19585 self->f->pushS(self, "2"); 19586 delElemIndexO(self, 2); 19587 self->f->pushS(self, "3"); 19588 self->f->pushS(self, "4"); 19589 self->f->pushS(self, "5"); 19590 r = binarySearchSmallStringO(self, value); 19591 ck_assert_int_eq(r, -1); 19592 // index 19593 trimO(self); 19594 r = binarySearchSmallStringO(self, value); 19595 ck_assert_int_eq(r, 3); 19596 // index in the lower half of the array 19597 setValO(value, "1"); 19598 r = binarySearchSmallStringO(self, value); 19599 ck_assert_int_eq(r, 1); 19600 // not index 19601 setValO(value, "asd"); 19602 r = binarySearchSmallStringO(self, value); 19603 ck_assert_int_eq(r, -1); 19604 // non smallString object 19605 terminateO(value); 19606 value = (smallStringt*) allocSmallInt(2); 19607 r = binarySearchSmallStringO(self, value); 19608 ck_assert_int_eq(r, -1); 19609 // NULL value 19610 r = binarySearchSmallStringO(self, NULL); 19611 ck_assert_int_eq(r, -1); 19612 // empty array 19613 emptyO(self); 19614 r = binarySearchSmallStringO(self, value); 19615 ck_assert_int_eq(r, -1); 19616 terminateO(self); 19617 terminateO(value); 19618 19619 } 19620 19621 19622 void binarySearchSmallContainerSmallJsonT(void) { 19623 19624 ssize_t r; 19625 smallJsont *self = allocSmallJson(); 19626 createAllocateSmallContainer(value); 19627 19628 r = self->f->binarySearchSmallContainer(self, value); 19629 ck_assert_int_eq(r, -1); 19630 terminateO(self); 19631 terminateO(value); 19632 19633 } 19634 19635 19636 void icHasSmallJsonT(void) { 19637 19638 bool r; 19639 smallJsont *self = allocSmallJson(); 19640 baset *value = (baset*)allocSmallString("a"); 19641 19642 // has 19643 self->f->pushS(self, "A"); 19644 r = icHasO(self, value); 19645 ck_assert(r); 19646 // not has 19647 emptyO(self); 19648 r = icHasO(self, value); 19649 ck_assert(!r); 19650 // NULL value 19651 r = icHasO(self, NULL); 19652 ck_assert(!r); 19653 terminateO(self); 19654 terminateO(value); 19655 19656 } 19657 19658 19659 void icHasSSmallJsonT(void) { 19660 19661 bool r; 19662 smallJsont *self = allocSmallJson(); 19663 const char *value = "ASD"; 19664 19665 // has 19666 self->f->pushS(self, "asd"); 19667 r = icHasSO(self, value); 19668 ck_assert(r); 19669 // not has 19670 emptyO(self); 19671 r = icHasSO(self, value); 19672 ck_assert(!r); 19673 // NULL value 19674 r = icHasSO(self, NULL); 19675 ck_assert(!r); 19676 terminateO(self); 19677 // json dict 19678 self = allocSmallJson(); 19679 self->f->setInt(self, "u", 0); 19680 ck_assert(!icHasSO(self, "U")); 19681 ck_assert(icHasSO(self, "u")); 19682 terminateO(self); 19683 19684 } 19685 19686 19687 void icHasCharSmallJsonT(void) { 19688 19689 bool r; 19690 smallJsont *self = allocSmallJson(); 19691 char value = 'A'; 19692 19693 // has 19694 self->f->pushS(self, "a"); 19695 r = icHasCharO(self, value); 19696 ck_assert(r); 19697 // not has 19698 emptyO(self); 19699 r = icHasCharO(self, value); 19700 ck_assert(!r); 19701 terminateO(self); 19702 19703 } 19704 19705 19706 void icHasDictSmallJsonT(void) { 19707 19708 bool r; 19709 smallJsont *self = allocSmallJson(); 19710 smallDictt *value = allocSmallDict(); 19711 value->f->setInt(value, "A", 1); 19712 19713 // has 19714 createAllocateSmallDict(d); 19715 d->f->setInt(d, "a", 1); 19716 self->f->pushNFreeDict(self, d); 19717 r = icHasDictO(self, value); 19718 ck_assert(r); 19719 // not has 19720 emptyO(self); 19721 r = icHasDictO(self, value); 19722 ck_assert(!r); 19723 // NULL value 19724 r = icHasDictO(self, NULL); 19725 ck_assert(!r); 19726 terminateO(self); 19727 terminateO(value); 19728 19729 } 19730 19731 19732 void icHasArraySmallJsonT(void) { 19733 19734 bool r; 19735 smallJsont *self = allocSmallJson(); 19736 smallArrayt *value = allocSmallArray(); 19737 value->f->pushS(value, "A"); 19738 19739 // has 19740 createAllocateSmallArray(a); 19741 a->f->pushS(a, "a"); 19742 self->f->pushNFreeArray(self, a); 19743 r = icHasArrayO(self, value); 19744 ck_assert(r); 19745 // not has 19746 emptyO(self); 19747 r = icHasArrayO(self, value); 19748 ck_assert(!r); 19749 // NULL value 19750 r = icHasArrayO(self, NULL); 19751 ck_assert(!r); 19752 terminateO(self); 19753 terminateO(value); 19754 19755 } 19756 19757 19758 void icHasArraycSmallJsonT(void) { 19759 19760 bool r; 19761 smallJsont *self = allocSmallJson(); 19762 char **value = listCreateS("A","BB"); 19763 19764 // has 19765 self->f->pushNFreeArrayc(self, listCreateS("a","bb")); 19766 r = icHasArraycO(self, value); 19767 ck_assert(r); 19768 // not has 19769 emptyO(self); 19770 r = icHasArraycO(self, value); 19771 ck_assert(!r); 19772 // NULL value 19773 r = icHasArraycO(self, NULL); 19774 ck_assert(!r); 19775 terminateO(self); 19776 listFreeS(value); 19777 19778 } 19779 19780 19781 void icHasSmallStringSmallJsonT(void) { 19782 19783 bool r; 19784 smallJsont *self = allocSmallJson(); 19785 smallStringt *value = allocSmallString("QWE"); 19786 19787 // has 19788 self->f->pushS(self, "qwe"); 19789 r = self->f->icHasSmallString(self, value); 19790 ck_assert(r); 19791 // not has 19792 emptyO(self); 19793 r = self->f->icHasSmallString(self, value); 19794 ck_assert(!r); 19795 // NULL value 19796 r = self->f->icHasSmallString(self, NULL); 19797 ck_assert(!r); 19798 terminateO(self); 19799 terminateO(value); 19800 19801 } 19802 19803 19804 void icFindSmallJsonT(void) { 19805 19806 smallJsont* r; 19807 smallJsont *self = allocSmallJson(); 19808 setTopSO(self, ""); 19809 19810 // icFind string in the middle 19811 freeO(self); 19812 setTopSO(self, "sheepy"); 19813 r = icFindO(self, "EE"); 19814 ck_assert_ptr_ne(r, null); 19815 ck_assert_str_eq(sjGet(r), "eepy"); 19816 terminateO(r); 19817 // find non existing string 19818 ck_assert_ptr_eq(icFindO(self, "$"), NULL); 19819 // find NULL 19820 ck_assert_ptr_eq(icFindO(self, NULL), NULL); 19821 // empty string 19822 freeO(self); 19823 setTopSO(self, ""); 19824 ck_assert_ptr_eq(icFindO(self, "$"), NULL); 19825 // NULL string 19826 freeO(self); 19827 ck_assert_ptr_eq(icFindO(self, "$"), NULL); 19828 terminateO(self); 19829 19830 } 19831 19832 19833 void icFindCharSmallJsonT(void) { 19834 19835 smallJsont* r; 19836 smallJsont *self = allocSmallJson(); 19837 setTopSO(self, ""); 19838 19839 // find string in the middle 19840 freeO(self); 19841 setTopSO(self, "sheepy"); 19842 r = icFindCharO(self, 'E'); 19843 ck_assert_ptr_ne(r, null); 19844 ck_assert_str_eq(sjGet(r), "eepy"); 19845 terminateO(r); 19846 // find non existing string 19847 ck_assert_ptr_eq(icFindCharO(self, '$'), NULL); 19848 // find 0 19849 r = icFindCharO(self, 0); 19850 ck_assert_ptr_ne(r, null); 19851 ck_assert_str_eq(sjGet(r), ""); 19852 terminateO(r); 19853 // empty string 19854 freeO(self); 19855 setTopSO(self, ""); 19856 ck_assert_ptr_eq(icFindCharO(self, '$'), NULL); 19857 ck_assert_ptr_eq(icFindCharO(self, 0), NULL); 19858 // NULL string 19859 freeO(self); 19860 ck_assert_ptr_eq(icFindCharO(self, '$'), NULL); 19861 ck_assert_ptr_eq(icFindCharO(self, 0), NULL); 19862 terminateO(self); 19863 19864 } 19865 19866 19867 void icFindSmallStringSmallJsonT(void) { 19868 19869 smallJsont* r; 19870 smallJsont *self = allocSmallJson(); 19871 setTopSO(self, ""); 19872 smallStringt *needle = allocSmallString("EE"); 19873 19874 // find string in the middle 19875 freeO(self); 19876 setTopSO(self, "sheepy"); 19877 r = self->f->icFindSmallString(self, needle); 19878 ck_assert_ptr_ne(r, null); 19879 ck_assert_str_eq(sjGet(r), "eepy"); 19880 terminateO(r); 19881 // find non existing string 19882 setValO(needle, "$"); 19883 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 19884 // non smallString object 19885 terminateO(needle); 19886 needle = (smallStringt*) allocSmallInt(1); 19887 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 19888 terminateO(needle); 19889 // find NULL 19890 ck_assert_ptr_eq(self->f->icFindSmallString(self, NULL), NULL); 19891 // empty string 19892 freeO(self); 19893 setTopSO(self, ""); 19894 needle = allocSmallString("$"); 19895 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 19896 // NULL string 19897 freeO(self); 19898 ck_assert_ptr_eq(self->f->icFindSmallString(self, needle), NULL); 19899 terminateO(needle); 19900 terminateO(self); 19901 19902 } 19903 19904 19905 void icFindJsonSmallJsonT(void) { 19906 19907 smallJsont* r; 19908 smallJsont *self = allocSmallJson(); 19909 setTopSO(self, ""); 19910 smallJsont *needle = allocSmallJson(); 19911 19912 // find string in the middle 19913 freeO(self); 19914 setTopSO(self, "sheepy"); 19915 setTopSO(needle, "EE"); 19916 r = self->f->icFindJson(self, needle); 19917 ck_assert_ptr_ne(r, null); 19918 ck_assert_str_eq(sjGet(r), "eepy"); 19919 terminateO(r); 19920 // find non existing string 19921 freeO(needle); 19922 setTopSO(needle, "$"); 19923 ck_assert_ptr_eq(self->f->icFindJson(self, needle), NULL); 19924 // non json string 19925 freeO(needle); 19926 ck_assert_ptr_eq(self->f->icFindJson(self, needle), NULL); 19927 // non json object 19928 terminateO(needle); 19929 needle = (smallJsont*) allocSmallInt(1); 19930 ck_assert_ptr_eq(self->f->icFindJson(self, needle), NULL); 19931 terminateO(needle); 19932 // find NULL 19933 ck_assert_ptr_eq(self->f->icFindJson(self, NULL), NULL); 19934 // empty string 19935 freeO(self); 19936 setTopSO(self, ""); 19937 needle = allocSmallJson(); 19938 setTopSO(needle, "$"); 19939 ck_assert_ptr_eq(self->f->icFindJson(self, needle), NULL); 19940 // NULL string 19941 freeO(self); 19942 ck_assert_ptr_eq(self->f->icFindJson(self, needle), NULL); 19943 terminateO(needle); 19944 terminateO(self); 19945 19946 } 19947 19948 19949 void icIndexOfSmallJsonT(void) { 19950 19951 ssize_t r; 19952 smallJsont *self = allocSmallJson(); 19953 baset *value = (baset*)allocSmallString("A"); 19954 19955 // index 19956 self->f->pushS(self, "2"); 19957 self->f->pushS(self, "3"); 19958 delElemIndexO(self, 1); 19959 self->f->pushS(self, "a"); 19960 r = icIndexOfO(self, value); 19961 ck_assert_int_eq(r, 2); 19962 // not index 19963 smallStringt *v = (smallStringt*) value; 19964 setValO(v, "3"); 19965 r = icIndexOfO(self, value); 19966 ck_assert_int_eq(r, -1); 19967 // NULL value 19968 r = icIndexOfO(self, NULL); 19969 ck_assert_int_eq(r, -1); 19970 terminateO(self); 19971 terminateO(value); 19972 19973 } 19974 19975 19976 void icIndexOfSSmallJsonT(void) { 19977 19978 ssize_t r; 19979 smallJsont *self = allocSmallJson(); 19980 const char *value = "ASD"; 19981 19982 // indexOf 19983 self->f->pushUndefined(self); 19984 self->f->pushUndefined(self); 19985 delElemIndexO(self, 1); 19986 self->f->pushS(self, "asd"); 19987 r = icIndexOfSO(self, value); 19988 ck_assert_int_eq(r, 2); 19989 // not indexOf 19990 delElemIndexO(self, 2); 19991 r = icIndexOfSO(self, value); 19992 ck_assert_int_eq(r, -1); 19993 // NULL value 19994 r = icIndexOfSO(self, NULL); 19995 ck_assert_int_eq(r, -1); 19996 terminateO(self); 19997 // json string 19998 self = allocSmallJson(); 19999 // indexOf string in the middle 20000 setTopSO(self, "sheepy"); 20001 ck_assert_int_eq(icIndexOfSO(self, "EE"), 2); 20002 // indexOf non existing string 20003 ck_assert_int_eq(icIndexOfSO(self, "$"), -1); 20004 terminateO(self); 20005 20006 } 20007 20008 20009 void icIndexOfCharSmallJsonT(void) { 20010 20011 ssize_t r; 20012 smallJsont *self = allocSmallJson(); 20013 char value = 'A'; 20014 20015 // indexOf 20016 self->f->pushUndefined(self); 20017 self->f->pushUndefined(self); 20018 delElemIndexO(self, 1); 20019 self->f->pushS(self, "a"); 20020 r = icIndexOfCharO(self, value); 20021 ck_assert_int_eq(r, 2); 20022 // not indexOf 20023 delElemIndexO(self, 2); 20024 r = icIndexOfCharO(self, value); 20025 ck_assert_int_eq(r, -1); 20026 terminateO(self); 20027 20028 } 20029 20030 20031 void icIndexOfDictSmallJsonT(void) { 20032 20033 ssize_t r; 20034 smallJsont *self = allocSmallJson(); 20035 smallDictt *value = allocSmallDict(); 20036 value->f->setInt(value, "B", 1); 20037 20038 // indexOf 20039 createAllocateSmallDict(elem); 20040 elem->f->setInt(elem, "a", 1); 20041 self->f->pushDict(self, elem); 20042 resetO(elem); 20043 self->f->pushUndefined(self); 20044 delElemIndexO(self, 1); 20045 elem->f->setInt(elem, "b", 1); 20046 self->f->pushNFreeDict(self, elem); 20047 r = icIndexOfDictO(self, value); 20048 ck_assert_int_eq(r, 2); 20049 // not indexOf 20050 delElemIndexO(self, 2); 20051 r = icIndexOfDictO(self, value); 20052 ck_assert_int_eq(r, -1); 20053 // non smallDict object 20054 terminateO(value); 20055 value = (smallDictt*) allocSmallInt(2); 20056 r = icIndexOfDictO(self, value); 20057 ck_assert_int_eq(r, -1); 20058 // NULL value 20059 r = icIndexOfDictO(self, NULL); 20060 ck_assert_int_eq(r, -1); 20061 terminateO(self); 20062 terminateO(value); 20063 20064 } 20065 20066 20067 void icIndexOfArraySmallJsonT(void) { 20068 20069 ssize_t r; 20070 smallJsont *self = allocSmallJson(); 20071 smallArrayt *value = allocSmallArray(); 20072 value->f->pushS(value, "A"); 20073 20074 // indexOf 20075 createAllocateSmallArray(elem); 20076 elem->f->pushInt(elem, 1); 20077 self->f->pushArray(self, elem); 20078 resetO(elem); 20079 self->f->pushUndefined(self); 20080 delElemIndexO(self, 1); 20081 elem->f->pushS(elem, "a"); 20082 self->f->pushNFreeArray(self, elem); 20083 r = icIndexOfArrayO(self, value); 20084 ck_assert_int_eq(r, 2); 20085 // value not found 20086 terminateO(value); 20087 value = allocSmallArray(); 20088 r = icIndexOfArrayO(self, value); 20089 ck_assert_int_eq(r, -1); 20090 // non smallArray object 20091 terminateO(value); 20092 value = (smallArrayt*) allocSmallInt(2); 20093 r = icIndexOfArrayO(self, value); 20094 ck_assert_int_eq(r, -1); 20095 // not indexOf 20096 emptyO(self); 20097 r = icIndexOfArrayO(self, value); 20098 ck_assert_int_eq(r, -1); 20099 // NULL value 20100 r = icIndexOfArrayO(self, NULL); 20101 ck_assert_int_eq(r, -1); 20102 terminateO(self); 20103 terminateO(value); 20104 20105 } 20106 20107 20108 void icIndexOfArraycSmallJsonT(void) { 20109 20110 ssize_t r; 20111 smallJsont *self = allocSmallJson(); 20112 char **value = listCreateS("A","BB"); 20113 20114 // indexOf 20115 char **elem = listCreateS("!!","@@@"); 20116 self->f->pushNFreeArrayc(self, elem); 20117 self->f->pushUndefined(self); 20118 delElemIndexO(self, 1); 20119 self->f->pushNFreeArrayc(self, listCreateS("a","bb")); 20120 r = icIndexOfArraycO(self, value); 20121 ck_assert_int_eq(r, 2); 20122 // not indexOf 20123 delElemIndexO(self, 2); 20124 r = icIndexOfArraycO(self, value); 20125 ck_assert_int_eq(r, -1); 20126 // NULL value 20127 r = icIndexOfArraycO(self, NULL); 20128 ck_assert_int_eq(r, -1); 20129 terminateO(self); 20130 listFreeS(value); 20131 20132 } 20133 20134 20135 void icIndexOfSmallStringSmallJsonT(void) { 20136 20137 ssize_t r; 20138 smallJsont *self = allocSmallJson(); 20139 smallStringt *value = allocSmallString("QWE"); 20140 20141 // indexOf 20142 self->f->pushUndefined(self); 20143 self->f->pushUndefined(self); 20144 delElemIndexO(self, 1); 20145 self->f->pushS(self, "qwe"); 20146 r = self->f->icIndexOfSmallString(self, value); 20147 ck_assert_int_eq(r, 2); 20148 // not indexOf 20149 delElemIndexO(self, 2); 20150 r = self->f->icIndexOfSmallString(self, value); 20151 ck_assert_int_eq(r, -1); 20152 // empty string 20153 freeO(value); 20154 r = self->f->icIndexOfSmallString(self, value); 20155 ck_assert_int_eq(r, -1); 20156 // non smallString object 20157 terminateO(value); 20158 value = (smallStringt*) allocSmallInt(2); 20159 r = self->f->icIndexOfSmallString(self, value); 20160 ck_assert_int_eq(r, -1); 20161 // NULL value 20162 r = self->f->icIndexOfSmallString(self, NULL); 20163 ck_assert_int_eq(r, -1); 20164 terminateO(self); 20165 terminateO(value); 20166 // json string 20167 self = allocSmallJson(); 20168 smallStringt *needle = allocSmallString("EE"); 20169 // indexOf string in the middle 20170 setTopSO(self, "sheepy"); 20171 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), 2); 20172 // indexOf non existing string 20173 setValO(needle, "$"); 20174 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), -1); 20175 // non smallString object 20176 terminateO(needle); 20177 needle = (smallStringt*) allocSmallInt(1); 20178 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), -1); 20179 terminateO(needle); 20180 // empty string 20181 freeO(self); 20182 setTopSO(self, ""); 20183 needle = allocSmallString("$"); 20184 ck_assert_int_eq(self->f->icIndexOfSmallString(self, needle), -1); 20185 terminateO(needle); 20186 terminateO(self); 20187 20188 } 20189 20190 20191 void icBinarySearchSmallJsonT(void) { 20192 20193 ssize_t r; 20194 smallJsont *self = allocSmallJson(); 20195 baset *value = (baset*)allocSmallString("E"); 20196 20197 // index not trimmed (an element is NULL) 20198 self->f->pushS(self, "a"); 20199 self->f->pushS(self, "b"); 20200 self->f->pushS(self, "c"); 20201 delElemIndexO(self, 2); 20202 self->f->pushS(self, "d"); 20203 self->f->pushS(self, "e"); 20204 self->f->pushS(self, "f"); 20205 r = icBinarySearchO(self, value); 20206 ck_assert_int_eq(r, -1); 20207 // index 20208 trimO(self); 20209 r = icBinarySearchO(self, value); 20210 ck_assert_int_eq(r, 3); 20211 smallStringt *v = (smallStringt*) value; 20212 // index in the lower half of the array 20213 setValO(v, "B"); 20214 r = icBinarySearchO(self, value); 20215 ck_assert_int_eq(r, 1); 20216 // not index 20217 setValO(v, "asd"); 20218 r = icBinarySearchO(self, value); 20219 ck_assert_int_eq(r, -1); 20220 // NULL value 20221 r = icBinarySearchO(self, NULL); 20222 ck_assert_int_eq(r, -1); 20223 // empty array 20224 emptyO(self); 20225 r = icBinarySearchO(self, value); 20226 ck_assert_int_eq(r, -1); 20227 terminateO(self); 20228 terminateO(value); 20229 20230 } 20231 20232 20233 void icBinarySearchSSmallJsonT(void) { 20234 20235 ssize_t r; 20236 smallJsont *self = allocSmallJson(); 20237 const char *value = "E"; 20238 20239 // index not trimmed (an element is NULL) 20240 self->f->pushS(self, "a"); 20241 self->f->pushS(self, "b"); 20242 self->f->pushS(self, "c"); 20243 delElemIndexO(self, 2); 20244 self->f->pushS(self, "d"); 20245 self->f->pushS(self, "e"); 20246 self->f->pushS(self, "f"); 20247 r = icBinarySearchSO(self, value); 20248 ck_assert_int_eq(r, -1); 20249 // index 20250 trimO(self); 20251 r = icBinarySearchSO(self, value); 20252 ck_assert_int_eq(r, 3); 20253 // index in the lower half of the array 20254 value = "B"; 20255 r = icBinarySearchSO(self, value); 20256 ck_assert_int_eq(r, 1); 20257 // not index 20258 value = "asd"; 20259 r = icBinarySearchSO(self, value); 20260 ck_assert_int_eq(r, -1); 20261 // NULL value 20262 r = icBinarySearchSO(self, NULL); 20263 ck_assert_int_eq(r, -1); 20264 // empty array 20265 emptyO(self); 20266 r = icBinarySearchSO(self, value); 20267 ck_assert_int_eq(r, -1); 20268 terminateO(self); 20269 20270 } 20271 20272 20273 void icBinarySearchCharSmallJsonT(void) { 20274 20275 ssize_t r; 20276 smallJsont *self = allocSmallJson(); 20277 char value = 'E'; 20278 20279 // index not trimmed (an element is NULL) 20280 self->f->pushS(self, "a"); 20281 self->f->pushS(self, "b"); 20282 self->f->pushS(self, "c"); 20283 delElemIndexO(self, 2); 20284 self->f->pushS(self, "d"); 20285 self->f->pushS(self, "e"); 20286 self->f->pushS(self, "f"); 20287 r = icBinarySearchCharO(self, value); 20288 ck_assert_int_eq(r, -1); 20289 // index 20290 trimO(self); 20291 r = icBinarySearchCharO(self, value); 20292 ck_assert_int_eq(r, 3); 20293 // index in the lower half of the array 20294 value = 'B'; 20295 r = icBinarySearchCharO(self, value); 20296 ck_assert_int_eq(r, 1); 20297 // not index 20298 value = '1'; 20299 r = icBinarySearchCharO(self, value); 20300 ck_assert_int_eq(r, -1); 20301 // empty array 20302 emptyO(self); 20303 r = icBinarySearchCharO(self, value); 20304 ck_assert_int_eq(r, -1); 20305 terminateO(self); 20306 20307 } 20308 20309 20310 void icBinarySearchDictSmallJsonT(void) { 20311 20312 ssize_t r; 20313 smallJsont *self = allocSmallJson(); 20314 smallDictt *value = allocSmallDict(); 20315 value->f->setInt(value, "B", 2); 20316 20317 // index not trimmed (an element is NULL) 20318 createAllocateSmallDict(elem); 20319 elem->f->setInt(elem, "a", 1); 20320 self->f->pushUndefined(self); 20321 self->f->pushDict(self, elem); 20322 resetO(elem); 20323 self->f->pushUndefined(self); 20324 delElemIndexO(self, 2); 20325 elem->f->setInt(elem, "b", 2); 20326 self->f->pushNFreeDict(self, elem); 20327 self->f->pushS(self, "4"); 20328 self->f->pushS(self, "5"); 20329 r = icBinarySearchDictO(self, value); 20330 ck_assert_int_eq(r, -1); 20331 // index 20332 trimO(self); 20333 r = icBinarySearchDictO(self, value); 20334 ck_assert_int_eq(r, 2); 20335 // index in the lower half of the array 20336 freeO(value); 20337 value->f->setInt(value, "A", 1); 20338 r = icBinarySearchDictO(self, value); 20339 ck_assert_int_eq(r, 1); 20340 // not index 20341 freeO(value); 20342 r = icBinarySearchDictO(self, value); 20343 ck_assert_int_eq(r, -1); 20344 // non smallDict object 20345 terminateO(value); 20346 value = (smallDictt*) allocSmallInt(2); 20347 r = icBinarySearchDictO(self, value); 20348 ck_assert_int_eq(r, -1); 20349 // NULL value 20350 r = icBinarySearchDictO(self, NULL); 20351 ck_assert_int_eq(r, -1); 20352 // empty array 20353 emptyO(self); 20354 r = icBinarySearchDictO(self, value); 20355 ck_assert_int_eq(r, -1); 20356 terminateO(self); 20357 terminateO(value); 20358 20359 } 20360 20361 20362 void icBinarySearchArraySmallJsonT(void) { 20363 20364 ssize_t r; 20365 smallJsont *self = allocSmallJson(); 20366 smallArrayt *value = allocSmallArray(); 20367 value->f->pushS(value, "B"); 20368 20369 // index not trimmed (an element is NULL) 20370 createAllocateSmallArray(elem); 20371 elem->f->pushS(elem, "a"); 20372 self->f->pushUndefined(self); 20373 self->f->pushArray(self, elem); 20374 resetO(elem); 20375 self->f->pushUndefined(self); 20376 delElemIndexO(self, 2); 20377 elem->f->pushS(elem, "b"); 20378 self->f->pushNFreeArray(self, elem); 20379 self->f->pushS(self, "4"); 20380 self->f->pushS(self, "5"); 20381 r = icBinarySearchArrayO(self, value); 20382 ck_assert_int_eq(r, -1); 20383 // index 20384 trimO(self); 20385 r = icBinarySearchArrayO(self, value); 20386 ck_assert_int_eq(r, 2); 20387 // index in the lower half of the array 20388 freeO(value); 20389 value->f->pushS(value, "A"); 20390 r = icBinarySearchArrayO(self, value); 20391 ck_assert_int_eq(r, 1); 20392 // not index 20393 freeO(value); 20394 r = icBinarySearchArrayO(self, value); 20395 ck_assert_int_eq(r, -1); 20396 // non smallArray object 20397 terminateO(value); 20398 value = (smallArrayt*) allocSmallInt(2); 20399 r = icBinarySearchArrayO(self, value); 20400 ck_assert_int_eq(r, -1); 20401 // NULL value 20402 r = icBinarySearchArrayO(self, NULL); 20403 ck_assert_int_eq(r, -1); 20404 // empty array 20405 emptyO(self); 20406 r = icBinarySearchArrayO(self, value); 20407 ck_assert_int_eq(r, -1); 20408 terminateO(self); 20409 terminateO(value); 20410 20411 } 20412 20413 20414 void icBinarySearchArraycSmallJsonT(void) { 20415 20416 ssize_t r; 20417 smallJsont *self = allocSmallJson(); 20418 char **value = listCreateS("B"); 20419 20420 // index not trimmed (an element is NULL) 20421 char **elem = listCreateS("a"); 20422 self->f->pushUndefined(self); 20423 self->f->pushNFreeArrayc(self, elem); 20424 self->f->pushUndefined(self); 20425 delElemIndexO(self, 2); 20426 elem = listCreateS("b"); 20427 self->f->pushNFreeArrayc(self, elem); 20428 self->f->pushS(self, "4"); 20429 self->f->pushS(self, "5"); 20430 r = icBinarySearchArraycO(self, value); 20431 ck_assert_int_eq(r, -1); 20432 // index 20433 trimO(self); 20434 r = icBinarySearchArraycO(self, value); 20435 ck_assert_int_eq(r, 2); 20436 // index in the lower half of the array 20437 free(value[0]); 20438 value[0] = strdup("A"); 20439 r = icBinarySearchArraycO(self, value); 20440 ck_assert_int_eq(r, 1); 20441 // not index 20442 free(value[0]); 20443 value[0] = strdup("asd"); 20444 r = icBinarySearchArraycO(self, value); 20445 ck_assert_int_eq(r, -1); 20446 // NULL value 20447 r = icBinarySearchArraycO(self, NULL); 20448 ck_assert_int_eq(r, -1); 20449 // empty array 20450 emptyO(self); 20451 r = icBinarySearchArraycO(self, value); 20452 ck_assert_int_eq(r, -1); 20453 terminateO(self); 20454 listFreeS(value); 20455 20456 } 20457 20458 20459 void icBinarySearchSmallStringSmallJsonT(void) { 20460 20461 ssize_t r; 20462 smallJsont *self = allocSmallJson(); 20463 smallStringt *value = allocSmallString("E"); 20464 20465 // index not trimmed (an element is NULL) 20466 self->f->pushS(self, "a"); 20467 self->f->pushS(self, "b"); 20468 self->f->pushS(self, "c"); 20469 delElemIndexO(self, 2); 20470 self->f->pushS(self, "d"); 20471 self->f->pushS(self, "e"); 20472 self->f->pushS(self, "f"); 20473 r = icBinarySearchSmallStringO(self, value); 20474 ck_assert_int_eq(r, -1); 20475 // index 20476 trimO(self); 20477 r = icBinarySearchSmallStringO(self, value); 20478 ck_assert_int_eq(r, 3); 20479 // index in the lower half of the array 20480 setValO(value, "B"); 20481 r = icBinarySearchSmallStringO(self, value); 20482 ck_assert_int_eq(r, 1); 20483 // not index 20484 setValO(value, "asd"); 20485 r = icBinarySearchSmallStringO(self, value); 20486 ck_assert_int_eq(r, -1); 20487 // empty value 20488 freeO(value); 20489 r = icBinarySearchSmallStringO(self, value); 20490 ck_assert_int_eq(r, -1); 20491 // non smallString object 20492 terminateO(value); 20493 value = (smallStringt*) allocSmallInt(2); 20494 r = icBinarySearchSmallStringO(self, value); 20495 ck_assert_int_eq(r, -1); 20496 // NULL value 20497 r = icBinarySearchSmallStringO(self, NULL); 20498 ck_assert_int_eq(r, -1); 20499 // empty array 20500 emptyO(self); 20501 r = icBinarySearchSmallStringO(self, value); 20502 ck_assert_int_eq(r, -1); 20503 terminateO(self); 20504 terminateO(value); 20505 20506 } 20507 20508 20509 void keyBySmallJsonT(void) { 20510 20511 char* r; 20512 smallJsont *self = allocSmallJson(); 20513 baset *value; 20514 20515 smallJsont *r2 = self->f->setInt(self, "1", 1); 20516 ck_assert_ptr_ne(r2, null); 20517 value = (baset*) allocSmallInt(1); 20518 r = keyByO(self, value); 20519 ck_assert_str_eq(r, "1"); 20520 // non existing object 20521 smallIntt *i = allocSmallInt(2); 20522 r = keyByO(self, (baset*)i); 20523 terminateO(i); 20524 ck_assert_ptr_eq(r, null); 20525 // null value 20526 r = keyByO(self, null); 20527 ck_assert_ptr_eq(r, null); 20528 // empty self 20529 freeO(self); 20530 r = keyByO(self, value); 20531 ck_assert_ptr_eq(r, null); 20532 terminateO(self); 20533 terminateO(value); 20534 20535 } 20536 20537 20538 void keyByUndefinedSmallJsonT(void) { 20539 20540 char* r; 20541 smallJsont *self = allocSmallJson(); 20542 undefinedt *value; 20543 20544 smallJsont *r2 = self->f->setUndefined(self, "1"); 20545 ck_assert_ptr_ne(r2, null); 20546 value = allocUndefined(); 20547 r = keyByUndefinedO(self, value); 20548 ck_assert_str_eq(r, "1"); 20549 // non existing object 20550 r2 = self->f->setInt(self, "1", 1); 20551 ck_assert_ptr_ne(r2, null); 20552 r = keyByUndefinedO(self, value); 20553 ck_assert_ptr_eq(r, null); 20554 // non undefined object 20555 smallIntt *i = allocSmallInt(2); 20556 r = keyByUndefinedO(self, (undefinedt*)i); 20557 terminateO(i); 20558 ck_assert_ptr_eq(r, null); 20559 // null value 20560 r = keyByUndefinedO(self, null); 20561 ck_assert_ptr_eq(r, null); 20562 // empty self 20563 freeO(self); 20564 r = keyByUndefinedO(self, value); 20565 ck_assert_ptr_eq(r, null); 20566 terminateO(self); 20567 terminateO(value); 20568 20569 } 20570 20571 20572 void keyByBoolSmallJsonT(void) { 20573 20574 char* r; 20575 smallJsont *self = allocSmallJson(); 20576 20577 smallJsont *r2 = self->f->setBool(self, "1", true); 20578 ck_assert_ptr_ne(r2, null); 20579 r = keyByBoolO(self, true); 20580 ck_assert_str_eq(r, "1"); 20581 // non existing object 20582 r2 = self->f->setInt(self, "1", 1); 20583 ck_assert_ptr_ne(r2, null); 20584 r = keyByBoolO(self, true); 20585 ck_assert_ptr_eq(r, null); 20586 // empty self 20587 freeO(self); 20588 r = keyByBoolO(self, true); 20589 ck_assert_ptr_eq(r, null); 20590 setTypeDictO(self); 20591 r = keyByBoolO(self, true); 20592 ck_assert_ptr_eq(r, null); 20593 terminateO(self); 20594 20595 } 20596 20597 20598 void keyByDoubleSmallJsonT(void) { 20599 20600 char* r; 20601 smallJsont *self = allocSmallJson(); 20602 20603 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 20604 ck_assert_ptr_ne(r2, null); 20605 r = keyByDoubleO(self, 2.2); 20606 ck_assert_str_eq(r, "1"); 20607 // non existing object 20608 r2 = self->f->setInt(self, "1", 1); 20609 ck_assert_ptr_ne(r2, null); 20610 r = keyByDoubleO(self, 2.2); 20611 ck_assert_ptr_eq(r, null); 20612 // empty self 20613 freeO(self); 20614 r = keyByDoubleO(self, 2.2); 20615 ck_assert_ptr_eq(r, null); 20616 setTypeDictO(self); 20617 r = keyByDoubleO(self, 2.2); 20618 ck_assert_ptr_eq(r, null); 20619 terminateO(self); 20620 20621 } 20622 20623 20624 void keyByIntSmallJsonT(void) { 20625 20626 char* r; 20627 smallJsont *self = allocSmallJson(); 20628 20629 smallJsont *r2 = self->f->setInt(self, "1", 2); 20630 ck_assert_ptr_ne(r2, null); 20631 r = keyByIntO(self, 2); 20632 ck_assert_str_eq(r, "1"); 20633 // non existing object 20634 r2 = self->f->setInt(self, "1", 1); 20635 ck_assert_ptr_ne(r2, null); 20636 r = keyByIntO(self, 2); 20637 ck_assert_ptr_eq(r, null); 20638 // empty self 20639 freeO(self); 20640 r = keyByIntO(self, 2); 20641 ck_assert_ptr_eq(r, null); 20642 setTypeDictO(self); 20643 r = keyByIntO(self, 0); 20644 ck_assert_ptr_eq(r, null); 20645 terminateO(self); 20646 20647 } 20648 20649 20650 void keyBySSmallJsonT(void) { 20651 20652 char* r; 20653 smallJsont *self = allocSmallJson(); 20654 20655 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 20656 ck_assert_ptr_ne(r2, null); 20657 r = keyBySO(self, "qwe"); 20658 ck_assert_str_eq(r, "1"); 20659 // non existing object 20660 r2 = self->f->setInt(self, "1", 1); 20661 ck_assert_ptr_ne(r2, null); 20662 r = keyBySO(self, "qwe"); 20663 ck_assert_ptr_eq(r, null); 20664 // null value 20665 r = keyBySO(self, null); 20666 ck_assert_ptr_eq(r, null); 20667 // empty self 20668 freeO(self); 20669 r = keyBySO(self, "qwe"); 20670 ck_assert_ptr_eq(r, null); 20671 setTypeDictO(self); 20672 r = keyBySO(self, ""); 20673 ck_assert_ptr_eq(r, null); 20674 terminateO(self); 20675 20676 } 20677 20678 20679 void keyByCharSmallJsonT(void) { 20680 20681 char* r; 20682 smallJsont *self = allocSmallJson(); 20683 20684 smallJsont *r2 = self->f->setS(self, "1", "q"); 20685 ck_assert_ptr_ne(r2, null); 20686 r = keyByCharO(self, 'q'); 20687 ck_assert_str_eq(r, "1"); 20688 // non existing object 20689 r2 = self->f->setInt(self, "1", 1); 20690 ck_assert_ptr_ne(r2, null); 20691 r = keyByCharO(self, 'q'); 20692 ck_assert_ptr_eq(r, null); 20693 // empty self 20694 freeO(self); 20695 r = keyByCharO(self, 'q'); 20696 ck_assert_ptr_eq(r, null); 20697 setTypeDictO(self); 20698 r = keyByCharO(self, 'a'); 20699 ck_assert_ptr_eq(r, null); 20700 terminateO(self); 20701 20702 } 20703 20704 20705 void keyByDictSmallJsonT(void) { 20706 20707 char* r; 20708 smallJsont *self = allocSmallJson(); 20709 smallDictt *dict = allocSmallDict(); 20710 20711 createAllocateSmallDict(d); 20712 d->f->setS(d, "another", "dict"); 20713 smallJsont *r2 = self->f->setNFreeDict(self, "d", d); 20714 ck_assert_ptr_ne(r2, null); 20715 r2 = self->f->setNFreeDict(self, "1", dict); 20716 ck_assert_ptr_ne(r2, null); 20717 dict = allocSmallDict(); 20718 r = keyByDictO(self, dict); 20719 ck_assert_str_eq(r, "1"); 20720 // non existing object 20721 r2 = self->f->setInt(self, "1", 1); 20722 ck_assert_ptr_ne(r2, null); 20723 r = keyByDictO(self, dict); 20724 ck_assert_ptr_eq(r, null); 20725 // non smallDict object 20726 smallIntt *i = allocSmallInt(2); 20727 r = keyByDictO(self, (smallDictt*)i); 20728 terminateO(i); 20729 ck_assert_ptr_eq(r, null); 20730 // null value 20731 r = keyByDictO(self, null); 20732 ck_assert_ptr_eq(r, null); 20733 // empty self 20734 freeO(self); 20735 r = keyByDictO(self, dict); 20736 ck_assert_ptr_eq(r, null); 20737 setTypeDictO(self); 20738 r = keyByDictO(self, dict); 20739 ck_assert_ptr_eq(r, null); 20740 terminateO(self); 20741 terminateO(dict); 20742 20743 } 20744 20745 20746 void keyByArraySmallJsonT(void) { 20747 20748 char* r; 20749 smallJsont *self = allocSmallJson(); 20750 smallArrayt *array = allocSmallArray(); 20751 20752 createAllocateSmallArray(d); 20753 d->f->pushS(d, "another array"); 20754 smallJsont *r2 = self->f->setNFreeArray(self, "d", d); 20755 ck_assert_ptr_ne(r2, null); 20756 r2 = self->f->setNFreeArray(self, "1", array); 20757 ck_assert_ptr_ne(r2, null); 20758 array = allocSmallArray(); 20759 r = keyByArrayO(self, array); 20760 ck_assert_str_eq(r, "1"); 20761 // non existing object 20762 r2 = self->f->setInt(self, "1", 1); 20763 ck_assert_ptr_ne(r2, null); 20764 r = keyByArrayO(self, array); 20765 ck_assert_ptr_eq(r, null); 20766 // non smallArray object 20767 smallIntt *i = allocSmallInt(2); 20768 r = keyByArrayO(self, (smallArrayt*)i); 20769 terminateO(i); 20770 ck_assert_ptr_eq(r, null); 20771 // null value 20772 r = keyByArrayO(self, null); 20773 ck_assert_ptr_eq(r, null); 20774 // empty self 20775 freeO(self); 20776 r = keyByArrayO(self, array); 20777 ck_assert_ptr_eq(r, null); 20778 setTypeDictO(self); 20779 r = keyByArrayO(self, array); 20780 ck_assert_ptr_eq(r, null); 20781 terminateO(self); 20782 terminateO(array); 20783 20784 } 20785 20786 20787 void keyByArraycSmallJsonT(void) { 20788 20789 char* r; 20790 smallJsont *self = allocSmallJson(); 20791 char **array = listCreateS("a","b"); 20792 20793 char **d = listCreateS("asd", "zxcv"); 20794 smallJsont *r2 = self->f->setNFreeArrayc(self, "d", d); 20795 ck_assert_ptr_ne(r2, null); 20796 r2 = self->f->setArrayc(self, "1", array); 20797 ck_assert_ptr_ne(r2, null); 20798 r = keyByArraycO(self, array); 20799 ck_assert_ptr_ne(r, NULL); 20800 ck_assert_str_eq(r, "1"); 20801 // non existing object 20802 r2 = self->f->setInt(self, "1", 1); 20803 ck_assert_ptr_ne(r2, null); 20804 r = keyByArraycO(self, array); 20805 ck_assert_ptr_eq(r, null); 20806 // null value 20807 r = keyByArraycO(self, null); 20808 ck_assert_ptr_eq(r, null); 20809 // empty self 20810 freeO(self); 20811 r = keyByArraycO(self, array); 20812 ck_assert_ptr_eq(r, null); 20813 setTypeDictO(self); 20814 r = keyByArraycO(self, array); 20815 ck_assert_ptr_eq(r, null); 20816 terminateO(self); 20817 listFreeS(array); 20818 20819 } 20820 20821 20822 void keyBySmallBoolSmallJsonT(void) { 20823 20824 char* r; 20825 smallJsont *self = allocSmallJson(); 20826 smallBoolt *value = allocSmallBool(true); 20827 20828 createAllocateSmallBool(d); 20829 setValO(d, false); 20830 smallJsont *r2 = self->f->setNFreeSmallBool(self, "d", d); 20831 ck_assert_ptr_ne(r2, null); 20832 r2 = self->f->setNFreeSmallBool(self, "1", value); 20833 ck_assert_ptr_ne(r2, null); 20834 value = allocSmallBool(true); 20835 r = keyBySmallBoolO(self, value); 20836 ck_assert_str_eq(r, "1"); 20837 // non existing object 20838 r2 = self->f->setInt(self, "1", 1); 20839 ck_assert_ptr_ne(r2, null); 20840 r = keyBySmallBoolO(self, value); 20841 ck_assert_ptr_eq(r, null); 20842 // non smallBool object 20843 smallIntt *i = allocSmallInt(2); 20844 r = keyBySmallBoolO(self, (smallBoolt*)i); 20845 terminateO(i); 20846 ck_assert_ptr_eq(r, null); 20847 // null value 20848 r = keyBySmallBoolO(self, null); 20849 ck_assert_ptr_eq(r, null); 20850 // empty self 20851 freeO(self); 20852 r = keyBySmallBoolO(self, value); 20853 ck_assert_ptr_eq(r, null); 20854 setTypeDictO(self); 20855 r = keyBySmallBoolO(self, value); 20856 ck_assert_ptr_eq(r, null); 20857 terminateO(self); 20858 terminateO(value); 20859 20860 } 20861 20862 20863 void keyBySmallBytesSmallJsonT(void) { 20864 20865 char* r; 20866 smallJsont *self = allocSmallJson(); 20867 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 20868 20869 smallBytest *d = allocSmallBytes("asd", sizeof("asd")); 20870 smallJsont *r2 = self->f->setNFreeSmallBytes(self, "d", d); 20871 ck_assert_ptr_ne(r2, null); 20872 r2 = self->f->setNFreeSmallBytes(self, "1", value); 20873 ck_assert_ptr_ne(r2, null); 20874 value = allocSmallBytes("qwe", sizeof("qwe")); 20875 r = keyBySmallBytesO(self, value); 20876 ck_assert_str_eq(r, "1"); 20877 // non existing object 20878 r2 = self->f->setInt(self, "1", 1); 20879 ck_assert_ptr_ne(r2, null); 20880 r = keyBySmallBytesO(self, value); 20881 ck_assert_ptr_eq(r, null); 20882 // empty value 20883 freeO(value); 20884 r = keyBySmallBytesO(self, value); 20885 ck_assert_ptr_eq(r, null); 20886 // non smallBytes object 20887 smallIntt *i = allocSmallInt(2); 20888 r = keyBySmallBytesO(self, (smallBytest*)i); 20889 terminateO(i); 20890 ck_assert_ptr_eq(r, null); 20891 // null value 20892 r = keyBySmallBytesO(self, null); 20893 ck_assert_ptr_eq(r, null); 20894 // empty self 20895 freeO(self); 20896 r = keyBySmallBytesO(self, value); 20897 ck_assert_ptr_eq(r, null); 20898 setTypeDictO(self); 20899 r = keyBySmallBytesO(self, value); 20900 ck_assert_ptr_eq(r, null); 20901 terminateO(self); 20902 terminateO(value); 20903 20904 } 20905 20906 20907 void keyBySmallDoubleSmallJsonT(void) { 20908 20909 char* r; 20910 smallJsont *self = allocSmallJson(); 20911 smallDoublet *value = allocSmallDouble(2.2); 20912 20913 createAllocateSmallDouble(d); 20914 smallJsont *r2 = self->f->setNFreeSmallDouble(self, "d", d); 20915 ck_assert_ptr_ne(r2, null); 20916 r2 = self->f->setNFreeSmallDouble(self, "1", value); 20917 ck_assert_ptr_ne(r2, null); 20918 value = allocSmallDouble(2.2); 20919 r = keyBySmallDoubleO(self, value); 20920 ck_assert_str_eq(r, "1"); 20921 // non existing object 20922 r2 = self->f->setInt(self, "1", 1); 20923 ck_assert_ptr_ne(r2, null); 20924 r = keyBySmallDoubleO(self, value); 20925 ck_assert_ptr_eq(r, null); 20926 // non smallDouble object 20927 smallIntt *i = allocSmallInt(2); 20928 r = keyBySmallDoubleO(self, (smallDoublet*)i); 20929 terminateO(i); 20930 ck_assert_ptr_eq(r, null); 20931 // null value 20932 r = keyBySmallDoubleO(self, null); 20933 ck_assert_ptr_eq(r, null); 20934 // empty self 20935 freeO(self); 20936 r = keyBySmallDoubleO(self, value); 20937 ck_assert_ptr_eq(r, null); 20938 setTypeDictO(self); 20939 r = keyBySmallDoubleO(self, value); 20940 ck_assert_ptr_eq(r, null); 20941 terminateO(self); 20942 terminateO(value); 20943 20944 } 20945 20946 20947 void keyBySmallIntSmallJsonT(void) { 20948 20949 char* r; 20950 smallJsont *self = allocSmallJson(); 20951 smallIntt *value = allocSmallInt(2); 20952 20953 createAllocateSmallInt(d); 20954 smallJsont *r2 = self->f->setNFreeSmallInt(self, "d", d); 20955 ck_assert_ptr_ne(r2, null); 20956 r2 = self->f->setNFreeSmallInt(self, "1", value); 20957 ck_assert_ptr_ne(r2, null); 20958 value = allocSmallInt(2); 20959 r = keyBySmallIntO(self, value); 20960 ck_assert_str_eq(r, "1"); 20961 // non existing object 20962 r2 = self->f->setInt(self, "1", 1); 20963 ck_assert_ptr_ne(r2, null); 20964 r = keyBySmallIntO(self, value); 20965 ck_assert_ptr_eq(r, null); 20966 // non smallInt object 20967 smallBoolt *i = allocSmallBool(false); 20968 r = keyBySmallIntO(self, (smallIntt*)i); 20969 terminateO(i); 20970 ck_assert_ptr_eq(r, null); 20971 // null value 20972 r = keyBySmallIntO(self, null); 20973 ck_assert_ptr_eq(r, null); 20974 // empty self 20975 freeO(self); 20976 r = keyBySmallIntO(self, value); 20977 ck_assert_ptr_eq(r, null); 20978 setTypeDictO(self); 20979 r = keyBySmallIntO(self, value); 20980 ck_assert_ptr_eq(r, null); 20981 terminateO(self); 20982 terminateO(value); 20983 20984 } 20985 20986 20987 void keyBySmallJsonSmallJsonT(void) { 20988 20989 char* r; 20990 smallJsont *self = allocSmallJson(); 20991 smallJsont *value = allocSmallJson(); 20992 20993 // undefined 20994 createUndefined(u); 20995 setTopO(value, (baset*)&u); 20996 self->f->setUndefined(self, "1"); 20997 r = self->f->keyBySmallJson(self, value); 20998 ck_assert_str_eq(r, "1"); 20999 freeO(value); 21000 // bool 21001 setTopBoolO(value, true); 21002 self->f->setBool(self, "b", true); 21003 r = self->f->keyBySmallJson(self, value); 21004 ck_assert_str_eq(r, "b"); 21005 freeO(value); 21006 // double 21007 setTopDoubleO(value, 2.2); 21008 self->f->setDouble(self, "db", 2.2); 21009 r = self->f->keyBySmallJson(self, value); 21010 ck_assert_str_eq(r, "db"); 21011 freeO(value); 21012 // int 21013 setTopIntO(value, 2); 21014 self->f->setInt(self, "i", 2); 21015 r = self->f->keyBySmallJson(self, value); 21016 ck_assert_str_eq(r, "i"); 21017 freeO(value); 21018 // string 21019 setTopSO(value, "qwe"); 21020 self->f->setS(self, "s", "qwe"); 21021 r = self->f->keyBySmallJson(self, value); 21022 ck_assert_str_eq(r, "s"); 21023 freeO(value); 21024 // dict 21025 smallDictt *D = allocSmallDict(); 21026 setTopNFreeDictO(value, D); 21027 self->f->setNFreeDict(self, "d", allocSmallDict()); 21028 r = self->f->keyBySmallJson(self, value); 21029 ck_assert_str_eq(r, "d"); 21030 freeO(value); 21031 // array 21032 smallArrayt *a = allocSmallArray(); 21033 setTopNFreeArrayO(value, a); 21034 self->f->setNFreeArray(self, "a", allocSmallArray()); 21035 r = self->f->keyBySmallJson(self, value); 21036 ck_assert_str_eq(r, "a"); 21037 freeO(value); 21038 // empty value 21039 r = self->f->keyBySmallJson(self, value); 21040 ck_assert_ptr_eq(r, null); 21041 // non smallJson object 21042 smallIntt *i = allocSmallInt(2); 21043 r = self->f->keyBySmallJson(self, (smallJsont*)i); 21044 terminateO(i); 21045 ck_assert_ptr_eq(r, null); 21046 // null value 21047 r = self->f->keyBySmallJson(self, null); 21048 ck_assert_ptr_eq(r, null); 21049 // empty self 21050 freeO(self); 21051 r = self->f->keyBySmallJson(self, value); 21052 ck_assert_ptr_eq(r, null); 21053 setTypeDictO(self); 21054 r = self->f->keyBySmallJson(self, value); 21055 ck_assert_ptr_eq(r, null); 21056 terminateO(self); 21057 terminateO(value); 21058 21059 } 21060 21061 21062 void keyBySmallStringSmallJsonT(void) { 21063 21064 char* r; 21065 smallJsont *self = allocSmallJson(); 21066 smallStringt *value = allocSmallString("qwe"); 21067 21068 createAllocateSmallString(d); 21069 smallJsont *r2 = self->f->setNFreeSmallString(self, "d", d); 21070 ck_assert_ptr_ne(r2, null); 21071 r2 = self->f->setNFreeSmallString(self, "1", value); 21072 ck_assert_ptr_ne(r2, null); 21073 value = allocSmallString("qwe"); 21074 r = keyBySmallStringO(self, value); 21075 ck_assert_str_eq(r, "1"); 21076 // non existing object 21077 r2 = self->f->setInt(self, "1", 1); 21078 ck_assert_ptr_ne(r2, null); 21079 r = keyBySmallStringO(self, value); 21080 ck_assert_ptr_eq(r, null); 21081 // empty value 21082 freeO(value); 21083 r = keyBySmallStringO(self, value); 21084 ck_assert_ptr_eq(r, null); 21085 // non smallString object 21086 smallIntt *i = allocSmallInt(2); 21087 r = keyBySmallStringO(self, (smallStringt*)i); 21088 terminateO(i); 21089 ck_assert_ptr_eq(r, null); 21090 // null value 21091 r = keyBySmallStringO(self, null); 21092 ck_assert_ptr_eq(r, null); 21093 // empty self 21094 freeO(self); 21095 r = keyBySmallStringO(self, value); 21096 ck_assert_ptr_eq(r, null); 21097 setTypeDictO(self); 21098 r = keyBySmallStringO(self, value); 21099 ck_assert_ptr_eq(r, null); 21100 terminateO(self); 21101 terminateO(value); 21102 21103 } 21104 21105 21106 void keyBySmallContainerSmallJsonT(void) { 21107 21108 char* r; 21109 smallJsont *self = allocSmallJson(); 21110 smallContainert *value = allocSmallContainer(null); 21111 21112 createAllocateSmallString(d); 21113 smallJsont *r2 = self->f->setNFreeSmallString(self, "d", d); 21114 ck_assert_ptr_ne(r2, null); 21115 r = keyBySmallContainerO(self, value); 21116 ck_assert_ptr_eq(r, null); 21117 // non smallContainer object 21118 smallIntt *i = allocSmallInt(2); 21119 r = keyBySmallContainerO(self, (smallContainert*)i); 21120 terminateO(i); 21121 ck_assert_ptr_eq(r, null); 21122 // null value 21123 r = keyBySmallContainerO(self, null); 21124 ck_assert_ptr_eq(r, null); 21125 // empty self 21126 freeO(self); 21127 r = keyBySmallContainerO(self, value); 21128 ck_assert_ptr_eq(r, null); 21129 setTypeDictO(self); 21130 r = keyBySmallContainerO(self, value); 21131 ck_assert_ptr_eq(r, null); 21132 terminateO(self); 21133 terminateO(value); 21134 21135 } 21136 21137 21138 void icKeyBySmallJsonT(void) { 21139 21140 char* r; 21141 smallJsont *self = allocSmallJson(); 21142 baset *value; 21143 21144 smallJsont *r2 = self->f->setS(self, "1", "QQ"); 21145 ck_assert_ptr_ne(r2, null); 21146 value = (baset*) allocSmallString("qq"); 21147 r = icKeyByO(self, value); 21148 ck_assert_str_eq(r, "1"); 21149 // non existing object 21150 smallIntt *i = allocSmallInt(2); 21151 r = icKeyByO(self, (baset*)i); 21152 terminateO(i); 21153 ck_assert_ptr_eq(r, null); 21154 // null value 21155 r = icKeyByO(self, null); 21156 ck_assert_ptr_eq(r, null); 21157 // empty self 21158 freeO(self); 21159 r = icKeyByO(self, value); 21160 ck_assert_ptr_eq(r, null); 21161 terminateO(self); 21162 terminateO(value); 21163 21164 } 21165 21166 21167 void icKeyBySSmallJsonT(void) { 21168 21169 char* r; 21170 smallJsont *self = allocSmallJson(); 21171 21172 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 21173 ck_assert_ptr_ne(r2, null); 21174 r = icKeyBySO(self, "QWE"); 21175 ck_assert_str_eq(r, "1"); 21176 // non existing object 21177 r2 = self->f->setInt(self, "1", 1); 21178 ck_assert_ptr_ne(r2, null); 21179 r = icKeyBySO(self, "qwe"); 21180 ck_assert_ptr_eq(r, null); 21181 // null value 21182 r = icKeyBySO(self, null); 21183 ck_assert_ptr_eq(r, null); 21184 // empty self 21185 freeO(self); 21186 r = icKeyBySO(self, "qwe"); 21187 ck_assert_ptr_eq(r, null); 21188 terminateO(self); 21189 21190 } 21191 21192 21193 void icKeyByCharSmallJsonT(void) { 21194 21195 char* r; 21196 smallJsont *self = allocSmallJson(); 21197 21198 smallJsont *r2 = self->f->setS(self, "1", "q"); 21199 ck_assert_ptr_ne(r2, null); 21200 r = icKeyByCharO(self, 'Q'); 21201 ck_assert_str_eq(r, "1"); 21202 // non existing object 21203 r2 = self->f->setInt(self, "1", 1); 21204 ck_assert_ptr_ne(r2, null); 21205 r = icKeyByCharO(self, 'q'); 21206 ck_assert_ptr_eq(r, null); 21207 // empty self 21208 freeO(self); 21209 r = icKeyByCharO(self, 'q'); 21210 ck_assert_ptr_eq(r, null); 21211 terminateO(self); 21212 21213 } 21214 21215 21216 void icKeyByDictSmallJsonT(void) { 21217 21218 char* r; 21219 smallJsont *self = allocSmallJson(); 21220 smallDictt *dict = allocSmallDict(); 21221 21222 createAllocateSmallDict(d); 21223 d->f->setS(d, "another", "dict"); 21224 smallJsont *r2 = self->f->setNFreeDict(self, "d", d); 21225 ck_assert_ptr_ne(r2, null); 21226 dict->f->setS(dict, "asd", "asd"); 21227 r2 = self->f->setNFreeDict(self, "1", dict); 21228 ck_assert_ptr_ne(r2, null); 21229 dict = allocSmallDict(); 21230 dict->f->setS(dict, "ASD", "asd"); 21231 r = icKeyByDictO(self, dict); 21232 ck_assert_str_eq(r, "1"); 21233 // non existing object 21234 r2 = self->f->setInt(self, "1", 1); 21235 ck_assert_ptr_ne(r2, null); 21236 r = icKeyByDictO(self, dict); 21237 ck_assert_ptr_eq(r, null); 21238 // non smallDict object 21239 smallIntt *i = allocSmallInt(2); 21240 r = icKeyByDictO(self, (smallDictt*)i); 21241 terminateO(i); 21242 ck_assert_ptr_eq(r, null); 21243 // null value 21244 r = icKeyByDictO(self, null); 21245 ck_assert_ptr_eq(r, null); 21246 // empty self 21247 freeO(self); 21248 r = icKeyByDictO(self, dict); 21249 ck_assert_ptr_eq(r, null); 21250 terminateO(self); 21251 terminateO(dict); 21252 21253 } 21254 21255 21256 void icKeyByArraySmallJsonT(void) { 21257 21258 char* r; 21259 smallJsont *self = allocSmallJson(); 21260 smallArrayt *array = allocSmallArray(); 21261 21262 createAllocateSmallArray(d); 21263 d->f->pushS(d, "another array"); 21264 smallJsont *r2 = self->f->setNFreeArray(self, "d", d); 21265 ck_assert_ptr_ne(r2, null); 21266 array->f->pushS(array, "the array"); 21267 r2 = self->f->setNFreeArray(self, "1", array); 21268 ck_assert_ptr_ne(r2, null); 21269 array = allocSmallArray(); 21270 array->f->pushS(array, "The array"); 21271 r = icKeyByArrayO(self, array); 21272 ck_assert_str_eq(r, "1"); 21273 // non existing object 21274 r2 = self->f->setInt(self, "1", 1); 21275 ck_assert_ptr_ne(r2, null); 21276 r = icKeyByArrayO(self, array); 21277 ck_assert_ptr_eq(r, null); 21278 // non smallArray object 21279 smallIntt *i = allocSmallInt(2); 21280 r = icKeyByArrayO(self, (smallArrayt*)i); 21281 terminateO(i); 21282 ck_assert_ptr_eq(r, null); 21283 // null value 21284 r = icKeyByArrayO(self, null); 21285 ck_assert_ptr_eq(r, null); 21286 // empty self 21287 freeO(self); 21288 r = icKeyByArrayO(self, array); 21289 ck_assert_ptr_eq(r, null); 21290 terminateO(self); 21291 terminateO(array); 21292 21293 } 21294 21295 21296 void icKeyByArraycSmallJsonT(void) { 21297 21298 char* r; 21299 smallJsont *self = allocSmallJson(); 21300 char **array = listCreateS("a","b"); 21301 21302 char **d = listCreateS("asd", "zxcv"); 21303 smallJsont *r2 = self->f->setNFreeArrayc(self, "d", d); 21304 ck_assert_ptr_ne(r2, null); 21305 r2 = self->f->setArrayc(self, "1", array); 21306 ck_assert_ptr_ne(r2, null); 21307 iUpperS(&array[0]); 21308 r = icKeyByArraycO(self, array); 21309 ck_assert_ptr_ne(r, NULL); 21310 ck_assert_str_eq(r, "1"); 21311 // non existing object 21312 r2 = self->f->setInt(self, "1", 1); 21313 ck_assert_ptr_ne(r2, null); 21314 r = icKeyByArraycO(self, array); 21315 ck_assert_ptr_eq(r, null); 21316 // null value 21317 r = icKeyByArraycO(self, null); 21318 ck_assert_ptr_eq(r, null); 21319 // empty self 21320 freeO(self); 21321 r = icKeyByArraycO(self, array); 21322 ck_assert_ptr_eq(r, null); 21323 terminateO(self); 21324 listFreeS(array); 21325 21326 } 21327 21328 21329 void icKeyBySmallStringSmallJsonT(void) { 21330 21331 char* r; 21332 smallJsont *self = allocSmallJson(); 21333 smallStringt *value = allocSmallString("qwe"); 21334 21335 createAllocateSmallString(d); 21336 smallJsont *r2 = self->f->setNFreeSmallString(self, "d", d); 21337 ck_assert_ptr_ne(r2, null); 21338 r2 = self->f->setNFreeSmallString(self, "1", value); 21339 ck_assert_ptr_ne(r2, null); 21340 value = allocSmallString("QWE"); 21341 r = icKeyBySmallStringO(self, value); 21342 ck_assert_str_eq(r, "1"); 21343 // non existing object 21344 r2 = self->f->setInt(self, "1", 1); 21345 ck_assert_ptr_ne(r2, null); 21346 r = icKeyBySmallStringO(self, value); 21347 ck_assert_ptr_eq(r, null); 21348 // empty value 21349 freeO(value); 21350 r = icKeyBySmallStringO(self, value); 21351 ck_assert_ptr_eq(r, null); 21352 // non smallString object 21353 smallIntt *i = allocSmallInt(2); 21354 r = icKeyBySmallStringO(self, (smallStringt*)i); 21355 terminateO(i); 21356 ck_assert_ptr_eq(r, null); 21357 // null value 21358 r = icKeyBySmallStringO(self, null); 21359 ck_assert_ptr_eq(r, null); 21360 // empty self 21361 freeO(self); 21362 r = icKeyBySmallStringO(self, value); 21363 ck_assert_ptr_eq(r, null); 21364 setTypeDictO(self); 21365 r = icKeyBySmallStringO(self, value); 21366 ck_assert_ptr_eq(r, null); 21367 terminateO(self); 21368 terminateO(value); 21369 21370 } 21371 21372 21373 void replaceSmallJsonT(void) { 21374 21375 smallJsont* r; 21376 smallJsont *self = allocSmallJson(); 21377 setTopSO(self, "#ee#ee#ad"); 21378 21379 // replace string, multiple character new delimeter 21380 r = replaceO(self, "#","^^", 0); 21381 ck_assert_ptr_ne(r, null); 21382 char *s = toStringO(r); 21383 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 21384 free(s); 21385 // replace string, multiple character old delimeter 21386 freeO(self); 21387 setTopSO(self, "AA##ee##ee#"); 21388 r = replaceO(self, "##","|", 0); 21389 ck_assert_ptr_ne(r, null); 21390 s = toStringO(r); 21391 ck_assert_str_eq(s, "AA|ee|ee#"); 21392 free(s); 21393 // replace one time at the start of string 21394 freeO(self); 21395 setTopSO(self, "#ee#ee#ad"); 21396 r = replaceO(self, "#","^^",1); 21397 ck_assert_ptr_ne(r, null); 21398 s = toStringO(r); 21399 ck_assert_str_eq(s, "^^ee#ee#ad"); 21400 free(s); 21401 // replace one time 21402 freeO(self); 21403 setTopSO(self, "AA##ee##ee#"); 21404 r = replaceO(self, "##","|",1); 21405 ck_assert_ptr_ne(r, null); 21406 s = toStringO(r); 21407 ck_assert_str_eq(s, "AA|ee##ee#"); 21408 free(s); 21409 // NULL new delimiter, one time: same as empty delimiter 21410 freeO(self); 21411 setTopSO(self, "AA##ee##ee#"); 21412 r = replaceO(self, "##",NULL,1); 21413 ck_assert_ptr_ne(r, null); 21414 s = toStringO(r); 21415 ck_assert_str_eq(s, "AAee##ee#"); 21416 free(s); 21417 // empty string 21418 freeO(self); 21419 setTopSO(self, ""); 21420 r = replaceO(self, "##",NULL,1); 21421 ck_assert_ptr_ne(r, null); 21422 s = toStringO(r); 21423 ck_assert_str_eq(s, ""); 21424 free(s); 21425 // empty old delimiter 21426 freeO(self); 21427 setTopSO(self, "qwe"); 21428 ck_assert_ptr_eq(replaceO(self, "","|",1), NULL); 21429 // NULL old delimiter 21430 ck_assert_ptr_eq(replaceO(self, NULL,"|",1), NULL); 21431 // empty old delimiter 21432 ck_assert_ptr_eq(replaceO(self, "","|",1), NULL); 21433 // NULL string 21434 freeO(self); 21435 ck_assert_ptr_eq(replaceO(self, "##","|",1), NULL); 21436 terminateO(self); 21437 21438 } 21439 21440 21441 void replaceCharSSmallJsonT(void) { 21442 21443 smallJsont* r; 21444 smallJsont *self = allocSmallJson(); 21445 setTopSO(self, ""); 21446 21447 // replace string, multiple character new delimeter 21448 freeO(self); 21449 setTopSO(self, "#ee#ee#ad"); 21450 r = replaceCharSO(self, '#',"^^", 0); 21451 ck_assert_ptr_ne(r, null); 21452 char *s = toStringO(r); 21453 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 21454 free(s); 21455 // replace one time at the start of string 21456 freeO(self); 21457 setTopSO(self, "#ee#ee#ad"); 21458 r = replaceCharSO(self, '#',"^^",1); 21459 ck_assert_ptr_ne(r, null); 21460 s = toStringO(r); 21461 ck_assert_str_eq(s, "^^ee#ee#ad"); 21462 free(s); 21463 // replace one time 21464 freeO(self); 21465 setTopSO(self, "AA##ee##ee#"); 21466 r = replaceCharSO(self, '#',"|",1); 21467 ck_assert_ptr_ne(r, null); 21468 s = toStringO(r); 21469 ck_assert_str_eq(s, "AA|#ee##ee#"); 21470 free(s); 21471 // NULL new delimiter, one time: same as empty delimiter 21472 freeO(self); 21473 setTopSO(self, "AA#ee##ee#"); 21474 r = replaceCharSO(self, '#',NULL,1); 21475 ck_assert_ptr_ne(r, null); 21476 s = toStringO(r); 21477 ck_assert_str_eq(s, "AAee##ee#"); 21478 free(s); 21479 // empty string 21480 freeO(self); 21481 setTopSO(self, ""); 21482 r = replaceCharSO(self, '#',NULL,1); 21483 ck_assert_ptr_ne(r, null); 21484 s = toStringO(r); 21485 ck_assert_str_eq(s, ""); 21486 free(s); 21487 // empty old delimiter 21488 freeO(self); 21489 setTopSO(self, "qwe"); 21490 ck_assert_ptr_eq(replaceCharSO(self, 0,"|",1), NULL); 21491 // NULL string 21492 freeO(self); 21493 ck_assert_ptr_eq(replaceCharSO(self, '#',"|",1), NULL); 21494 terminateO(self); 21495 21496 } 21497 21498 21499 void replaceSCharSmallJsonT(void) { 21500 21501 smallJsont* r; 21502 smallJsont *self = allocSmallJson(); 21503 setTopSO(self, ""); 21504 21505 // replace string, multiple character new delimeter 21506 freeO(self); 21507 setTopSO(self, "#ee#ee#ad"); 21508 r = replaceSCharO(self, "#",'^',0); 21509 ck_assert_ptr_ne(r, null); 21510 char *s = toStringO(r); 21511 ck_assert_str_eq(s, "^ee^ee^ad"); 21512 free(s); 21513 // replace string, multiple character old delimeter 21514 freeO(self); 21515 setTopSO(self, "AA##ee##ee#"); 21516 r = replaceSCharO(self, "##",'|',0); 21517 ck_assert_ptr_ne(r, null); 21518 s = toStringO(r); 21519 ck_assert_str_eq(s, "AA|ee|ee#"); 21520 free(s); 21521 // replace string empty char, multiple character old delimeter 21522 freeO(self); 21523 setTopSO(self, "AA##ee##ee#"); 21524 r = replaceSCharO(self, "##", 0,0); 21525 ck_assert_ptr_ne(r, null); 21526 s = toStringO(r); 21527 ck_assert_str_eq(s, "AAeeee#"); 21528 free(s); 21529 // replace one time at the start of string 21530 freeO(self); 21531 setTopSO(self, "#ee#ee#ad"); 21532 r = replaceSCharO(self, "#",'^',1); 21533 ck_assert_ptr_ne(r, null); 21534 s = toStringO(r); 21535 ck_assert_str_eq(s, "^ee#ee#ad"); 21536 free(s); 21537 // replace one time 21538 freeO(self); 21539 setTopSO(self, "AA##ee##ee#"); 21540 r = replaceSCharO(self, "##",'|',1); 21541 ck_assert_ptr_ne(r, null); 21542 s = toStringO(r); 21543 ck_assert_str_eq(s, "AA|ee##ee#"); 21544 free(s); 21545 // empty string 21546 freeO(self); 21547 setTopSO(self, ""); 21548 r = replaceSCharO(self, "##",0,1); 21549 ck_assert_ptr_ne(r, null); 21550 s = toStringO(r); 21551 ck_assert_str_eq(s, ""); 21552 free(s); 21553 // empty old delimiter 21554 freeO(self); 21555 setTopSO(self, "qwe"); 21556 ck_assert_ptr_eq(replaceSCharO(self, "",'|',1), NULL); 21557 // NULL old delimiter 21558 ck_assert_ptr_eq(replaceSCharO(self, NULL,'|',1), NULL); 21559 // NULL string 21560 freeO(self); 21561 ck_assert_ptr_eq(replaceSCharO(self, "##",'|',1), NULL); 21562 terminateO(self); 21563 21564 } 21565 21566 21567 void replaceCharCharSmallJsonT(void) { 21568 21569 smallJsont* r; 21570 smallJsont *self = allocSmallJson(); 21571 setTopSO(self, ""); 21572 21573 // replace string, multiple character new delimeter 21574 freeO(self); 21575 setTopSO(self, "#ee#ee#ad"); 21576 r = replaceCharCharO(self, '#','^', 0); 21577 ck_assert_ptr_ne(r, null); 21578 char *s = toStringO(r); 21579 ck_assert_str_eq(s, "^ee^ee^ad"); 21580 free(s); 21581 // replace one time at the start of string 21582 freeO(self); 21583 setTopSO(self, "#ee#ee#ad"); 21584 r = replaceCharCharO(self, '#','^',1); 21585 ck_assert_ptr_ne(r, null); 21586 s = toStringO(r); 21587 ck_assert_str_eq(s, "^ee#ee#ad"); 21588 free(s); 21589 // replace one time 21590 freeO(self); 21591 setTopSO(self, "AA#ee##ee#"); 21592 r = replaceCharCharO(self, '#','|',1); 21593 ck_assert_ptr_ne(r, null); 21594 s = toStringO(r); 21595 ck_assert_str_eq(s, "AA|ee##ee#"); 21596 free(s); 21597 // empty string 21598 freeO(self); 21599 setTopSO(self, ""); 21600 r = replaceCharCharO(self, '#','^',1); 21601 ck_assert_ptr_ne(r, null); 21602 s = toStringO(r); 21603 ck_assert_str_eq(s, ""); 21604 free(s); 21605 // empty old delimiter 21606 freeO(self); 21607 setTopSO(self, "qwe"); 21608 ck_assert_ptr_eq(replaceCharCharO(self, 0,'|',1), NULL); 21609 // NULL string 21610 freeO(self); 21611 ck_assert_ptr_eq(replaceCharCharO(self, '#','|',1), NULL); 21612 terminateO(self); 21613 21614 } 21615 21616 21617 void replaceSmallStringSmallStringSmallJsonT(void) { 21618 21619 smallJsont* r; 21620 smallJsont *self = allocSmallJson(); 21621 setTopSO(self, "#ee#ee#ad"); 21622 smallStringt *olds = allocSmallString(""); 21623 smallStringt *news = allocSmallString(""); 21624 21625 // replace string, multiple character new delimeter 21626 setValO(olds, "#"); 21627 setValO(news, "^^"); 21628 r = replaceSmallStringSmallStringO(self, olds, news, 0); 21629 ck_assert_ptr_ne(r, null); 21630 char *s = toStringO(r); 21631 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 21632 free(s); 21633 // replace string, multiple character old delimeter 21634 freeO(self); 21635 setTopSO(self, "AA##ee##ee#"); 21636 setValO(olds, "##"); 21637 setValO(news, "|"); 21638 r = replaceSmallStringSmallStringO(self, olds, news, 0); 21639 ck_assert_ptr_ne(r, null); 21640 s = toStringO(r); 21641 ck_assert_str_eq(s, "AA|ee|ee#"); 21642 free(s); 21643 // replace one time at the start of string 21644 freeO(self); 21645 setTopSO(self, "#ee#ee#ad"); 21646 setValO(olds, "#"); 21647 setValO(news, "^^"); 21648 r = replaceSmallStringSmallStringO(self, olds, news,1); 21649 ck_assert_ptr_ne(r, null); 21650 s = toStringO(r); 21651 ck_assert_str_eq(s, "^^ee#ee#ad"); 21652 free(s); 21653 // replace one time 21654 freeO(self); 21655 setTopSO(self, "AA##ee##ee#"); 21656 setValO(olds, "##"); 21657 setValO(news, "|"); 21658 r = replaceSmallStringSmallStringO(self, olds, news,1); 21659 ck_assert_ptr_ne(r, null); 21660 s = toStringO(r); 21661 ck_assert_str_eq(s, "AA|ee##ee#"); 21662 free(s); 21663 // NULL new delimiter, one time: same as empty delimiter 21664 freeO(self); 21665 setTopSO(self, "AA##ee##ee#"); 21666 setValO(olds, "##"); 21667 r = replaceSmallStringSmallStringO(self, olds, NULL,1); 21668 ck_assert_ptr_ne(r, null); 21669 s = toStringO(r); 21670 ck_assert_str_eq(s, "AAee##ee#"); 21671 free(s); 21672 // non smallString object 21673 terminateO(olds); 21674 olds = (smallStringt*) allocSmallInt(1); 21675 r = replaceSmallStringSmallStringO(self, olds, news,1); 21676 ck_assert_ptr_eq(r, null); 21677 terminateO(olds); 21678 terminateO(news); 21679 olds = allocSmallString(""); 21680 news = (smallStringt*) allocSmallInt(1); 21681 r = replaceSmallStringSmallStringO(self, olds, news,1); 21682 ck_assert_ptr_eq(r, null); 21683 terminateO(news); 21684 news = allocSmallString(""); 21685 // empty string 21686 freeO(self); 21687 setTopSO(self, ""); 21688 setValO(olds, "##"); 21689 r = replaceSmallStringSmallStringO(self, olds, NULL,1); 21690 ck_assert_ptr_ne(r, null); 21691 s = toStringO(r); 21692 ck_assert_str_eq(s, ""); 21693 free(s); 21694 // empty old delimiter 21695 freeO(self); 21696 setTopSO(self, "qwe"); 21697 setValO(olds, ""); 21698 setValO(news, "|"); 21699 ck_assert_ptr_eq(replaceSmallStringSmallStringO(self, olds, news,1), NULL); 21700 // NULL old delimiter 21701 ck_assert_ptr_eq(replaceSmallStringSmallStringO(self, NULL, news,1), NULL); 21702 // NULL string 21703 freeO(self); 21704 ck_assert_ptr_eq(replaceSmallStringSmallStringO(self, olds, news,1), NULL); 21705 terminateO(olds); 21706 terminateO(news); 21707 terminateO(self); 21708 21709 } 21710 21711 21712 void replaceSmallStringSSmallJsonT(void) { 21713 21714 smallJsont* r; 21715 smallJsont *self = allocSmallJson(); 21716 setTopSO(self, "#ee#ee#ad"); 21717 smallStringt *olds = allocSmallString(""); 21718 const char *news; 21719 21720 // replace string, multiple character new delimeter 21721 setValO(olds, "#"); 21722 news = "^^"; 21723 r = replaceSmallStringSO(self, olds, news, 0); 21724 ck_assert_ptr_ne(r, null); 21725 char *s = toStringO(r); 21726 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 21727 free(s); 21728 // replace string, multiple character old delimeter 21729 freeO(self); 21730 setTopSO(self, "AA##ee##ee#"); 21731 setValO(olds, "##"); 21732 news = "|"; 21733 r = replaceSmallStringSO(self, olds, news, 0); 21734 ck_assert_ptr_ne(r, null); 21735 s = toStringO(r); 21736 ck_assert_str_eq(s, "AA|ee|ee#"); 21737 free(s); 21738 // replace one time at the start of string 21739 freeO(self); 21740 setTopSO(self, "#ee#ee#ad"); 21741 setValO(olds, "#"); 21742 news = "^^"; 21743 r = replaceSmallStringSO(self, olds, news,1); 21744 ck_assert_ptr_ne(r, null); 21745 s = toStringO(r); 21746 ck_assert_str_eq(s, "^^ee#ee#ad"); 21747 free(s); 21748 // replace one time 21749 freeO(self); 21750 setTopSO(self, "AA##ee##ee#"); 21751 setValO(olds, "##"); 21752 news = "|"; 21753 r = replaceSmallStringSO(self, olds, news,1); 21754 ck_assert_ptr_ne(r, null); 21755 s = toStringO(r); 21756 ck_assert_str_eq(s, "AA|ee##ee#"); 21757 free(s); 21758 // NULL new delimiter, one time: same as empty delimiter 21759 freeO(self); 21760 setTopSO(self, "AA##ee##ee#"); 21761 setValO(olds, "##"); 21762 r = replaceSmallStringSO(self, olds, NULL,1); 21763 ck_assert_ptr_ne(r, null); 21764 s = toStringO(r); 21765 ck_assert_str_eq(s, "AAee##ee#"); 21766 free(s); 21767 // non smallString object 21768 terminateO(olds); 21769 olds = (smallStringt*) allocSmallInt(1); 21770 r = replaceSmallStringSO(self, olds, news,1); 21771 ck_assert_ptr_eq(r, null); 21772 terminateO(olds); 21773 olds = allocSmallString(""); 21774 // empty string 21775 freeO(self); 21776 setTopSO(self, ""); 21777 setValO(olds, "##"); 21778 r = replaceSmallStringSO(self, olds, NULL,1); 21779 ck_assert_ptr_ne(r, null); 21780 s = toStringO(r); 21781 ck_assert_str_eq(s, ""); 21782 free(s); 21783 // empty old delimiter 21784 freeO(self); 21785 setTopSO(self, "qwe"); 21786 setValO(olds, ""); 21787 news = "|"; 21788 ck_assert_ptr_eq(replaceSmallStringSO(self, olds, news,1), NULL); 21789 // NULL old delimiter 21790 ck_assert_ptr_eq(replaceSmallStringSO(self, NULL, news,1), NULL); 21791 // NULL string 21792 freeO(self); 21793 ck_assert_ptr_eq(replaceSmallStringSO(self, olds, news,1), NULL); 21794 terminateO(olds); 21795 terminateO(self); 21796 21797 } 21798 21799 21800 void replaceSmallStringCharSmallJsonT(void) { 21801 21802 smallJsont* r; 21803 smallJsont *self = allocSmallJson(); 21804 setTopSO(self, "#ee#ee#ad"); 21805 smallStringt *olds = allocSmallString(""); 21806 char news; 21807 21808 // replace string, multiple character new delimeter 21809 setValO(olds, "#"); 21810 news = '^'; 21811 r = replaceSmallStringCharO(self, olds, news, 0); 21812 ck_assert_ptr_ne(r, null); 21813 char *s = toStringO(r); 21814 ck_assert_str_eq(s, "^ee^ee^ad"); 21815 free(s); 21816 // replace string, multiple character old delimeter 21817 freeO(self); 21818 setTopSO(self, "AA##ee##ee#"); 21819 setValO(olds, "##"); 21820 news = '|'; 21821 r = replaceSmallStringCharO(self, olds, news, 0); 21822 ck_assert_ptr_ne(r, null); 21823 s = toStringO(r); 21824 ck_assert_str_eq(s, "AA|ee|ee#"); 21825 free(s); 21826 // replace one time at the start of string 21827 freeO(self); 21828 setTopSO(self, "#ee#ee#ad"); 21829 setValO(olds, "#"); 21830 news = '^'; 21831 r = replaceSmallStringCharO(self, olds, news,1); 21832 ck_assert_ptr_ne(r, null); 21833 s = toStringO(r); 21834 ck_assert_str_eq(s, "^ee#ee#ad"); 21835 free(s); 21836 // replace one time 21837 freeO(self); 21838 setTopSO(self, "AA##ee##ee#"); 21839 setValO(olds, "##"); 21840 news = '|'; 21841 r = replaceSmallStringCharO(self, olds, news,1); 21842 ck_assert_ptr_ne(r, null); 21843 s = toStringO(r); 21844 ck_assert_str_eq(s, "AA|ee##ee#"); 21845 free(s); 21846 // non smallString object 21847 terminateO(olds); 21848 olds = (smallStringt*) allocSmallInt(1); 21849 r = replaceSmallStringCharO(self, olds, news,1); 21850 ck_assert_ptr_eq(r, null); 21851 terminateO(olds); 21852 olds = allocSmallString(""); 21853 // empty string 21854 freeO(self); 21855 setTopSO(self, ""); 21856 setValO(olds, "##"); 21857 r = replaceSmallStringCharO(self, olds, news,1); 21858 ck_assert_ptr_ne(r, null); 21859 s = toStringO(r); 21860 ck_assert_str_eq(s, ""); 21861 free(s); 21862 // empty old delimiter 21863 freeO(self); 21864 setTopSO(self, "qwe"); 21865 setValO(olds, ""); 21866 news = '|'; 21867 ck_assert_ptr_eq(replaceSmallStringCharO(self, olds, news,1), NULL); 21868 // NULL old delimiter 21869 ck_assert_ptr_eq(replaceSmallStringCharO(self, NULL, news,1), NULL); 21870 // NULL string 21871 freeO(self); 21872 ck_assert_ptr_eq(replaceSmallStringCharO(self, olds, news,1), NULL); 21873 terminateO(olds); 21874 terminateO(self); 21875 21876 } 21877 21878 21879 void replaceSSmallStringSmallJsonT(void) { 21880 21881 smallJsont* r; 21882 smallJsont *self = allocSmallJson(); 21883 setTopSO(self, "#ee#ee#ad"); 21884 const char *olds; 21885 smallStringt *news = allocSmallString(""); 21886 21887 // replace string, multiple character new delimeter 21888 olds = "#"; 21889 setValO(news, "^^"); 21890 r = replaceSSmallStringO(self, olds, news, 0); 21891 ck_assert_ptr_ne(r, null); 21892 char *s = toStringO(r); 21893 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 21894 free(s); 21895 // replace string, multiple character old delimeter 21896 freeO(self); 21897 setTopSO(self, "AA##ee##ee#"); 21898 olds = "##"; 21899 setValO(news, "|"); 21900 r = replaceSSmallStringO(self, olds, news, 0); 21901 ck_assert_ptr_ne(r, null); 21902 s = toStringO(r); 21903 ck_assert_str_eq(s, "AA|ee|ee#"); 21904 free(s); 21905 // replace one time at the start of string 21906 freeO(self); 21907 setTopSO(self, "#ee#ee#ad"); 21908 olds = "#"; 21909 setValO(news, "^^"); 21910 r = replaceSSmallStringO(self, olds, news,1); 21911 ck_assert_ptr_ne(r, null); 21912 s = toStringO(r); 21913 ck_assert_str_eq(s, "^^ee#ee#ad"); 21914 free(s); 21915 // replace one time 21916 freeO(self); 21917 setTopSO(self, "AA##ee##ee#"); 21918 olds = "##"; 21919 setValO(news, "|"); 21920 r = replaceSSmallStringO(self, olds, news,1); 21921 ck_assert_ptr_ne(r, null); 21922 s = toStringO(r); 21923 ck_assert_str_eq(s, "AA|ee##ee#"); 21924 free(s); 21925 // NULL new delimiter, one time: same as empty delimiter 21926 freeO(self); 21927 setTopSO(self, "AA##ee##ee#"); 21928 olds = "##"; 21929 r = replaceSSmallStringO(self, olds, NULL,1); 21930 ck_assert_ptr_ne(r, null); 21931 s = toStringO(r); 21932 ck_assert_str_eq(s, "AAee##ee#"); 21933 free(s); 21934 // non smallString object 21935 terminateO(news); 21936 news = (smallStringt*) allocSmallInt(1); 21937 r = replaceSSmallStringO(self, olds, news,1); 21938 ck_assert_ptr_eq(r, null); 21939 terminateO(news); 21940 news = allocSmallString(""); 21941 // empty string 21942 freeO(self); 21943 setTopSO(self, ""); 21944 olds = "##"; 21945 r = replaceSSmallStringO(self, olds, NULL,1); 21946 ck_assert_ptr_ne(r, null); 21947 s = toStringO(r); 21948 ck_assert_str_eq(s, ""); 21949 free(s); 21950 // empty old delimiter 21951 freeO(self); 21952 setTopSO(self, "qwe"); 21953 olds = ""; 21954 setValO(news, "|"); 21955 ck_assert_ptr_eq(replaceSSmallStringO(self, olds, news,1), NULL); 21956 // NULL old delimiter 21957 ck_assert_ptr_eq(replaceSSmallStringO(self, NULL, news,1), NULL); 21958 // NULL string 21959 freeO(self); 21960 ck_assert_ptr_eq(replaceSSmallStringO(self, olds, news,1), NULL); 21961 terminateO(news); 21962 terminateO(self); 21963 21964 } 21965 21966 21967 void replaceCharSmallStringSmallJsonT(void) { 21968 21969 smallJsont* r; 21970 smallJsont *self = allocSmallJson(); 21971 setTopSO(self, "#ee#ee#ad"); 21972 char olds; 21973 smallStringt *news = allocSmallString(""); 21974 21975 // replace string, multiple character new delimeter 21976 olds = '#'; 21977 setValO(news, "^^"); 21978 r = replaceCharSmallStringO(self, olds, news, 0); 21979 ck_assert_ptr_ne(r, null); 21980 char *s = toStringO(r); 21981 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 21982 free(s); 21983 // replace string, multiple character old delimeter 21984 freeO(self); 21985 setTopSO(self, "AA#ee#ee"); 21986 olds = '#'; 21987 setValO(news, "|"); 21988 r = replaceCharSmallStringO(self, olds, news, 0); 21989 ck_assert_ptr_ne(r, null); 21990 s = toStringO(r); 21991 ck_assert_str_eq(s, "AA|ee|ee"); 21992 free(s); 21993 // replace one time at the start of string 21994 freeO(self); 21995 setTopSO(self, "#ee#ee#ad"); 21996 olds = '#'; 21997 setValO(news, "^^"); 21998 r = replaceCharSmallStringO(self, olds, news,1); 21999 ck_assert_ptr_ne(r, null); 22000 s = toStringO(r); 22001 ck_assert_str_eq(s, "^^ee#ee#ad"); 22002 free(s); 22003 // replace one time 22004 freeO(self); 22005 setTopSO(self, "AA#ee##ee#"); 22006 olds = '#'; 22007 setValO(news, "|"); 22008 r = replaceCharSmallStringO(self, olds, news,1); 22009 ck_assert_ptr_ne(r, null); 22010 s = toStringO(r); 22011 ck_assert_str_eq(s, "AA|ee##ee#"); 22012 free(s); 22013 // NULL new delimiter, one time: same as empty delimiter 22014 freeO(self); 22015 setTopSO(self, "AA#ee##ee#"); 22016 olds = '#'; 22017 r = replaceCharSmallStringO(self, olds, NULL,1); 22018 ck_assert_ptr_ne(r, null); 22019 s = toStringO(r); 22020 ck_assert_str_eq(s, "AAee##ee#"); 22021 free(s); 22022 // non smallString object 22023 terminateO(news); 22024 news = (smallStringt*) allocSmallInt(1); 22025 r = replaceCharSmallStringO(self, olds, news,1); 22026 ck_assert_ptr_eq(r, null); 22027 terminateO(news); 22028 news = allocSmallString(""); 22029 // empty string 22030 freeO(self); 22031 setTopSO(self, ""); 22032 olds = '#'; 22033 r = replaceCharSmallStringO(self, olds, NULL,1); 22034 ck_assert_ptr_ne(r, null); 22035 s = toStringO(r); 22036 ck_assert_str_eq(s, ""); 22037 free(s); 22038 // NULL string 22039 freeO(self); 22040 setValO(news, "|"); 22041 ck_assert_ptr_eq(replaceCharSmallStringO(self, olds, news,1), NULL); 22042 terminateO(news); 22043 terminateO(self); 22044 22045 } 22046 22047 22048 void replaceJsonJsonSmallJsonT(void) { 22049 22050 smallJsont* r; 22051 smallJsont *self = allocSmallJson(); 22052 setTopSO(self, "#ee#ee#ad"); 22053 smallJsont *olds = allocSmallJson(); 22054 smallJsont *news = allocSmallJson(); 22055 22056 // replace string, multiple character new delimeter 22057 freeO(olds); 22058 freeO(news); 22059 setTopSO(olds, "#"); 22060 setTopSO(news, "^^"); 22061 r = replaceJsonJsonO(self, olds, news, 0); 22062 ck_assert_ptr_ne(r, null); 22063 char *s = toStringO(r); 22064 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22065 free(s); 22066 // replace string, multiple character old delimeter 22067 freeO(self); 22068 setTopSO(self, "AA##ee##ee#"); 22069 freeO(olds); 22070 freeO(news); 22071 setTopSO(olds, "##"); 22072 setTopSO(news, "|"); 22073 r = replaceJsonJsonO(self, olds, news, 0); 22074 ck_assert_ptr_ne(r, null); 22075 s = toStringO(r); 22076 ck_assert_str_eq(s, "AA|ee|ee#"); 22077 free(s); 22078 // replace one time at the start of string 22079 freeO(self); 22080 setTopSO(self, "#ee#ee#ad"); 22081 freeO(olds); 22082 freeO(news); 22083 setTopSO(olds, "#"); 22084 setTopSO(news, "^^"); 22085 r = replaceJsonJsonO(self, olds, news,1); 22086 ck_assert_ptr_ne(r, null); 22087 s = toStringO(r); 22088 ck_assert_str_eq(s, "^^ee#ee#ad"); 22089 free(s); 22090 // replace one time 22091 freeO(self); 22092 setTopSO(self, "AA##ee##ee#"); 22093 freeO(olds); 22094 freeO(news); 22095 setTopSO(olds, "##"); 22096 setTopSO(news, "|"); 22097 r = replaceJsonJsonO(self, olds, news,1); 22098 ck_assert_ptr_ne(r, null); 22099 s = toStringO(r); 22100 ck_assert_str_eq(s, "AA|ee##ee#"); 22101 free(s); 22102 // NULL new delimiter, one time: same as empty delimiter 22103 freeO(self); 22104 setTopSO(self, "AA##ee##ee#"); 22105 freeO(olds); 22106 setTopSO(olds, "##"); 22107 r = replaceJsonJsonO(self, olds, NULL,1); 22108 ck_assert_ptr_ne(r, null); 22109 s = toStringO(r); 22110 ck_assert_str_eq(s, "AAee##ee#"); 22111 free(s); 22112 // non json string 22113 freeO(olds); 22114 setTopIntO(olds, 1); 22115 r = replaceJsonJsonO(self, olds, news,1); 22116 ck_assert_ptr_eq(r, null); 22117 freeO(olds); 22118 freeO(news); 22119 setTopSO(olds, "e"); 22120 setTopIntO(news, 1); 22121 r = replaceJsonJsonO(self, olds, news,1); 22122 ck_assert_ptr_eq(r, null); 22123 // non json object 22124 terminateO(olds); 22125 olds = (smallJsont*) allocSmallInt(1); 22126 r = replaceJsonJsonO(self, olds, news,1); 22127 ck_assert_ptr_eq(r, null); 22128 terminateO(olds); 22129 terminateO(news); 22130 olds = allocSmallJson(); 22131 news = (smallJsont*) allocSmallInt(1); 22132 r = replaceJsonJsonO(self, olds, news,1); 22133 ck_assert_ptr_eq(r, null); 22134 terminateO(news); 22135 news = allocSmallJson(); 22136 // empty string 22137 freeO(self); 22138 setTopSO(self, ""); 22139 freeO(olds); 22140 setTopSO(olds, "##"); 22141 r = replaceJsonJsonO(self, olds, NULL,1); 22142 ck_assert_ptr_ne(r, null); 22143 s = toStringO(r); 22144 ck_assert_str_eq(s, ""); 22145 free(s); 22146 // empty old delimiter 22147 freeO(self); 22148 setTopSO(self, "qwe"); 22149 freeO(olds); 22150 freeO(news); 22151 setTopSO(olds, ""); 22152 setTopSO(news, "|"); 22153 ck_assert_ptr_eq(replaceJsonJsonO(self, olds, news,1), NULL); 22154 // NULL old delimiter 22155 ck_assert_ptr_eq(replaceJsonJsonO(self, NULL, news,1), NULL); 22156 // NULL string 22157 freeO(self); 22158 ck_assert_ptr_eq(replaceJsonJsonO(self, olds, news,1), NULL); 22159 terminateO(olds); 22160 terminateO(news); 22161 terminateO(self); 22162 22163 } 22164 22165 22166 void replaceJsonSmallStringSmallJsonT(void) { 22167 22168 smallJsont* r; 22169 smallJsont *self = allocSmallJson(); 22170 setTopSO(self, "#ee#ee#ad"); 22171 smallJsont *olds = allocSmallJson(); 22172 smallStringt *news = allocSmallString(""); 22173 22174 // replace string, multiple character new delimeter 22175 freeO(olds); 22176 setTopSO(olds, "#"); 22177 setValO(news, "^^"); 22178 r = replaceJsonSmallStringO(self, olds, news, 0); 22179 ck_assert_ptr_ne(r, null); 22180 char *s = toStringO(r); 22181 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22182 free(s); 22183 // replace string, multiple character old delimeter 22184 freeO(self); 22185 setTopSO(self, "AA##ee##ee#"); 22186 freeO(olds); 22187 setTopSO(olds, "##"); 22188 setValO(news, "|"); 22189 r = replaceJsonSmallStringO(self, olds, news, 0); 22190 ck_assert_ptr_ne(r, null); 22191 s = toStringO(r); 22192 ck_assert_str_eq(s, "AA|ee|ee#"); 22193 free(s); 22194 // replace one time at the start of string 22195 freeO(self); 22196 setTopSO(self, "#ee#ee#ad"); 22197 freeO(olds); 22198 setTopSO(olds, "#"); 22199 setValO(news, "^^"); 22200 r = replaceJsonSmallStringO(self, olds, news,1); 22201 ck_assert_ptr_ne(r, null); 22202 s = toStringO(r); 22203 ck_assert_str_eq(s, "^^ee#ee#ad"); 22204 free(s); 22205 // replace one time 22206 freeO(self); 22207 setTopSO(self, "AA##ee##ee#"); 22208 freeO(olds); 22209 setTopSO(olds, "##"); 22210 setValO(news, "|"); 22211 r = replaceJsonSmallStringO(self, olds, news,1); 22212 ck_assert_ptr_ne(r, null); 22213 s = toStringO(r); 22214 ck_assert_str_eq(s, "AA|ee##ee#"); 22215 free(s); 22216 // NULL new delimiter, one time: same as empty delimiter 22217 freeO(self); 22218 setTopSO(self, "AA##ee##ee#"); 22219 freeO(olds); 22220 setTopSO(olds, "##"); 22221 r = replaceJsonSmallStringO(self, olds, NULL,1); 22222 ck_assert_ptr_ne(r, null); 22223 s = toStringO(r); 22224 ck_assert_str_eq(s, "AAee##ee#"); 22225 free(s); 22226 // non json string 22227 freeO(olds); 22228 setTopIntO(olds, 1); 22229 r = replaceJsonSmallStringO(self, olds, news,1); 22230 ck_assert_ptr_eq(r, null); 22231 // non json object 22232 terminateO(olds); 22233 olds = (smallJsont*) allocSmallInt(1); 22234 r = replaceJsonSmallStringO(self, olds, news,1); 22235 ck_assert_ptr_eq(r, null); 22236 terminateO(olds); 22237 terminateO(news); 22238 olds = allocSmallJson(); 22239 news = (smallStringt*) allocSmallInt(1); 22240 r = replaceJsonSmallStringO(self, olds, news,1); 22241 ck_assert_ptr_eq(r, null); 22242 terminateO(news); 22243 news = allocSmallString(""); 22244 // empty string 22245 freeO(self); 22246 setTopSO(self, ""); 22247 freeO(olds); 22248 setTopSO(olds, "##"); 22249 r = replaceJsonSmallStringO(self, olds, NULL,1); 22250 ck_assert_ptr_ne(r, null); 22251 s = toStringO(r); 22252 ck_assert_str_eq(s, ""); 22253 free(s); 22254 // empty old delimiter 22255 freeO(self); 22256 setTopSO(self, "qwe"); 22257 freeO(olds); 22258 setTopSO(olds, ""); 22259 setValO(news, "|"); 22260 ck_assert_ptr_eq(replaceJsonSmallStringO(self, olds, news,1), NULL); 22261 // NULL old delimiter 22262 ck_assert_ptr_eq(replaceJsonSmallStringO(self, NULL, news,1), NULL); 22263 // NULL string 22264 freeO(self); 22265 ck_assert_ptr_eq(replaceJsonSmallStringO(self, olds, news,1), NULL); 22266 terminateO(olds); 22267 terminateO(news); 22268 terminateO(self); 22269 22270 } 22271 22272 22273 void replaceJsonSSmallJsonT(void) { 22274 22275 smallJsont* r; 22276 smallJsont *self = allocSmallJson(); 22277 setTopSO(self, "#ee#ee#ad"); 22278 smallJsont *olds = allocSmallJson(); 22279 const char *news; 22280 22281 // replace string, multiple character new delimeter 22282 freeO(olds); 22283 setTopSO(olds, "#"); 22284 news = "^^"; 22285 r = replaceJsonSO(self, olds, news, 0); 22286 ck_assert_ptr_ne(r, null); 22287 char *s = toStringO(r); 22288 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22289 free(s); 22290 // replace string, multiple character old delimeter 22291 freeO(self); 22292 setTopSO(self, "AA##ee##ee#"); 22293 freeO(olds); 22294 setTopSO(olds, "##"); 22295 news = "|"; 22296 r = replaceJsonSO(self, olds, news, 0); 22297 ck_assert_ptr_ne(r, null); 22298 s = toStringO(r); 22299 ck_assert_str_eq(s, "AA|ee|ee#"); 22300 free(s); 22301 // replace one time at the start of string 22302 freeO(self); 22303 setTopSO(self, "#ee#ee#ad"); 22304 freeO(olds); 22305 setTopSO(olds, "#"); 22306 news = "^^"; 22307 r = replaceJsonSO(self, olds, news,1); 22308 ck_assert_ptr_ne(r, null); 22309 s = toStringO(r); 22310 ck_assert_str_eq(s, "^^ee#ee#ad"); 22311 free(s); 22312 // replace one time 22313 freeO(self); 22314 setTopSO(self, "AA##ee##ee#"); 22315 freeO(olds); 22316 setTopSO(olds, "##"); 22317 news = "|"; 22318 r = replaceJsonSO(self, olds, news,1); 22319 ck_assert_ptr_ne(r, null); 22320 s = toStringO(r); 22321 ck_assert_str_eq(s, "AA|ee##ee#"); 22322 free(s); 22323 // NULL new delimiter, one time: same as empty delimiter 22324 freeO(self); 22325 setTopSO(self, "AA##ee##ee#"); 22326 freeO(olds); 22327 setTopSO(olds, "##"); 22328 r = replaceJsonSO(self, olds, NULL,1); 22329 ck_assert_ptr_ne(r, null); 22330 s = toStringO(r); 22331 ck_assert_str_eq(s, "AAee##ee#"); 22332 free(s); 22333 // non json string 22334 freeO(olds); 22335 setTopIntO(olds, 1); 22336 r = replaceJsonSO(self, olds, news,1); 22337 ck_assert_ptr_eq(r, null); 22338 // non json object 22339 terminateO(olds); 22340 olds = (smallJsont*) allocSmallInt(1); 22341 r = replaceJsonSO(self, olds, news,1); 22342 ck_assert_ptr_eq(r, null); 22343 terminateO(olds); 22344 // empty string 22345 olds = allocSmallJson(); 22346 freeO(self); 22347 setTopSO(self, ""); 22348 setTopSO(olds, "##"); 22349 r = replaceJsonSO(self, olds, NULL,1); 22350 ck_assert_ptr_ne(r, null); 22351 s = toStringO(r); 22352 ck_assert_str_eq(s, ""); 22353 free(s); 22354 // empty old delimiter 22355 freeO(self); 22356 setTopSO(self, "qwe"); 22357 freeO(olds); 22358 setTopSO(olds, ""); 22359 news = "|"; 22360 ck_assert_ptr_eq(replaceJsonSO(self, olds, news,1), NULL); 22361 // NULL old delimiter 22362 ck_assert_ptr_eq(replaceJsonSO(self, NULL, news,1), NULL); 22363 // NULL string 22364 freeO(self); 22365 ck_assert_ptr_eq(replaceJsonSO(self, olds, news,1), NULL); 22366 terminateO(olds); 22367 terminateO(self); 22368 22369 } 22370 22371 22372 void replaceJsonCharSmallJsonT(void) { 22373 22374 smallJsont* r; 22375 smallJsont *self = allocSmallJson(); 22376 setTopSO(self, "#ee#ee#ad"); 22377 smallJsont *olds = allocSmallJson(); 22378 char news; 22379 22380 // replace string, multiple character new delimeter 22381 freeO(olds); 22382 setTopSO(olds, "#"); 22383 news = '^'; 22384 r = replaceJsonCharO(self, olds, news, 0); 22385 ck_assert_ptr_ne(r, null); 22386 char *s = toStringO(r); 22387 ck_assert_str_eq(s, "^ee^ee^ad"); 22388 free(s); 22389 // replace string, multiple character old delimeter 22390 freeO(self); 22391 setTopSO(self, "AA##ee##ee#"); 22392 freeO(olds); 22393 setTopSO(olds, "##"); 22394 news = '|'; 22395 r = replaceJsonCharO(self, olds, news, 0); 22396 ck_assert_ptr_ne(r, null); 22397 s = toStringO(r); 22398 ck_assert_str_eq(s, "AA|ee|ee#"); 22399 free(s); 22400 // replace one time at the start of string 22401 freeO(self); 22402 setTopSO(self, "#ee#ee#ad"); 22403 freeO(olds); 22404 setTopSO(olds, "#"); 22405 news = '^'; 22406 r = replaceJsonCharO(self, olds, news,1); 22407 ck_assert_ptr_ne(r, null); 22408 s = toStringO(r); 22409 ck_assert_str_eq(s, "^ee#ee#ad"); 22410 free(s); 22411 // replace one time 22412 freeO(self); 22413 setTopSO(self, "AA##ee##ee#"); 22414 freeO(olds); 22415 setTopSO(olds, "##"); 22416 news = '|'; 22417 r = replaceJsonCharO(self, olds, news,1); 22418 ck_assert_ptr_ne(r, null); 22419 s = toStringO(r); 22420 ck_assert_str_eq(s, "AA|ee##ee#"); 22421 free(s); 22422 // non json string 22423 freeO(self); 22424 setTopSO(self, "AA##ee##ee#"); 22425 freeO(olds); 22426 setTopIntO(olds, 1); 22427 r = replaceJsonCharO(self, olds, news,1); 22428 ck_assert_ptr_eq(r, null); 22429 // non json object 22430 terminateO(olds); 22431 olds = (smallJsont*) allocSmallInt(1); 22432 r = replaceJsonCharO(self, olds, news,1); 22433 ck_assert_ptr_eq(r, null); 22434 terminateO(olds); 22435 // empty string 22436 olds = allocSmallJson(); 22437 freeO(self); 22438 setTopSO(self, ""); 22439 setTopSO(olds, "##"); 22440 r = replaceJsonCharO(self, olds, news,1); 22441 ck_assert_ptr_ne(r, null); 22442 s = toStringO(r); 22443 ck_assert_str_eq(s, ""); 22444 free(s); 22445 // empty old delimiter 22446 freeO(self); 22447 setTopSO(self, "qwe"); 22448 freeO(olds); 22449 setTopSO(olds, ""); 22450 news = '|'; 22451 ck_assert_ptr_eq(replaceJsonCharO(self, olds, news,1), NULL); 22452 // NULL old delimiter 22453 ck_assert_ptr_eq(replaceJsonCharO(self, NULL, news,1), NULL); 22454 // NULL string 22455 freeO(self); 22456 ck_assert_ptr_eq(replaceJsonCharO(self, olds, news,1), NULL); 22457 terminateO(olds); 22458 terminateO(self); 22459 22460 } 22461 22462 22463 void replaceSmallStringJsonSmallJsonT(void) { 22464 22465 smallJsont* r; 22466 smallJsont *self = allocSmallJson(); 22467 setTopSO(self, "#ee#ee#ad"); 22468 smallStringt *olds = allocSmallString(""); 22469 smallJsont *news = allocSmallJson(); 22470 22471 // replace string, multiple character new delimeter 22472 freeO(news); 22473 setValO(olds, "#"); 22474 setTopSO(news, "^^"); 22475 r = self->f->replaceSmallStringJson(self, olds, news, 0); 22476 ck_assert_ptr_ne(r, null); 22477 char *s = toStringO(r); 22478 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22479 free(s); 22480 // replace string, multiple character old delimeter 22481 freeO(self); 22482 setTopSO(self, "AA##ee##ee#"); 22483 freeO(news); 22484 setValO(olds, "##"); 22485 setTopSO(news, "|"); 22486 r = self->f->replaceSmallStringJson(self, olds, news, 0); 22487 ck_assert_ptr_ne(r, null); 22488 s = toStringO(r); 22489 ck_assert_str_eq(s, "AA|ee|ee#"); 22490 free(s); 22491 // replace one time at the start of string 22492 freeO(self); 22493 setTopSO(self, "#ee#ee#ad"); 22494 freeO(news); 22495 setValO(olds, "#"); 22496 setTopSO(news, "^^"); 22497 r = self->f->replaceSmallStringJson(self, olds, news,1); 22498 ck_assert_ptr_ne(r, null); 22499 s = toStringO(r); 22500 ck_assert_str_eq(s, "^^ee#ee#ad"); 22501 free(s); 22502 // replace one time 22503 freeO(self); 22504 setTopSO(self, "AA##ee##ee#"); 22505 freeO(news); 22506 setValO(olds, "##"); 22507 setTopSO(news, "|"); 22508 r = self->f->replaceSmallStringJson(self, olds, news,1); 22509 ck_assert_ptr_ne(r, null); 22510 s = toStringO(r); 22511 ck_assert_str_eq(s, "AA|ee##ee#"); 22512 free(s); 22513 // NULL new delimiter, one time: same as empty delimiter 22514 freeO(self); 22515 setTopSO(self, "AA##ee##ee#"); 22516 setValO(olds, "##"); 22517 r = self->f->replaceSmallStringJson(self, olds, NULL,1); 22518 ck_assert_ptr_ne(r, null); 22519 s = toStringO(r); 22520 ck_assert_str_eq(s, "AAee##ee#"); 22521 free(s); 22522 // non json string 22523 freeO(news); 22524 setTopIntO(news, 1); 22525 r = self->f->replaceSmallStringJson(self, olds, news,1); 22526 ck_assert_ptr_eq(r, null); 22527 // non json object 22528 terminateO(olds); 22529 olds = (smallStringt*) allocSmallInt(1); 22530 r = self->f->replaceSmallStringJson(self, olds, news,1); 22531 ck_assert_ptr_eq(r, null); 22532 terminateO(olds); 22533 terminateO(news); 22534 olds = allocSmallString(""); 22535 news = (smallJsont*) allocSmallInt(1); 22536 r = self->f->replaceSmallStringJson(self, olds, news,1); 22537 ck_assert_ptr_eq(r, null); 22538 terminateO(news); 22539 news = allocSmallJson(); 22540 // empty string 22541 freeO(self); 22542 setTopSO(self, ""); 22543 setValO(olds, "##"); 22544 r = self->f->replaceSmallStringJson(self, olds, NULL,1); 22545 ck_assert_ptr_ne(r, null); 22546 s = toStringO(r); 22547 ck_assert_str_eq(s, ""); 22548 free(s); 22549 // empty old delimiter 22550 freeO(self); 22551 setTopSO(self, "qwe"); 22552 freeO(news); 22553 setValO(olds, ""); 22554 setTopSO(news, "|"); 22555 ck_assert_ptr_eq(self->f->replaceSmallStringJson(self, olds, news,1), NULL); 22556 // NULL old delimiter 22557 ck_assert_ptr_eq(self->f->replaceSmallStringJson(self, NULL, news,1), NULL); 22558 // NULL string 22559 freeO(self); 22560 ck_assert_ptr_eq(self->f->replaceSmallStringJson(self, olds, news,1), NULL); 22561 terminateO(olds); 22562 terminateO(news); 22563 terminateO(self); 22564 22565 } 22566 22567 22568 void replaceSJsonSmallJsonT(void) { 22569 22570 smallJsont* r; 22571 smallJsont *self = allocSmallJson(); 22572 setTopSO(self, "#ee#ee#ad"); 22573 const char *olds; 22574 smallJsont *news = allocSmallJson(); 22575 22576 // replace string, multiple character new delimeter 22577 freeO(news); 22578 olds = "#"; 22579 setTopSO(news, "^^"); 22580 r = replaceSJsonO(self, olds, news, 0); 22581 ck_assert_ptr_ne(r, null); 22582 char *s = toStringO(r); 22583 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22584 free(s); 22585 // replace string, multiple character old delimeter 22586 freeO(self); 22587 setTopSO(self, "AA##ee##ee#"); 22588 freeO(news); 22589 olds = "##"; 22590 setTopSO(news, "|"); 22591 r = replaceSJsonO(self, olds, news, 0); 22592 ck_assert_ptr_ne(r, null); 22593 s = toStringO(r); 22594 ck_assert_str_eq(s, "AA|ee|ee#"); 22595 free(s); 22596 // replace one time at the start of string 22597 freeO(self); 22598 setTopSO(self, "#ee#ee#ad"); 22599 freeO(news); 22600 olds = "#"; 22601 setTopSO(news, "^^"); 22602 r = replaceSJsonO(self, olds, news,1); 22603 ck_assert_ptr_ne(r, null); 22604 s = toStringO(r); 22605 ck_assert_str_eq(s, "^^ee#ee#ad"); 22606 free(s); 22607 // replace one time 22608 freeO(self); 22609 setTopSO(self, "AA##ee##ee#"); 22610 freeO(news); 22611 olds = "##"; 22612 setTopSO(news, "|"); 22613 r = replaceSJsonO(self, olds, news,1); 22614 ck_assert_ptr_ne(r, null); 22615 s = toStringO(r); 22616 ck_assert_str_eq(s, "AA|ee##ee#"); 22617 free(s); 22618 // NULL new delimiter, one time: same as empty delimiter 22619 freeO(self); 22620 setTopSO(self, "AA##ee##ee#"); 22621 olds = "##"; 22622 r = replaceSJsonO(self, olds, NULL,1); 22623 ck_assert_ptr_ne(r, null); 22624 s = toStringO(r); 22625 ck_assert_str_eq(s, "AAee##ee#"); 22626 free(s); 22627 // non json string 22628 freeO(news); 22629 olds = "e"; 22630 setTopIntO(news, 1); 22631 r = replaceSJsonO(self, olds, news,1); 22632 ck_assert_ptr_eq(r, null); 22633 // non json object 22634 terminateO(news); 22635 news = (smallJsont*) allocSmallInt(1); 22636 r = replaceSJsonO(self, olds, news,1); 22637 ck_assert_ptr_eq(r, null); 22638 terminateO(news); 22639 news = allocSmallJson(); 22640 // empty string 22641 freeO(self); 22642 setTopSO(self, ""); 22643 olds = "##"; 22644 r = replaceSJsonO(self, olds, NULL,1); 22645 ck_assert_ptr_ne(r, null); 22646 s = toStringO(r); 22647 ck_assert_str_eq(s, ""); 22648 free(s); 22649 // empty old delimiter 22650 freeO(self); 22651 setTopSO(self, "qwe"); 22652 freeO(news); 22653 olds = ""; 22654 setTopSO(news, "|"); 22655 ck_assert_ptr_eq(replaceSJsonO(self, olds, news,1), NULL); 22656 // NULL old delimiter 22657 ck_assert_ptr_eq(replaceSJsonO(self, NULL, news,1), NULL); 22658 // NULL string 22659 freeO(self); 22660 ck_assert_ptr_eq(replaceSJsonO(self, olds, news,1), NULL); 22661 terminateO(news); 22662 terminateO(self); 22663 22664 } 22665 22666 22667 void replaceCharJsonSmallJsonT(void) { 22668 22669 smallJsont* r; 22670 smallJsont *self = allocSmallJson(); 22671 setTopSO(self, "#ee#ee#ad"); 22672 char olds; 22673 smallJsont *news = allocSmallJson(); 22674 22675 // replace string, multiple character new delimeter 22676 freeO(news); 22677 olds = '#'; 22678 setTopSO(news, "^^"); 22679 r = replaceCharJsonO(self, olds, news, 0); 22680 ck_assert_ptr_ne(r, null); 22681 char *s = toStringO(r); 22682 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22683 free(s); 22684 // replace string, multiple character old delimeter 22685 freeO(self); 22686 setTopSO(self, "AA#ee#ee"); 22687 freeO(news); 22688 olds = '#'; 22689 setTopSO(news, "|"); 22690 r = replaceCharJsonO(self, olds, news, 0); 22691 ck_assert_ptr_ne(r, null); 22692 s = toStringO(r); 22693 ck_assert_str_eq(s, "AA|ee|ee"); 22694 free(s); 22695 // replace one time at the start of string 22696 freeO(self); 22697 setTopSO(self, "#ee#ee#ad"); 22698 freeO(news); 22699 olds = '#'; 22700 setTopSO(news, "^^"); 22701 r = replaceCharJsonO(self, olds, news,1); 22702 ck_assert_ptr_ne(r, null); 22703 s = toStringO(r); 22704 ck_assert_str_eq(s, "^^ee#ee#ad"); 22705 free(s); 22706 // replace one time 22707 freeO(self); 22708 setTopSO(self, "AA#ee##ee#"); 22709 freeO(news); 22710 olds = '#'; 22711 setTopSO(news, "|"); 22712 r = replaceCharJsonO(self, olds, news,1); 22713 ck_assert_ptr_ne(r, null); 22714 s = toStringO(r); 22715 ck_assert_str_eq(s, "AA|ee##ee#"); 22716 free(s); 22717 // NULL new delimiter, one time: same as empty delimiter 22718 freeO(self); 22719 setTopSO(self, "AA#ee##ee#"); 22720 olds = '#'; 22721 r = replaceCharJsonO(self, olds, NULL,1); 22722 ck_assert_ptr_ne(r, null); 22723 s = toStringO(r); 22724 ck_assert_str_eq(s, "AAee##ee#"); 22725 free(s); 22726 // non json string 22727 freeO(news); 22728 olds = 'e'; 22729 setTopIntO(news, 1); 22730 r = replaceCharJsonO(self, olds, news,1); 22731 ck_assert_ptr_eq(r, null); 22732 // non json object 22733 terminateO(news); 22734 news = (smallJsont*) allocSmallInt(1); 22735 r = replaceCharJsonO(self, olds, news,1); 22736 ck_assert_ptr_eq(r, null); 22737 terminateO(news); 22738 news = allocSmallJson(); 22739 // empty string 22740 freeO(self); 22741 setTopSO(self, ""); 22742 olds = '#'; 22743 r = replaceCharJsonO(self, olds, NULL,1); 22744 ck_assert_ptr_ne(r, null); 22745 s = toStringO(r); 22746 ck_assert_str_eq(s, ""); 22747 free(s); 22748 // NULL string 22749 freeO(self); 22750 freeO(news); 22751 setTopSO(news, "|"); 22752 ck_assert_ptr_eq(replaceCharJsonO(self, olds, news,1), NULL); 22753 terminateO(news); 22754 terminateO(self); 22755 22756 } 22757 22758 22759 void replaceManySmallJsonT(void) { 22760 22761 smallJsont* r; 22762 smallJsont *self = allocSmallJson(); 22763 setTopSO(self, ""); 22764 22765 // replace string, multiple character new delimeter 22766 freeO(self); 22767 setTopSO(self, "#ee#ee#ad"); 22768 r = replaceManyO(self, "#","^^","ad","AD"); 22769 ck_assert_ptr_ne(r, null); 22770 char *s = toStringO(r); 22771 ck_assert_str_eq(s, "^^ee^^ee^^AD"); 22772 free(s); 22773 // replace string, empty new delimeter 22774 freeO(self); 22775 setTopSO(self, "#ee#ee#ad"); 22776 r = replaceManyO(self, "#","","ad","AD"); 22777 ck_assert_ptr_ne(r, null); 22778 s = toStringO(r); 22779 ck_assert_str_eq(s, "eeeeAD"); 22780 free(s); 22781 // not enough olds:news pairs 22782 freeO(self); 22783 setTopSO(self, "#ee#ee#ad"); 22784 r = replaceManyO(self, "#","","ad"); 22785 ck_assert_ptr_ne(r, null); 22786 s = toStringO(r); 22787 ck_assert_str_eq(s, "eeeead"); 22788 free(s); 22789 // NULL new delimiter: same as only 2 parameters or not enough olds:news pairs 22790 freeO(self); 22791 setTopSO(self, "AA##ee##ee#"); 22792 r = replaceManyO(self, "##",NULL); 22793 ck_assert_ptr_eq(r, null); 22794 // empty string 22795 freeO(self); 22796 setTopSO(self, ""); 22797 r = replaceManyO(self, "##", ""); 22798 ck_assert_ptr_ne(r, null); 22799 s = toStringO(r); 22800 ck_assert_str_eq(s, ""); 22801 free(s); 22802 // empty string many pairs 22803 freeO(self); 22804 setTopSO(self, ""); 22805 r = replaceManyO(self, "##", "", "$$", ""); 22806 ck_assert_ptr_ne(r, null); 22807 s = toStringO(r); 22808 ck_assert_str_eq(s, ""); 22809 free(s); 22810 // empty string many pairs empty olds 22811 freeO(self); 22812 setTopSO(self, ""); 22813 r = replaceManyO(self, "##", "", "", ""); 22814 ck_assert_ptr_ne(r, null); 22815 s = toStringO(r); 22816 ck_assert_str_eq(s, ""); 22817 free(s); 22818 // empty string and NULL old delimiter 22819 freeO(self); 22820 setTopSO(self, ""); 22821 r = replaceManyO(self, NULL,"|"); 22822 ck_assert_ptr_ne(r, null); 22823 s = toStringO(r); 22824 ck_assert_str_eq(s, ""); 22825 free(s); 22826 // empty string and NULL old delimiter not first - same as replace empty string 22827 freeO(self); 22828 setTopSO(self, ""); 22829 r = replaceManyO(self,"##","|", NULL,"|"); 22830 ck_assert_ptr_ne(r, null); 22831 s = toStringO(r); 22832 ck_assert_str_eq(s, ""); 22833 free(s); 22834 // empty old delimiter 22835 freeO(self); 22836 setTopSO(self, "AA##ee##ee#"); 22837 ck_assert_ptr_eq(replaceManyO(self, "","|", "AA", "BB"), NULL); 22838 // empty old delimiter not first 22839 ck_assert_ptr_eq(replaceManyO(self, "##","|", "", "BB"), NULL); 22840 // NULL string 22841 freeO(self); 22842 ck_assert_ptr_eq(replaceManyO(self, "##","|"), NULL); 22843 terminateO(self); 22844 22845 } 22846 22847 22848 void icReplaceSmallJsonT(void) { 22849 22850 smallJsont* r; 22851 smallJsont *self = allocSmallJson(); 22852 setTopSO(self, "BeebeeBad"); 22853 22854 // replace string, multiple character new delimeter 22855 r = icReplaceO(self, "b","^^", 0); 22856 ck_assert_ptr_ne(r, null); 22857 char *s = toStringO(r); 22858 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22859 free(s); 22860 // replace string, multiple character old delimeter 22861 freeO(self); 22862 setTopSO(self, "AA##ee##ee#"); 22863 r = icReplaceO(self, "##","|", 0); 22864 ck_assert_ptr_ne(r, null); 22865 s = toStringO(r); 22866 ck_assert_str_eq(s, "AA|ee|ee#"); 22867 free(s); 22868 // replace one time at the start of string 22869 freeO(self); 22870 setTopSO(self, "#ee#ee#ad"); 22871 r = icReplaceO(self, "#","^^",1); 22872 ck_assert_ptr_ne(r, null); 22873 s = toStringO(r); 22874 ck_assert_str_eq(s, "^^ee#ee#ad"); 22875 free(s); 22876 // replace one time 22877 freeO(self); 22878 setTopSO(self, "AA##ee##ee#"); 22879 r = icReplaceO(self, "##","|",1); 22880 ck_assert_ptr_ne(r, null); 22881 s = toStringO(r); 22882 ck_assert_str_eq(s, "AA|ee##ee#"); 22883 free(s); 22884 // NULL new delimiter, one time: same as empty delimiter 22885 freeO(self); 22886 setTopSO(self, "AA##ee##ee#"); 22887 r = icReplaceO(self, "##",NULL,1); 22888 ck_assert_ptr_ne(r, null); 22889 s = toStringO(r); 22890 ck_assert_str_eq(s, "AAee##ee#"); 22891 free(s); 22892 // empty string 22893 freeO(self); 22894 setTopSO(self, ""); 22895 r = icReplaceO(self, "##",NULL,1); 22896 ck_assert_ptr_ne(r, null); 22897 s = toStringO(r); 22898 ck_assert_str_eq(s, ""); 22899 free(s); 22900 // empty old delimiter 22901 freeO(self); 22902 setTopSO(self, "qwe"); 22903 ck_assert_ptr_eq(icReplaceO(self, "","|",1), NULL); 22904 // NULL old delimiter 22905 ck_assert_ptr_eq(icReplaceO(self, NULL,"|",1), NULL); 22906 // empty old delimiter 22907 ck_assert_ptr_eq(icReplaceO(self, "","|",1), NULL); 22908 // NULL string 22909 freeO(self); 22910 ck_assert_ptr_eq(icReplaceO(self, "##","|",1), NULL); 22911 terminateO(self); 22912 22913 } 22914 22915 22916 void icReplaceCharSSmallJsonT(void) { 22917 22918 smallJsont* r; 22919 smallJsont *self = allocSmallJson(); 22920 setTopSO(self, ""); 22921 22922 // replace string, multiple character new delimeter 22923 freeO(self); 22924 setTopSO(self, "BeebeeBad"); 22925 r = icReplaceCharSO(self, 'B',"^^", 0); 22926 ck_assert_ptr_ne(r, null); 22927 char *s = toStringO(r); 22928 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 22929 free(s); 22930 // replace one time at the start of string 22931 freeO(self); 22932 setTopSO(self, "#ee#ee#ad"); 22933 r = icReplaceCharSO(self, '#',"^^",1); 22934 ck_assert_ptr_ne(r, null); 22935 s = toStringO(r); 22936 ck_assert_str_eq(s, "^^ee#ee#ad"); 22937 free(s); 22938 // replace one time 22939 freeO(self); 22940 setTopSO(self, "AA##ee##ee#"); 22941 r = icReplaceCharSO(self, '#',"|",1); 22942 ck_assert_ptr_ne(r, null); 22943 s = toStringO(r); 22944 ck_assert_str_eq(s, "AA|#ee##ee#"); 22945 free(s); 22946 // NULL new delimiter, one time: same as empty delimiter 22947 freeO(self); 22948 setTopSO(self, "AA#ee##ee#"); 22949 r = icReplaceCharSO(self, '#',NULL,1); 22950 ck_assert_ptr_ne(r, null); 22951 s = toStringO(r); 22952 ck_assert_str_eq(s, "AAee##ee#"); 22953 free(s); 22954 // empty string 22955 freeO(self); 22956 setTopSO(self, ""); 22957 r = icReplaceCharSO(self, '#',NULL,1); 22958 ck_assert_ptr_ne(r, null); 22959 s = toStringO(r); 22960 ck_assert_str_eq(s, ""); 22961 free(s); 22962 // empty old delimiter 22963 freeO(self); 22964 setTopSO(self, "qwe"); 22965 ck_assert_ptr_eq(icReplaceCharSO(self, 0,"|",1), NULL); 22966 // NULL string 22967 freeO(self); 22968 ck_assert_ptr_eq(icReplaceCharSO(self, '#',"|",1), NULL); 22969 terminateO(self); 22970 22971 } 22972 22973 22974 void icReplaceSCharSmallJsonT(void) { 22975 22976 smallJsont* r; 22977 smallJsont *self = allocSmallJson(); 22978 setTopSO(self, ""); 22979 22980 // replace string, multiple character new delimeter 22981 freeO(self); 22982 setTopSO(self, "BeebeeBad"); 22983 r = icReplaceSCharO(self, "b",'^',0); 22984 ck_assert_ptr_ne(r, null); 22985 char *s = toStringO(r); 22986 ck_assert_str_eq(s, "^ee^ee^ad"); 22987 free(s); 22988 // replace string, multiple character old delimeter 22989 freeO(self); 22990 setTopSO(self, "AA##ee##ee#"); 22991 r = icReplaceSCharO(self, "##",'|',0); 22992 ck_assert_ptr_ne(r, null); 22993 s = toStringO(r); 22994 ck_assert_str_eq(s, "AA|ee|ee#"); 22995 free(s); 22996 // replace string empty char, multiple character old delimeter 22997 freeO(self); 22998 setTopSO(self, "AA##ee##ee#"); 22999 r = icReplaceSCharO(self, "##", 0,0); 23000 ck_assert_ptr_ne(r, null); 23001 s = toStringO(r); 23002 ck_assert_str_eq(s, "AAeeee#"); 23003 free(s); 23004 // replace one time at the start of string 23005 freeO(self); 23006 setTopSO(self, "#ee#ee#ad"); 23007 r = icReplaceSCharO(self, "#",'^',1); 23008 ck_assert_ptr_ne(r, null); 23009 s = toStringO(r); 23010 ck_assert_str_eq(s, "^ee#ee#ad"); 23011 free(s); 23012 // replace one time 23013 freeO(self); 23014 setTopSO(self, "AA##ee##ee#"); 23015 r = icReplaceSCharO(self, "##",'|',1); 23016 ck_assert_ptr_ne(r, null); 23017 s = toStringO(r); 23018 ck_assert_str_eq(s, "AA|ee##ee#"); 23019 free(s); 23020 // empty string 23021 freeO(self); 23022 setTopSO(self, ""); 23023 r = icReplaceSCharO(self, "##",0,1); 23024 ck_assert_ptr_ne(r, null); 23025 s = toStringO(r); 23026 ck_assert_str_eq(s, ""); 23027 free(s); 23028 // empty old delimiter 23029 freeO(self); 23030 setTopSO(self, "qwe"); 23031 ck_assert_ptr_eq(icReplaceSCharO(self, "",'|',1), NULL); 23032 // NULL old delimiter 23033 ck_assert_ptr_eq(icReplaceSCharO(self, NULL,'|',1), NULL); 23034 // NULL string 23035 freeO(self); 23036 ck_assert_ptr_eq(icReplaceSCharO(self, "##",'|',1), NULL); 23037 terminateO(self); 23038 23039 } 23040 23041 23042 void icReplaceCharCharSmallJsonT(void) { 23043 23044 smallJsont* r; 23045 smallJsont *self = allocSmallJson(); 23046 setTopSO(self, ""); 23047 23048 // replace string, multiple character new delimeter 23049 freeO(self); 23050 setTopSO(self, "beeBeebad"); 23051 r = icReplaceCharCharO(self, 'b','^', 0); 23052 ck_assert_ptr_ne(r, null); 23053 char *s = toStringO(r); 23054 ck_assert_str_eq(s, "^ee^ee^ad"); 23055 free(s); 23056 // replace one time at the start of string 23057 freeO(self); 23058 setTopSO(self, "#ee#ee#ad"); 23059 r = icReplaceCharCharO(self, '#','^',1); 23060 ck_assert_ptr_ne(r, null); 23061 s = toStringO(r); 23062 ck_assert_str_eq(s, "^ee#ee#ad"); 23063 free(s); 23064 // replace one time 23065 freeO(self); 23066 setTopSO(self, "AA#ee##ee#"); 23067 r = icReplaceCharCharO(self, '#','|',1); 23068 ck_assert_ptr_ne(r, null); 23069 s = toStringO(r); 23070 ck_assert_str_eq(s, "AA|ee##ee#"); 23071 free(s); 23072 // empty string 23073 freeO(self); 23074 setTopSO(self, ""); 23075 r = icReplaceCharCharO(self, '#','^',1); 23076 ck_assert_ptr_ne(r, null); 23077 s = toStringO(r); 23078 ck_assert_str_eq(s, ""); 23079 free(s); 23080 // empty old delimiter 23081 freeO(self); 23082 setTopSO(self, "qwe"); 23083 ck_assert_ptr_eq(icReplaceCharCharO(self, 0,'|',1), NULL); 23084 // NULL string 23085 freeO(self); 23086 ck_assert_ptr_eq(icReplaceCharCharO(self, '#','|',1), NULL); 23087 terminateO(self); 23088 23089 } 23090 23091 23092 void icReplaceSmallStringSmallStringSmallJsonT(void) { 23093 23094 smallJsont* r; 23095 smallJsont *self = allocSmallJson(); 23096 setTopSO(self, "beebeebad"); 23097 smallStringt *olds = allocSmallString(""); 23098 smallStringt *news = allocSmallString(""); 23099 23100 // replace string, multiple character new delimeter 23101 setValO(olds, "B"); 23102 setValO(news, "^^"); 23103 r = icReplaceSmallStringSmallStringO(self, olds, news, 0); 23104 ck_assert_ptr_ne(r, null); 23105 char *s = toStringO(r); 23106 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23107 free(s); 23108 // replace string, multiple character old delimeter 23109 freeO(self); 23110 setTopSO(self, "AA##ee##ee#"); 23111 setValO(olds, "##"); 23112 setValO(news, "|"); 23113 r = icReplaceSmallStringSmallStringO(self, olds, news, 0); 23114 ck_assert_ptr_ne(r, null); 23115 s = toStringO(r); 23116 ck_assert_str_eq(s, "AA|ee|ee#"); 23117 free(s); 23118 // replace one time at the start of string 23119 freeO(self); 23120 setTopSO(self, "#ee#ee#ad"); 23121 setValO(olds, "#"); 23122 setValO(news, "^^"); 23123 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 23124 ck_assert_ptr_ne(r, null); 23125 s = toStringO(r); 23126 ck_assert_str_eq(s, "^^ee#ee#ad"); 23127 free(s); 23128 // replace one time 23129 freeO(self); 23130 setTopSO(self, "AA##ee##ee#"); 23131 setValO(olds, "##"); 23132 setValO(news, "|"); 23133 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 23134 ck_assert_ptr_ne(r, null); 23135 s = toStringO(r); 23136 ck_assert_str_eq(s, "AA|ee##ee#"); 23137 free(s); 23138 // NULL new delimiter, one time: same as empty delimiter 23139 freeO(self); 23140 setTopSO(self, "AA##ee##ee#"); 23141 setValO(olds, "##"); 23142 r = icReplaceSmallStringSmallStringO(self, olds, NULL,1); 23143 ck_assert_ptr_ne(r, null); 23144 s = toStringO(r); 23145 ck_assert_str_eq(s, "AAee##ee#"); 23146 free(s); 23147 // non smallString object 23148 terminateO(olds); 23149 olds = (smallStringt*) allocSmallInt(1); 23150 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 23151 ck_assert_ptr_eq(r, null); 23152 terminateO(olds); 23153 terminateO(news); 23154 olds = allocSmallString(""); 23155 news = (smallStringt*) allocSmallInt(1); 23156 r = icReplaceSmallStringSmallStringO(self, olds, news,1); 23157 ck_assert_ptr_eq(r, null); 23158 terminateO(news); 23159 news = allocSmallString(""); 23160 // empty string 23161 freeO(self); 23162 setTopSO(self, ""); 23163 setValO(olds, "##"); 23164 r = icReplaceSmallStringSmallStringO(self, olds, NULL,1); 23165 ck_assert_ptr_ne(r, null); 23166 s = toStringO(r); 23167 ck_assert_str_eq(s, ""); 23168 free(s); 23169 // empty old delimiter 23170 freeO(self); 23171 setTopSO(self, "qwe"); 23172 setValO(olds, ""); 23173 setValO(news, "|"); 23174 ck_assert_ptr_eq(icReplaceSmallStringSmallStringO(self, olds, news,1), NULL); 23175 // NULL old delimiter 23176 ck_assert_ptr_eq(icReplaceSmallStringSmallStringO(self, NULL, news,1), NULL); 23177 // NULL string 23178 freeO(self); 23179 ck_assert_ptr_eq(icReplaceSmallStringSmallStringO(self, olds, news,1), NULL); 23180 terminateO(olds); 23181 terminateO(news); 23182 terminateO(self); 23183 23184 } 23185 23186 23187 void icReplaceSmallStringSSmallJsonT(void) { 23188 23189 smallJsont* r; 23190 smallJsont *self = allocSmallJson(); 23191 setTopSO(self, "beebeebad"); 23192 smallStringt *olds = allocSmallString(""); 23193 const char *news; 23194 23195 // replace string, multiple character new delimeter 23196 setValO(olds, "B"); 23197 news = "^^"; 23198 r = icReplaceSmallStringSO(self, olds, news, 0); 23199 ck_assert_ptr_ne(r, null); 23200 char *s = toStringO(r); 23201 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23202 free(s); 23203 // replace string, multiple character old delimeter 23204 freeO(self); 23205 setTopSO(self, "AA##ee##ee#"); 23206 setValO(olds, "##"); 23207 news = "|"; 23208 r = icReplaceSmallStringSO(self, olds, news, 0); 23209 ck_assert_ptr_ne(r, null); 23210 s = toStringO(r); 23211 ck_assert_str_eq(s, "AA|ee|ee#"); 23212 free(s); 23213 // replace one time at the start of string 23214 freeO(self); 23215 setTopSO(self, "#ee#ee#ad"); 23216 setValO(olds, "#"); 23217 news = "^^"; 23218 r = icReplaceSmallStringSO(self, olds, news,1); 23219 ck_assert_ptr_ne(r, null); 23220 s = toStringO(r); 23221 ck_assert_str_eq(s, "^^ee#ee#ad"); 23222 free(s); 23223 // replace one time 23224 freeO(self); 23225 setTopSO(self, "AA##ee##ee#"); 23226 setValO(olds, "##"); 23227 news = "|"; 23228 r = icReplaceSmallStringSO(self, olds, news,1); 23229 ck_assert_ptr_ne(r, null); 23230 s = toStringO(r); 23231 ck_assert_str_eq(s, "AA|ee##ee#"); 23232 free(s); 23233 // NULL new delimiter, one time: same as empty delimiter 23234 freeO(self); 23235 setTopSO(self, "AA##ee##ee#"); 23236 setValO(olds, "##"); 23237 r = icReplaceSmallStringSO(self, olds, NULL,1); 23238 ck_assert_ptr_ne(r, null); 23239 s = toStringO(r); 23240 ck_assert_str_eq(s, "AAee##ee#"); 23241 free(s); 23242 // non smallString object 23243 terminateO(olds); 23244 olds = (smallStringt*) allocSmallInt(1); 23245 r = icReplaceSmallStringSO(self, olds, news,1); 23246 ck_assert_ptr_eq(r, null); 23247 terminateO(olds); 23248 olds = allocSmallString(""); 23249 // empty string 23250 freeO(self); 23251 setTopSO(self, ""); 23252 setValO(olds, "##"); 23253 r = icReplaceSmallStringSO(self, olds, NULL,1); 23254 ck_assert_ptr_ne(r, null); 23255 s = toStringO(r); 23256 ck_assert_str_eq(s, ""); 23257 free(s); 23258 // empty old delimiter 23259 freeO(self); 23260 setTopSO(self, "qwe"); 23261 setValO(olds, ""); 23262 news = "|"; 23263 ck_assert_ptr_eq(icReplaceSmallStringSO(self, olds, news,1), NULL); 23264 // NULL old delimiter 23265 ck_assert_ptr_eq(icReplaceSmallStringSO(self, NULL, news,1), NULL); 23266 // NULL string 23267 freeO(self); 23268 ck_assert_ptr_eq(icReplaceSmallStringSO(self, olds, news,1), NULL); 23269 terminateO(olds); 23270 terminateO(self); 23271 23272 } 23273 23274 23275 void icReplaceSmallStringCharSmallJsonT(void) { 23276 23277 smallJsont* r; 23278 smallJsont *self = allocSmallJson(); 23279 setTopSO(self, "beebeebad"); 23280 smallStringt *olds = allocSmallString(""); 23281 char news; 23282 23283 // replace string, multiple character new delimeter 23284 setValO(olds, "B"); 23285 news = '^'; 23286 r = icReplaceSmallStringCharO(self, olds, news, 0); 23287 ck_assert_ptr_ne(r, null); 23288 char *s = toStringO(r); 23289 ck_assert_str_eq(s, "^ee^ee^ad"); 23290 free(s); 23291 // replace string, multiple character old delimeter 23292 freeO(self); 23293 setTopSO(self, "AA##ee##ee#"); 23294 setValO(olds, "##"); 23295 news = '|'; 23296 r = icReplaceSmallStringCharO(self, olds, news, 0); 23297 ck_assert_ptr_ne(r, null); 23298 s = toStringO(r); 23299 ck_assert_str_eq(s, "AA|ee|ee#"); 23300 free(s); 23301 // replace one time at the start of string 23302 freeO(self); 23303 setTopSO(self, "#ee#ee#ad"); 23304 setValO(olds, "#"); 23305 news = '^'; 23306 r = icReplaceSmallStringCharO(self, olds, news,1); 23307 ck_assert_ptr_ne(r, null); 23308 s = toStringO(r); 23309 ck_assert_str_eq(s, "^ee#ee#ad"); 23310 free(s); 23311 // replace one time 23312 freeO(self); 23313 setTopSO(self, "AA##ee##ee#"); 23314 setValO(olds, "##"); 23315 news = '|'; 23316 r = icReplaceSmallStringCharO(self, olds, news,1); 23317 ck_assert_ptr_ne(r, null); 23318 s = toStringO(r); 23319 ck_assert_str_eq(s, "AA|ee##ee#"); 23320 free(s); 23321 // non smallString object 23322 terminateO(olds); 23323 olds = (smallStringt*) allocSmallInt(1); 23324 r = icReplaceSmallStringCharO(self, olds, news,1); 23325 ck_assert_ptr_eq(r, null); 23326 terminateO(olds); 23327 olds = allocSmallString(""); 23328 // empty string 23329 freeO(self); 23330 setTopSO(self, ""); 23331 setValO(olds, "##"); 23332 r = icReplaceSmallStringCharO(self, olds, news,1); 23333 ck_assert_ptr_ne(r, null); 23334 s = toStringO(r); 23335 ck_assert_str_eq(s, ""); 23336 free(s); 23337 // empty old delimiter 23338 freeO(self); 23339 setTopSO(self, "qwe"); 23340 setValO(olds, ""); 23341 news = '|'; 23342 ck_assert_ptr_eq(icReplaceSmallStringCharO(self, olds, news,1), NULL); 23343 // NULL old delimiter 23344 ck_assert_ptr_eq(icReplaceSmallStringCharO(self, NULL, news,1), NULL); 23345 // NULL string 23346 freeO(self); 23347 ck_assert_ptr_eq(icReplaceSmallStringCharO(self, olds, news,1), NULL); 23348 terminateO(olds); 23349 terminateO(self); 23350 23351 } 23352 23353 23354 void icReplaceSSmallStringSmallJsonT(void) { 23355 23356 smallJsont* r; 23357 smallJsont *self = allocSmallJson(); 23358 setTopSO(self, "beebeebad"); 23359 const char *olds; 23360 smallStringt *news = allocSmallString(""); 23361 23362 // replace string, multiple character new delimeter 23363 olds = "B"; 23364 setValO(news, "^^"); 23365 r = icReplaceSSmallStringO(self, olds, news, 0); 23366 ck_assert_ptr_ne(r, null); 23367 char *s = toStringO(r); 23368 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23369 free(s); 23370 // replace string, multiple character old delimeter 23371 freeO(self); 23372 setTopSO(self, "AA##ee##ee#"); 23373 olds = "##"; 23374 setValO(news, "|"); 23375 r = icReplaceSSmallStringO(self, olds, news, 0); 23376 ck_assert_ptr_ne(r, null); 23377 s = toStringO(r); 23378 ck_assert_str_eq(s, "AA|ee|ee#"); 23379 free(s); 23380 // replace one time at the start of string 23381 freeO(self); 23382 setTopSO(self, "#ee#ee#ad"); 23383 olds = "#"; 23384 setValO(news, "^^"); 23385 r = icReplaceSSmallStringO(self, olds, news,1); 23386 ck_assert_ptr_ne(r, null); 23387 s = toStringO(r); 23388 ck_assert_str_eq(s, "^^ee#ee#ad"); 23389 free(s); 23390 // replace one time 23391 freeO(self); 23392 setTopSO(self, "AA##ee##ee#"); 23393 olds = "##"; 23394 setValO(news, "|"); 23395 r = icReplaceSSmallStringO(self, olds, news,1); 23396 ck_assert_ptr_ne(r, null); 23397 s = toStringO(r); 23398 ck_assert_str_eq(s, "AA|ee##ee#"); 23399 free(s); 23400 // NULL new delimiter, one time: same as empty delimiter 23401 freeO(self); 23402 setTopSO(self, "AA##ee##ee#"); 23403 olds = "##"; 23404 r = icReplaceSSmallStringO(self, olds, NULL,1); 23405 ck_assert_ptr_ne(r, null); 23406 s = toStringO(r); 23407 ck_assert_str_eq(s, "AAee##ee#"); 23408 free(s); 23409 // non smallString object 23410 terminateO(news); 23411 news = (smallStringt*) allocSmallInt(1); 23412 r = icReplaceSSmallStringO(self, olds, news,1); 23413 ck_assert_ptr_eq(r, null); 23414 terminateO(news); 23415 news = allocSmallString(""); 23416 // empty string 23417 freeO(self); 23418 setTopSO(self, ""); 23419 olds = "##"; 23420 r = icReplaceSSmallStringO(self, olds, NULL,1); 23421 ck_assert_ptr_ne(r, null); 23422 s = toStringO(r); 23423 ck_assert_str_eq(s, ""); 23424 free(s); 23425 // empty old delimiter 23426 freeO(self); 23427 setTopSO(self, "qwe"); 23428 olds = ""; 23429 setValO(news, "|"); 23430 ck_assert_ptr_eq(icReplaceSSmallStringO(self, olds, news,1), NULL); 23431 // NULL old delimiter 23432 ck_assert_ptr_eq(icReplaceSSmallStringO(self, NULL, news,1), NULL); 23433 // NULL string 23434 freeO(self); 23435 ck_assert_ptr_eq(icReplaceSSmallStringO(self, olds, news,1), NULL); 23436 terminateO(news); 23437 terminateO(self); 23438 23439 } 23440 23441 23442 void icReplaceCharSmallStringSmallJsonT(void) { 23443 23444 smallJsont* r; 23445 smallJsont *self = allocSmallJson(); 23446 setTopSO(self, "beebeebad"); 23447 char olds; 23448 smallStringt *news = allocSmallString(""); 23449 23450 // replace string, multiple character new delimeter 23451 olds = 'B'; 23452 setValO(news, "^^"); 23453 r = icReplaceCharSmallStringO(self, olds, news, 0); 23454 ck_assert_ptr_ne(r, null); 23455 char *s = toStringO(r); 23456 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23457 free(s); 23458 // replace string, multiple character old delimeter 23459 freeO(self); 23460 setTopSO(self, "AA#ee#ee"); 23461 olds = '#'; 23462 setValO(news, "|"); 23463 r = icReplaceCharSmallStringO(self, olds, news, 0); 23464 ck_assert_ptr_ne(r, null); 23465 s = toStringO(r); 23466 ck_assert_str_eq(s, "AA|ee|ee"); 23467 free(s); 23468 // replace one time at the start of string 23469 freeO(self); 23470 setTopSO(self, "#ee#ee#ad"); 23471 olds = '#'; 23472 setValO(news, "^^"); 23473 r = icReplaceCharSmallStringO(self, olds, news,1); 23474 ck_assert_ptr_ne(r, null); 23475 s = toStringO(r); 23476 ck_assert_str_eq(s, "^^ee#ee#ad"); 23477 free(s); 23478 // replace one time 23479 freeO(self); 23480 setTopSO(self, "AA#ee##ee#"); 23481 olds = '#'; 23482 setValO(news, "|"); 23483 r = icReplaceCharSmallStringO(self, olds, news,1); 23484 ck_assert_ptr_ne(r, null); 23485 s = toStringO(r); 23486 ck_assert_str_eq(s, "AA|ee##ee#"); 23487 free(s); 23488 // NULL new delimiter, one time: same as empty delimiter 23489 freeO(self); 23490 setTopSO(self, "AA#ee##ee#"); 23491 olds = '#'; 23492 r = icReplaceCharSmallStringO(self, olds, NULL,1); 23493 ck_assert_ptr_ne(r, null); 23494 s = toStringO(r); 23495 ck_assert_str_eq(s, "AAee##ee#"); 23496 free(s); 23497 // non smallString object 23498 terminateO(news); 23499 news = (smallStringt*) allocSmallInt(1); 23500 r = icReplaceCharSmallStringO(self, olds, news,1); 23501 ck_assert_ptr_eq(r, null); 23502 terminateO(news); 23503 news = allocSmallString(""); 23504 // empty string 23505 freeO(self); 23506 setTopSO(self, ""); 23507 olds = '#'; 23508 r = icReplaceCharSmallStringO(self, olds, NULL,1); 23509 ck_assert_ptr_ne(r, null); 23510 s = toStringO(r); 23511 ck_assert_str_eq(s, ""); 23512 free(s); 23513 // NULL string 23514 freeO(self); 23515 setValO(news, "|"); 23516 ck_assert_ptr_eq(icReplaceCharSmallStringO(self, olds, news,1), NULL); 23517 terminateO(news); 23518 terminateO(self); 23519 23520 } 23521 23522 23523 void icReplaceJsonJsonSmallJsonT(void) { 23524 23525 smallJsont* r; 23526 smallJsont *self = allocSmallJson(); 23527 setTopSO(self, "BeebeeBad"); 23528 smallJsont *olds = allocSmallJson(); 23529 smallJsont *news = allocSmallJson(); 23530 23531 // replace string, multiple character new delimeter 23532 freeO(olds); 23533 freeO(news); 23534 setTopSO(olds, "B"); 23535 setTopSO(news, "^^"); 23536 r = icReplaceJsonJsonO(self, olds, news, 0); 23537 ck_assert_ptr_ne(r, null); 23538 char *s = toStringO(r); 23539 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23540 free(s); 23541 // replace string, multiple character old delimeter 23542 freeO(self); 23543 setTopSO(self, "AA##ee##ee#"); 23544 freeO(olds); 23545 freeO(news); 23546 setTopSO(olds, "##"); 23547 setTopSO(news, "|"); 23548 r = icReplaceJsonJsonO(self, olds, news, 0); 23549 ck_assert_ptr_ne(r, null); 23550 s = toStringO(r); 23551 ck_assert_str_eq(s, "AA|ee|ee#"); 23552 free(s); 23553 // replace one time at the start of string 23554 freeO(self); 23555 setTopSO(self, "#ee#ee#ad"); 23556 freeO(olds); 23557 freeO(news); 23558 setTopSO(olds, "#"); 23559 setTopSO(news, "^^"); 23560 r = icReplaceJsonJsonO(self, olds, news,1); 23561 ck_assert_ptr_ne(r, null); 23562 s = toStringO(r); 23563 ck_assert_str_eq(s, "^^ee#ee#ad"); 23564 free(s); 23565 // replace one time 23566 freeO(self); 23567 setTopSO(self, "AA##ee##ee#"); 23568 freeO(olds); 23569 freeO(news); 23570 setTopSO(olds, "##"); 23571 setTopSO(news, "|"); 23572 r = icReplaceJsonJsonO(self, olds, news,1); 23573 ck_assert_ptr_ne(r, null); 23574 s = toStringO(r); 23575 ck_assert_str_eq(s, "AA|ee##ee#"); 23576 free(s); 23577 // NULL new delimiter, one time: same as empty delimiter 23578 freeO(self); 23579 setTopSO(self, "AA##ee##ee#"); 23580 freeO(olds); 23581 setTopSO(olds, "##"); 23582 r = icReplaceJsonJsonO(self, olds, NULL,1); 23583 ck_assert_ptr_ne(r, null); 23584 s = toStringO(r); 23585 ck_assert_str_eq(s, "AAee##ee#"); 23586 free(s); 23587 // non json string 23588 freeO(olds); 23589 setTopIntO(olds, 1); 23590 r = icReplaceJsonJsonO(self, olds, news,1); 23591 ck_assert_ptr_eq(r, null); 23592 freeO(olds); 23593 freeO(news); 23594 setTopSO(olds, "e"); 23595 setTopIntO(news, 1); 23596 r = icReplaceJsonJsonO(self, olds, news,1); 23597 ck_assert_ptr_eq(r, null); 23598 // non json object 23599 terminateO(olds); 23600 olds = (smallJsont*) allocSmallInt(1); 23601 r = icReplaceJsonJsonO(self, olds, news,1); 23602 ck_assert_ptr_eq(r, null); 23603 terminateO(olds); 23604 terminateO(news); 23605 olds = allocSmallJson(); 23606 news = (smallJsont*) allocSmallInt(1); 23607 r = icReplaceJsonJsonO(self, olds, news,1); 23608 ck_assert_ptr_eq(r, null); 23609 terminateO(news); 23610 news = allocSmallJson(); 23611 // empty string 23612 freeO(self); 23613 setTopSO(self, ""); 23614 freeO(olds); 23615 setTopSO(olds, "##"); 23616 r = icReplaceJsonJsonO(self, olds, NULL,1); 23617 ck_assert_ptr_ne(r, null); 23618 s = toStringO(r); 23619 ck_assert_str_eq(s, ""); 23620 free(s); 23621 // empty old delimiter 23622 freeO(self); 23623 setTopSO(self, "qwe"); 23624 freeO(olds); 23625 freeO(news); 23626 setTopSO(olds, ""); 23627 setTopSO(news, "|"); 23628 ck_assert_ptr_eq(icReplaceJsonJsonO(self, olds, news,1), NULL); 23629 // NULL old delimiter 23630 ck_assert_ptr_eq(icReplaceJsonJsonO(self, NULL, news,1), NULL); 23631 // NULL string 23632 freeO(self); 23633 ck_assert_ptr_eq(icReplaceJsonJsonO(self, olds, news,1), NULL); 23634 terminateO(olds); 23635 terminateO(news); 23636 terminateO(self); 23637 23638 } 23639 23640 23641 void icReplaceJsonSmallStringSmallJsonT(void) { 23642 23643 smallJsont* r; 23644 smallJsont *self = allocSmallJson(); 23645 setTopSO(self, "BeebeeBad"); 23646 smallJsont *olds = allocSmallJson(); 23647 smallStringt *news = allocSmallString(""); 23648 23649 // replace string, multiple character new delimeter 23650 freeO(olds); 23651 setTopSO(olds, "B"); 23652 setValO(news, "^^"); 23653 r = icReplaceJsonSmallStringO(self, olds, news, 0); 23654 ck_assert_ptr_ne(r, null); 23655 char *s = toStringO(r); 23656 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23657 free(s); 23658 // replace string, multiple character old delimeter 23659 freeO(self); 23660 setTopSO(self, "AA##ee##ee#"); 23661 freeO(olds); 23662 setTopSO(olds, "##"); 23663 setValO(news, "|"); 23664 r = icReplaceJsonSmallStringO(self, olds, news, 0); 23665 ck_assert_ptr_ne(r, null); 23666 s = toStringO(r); 23667 ck_assert_str_eq(s, "AA|ee|ee#"); 23668 free(s); 23669 // replace one time at the start of string 23670 freeO(self); 23671 setTopSO(self, "#ee#ee#ad"); 23672 freeO(olds); 23673 setTopSO(olds, "#"); 23674 setValO(news, "^^"); 23675 r = icReplaceJsonSmallStringO(self, olds, news,1); 23676 ck_assert_ptr_ne(r, null); 23677 s = toStringO(r); 23678 ck_assert_str_eq(s, "^^ee#ee#ad"); 23679 free(s); 23680 // replace one time 23681 freeO(self); 23682 setTopSO(self, "AA##ee##ee#"); 23683 freeO(olds); 23684 setTopSO(olds, "##"); 23685 setValO(news, "|"); 23686 r = icReplaceJsonSmallStringO(self, olds, news,1); 23687 ck_assert_ptr_ne(r, null); 23688 s = toStringO(r); 23689 ck_assert_str_eq(s, "AA|ee##ee#"); 23690 free(s); 23691 // NULL new delimiter, one time: same as empty delimiter 23692 freeO(self); 23693 setTopSO(self, "AA##ee##ee#"); 23694 freeO(olds); 23695 setTopSO(olds, "##"); 23696 r = icReplaceJsonSmallStringO(self, olds, NULL,1); 23697 ck_assert_ptr_ne(r, null); 23698 s = toStringO(r); 23699 ck_assert_str_eq(s, "AAee##ee#"); 23700 free(s); 23701 // non json string 23702 freeO(olds); 23703 setTopIntO(olds, 1); 23704 r = icReplaceJsonSmallStringO(self, olds, news,1); 23705 ck_assert_ptr_eq(r, null); 23706 // non json object 23707 terminateO(olds); 23708 olds = (smallJsont*) allocSmallInt(1); 23709 r = icReplaceJsonSmallStringO(self, olds, news,1); 23710 ck_assert_ptr_eq(r, null); 23711 terminateO(olds); 23712 terminateO(news); 23713 olds = allocSmallJson(); 23714 news = (smallStringt*) allocSmallInt(1); 23715 r = icReplaceJsonSmallStringO(self, olds, news,1); 23716 ck_assert_ptr_eq(r, null); 23717 terminateO(news); 23718 news = allocSmallString(""); 23719 // empty string 23720 freeO(self); 23721 setTopSO(self, ""); 23722 freeO(olds); 23723 setTopSO(olds, "##"); 23724 r = icReplaceJsonSmallStringO(self, olds, NULL,1); 23725 ck_assert_ptr_ne(r, null); 23726 s = toStringO(r); 23727 ck_assert_str_eq(s, ""); 23728 free(s); 23729 // empty old delimiter 23730 freeO(self); 23731 setTopSO(self, "qwe"); 23732 freeO(olds); 23733 setTopSO(olds, ""); 23734 setValO(news, "|"); 23735 ck_assert_ptr_eq(icReplaceJsonSmallStringO(self, olds, news,1), NULL); 23736 // NULL old delimiter 23737 ck_assert_ptr_eq(icReplaceJsonSmallStringO(self, NULL, news,1), NULL); 23738 // NULL string 23739 freeO(self); 23740 ck_assert_ptr_eq(icReplaceJsonSmallStringO(self, olds, news,1), NULL); 23741 terminateO(olds); 23742 terminateO(news); 23743 terminateO(self); 23744 23745 } 23746 23747 23748 void icReplaceJsonSSmallJsonT(void) { 23749 23750 smallJsont* r; 23751 smallJsont *self = allocSmallJson(); 23752 setTopSO(self, "BeebeeBad"); 23753 smallJsont *olds = allocSmallJson(); 23754 const char *news; 23755 23756 // replace string, multiple character new delimeter 23757 freeO(olds); 23758 setTopSO(olds, "b"); 23759 news = "^^"; 23760 r = icReplaceJsonSO(self, olds, news, 0); 23761 ck_assert_ptr_ne(r, null); 23762 char *s = toStringO(r); 23763 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23764 free(s); 23765 // replace string, multiple character old delimeter 23766 freeO(self); 23767 setTopSO(self, "AA##ee##ee#"); 23768 freeO(olds); 23769 setTopSO(olds, "##"); 23770 news = "|"; 23771 r = icReplaceJsonSO(self, olds, news, 0); 23772 ck_assert_ptr_ne(r, null); 23773 s = toStringO(r); 23774 ck_assert_str_eq(s, "AA|ee|ee#"); 23775 free(s); 23776 // replace one time at the start of string 23777 freeO(self); 23778 setTopSO(self, "#ee#ee#ad"); 23779 freeO(olds); 23780 setTopSO(olds, "#"); 23781 news = "^^"; 23782 r = icReplaceJsonSO(self, olds, news,1); 23783 ck_assert_ptr_ne(r, null); 23784 s = toStringO(r); 23785 ck_assert_str_eq(s, "^^ee#ee#ad"); 23786 free(s); 23787 // replace one time 23788 freeO(self); 23789 setTopSO(self, "AA##ee##ee#"); 23790 freeO(olds); 23791 setTopSO(olds, "##"); 23792 news = "|"; 23793 r = icReplaceJsonSO(self, olds, news,1); 23794 ck_assert_ptr_ne(r, null); 23795 s = toStringO(r); 23796 ck_assert_str_eq(s, "AA|ee##ee#"); 23797 free(s); 23798 // NULL new delimiter, one time: same as empty delimiter 23799 freeO(self); 23800 setTopSO(self, "AA##ee##ee#"); 23801 freeO(olds); 23802 setTopSO(olds, "##"); 23803 r = icReplaceJsonSO(self, olds, NULL,1); 23804 ck_assert_ptr_ne(r, null); 23805 s = toStringO(r); 23806 ck_assert_str_eq(s, "AAee##ee#"); 23807 free(s); 23808 // non json string 23809 freeO(olds); 23810 setTopIntO(olds, 1); 23811 r = icReplaceJsonSO(self, olds, news,1); 23812 ck_assert_ptr_eq(r, null); 23813 // non json object 23814 terminateO(olds); 23815 olds = (smallJsont*) allocSmallInt(1); 23816 r = icReplaceJsonSO(self, olds, news,1); 23817 ck_assert_ptr_eq(r, null); 23818 terminateO(olds); 23819 // empty string 23820 olds = allocSmallJson(); 23821 freeO(self); 23822 setTopSO(self, ""); 23823 setTopSO(olds, "##"); 23824 r = icReplaceJsonSO(self, olds, NULL,1); 23825 ck_assert_ptr_ne(r, null); 23826 s = toStringO(r); 23827 ck_assert_str_eq(s, ""); 23828 free(s); 23829 // empty old delimiter 23830 freeO(self); 23831 setTopSO(self, "qwe"); 23832 freeO(olds); 23833 setTopSO(olds, ""); 23834 news = "|"; 23835 ck_assert_ptr_eq(icReplaceJsonSO(self, olds, news,1), NULL); 23836 // NULL old delimiter 23837 ck_assert_ptr_eq(icReplaceJsonSO(self, NULL, news,1), NULL); 23838 // NULL string 23839 freeO(self); 23840 ck_assert_ptr_eq(icReplaceJsonSO(self, olds, news,1), NULL); 23841 terminateO(olds); 23842 terminateO(self); 23843 23844 } 23845 23846 23847 void icReplaceJsonCharSmallJsonT(void) { 23848 23849 smallJsont* r; 23850 smallJsont *self = allocSmallJson(); 23851 setTopSO(self, "beeBeebad"); 23852 smallJsont *olds = allocSmallJson(); 23853 char news; 23854 23855 // replace string, multiple character new delimeter 23856 freeO(olds); 23857 setTopSO(olds, "B"); 23858 news = '^'; 23859 r = icReplaceJsonCharO(self, olds, news, 0); 23860 ck_assert_ptr_ne(r, null); 23861 char *s = toStringO(r); 23862 ck_assert_str_eq(s, "^ee^ee^ad"); 23863 free(s); 23864 // replace string, multiple character old delimeter 23865 freeO(self); 23866 setTopSO(self, "AA##ee##ee#"); 23867 freeO(olds); 23868 setTopSO(olds, "##"); 23869 news = '|'; 23870 r = icReplaceJsonCharO(self, olds, news, 0); 23871 ck_assert_ptr_ne(r, null); 23872 s = toStringO(r); 23873 ck_assert_str_eq(s, "AA|ee|ee#"); 23874 free(s); 23875 // replace one time at the start of string 23876 freeO(self); 23877 setTopSO(self, "#ee#ee#ad"); 23878 freeO(olds); 23879 setTopSO(olds, "#"); 23880 news = '^'; 23881 r = icReplaceJsonCharO(self, olds, news,1); 23882 ck_assert_ptr_ne(r, null); 23883 s = toStringO(r); 23884 ck_assert_str_eq(s, "^ee#ee#ad"); 23885 free(s); 23886 // replace one time 23887 freeO(self); 23888 setTopSO(self, "AA##ee##ee#"); 23889 freeO(olds); 23890 setTopSO(olds, "##"); 23891 news = '|'; 23892 r = icReplaceJsonCharO(self, olds, news,1); 23893 ck_assert_ptr_ne(r, null); 23894 s = toStringO(r); 23895 ck_assert_str_eq(s, "AA|ee##ee#"); 23896 free(s); 23897 // non json string 23898 freeO(self); 23899 setTopSO(self, "AA##ee##ee#"); 23900 freeO(olds); 23901 setTopIntO(olds, 1); 23902 r = icReplaceJsonCharO(self, olds, news,1); 23903 ck_assert_ptr_eq(r, null); 23904 // non json object 23905 terminateO(olds); 23906 olds = (smallJsont*) allocSmallInt(1); 23907 r = icReplaceJsonCharO(self, olds, news,1); 23908 ck_assert_ptr_eq(r, null); 23909 terminateO(olds); 23910 // empty string 23911 olds = allocSmallJson(); 23912 freeO(self); 23913 setTopSO(self, ""); 23914 setTopSO(olds, "##"); 23915 r = icReplaceJsonCharO(self, olds, news,1); 23916 ck_assert_ptr_ne(r, null); 23917 s = toStringO(r); 23918 ck_assert_str_eq(s, ""); 23919 free(s); 23920 // empty old delimiter 23921 freeO(self); 23922 setTopSO(self, "qwe"); 23923 freeO(olds); 23924 setTopSO(olds, ""); 23925 news = '|'; 23926 ck_assert_ptr_eq(icReplaceJsonCharO(self, olds, news,1), NULL); 23927 // NULL old delimiter 23928 ck_assert_ptr_eq(icReplaceJsonCharO(self, NULL, news,1), NULL); 23929 // NULL string 23930 freeO(self); 23931 ck_assert_ptr_eq(icReplaceJsonCharO(self, olds, news,1), NULL); 23932 terminateO(olds); 23933 terminateO(self); 23934 23935 } 23936 23937 23938 void icReplaceSmallStringJsonSmallJsonT(void) { 23939 23940 smallJsont* r; 23941 smallJsont *self = allocSmallJson(); 23942 setTopSO(self, "BeeBeeBad"); 23943 smallStringt *olds = allocSmallString(""); 23944 smallJsont *news = allocSmallJson(); 23945 23946 // replace string, multiple character new delimeter 23947 freeO(news); 23948 setValO(olds, "b"); 23949 setTopSO(news, "^^"); 23950 r = self->f->icReplaceSmallStringJson(self, olds, news, 0); 23951 ck_assert_ptr_ne(r, null); 23952 char *s = toStringO(r); 23953 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 23954 free(s); 23955 // replace string, multiple character old delimeter 23956 freeO(self); 23957 setTopSO(self, "AA##ee##ee#"); 23958 freeO(news); 23959 setValO(olds, "##"); 23960 setTopSO(news, "|"); 23961 r = self->f->icReplaceSmallStringJson(self, olds, news, 0); 23962 ck_assert_ptr_ne(r, null); 23963 s = toStringO(r); 23964 ck_assert_str_eq(s, "AA|ee|ee#"); 23965 free(s); 23966 // replace one time at the start of string 23967 freeO(self); 23968 setTopSO(self, "#ee#ee#ad"); 23969 freeO(news); 23970 setValO(olds, "#"); 23971 setTopSO(news, "^^"); 23972 r = self->f->icReplaceSmallStringJson(self, olds, news,1); 23973 ck_assert_ptr_ne(r, null); 23974 s = toStringO(r); 23975 ck_assert_str_eq(s, "^^ee#ee#ad"); 23976 free(s); 23977 // replace one time 23978 freeO(self); 23979 setTopSO(self, "AA##ee##ee#"); 23980 freeO(news); 23981 setValO(olds, "##"); 23982 setTopSO(news, "|"); 23983 r = self->f->icReplaceSmallStringJson(self, olds, news,1); 23984 ck_assert_ptr_ne(r, null); 23985 s = toStringO(r); 23986 ck_assert_str_eq(s, "AA|ee##ee#"); 23987 free(s); 23988 // NULL new delimiter, one time: same as empty delimiter 23989 freeO(self); 23990 setTopSO(self, "AA##ee##ee#"); 23991 setValO(olds, "##"); 23992 r = self->f->icReplaceSmallStringJson(self, olds, NULL,1); 23993 ck_assert_ptr_ne(r, null); 23994 s = toStringO(r); 23995 ck_assert_str_eq(s, "AAee##ee#"); 23996 free(s); 23997 // non json string 23998 freeO(news); 23999 setTopIntO(news, 1); 24000 r = self->f->icReplaceSmallStringJson(self, olds, news,1); 24001 ck_assert_ptr_eq(r, null); 24002 // non json object 24003 terminateO(olds); 24004 olds = (smallStringt*) allocSmallInt(1); 24005 r = self->f->icReplaceSmallStringJson(self, olds, news,1); 24006 ck_assert_ptr_eq(r, null); 24007 terminateO(olds); 24008 terminateO(news); 24009 olds = allocSmallString(""); 24010 news = (smallJsont*) allocSmallInt(1); 24011 r = self->f->icReplaceSmallStringJson(self, olds, news,1); 24012 ck_assert_ptr_eq(r, null); 24013 terminateO(news); 24014 news = allocSmallJson(); 24015 // empty string 24016 freeO(self); 24017 setTopSO(self, ""); 24018 setValO(olds, "##"); 24019 r = self->f->icReplaceSmallStringJson(self, olds, NULL,1); 24020 ck_assert_ptr_ne(r, null); 24021 s = toStringO(r); 24022 ck_assert_str_eq(s, ""); 24023 free(s); 24024 // empty old delimiter 24025 freeO(self); 24026 setTopSO(self, "qwe"); 24027 freeO(news); 24028 setValO(olds, ""); 24029 setTopSO(news, "|"); 24030 ck_assert_ptr_eq(self->f->icReplaceSmallStringJson(self, olds, news,1), NULL); 24031 // NULL old delimiter 24032 ck_assert_ptr_eq(self->f->icReplaceSmallStringJson(self, NULL, news,1), NULL); 24033 // NULL string 24034 freeO(self); 24035 ck_assert_ptr_eq(self->f->icReplaceSmallStringJson(self, olds, news,1), NULL); 24036 terminateO(olds); 24037 terminateO(news); 24038 terminateO(self); 24039 24040 } 24041 24042 24043 void icReplaceSJsonSmallJsonT(void) { 24044 24045 smallJsont* r; 24046 smallJsont *self = allocSmallJson(); 24047 setTopSO(self, "beebeebad"); 24048 const char *olds; 24049 smallJsont *news = allocSmallJson(); 24050 24051 // replace string, multiple character new delimeter 24052 freeO(news); 24053 olds = "B"; 24054 setTopSO(news, "^^"); 24055 r = icReplaceSJsonO(self, olds, news, 0); 24056 ck_assert_ptr_ne(r, null); 24057 char *s = toStringO(r); 24058 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 24059 free(s); 24060 // replace string, multiple character old delimeter 24061 freeO(self); 24062 setTopSO(self, "AA##ee##ee#"); 24063 freeO(news); 24064 olds = "##"; 24065 setTopSO(news, "|"); 24066 r = icReplaceSJsonO(self, olds, news, 0); 24067 ck_assert_ptr_ne(r, null); 24068 s = toStringO(r); 24069 ck_assert_str_eq(s, "AA|ee|ee#"); 24070 free(s); 24071 // replace one time at the start of string 24072 freeO(self); 24073 setTopSO(self, "#ee#ee#ad"); 24074 freeO(news); 24075 olds = "#"; 24076 setTopSO(news, "^^"); 24077 r = icReplaceSJsonO(self, olds, news,1); 24078 ck_assert_ptr_ne(r, null); 24079 s = toStringO(r); 24080 ck_assert_str_eq(s, "^^ee#ee#ad"); 24081 free(s); 24082 // replace one time 24083 freeO(self); 24084 setTopSO(self, "AA##ee##ee#"); 24085 freeO(news); 24086 olds = "##"; 24087 setTopSO(news, "|"); 24088 r = icReplaceSJsonO(self, olds, news,1); 24089 ck_assert_ptr_ne(r, null); 24090 s = toStringO(r); 24091 ck_assert_str_eq(s, "AA|ee##ee#"); 24092 free(s); 24093 // NULL new delimiter, one time: same as empty delimiter 24094 freeO(self); 24095 setTopSO(self, "AA##ee##ee#"); 24096 olds = "##"; 24097 r = icReplaceSJsonO(self, olds, NULL,1); 24098 ck_assert_ptr_ne(r, null); 24099 s = toStringO(r); 24100 ck_assert_str_eq(s, "AAee##ee#"); 24101 free(s); 24102 // non json string 24103 freeO(news); 24104 olds = "e"; 24105 setTopIntO(news, 1); 24106 r = icReplaceSJsonO(self, olds, news,1); 24107 ck_assert_ptr_eq(r, null); 24108 // non json object 24109 terminateO(news); 24110 news = (smallJsont*) allocSmallInt(1); 24111 r = icReplaceSJsonO(self, olds, news,1); 24112 ck_assert_ptr_eq(r, null); 24113 terminateO(news); 24114 news = allocSmallJson(); 24115 // empty string 24116 freeO(self); 24117 setTopSO(self, ""); 24118 olds = "##"; 24119 r = icReplaceSJsonO(self, olds, NULL,1); 24120 ck_assert_ptr_ne(r, null); 24121 s = toStringO(r); 24122 ck_assert_str_eq(s, ""); 24123 free(s); 24124 // empty old delimiter 24125 freeO(self); 24126 setTopSO(self, "qwe"); 24127 freeO(news); 24128 olds = ""; 24129 setTopSO(news, "|"); 24130 ck_assert_ptr_eq(icReplaceSJsonO(self, olds, news,1), NULL); 24131 // NULL old delimiter 24132 ck_assert_ptr_eq(icReplaceSJsonO(self, NULL, news,1), NULL); 24133 // NULL string 24134 freeO(self); 24135 ck_assert_ptr_eq(icReplaceSJsonO(self, olds, news,1), NULL); 24136 terminateO(news); 24137 terminateO(self); 24138 24139 } 24140 24141 24142 void icReplaceCharJsonSmallJsonT(void) { 24143 24144 smallJsont* r; 24145 smallJsont *self = allocSmallJson(); 24146 setTopSO(self, "beebeebad"); 24147 char olds; 24148 smallJsont *news = allocSmallJson(); 24149 24150 // replace string, multiple character new delimeter 24151 freeO(news); 24152 olds = 'B'; 24153 setTopSO(news, "^^"); 24154 r = icReplaceCharJsonO(self, olds, news, 0); 24155 ck_assert_ptr_ne(r, null); 24156 char *s = toStringO(r); 24157 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 24158 free(s); 24159 // replace string, multiple character old delimeter 24160 freeO(self); 24161 setTopSO(self, "AA#ee#ee"); 24162 freeO(news); 24163 olds = '#'; 24164 setTopSO(news, "|"); 24165 r = icReplaceCharJsonO(self, olds, news, 0); 24166 ck_assert_ptr_ne(r, null); 24167 s = toStringO(r); 24168 ck_assert_str_eq(s, "AA|ee|ee"); 24169 free(s); 24170 // replace one time at the start of string 24171 freeO(self); 24172 setTopSO(self, "#ee#ee#ad"); 24173 freeO(news); 24174 olds = '#'; 24175 setTopSO(news, "^^"); 24176 r = icReplaceCharJsonO(self, olds, news,1); 24177 ck_assert_ptr_ne(r, null); 24178 s = toStringO(r); 24179 ck_assert_str_eq(s, "^^ee#ee#ad"); 24180 free(s); 24181 // replace one time 24182 freeO(self); 24183 setTopSO(self, "AA#ee##ee#"); 24184 freeO(news); 24185 olds = '#'; 24186 setTopSO(news, "|"); 24187 r = icReplaceCharJsonO(self, olds, news,1); 24188 ck_assert_ptr_ne(r, null); 24189 s = toStringO(r); 24190 ck_assert_str_eq(s, "AA|ee##ee#"); 24191 free(s); 24192 // NULL new delimiter, one time: same as empty delimiter 24193 freeO(self); 24194 setTopSO(self, "AA#ee##ee#"); 24195 olds = '#'; 24196 r = icReplaceCharJsonO(self, olds, NULL,1); 24197 ck_assert_ptr_ne(r, null); 24198 s = toStringO(r); 24199 ck_assert_str_eq(s, "AAee##ee#"); 24200 free(s); 24201 // non json string 24202 freeO(news); 24203 olds = 'e'; 24204 setTopIntO(news, 1); 24205 r = icReplaceCharJsonO(self, olds, news,1); 24206 ck_assert_ptr_eq(r, null); 24207 // non json object 24208 terminateO(news); 24209 news = (smallJsont*) allocSmallInt(1); 24210 r = icReplaceCharJsonO(self, olds, news,1); 24211 ck_assert_ptr_eq(r, null); 24212 terminateO(news); 24213 news = allocSmallJson(); 24214 // empty string 24215 freeO(self); 24216 setTopSO(self, ""); 24217 olds = '#'; 24218 r = icReplaceCharJsonO(self, olds, NULL,1); 24219 ck_assert_ptr_ne(r, null); 24220 s = toStringO(r); 24221 ck_assert_str_eq(s, ""); 24222 free(s); 24223 // NULL string 24224 freeO(self); 24225 freeO(news); 24226 setTopSO(news, "|"); 24227 ck_assert_ptr_eq(icReplaceCharJsonO(self, olds, news,1), NULL); 24228 terminateO(news); 24229 terminateO(self); 24230 24231 } 24232 24233 24234 void icReplaceManySmallJsonT(void) { 24235 24236 smallJsont* r; 24237 smallJsont *self = allocSmallJson(); 24238 setTopSO(self, ""); 24239 24240 // replace string, multiple character new delimeter 24241 freeO(self); 24242 setTopSO(self, "beebeebad"); 24243 r = icReplaceManyO(self, "B","^^","aD","AD"); 24244 ck_assert_ptr_ne(r, null); 24245 char *s = toStringO(r); 24246 ck_assert_str_eq(s, "^^ee^^ee^^AD"); 24247 free(s); 24248 // replace string, empty new delimeter 24249 freeO(self); 24250 setTopSO(self, "#ee#ee#ad"); 24251 r = icReplaceManyO(self, "#","","ad","AD"); 24252 ck_assert_ptr_ne(r, null); 24253 s = toStringO(r); 24254 ck_assert_str_eq(s, "eeeeAD"); 24255 free(s); 24256 // not enough olds:news pairs 24257 freeO(self); 24258 setTopSO(self, "#ee#ee#ad"); 24259 r = icReplaceManyO(self, "#","","ad"); 24260 ck_assert_ptr_ne(r, null); 24261 s = toStringO(r); 24262 ck_assert_str_eq(s, "eeeead"); 24263 free(s); 24264 // NULL new delimiter: same as only 2 parameters or not enough olds:news pairs 24265 freeO(self); 24266 setTopSO(self, "AA##ee##ee#"); 24267 r = icReplaceManyO(self, "##",NULL); 24268 ck_assert_ptr_eq(r, null); 24269 // empty string 24270 freeO(self); 24271 setTopSO(self, ""); 24272 r = icReplaceManyO(self, "##", ""); 24273 ck_assert_ptr_ne(r, null); 24274 s = toStringO(r); 24275 ck_assert_str_eq(s, ""); 24276 free(s); 24277 // empty string many pairs 24278 freeO(self); 24279 setTopSO(self, ""); 24280 r = icReplaceManyO(self, "##", "", "$$", ""); 24281 ck_assert_ptr_ne(r, null); 24282 s = toStringO(r); 24283 ck_assert_str_eq(s, ""); 24284 free(s); 24285 // empty string many pairs empty olds 24286 freeO(self); 24287 setTopSO(self, ""); 24288 r = icReplaceManyO(self, "##", "", "", ""); 24289 ck_assert_ptr_ne(r, null); 24290 s = toStringO(r); 24291 ck_assert_str_eq(s, ""); 24292 free(s); 24293 // empty string and NULL old delimiter 24294 freeO(self); 24295 setTopSO(self, ""); 24296 r = icReplaceManyO(self, NULL,"|"); 24297 ck_assert_ptr_ne(r, null); 24298 s = toStringO(r); 24299 ck_assert_str_eq(s, ""); 24300 free(s); 24301 // empty string and NULL old delimiter not first - same as replace empty string 24302 freeO(self); 24303 setTopSO(self, ""); 24304 r = icReplaceManyO(self,"##","|", NULL,"|"); 24305 ck_assert_ptr_ne(r, null); 24306 s = toStringO(r); 24307 ck_assert_str_eq(s, ""); 24308 free(s); 24309 // empty old delimiter 24310 freeO(self); 24311 setTopSO(self, "AA##ee##ee#"); 24312 ck_assert_ptr_eq(icReplaceManyO(self, "","|", "AA", "BB"), NULL); 24313 // empty old delimiter not first 24314 ck_assert_ptr_eq(icReplaceManyO(self, "##","|", "", "BB"), NULL); 24315 // NULL string 24316 freeO(self); 24317 ck_assert_ptr_eq(icReplaceManyO(self, "##","|"), NULL); 24318 terminateO(self); 24319 24320 } 24321 24322 24323 void equalSmallJsonSmallArrayT(void) { 24324 24325 bool r; 24326 smallJsont *self = allocG(rtSmallJsont); 24327 smallArrayt *array = allocSmallArray(); 24328 24329 // empty arrays 24330 setTypeArrayO(self); 24331 r = self->f->equalSmallArray(self, array); 24332 ck_assert(r); 24333 // empty self, non empty array 24334 array->f->pushInt(array, 1); 24335 r = self->f->equalSmallArray(self, array); 24336 ck_assert(!r); 24337 // non empty self, empty array 24338 emptyO(array); 24339 self->f->pushInt(self, 1); 24340 r = self->f->equalSmallArray(self, array); 24341 ck_assert(!r); 24342 // different lengths 24343 array->f->pushInt(array, 1); 24344 self->f->pushInt(self, 1); 24345 r = self->f->equalSmallArray(self, array); 24346 ck_assert(!r); 24347 // equal arrays 24348 array->f->pushInt(array, 1); 24349 r = self->f->equalSmallArray(self, array); 24350 ck_assert(r); 24351 // different int value 24352 array->f->setAtInt(array, 1, 2); 24353 r = self->f->equalSmallArray(self, array); 24354 ck_assert(!r); 24355 // array same length with a null element in self 24356 smallIntt *i = self->f->getAtSmallInt(self, 1); 24357 removeElemIndexO(self, 1); 24358 terminateO(i); 24359 r = self->f->equalSmallArray(self, array); 24360 ck_assert(!r); 24361 // array same length with a null element in both arrays 24362 i = array->f->getAtSmallInt(array, 1); 24363 removeElemO(array, 1); 24364 terminateO(i); 24365 r = self->f->equalSmallArray(self, array); 24366 ck_assert(r); 24367 // elements of different types 24368 self->f->setAtBool(self, 1, true); 24369 array->f->setAtInt(array, 1, 1); 24370 r = self->f->equalSmallArray(self, array); 24371 ck_assert(!r); 24372 // compare bool 24373 array->f->setAtBool(array, 1, true); 24374 r = self->f->equalSmallArray(self, array); 24375 ck_assert(r); 24376 array->f->setAtBool(array, 1, false); 24377 r = self->f->equalSmallArray(self, array); 24378 ck_assert(!r); 24379 // compare dict 24380 createSmallDict(d1); 24381 createSmallDict(d2); 24382 self->f->setAtDict(self, 1, &d1); 24383 array->f->setAtDict(array, 1, &d2); 24384 r = self->f->equalSmallArray(self, array); 24385 ck_assert(r); 24386 // reuse dict container, the data is in self already 24387 resetO(&d1); 24388 (&d1)->f->setInt(&d1, "a", 1); 24389 self->f->setAtDict(self, 1, &d1); 24390 r = self->f->equalSmallArray(self, array); 24391 ck_assert(!r); 24392 // compare double 24393 self->f->setAtDouble(self, 1, 0); 24394 array->f->setAtDouble(array, 1, 0); 24395 r = self->f->equalSmallArray(self, array); 24396 ck_assert(r); 24397 array->f->setAtDouble(array, 1, 10.5); 24398 r = self->f->equalSmallArray(self, array); 24399 ck_assert(!r); 24400 // compare string 24401 self->f->setAtS(self, 1, ""); 24402 array->f->setAtS(array, 1, ""); 24403 r = self->f->equalSmallArray(self, array); 24404 ck_assert(r); 24405 array->f->setAtS(array, 1, "NO"); 24406 r = self->f->equalSmallArray(self, array); 24407 ck_assert(!r); 24408 // compare array elements 24409 createSmallArray(a1); 24410 createSmallArray(a2); 24411 self->f->setAtArray(self, 1, &a1); 24412 array->f->setAtArray(array, 1, &a2); 24413 r = self->f->equalSmallArray(self, array); 24414 ck_assert(r); 24415 // reuse Array container, the data is in self already 24416 resetO(&a1); 24417 (&a1)->f->pushInt(&a1, 1); 24418 self->f->setAtArray(self, 1, &a1); 24419 r = self->f->equalSmallArray(self, array); 24420 ck_assert(!r); 24421 // compare bytes 24422 createSmallBytes(b1); 24423 createSmallBytes(b2); 24424 self->f->setAtSmallBytes(self, 1, &b1); 24425 array->f->setAtSmallBytes(array, 1, &b2); 24426 r = self->f->equalSmallArray(self, array); 24427 ck_assert(r); 24428 // reuse SmallBytes container, the data is in self already 24429 b1.B = null; 24430 pushBufferO(&b1, &self, 2); 24431 self->f->setAtSmallBytes(self, 1, &b1); 24432 r = self->f->equalSmallArray(self, array); 24433 ck_assert(!r); 24434 // compare data in both smallBytes elements 24435 b2.B = null; 24436 pushBufferO(&b2, (char*)(&self) + 4, 2); 24437 array->f->setAtSmallBytes(array, 1, &b2); 24438 r = self->f->equalSmallArray(self, array); 24439 ck_assert(!r); 24440 // non smallArray object 24441 terminateO(array); 24442 array = (smallArrayt*) allocSmallInt(2); 24443 r = self->f->equalSmallArray(self, array); 24444 ck_assert(!r); 24445 // NULL array 24446 r = self->f->equalSmallArray(self, NULL); 24447 ck_assert(!r); 24448 // non json array 24449 freeO(self); 24450 setTypeDictO(self); 24451 ck_assert(!self->f->equalSmallArray(self, array)); 24452 // non smallArray array 24453 freeO(self); 24454 setTypeArrayO(self); 24455 terminateO(array); 24456 array = (smallArrayt*) allocSmallInt(2); 24457 r = self->f->equalSmallArray(self, array); 24458 ck_assert(!r); 24459 terminateO(array); 24460 terminateO(self); 24461 24462 } 24463 24464 24465 void equalSmallJsonArrayT(void) { 24466 24467 bool r; 24468 smallJsont *self = allocG(rtSmallJsont); 24469 char ** p2 = NULL; 24470 24471 // empty arrays 24472 setTypeArrayO(self); 24473 r = self->f->equalArray(self, NULL); 24474 ck_assert(r); 24475 // empty self, non empty array 24476 p2 = listCreateS("a"); 24477 r = self->f->equalArray(self, p2); 24478 ck_assert(!r); 24479 // non empty self, empty array 24480 self->f->pushInt(self, 1); 24481 listFreeS(p2); 24482 listEmptyS(p2); 24483 r = self->f->equalArray(self, p2); 24484 ck_assert(!r); 24485 // different lengths 24486 listPushS(&p2, "a"); 24487 self->f->pushInt(self, 2); 24488 r = self->f->equalArray(self, p2); 24489 ck_assert(!r); 24490 // equal arrays 24491 emptyO(self); 24492 self->f->pushS(self, "a"); 24493 r = self->f->equalArray(self, p2); 24494 ck_assert(r); 24495 // not string type in self 24496 self->f->setAtInt(self, 0, 0); 24497 r = self->f->equalArray(self, p2); 24498 ck_assert(!r); 24499 // array same length with a null element in self 24500 smallIntt *i = self->f->getAtSmallInt(self, 0); 24501 terminateO(i); 24502 removeElemIndexO(self, 0); 24503 r = self->f->equalArray(self, p2); 24504 ck_assert(!r); 24505 // different strings 24506 self->f->setAtS(self, 0, "bb"); 24507 r = self->f->equalArray(self, p2); 24508 ck_assert(!r); 24509 // non json array 24510 freeO(self); 24511 setTypeBoolO(self); 24512 ck_assert(!self->f->equalArray(self, p2)); 24513 listFreeS(p2); 24514 terminateO(self); 24515 24516 } 24517 24518 24519 void equalSmallJsonBaseT(void) { 24520 24521 bool r; 24522 smallJsont *self = allocSmallJson(); 24523 baset* p2; 24524 24525 // json bool 24526 setTopBoolO(self, false); 24527 p2 = (baset*) allocSmallBool(false); 24528 r = self->f->equalBase(self, p2); 24529 ck_assert(r); 24530 freeO(self); 24531 setTopBoolO(self, true); 24532 r = self->f->equalBase(self, p2); 24533 ck_assert(!r); 24534 terminateO(p2); 24535 p2 = (baset*) allocSmallBool(true); 24536 r = self->f->equalBase(self, p2); 24537 ck_assert(r); 24538 // non equal 24539 terminateO(p2); 24540 p2 = (baset*) allocSmallString("true "); 24541 r = self->f->equalBase(self, p2); 24542 ck_assert(!r); 24543 // json double 24544 freeO(self); 24545 setTopDoubleO(self, 2.2); 24546 terminateO(p2); 24547 p2 = (baset*) allocSmallString("2.2"); 24548 r = self->f->equalBase(self, p2); 24549 ck_assert(r); 24550 freeO(self); 24551 setTopDoubleO(self, 2); 24552 r = self->f->equalBase(self, p2); 24553 ck_assert(!r); 24554 terminateO(p2); 24555 // p2 is an int so not equal to double (int)2 != (double)2 24556 // TODO is this reasonable? 24557 p2 = (baset*) allocSmallInt(2); 24558 r = self->f->equalBase(self, p2); 24559 ck_assert(!r); 24560 terminateO(p2); 24561 p2 = (baset*) allocSmallString("asd"); 24562 r = self->f->equalBase(self, p2); 24563 ck_assert(!r); 24564 // json int 24565 freeO(self); 24566 setTopIntO(self, 2); 24567 terminateO(p2); 24568 p2 = (baset*) allocSmallString("2"); 24569 r = self->f->equalBase(self, p2); 24570 ck_assert(r); 24571 terminateO(p2); 24572 p2 = (baset*) allocSmallString("3"); 24573 r = self->f->equalBase(self, p2); 24574 ck_assert(!r); 24575 terminateO(p2); 24576 p2 = (baset*) allocSmallDouble(2); 24577 r = self->f->equalBase(self, p2); 24578 ck_assert(!r); 24579 terminateO(p2); 24580 p2 = (baset*) allocSmallString("asd"); 24581 r = self->f->equalBase(self, p2); 24582 ck_assert(!r); 24583 // json string 24584 freeO(self); 24585 setTopSO(self, "12"); 24586 terminateO(p2); 24587 p2 = (baset*) allocSmallInt(12); 24588 r = self->f->equalBase(self, p2); 24589 ck_assert(r); 24590 // empty self 24591 freeO(self); 24592 r = self->f->equalBase(self, p2); 24593 ck_assert(!r); 24594 // json dict 24595 freeO(self); 24596 setTypeDictO(self); 24597 terminateO(p2); 24598 p2 = (baset*) allocSmallInt(12); 24599 r = self->f->equalBase(self, p2); 24600 ck_assert(!r); 24601 terminateO(p2); 24602 p2 = (baset*) allocSmallDict(); 24603 r = self->f->equalBase(self, p2); 24604 ck_assert(!r); 24605 // json array 24606 freeO(self); 24607 setTypeArrayO(self); 24608 terminateO(p2); 24609 p2 = (baset*) allocSmallInt(12); 24610 r = self->f->equalBase(self, p2); 24611 ck_assert(!r); 24612 self->f->pushInt(self, 1); 24613 r = self->f->equalBase(self, p2); 24614 ck_assert(!r); 24615 terminateO(p2); 24616 p2 = (baset*) allocSmallArray(); 24617 r = self->f->equalBase(self, p2); 24618 ck_assert(!r); 24619 // null object 24620 freeO(self); 24621 setTopSO(self, "qwe"); 24622 r = self->f->equalBase(self, null); 24623 ck_assert(!r); 24624 terminateO(p2); 24625 terminateO(self); 24626 24627 } 24628 24629 24630 void equalSmallJsonChaT(void) { 24631 24632 bool r; 24633 smallJsont *self = allocSmallJson(); 24634 setTopSO(self, ""); 24635 24636 r = equalChaO(self,'q'); 24637 ck_assert(!r); 24638 freeO(self); 24639 setTopSO(self, "q"); 24640 r = equalChaO(self,'q'); 24641 ck_assert(r); 24642 // empty strings 24643 freeO(self); 24644 r = equalChaO(self, ' '); 24645 ck_assert(!r); 24646 // json int 24647 freeO(self); 24648 setTopIntO(self, 1); 24649 r = equalChaO(self,'1'); 24650 ck_assert(r); 24651 r = equalChaO(self,'2'); 24652 ck_assert(!r); 24653 r = equalChaO(self,'q'); 24654 ck_assert(!r); 24655 // non json string or int 24656 freeO(self); 24657 setTypeBoolO(self); 24658 r = equalChaO(self,'2'); 24659 ck_assert(!r); 24660 terminateO(self); 24661 24662 } 24663 24664 24665 void equalSmallJsonCharT(void) { 24666 24667 bool r; 24668 smallJsont *self = allocSmallJson(); 24669 setTopSO(self, ""); 24670 24671 r = equalCharO(self,"qwe"); 24672 ck_assert(!r); 24673 freeO(self); 24674 setTopSO(self, "qwe"); 24675 r = equalCharO(self,"qwe"); 24676 ck_assert(r); 24677 // empty strings 24678 freeO(self); 24679 r = equalCharO(self, ""); 24680 ck_assert(!r); 24681 // json bool 24682 freeO(self); 24683 setTypeBoolO(self); 24684 r = equalCharO(self, "false"); 24685 ck_assert(r); 24686 r = equalCharO(self, "true"); 24687 ck_assert(!r); 24688 freeO(self); 24689 setTopBoolO(self, true); 24690 r = equalCharO(self, "false"); 24691 ck_assert(!r); 24692 r = equalCharO(self, "true"); 24693 ck_assert(r); 24694 r = equalCharO(self, " true"); 24695 ck_assert(!r); 24696 // json double 24697 freeO(self); 24698 setTopDoubleO(self, 2.2); 24699 r = equalCharO(self, "2.2"); 24700 ck_assert(r); 24701 freeO(self); 24702 setTopDoubleO(self, 2); 24703 r = equalCharO(self, "2.2"); 24704 ck_assert(!r); 24705 // value is an int so not equal to double (int)2 != (double)2 24706 // TODO is this reasonable? 24707 r = equalCharO(self, "2"); 24708 ck_assert(!r); 24709 r = equalCharO(self, "asd"); 24710 ck_assert(!r); 24711 // json int 24712 freeO(self); 24713 setTopIntO(self, 2); 24714 r = equalCharO(self, "2"); 24715 ck_assert(r); 24716 r = equalCharO(self, "3"); 24717 ck_assert(!r); 24718 r = equalCharO(self, "2.0"); 24719 ck_assert(!r); 24720 r = equalCharO(self, "asd"); 24721 ck_assert(!r); 24722 // null object 24723 freeO(self); 24724 setTopSO(self, "qwe"); 24725 r = equalCharO(self, null); 24726 ck_assert(!r); 24727 terminateO(self); 24728 24729 } 24730 24731 24732 void equalSmallJsonBoolT(void) { 24733 24734 bool r; 24735 smallJsont* self = allocG(rtSmallJsont); 24736 24737 // empty json 24738 r = equalBoolO(self, false); 24739 ck_assert(!r); 24740 // json bool 24741 freeO(self); 24742 setTypeBoolO(self); 24743 r = equalBoolO(self, false); 24744 ck_assert(r); 24745 // json double 24746 freeO(self); 24747 setTopDoubleO(self, 1); 24748 r = equalBoolO(self, true); 24749 ck_assert(r); 24750 // json int 24751 freeO(self); 24752 setTopIntO(self, 1); 24753 r = equalBoolO(self, true); 24754 ck_assert(r); 24755 // json string 24756 freeO(self); 24757 setTopSO(self, "TRUE"); 24758 r = equalBoolO(self, true); 24759 ck_assert(r); 24760 freeO(self); 24761 setTopSO(self, "FALSE"); 24762 r = equalBoolO(self, true); 24763 ck_assert(!r); 24764 freeO(self); 24765 setTopSO(self, "FALSE "); 24766 r = equalBoolO(self, false); 24767 ck_assert(!r); 24768 terminateO(self); 24769 24770 } 24771 24772 24773 void equalSmallJsonDoubleT(void) { 24774 24775 bool r; 24776 smallJsont* self = allocG(rtSmallJsont); 24777 24778 // empty json 24779 r = equalDoubleO(self, 0); 24780 ck_assert(!r); 24781 // json bool 24782 freeO(self); 24783 setTypeBoolO(self); 24784 r = equalDoubleO(self, 0); 24785 ck_assert(r); 24786 // json double 24787 freeO(self); 24788 setTopDoubleO(self, 1.2); 24789 r = equalDoubleO(self, 1.2); 24790 ck_assert(r); 24791 // json int 24792 freeO(self); 24793 setTopIntO(self, 1); 24794 r = equalDoubleO(self, 1); 24795 ck_assert(r); 24796 // json string 24797 freeO(self); 24798 setTopSO(self, "1.0"); 24799 r = equalDoubleO(self, 1); 24800 ck_assert(r); 24801 freeO(self); 24802 setTopSO(self, "1"); 24803 r = equalDoubleO(self, 1); 24804 ck_assert(!r); 24805 freeO(self); 24806 setTopSO(self, "qwe"); 24807 r = equalDoubleO(self, 0); 24808 ck_assert(!r); 24809 terminateO(self); 24810 24811 } 24812 24813 24814 void equalSmallJsonInt64T(void) { 24815 24816 bool r; 24817 smallJsont* self = allocG(rtSmallJsont); 24818 24819 // empty json 24820 r = equalInt64O(self, 0); 24821 ck_assert(!r); 24822 // json bool 24823 freeO(self); 24824 setTypeBoolO(self); 24825 r = equalInt64O(self, 0); 24826 ck_assert(r); 24827 // json double 24828 freeO(self); 24829 setTopDoubleO(self, 2); 24830 r = equalInt64O(self, 2); 24831 ck_assert(r); 24832 // json int 24833 freeO(self); 24834 setTopIntO(self, 2); 24835 r = equalInt64O(self, 2); 24836 ck_assert(r); 24837 // json string 24838 freeO(self); 24839 setTopSO(self, "3"); 24840 r = equalInt64O(self, 3); 24841 ck_assert(r); 24842 freeO(self); 24843 setTopSO(self, "1.0"); 24844 r = equalInt64O(self, 1); 24845 ck_assert(!r); 24846 freeO(self); 24847 setTopSO(self, "qwe"); 24848 r = equalInt64O(self, 0); 24849 ck_assert(!r); 24850 terminateO(self); 24851 24852 } 24853 24854 24855 void equalSmallJsonInt32T(void) { 24856 24857 bool r; 24858 smallJsont* self = allocG(rtSmallJsont); 24859 24860 // empty json 24861 r = equalInt32O(self, 0); 24862 ck_assert(!r); 24863 // json bool 24864 freeO(self); 24865 setTypeBoolO(self); 24866 r = equalInt32O(self, 0); 24867 ck_assert(r); 24868 // json double 24869 freeO(self); 24870 setTopDoubleO(self, 2); 24871 r = equalInt32O(self, 2); 24872 ck_assert(r); 24873 // json int 24874 freeO(self); 24875 setTopIntO(self, 2); 24876 r = equalInt32O(self, 2); 24877 ck_assert(r); 24878 // json string 24879 freeO(self); 24880 setTopSO(self, "3"); 24881 r = equalInt32O(self, 3); 24882 ck_assert(r); 24883 freeO(self); 24884 setTopSO(self, "1.0"); 24885 r = equalInt32O(self, 1); 24886 ck_assert(!r); 24887 freeO(self); 24888 setTopSO(self, "qwe"); 24889 r = equalInt32O(self, 0); 24890 ck_assert(!r); 24891 terminateO(self); 24892 24893 } 24894 24895 24896 void equalSmallJsonUint32T(void) { 24897 24898 bool r; 24899 smallJsont* self = allocG(rtSmallJsont); 24900 24901 // empty json 24902 r = equalUint32O(self, 0); 24903 ck_assert(!r); 24904 // json bool 24905 freeO(self); 24906 setTypeBoolO(self); 24907 r = equalUint32O(self, 0); 24908 ck_assert(r); 24909 // json double 24910 freeO(self); 24911 setTopDoubleO(self, 2); 24912 r = equalUint32O(self, 2); 24913 ck_assert(r); 24914 // json int 24915 freeO(self); 24916 setTopIntO(self, 2); 24917 r = equalUint32O(self, 2); 24918 ck_assert(r); 24919 // json string 24920 freeO(self); 24921 setTopSO(self, "3"); 24922 r = equalUint32O(self, 3); 24923 ck_assert(r); 24924 freeO(self); 24925 setTopSO(self, "1.0"); 24926 r = equalUint32O(self, 1); 24927 ck_assert(!r); 24928 freeO(self); 24929 setTopSO(self, "qwe"); 24930 r = equalUint32O(self, 0); 24931 ck_assert(!r); 24932 terminateO(self); 24933 24934 } 24935 24936 24937 void equalSmallJsonUint64T(void) { 24938 24939 bool r; 24940 smallJsont* self = allocG(rtSmallJsont); 24941 24942 // empty json 24943 r = equalUint64O(self, 0); 24944 ck_assert(!r); 24945 // json bool 24946 freeO(self); 24947 setTypeBoolO(self); 24948 r = equalUint64O(self, 0); 24949 ck_assert(r); 24950 // json double 24951 freeO(self); 24952 setTopDoubleO(self, 2); 24953 r = equalUint64O(self, 2); 24954 ck_assert(r); 24955 // json int 24956 freeO(self); 24957 setTopIntO(self, 2); 24958 r = equalUint64O(self, 2); 24959 ck_assert(r); 24960 // json string 24961 freeO(self); 24962 setTopSO(self, "3"); 24963 r = equalUint64O(self, 3); 24964 ck_assert(r); 24965 freeO(self); 24966 setTopSO(self, "1.0"); 24967 r = equalUint64O(self, 1); 24968 ck_assert(!r); 24969 freeO(self); 24970 setTopSO(self, "qwe"); 24971 r = equalUint64O(self, 0); 24972 ck_assert(!r); 24973 terminateO(self); 24974 24975 } 24976 24977 24978 void equalSmallJsonSmallBoolT(void) { 24979 24980 bool r; 24981 smallJsont* self = allocG(rtSmallJsont); 24982 smallBoolt* p2 = allocSmallBool(false); 24983 24984 // empty json 24985 r = equalSmallBoolO(self, p2); 24986 ck_assert(!r); 24987 // not equal 24988 setTopBoolO(self, true); 24989 r = equalSmallBoolO(self, p2); 24990 ck_assert(!r); 24991 // equal 24992 setValO(p2, true); 24993 r = equalSmallBoolO(self, p2); 24994 ck_assert(r); 24995 // empty smallBool 24996 freeO(p2); 24997 r = equalSmallBoolO(self, p2); 24998 ck_assert(!r); 24999 // non smallBool 25000 terminateO(p2); 25001 p2 = (smallBoolt*) allocSmallInt(0); 25002 r = equalSmallBoolO(self, p2); 25003 ck_assert(!r); 25004 // null 25005 r = equalSmallBoolO(self, null); 25006 ck_assert(!r); 25007 terminateO(p2); 25008 terminateO(self); 25009 25010 } 25011 25012 25013 void equalSmallJsonSmallBytesT(void) { 25014 25015 bool r; 25016 smallJsont* self = allocG(rtSmallJsont); 25017 smallBytest* p2 = allocSmallBytes("true", strlen("true")); 25018 25019 // empty json 25020 ck_assert(!self->f->equalSmallBytes(self, p2)); 25021 // json bool 25022 setTopBoolO(self, true); 25023 ck_assert(!self->f->equalSmallBytes(self, p2)); 25024 freeO(p2); 25025 pushBufferO(p2, "true", sizeof("true")); 25026 ck_assert(self->f->equalSmallBytes(self, p2)); 25027 freeO(self); 25028 setTopBoolO(self, false); 25029 ck_assert(!self->f->equalSmallBytes(self, p2)); 25030 freeO(p2); 25031 pushBufferO(p2, "false", sizeof("false")); 25032 ck_assert(self->f->equalSmallBytes(self, p2)); 25033 freeO(self); 25034 setTopBoolO(self, true); 25035 ck_assert(!self->f->equalSmallBytes(self, p2)); 25036 freeO(p2); 25037 pushBufferO(p2, "False", sizeof("False")); 25038 ck_assert(!self->f->equalSmallBytes(self, p2)); 25039 // json double 25040 freeO(self); 25041 setTopDoubleO(self, 2.2); 25042 freeO(p2); 25043 pushBufferO(p2, "2.2", strlen("2.2")); 25044 r = self->f->equalSmallBytes(self, p2); 25045 ck_assert(!r); 25046 freeO(p2); 25047 pushBufferO(p2, "2.2", sizeof("2.2")); 25048 r = self->f->equalSmallBytes(self, p2); 25049 ck_assert(r); 25050 freeO(self); 25051 setTopDoubleO(self, 2); 25052 r = self->f->equalSmallBytes(self, p2); 25053 ck_assert(!r); 25054 freeO(p2); 25055 pushBufferO(p2, "2", sizeof("2")); 25056 r = self->f->equalSmallBytes(self, p2); 25057 ck_assert(!r); 25058 freeO(p2); 25059 pushBufferO(p2, "asd", sizeof("asd")); 25060 r = self->f->equalSmallBytes(self, p2); 25061 ck_assert(!r); 25062 // json int 25063 freeO(self); 25064 setTopIntO(self, 2); 25065 freeO(p2); 25066 pushBufferO(p2, "2", strlen("2")); 25067 r = self->f->equalSmallBytes(self, p2); 25068 ck_assert(!r); 25069 freeO(p2); 25070 pushBufferO(p2, "2", sizeof("2")); 25071 r = self->f->equalSmallBytes(self, p2); 25072 ck_assert(r); 25073 freeO(p2); 25074 pushBufferO(p2, "3", sizeof("3")); 25075 r = self->f->equalSmallBytes(self, p2); 25076 ck_assert(!r); 25077 freeO(p2); 25078 pushBufferO(p2, "2.0", sizeof("2.0")); 25079 r = self->f->equalSmallBytes(self, p2); 25080 ck_assert(!r); 25081 freeO(p2); 25082 pushBufferO(p2, "asd", sizeof("asd")); 25083 r = self->f->equalSmallBytes(self, p2); 25084 ck_assert(!r); 25085 // json string 25086 freeO(self); 25087 setTopSO(self, "qweert"); 25088 r = self->f->equalSmallBytes(self, p2); 25089 ck_assert(!r); 25090 freeO(self); 25091 setTopSO(self, "asd"); 25092 r = self->f->equalSmallBytes(self, p2); 25093 ck_assert(r); 25094 // empty smallBytes 25095 freeO(p2); 25096 ck_assert(!self->f->equalSmallBytes(self, p2)); 25097 // non smallBytes 25098 terminateO(p2); 25099 p2 = (smallBytest*) allocSmallInt(0); 25100 ck_assert(!self->f->equalSmallBytes(self, p2)); 25101 // null 25102 ck_assert(!self->f->equalSmallBytes(self, null)); 25103 terminateO(p2); 25104 terminateO(self); 25105 25106 } 25107 25108 25109 void equalSmallJsonSmallDoubleT(void) { 25110 25111 bool r; 25112 smallJsont* self = allocG(rtSmallJsont); 25113 smallDoublet* p2 = allocSmallDouble(0); 25114 25115 // empty json 25116 r = equalSmallDoubleO(self, p2); 25117 ck_assert(!r); 25118 // json bool 25119 freeO(self); 25120 setTypeBoolO(self); 25121 r = equalSmallDoubleO(self, p2); 25122 ck_assert(r); 25123 // json double 25124 freeO(self); 25125 setTopDoubleO(self, 1.2); 25126 setValO(p2, 1.2); 25127 r = equalSmallDoubleO(self, p2); 25128 ck_assert(r); 25129 // json int 25130 freeO(self); 25131 setTopIntO(self, 1); 25132 setValO(p2, 1); 25133 r = equalSmallDoubleO(self, p2); 25134 ck_assert(r); 25135 // json string 25136 freeO(self); 25137 setTopSO(self, "1.0"); 25138 r = equalSmallDoubleO(self, p2); 25139 ck_assert(r); 25140 freeO(self); 25141 setTopSO(self, "1"); 25142 r = equalSmallDoubleO(self, p2); 25143 ck_assert(!r); 25144 freeO(self); 25145 setTopSO(self, "qwe"); 25146 r = equalSmallDoubleO(self, p2); 25147 ck_assert(!r); 25148 // empty smallDouble 25149 freeO(p2); 25150 ck_assert(!equalSmallDoubleO(self, p2)); 25151 // non smallDouble 25152 terminateO(p2); 25153 p2 = (smallDoublet*) allocSmallInt(0); 25154 ck_assert(!equalSmallDoubleO(self, p2)); 25155 // null 25156 ck_assert(!equalSmallDoubleO(self, null)); 25157 terminateO(p2); 25158 terminateO(self); 25159 25160 } 25161 25162 25163 void equalSmallJsonSmallIntT(void) { 25164 25165 bool r; 25166 smallJsont* self = allocG(rtSmallJsont); 25167 smallIntt* p2 = allocSmallInt(0); 25168 25169 // empty json 25170 r = equalSmallIntO(self, p2); 25171 ck_assert(!r); 25172 // json bool 25173 freeO(self); 25174 setTypeBoolO(self); 25175 r = equalSmallIntO(self, p2); 25176 ck_assert(r); 25177 // json double 25178 freeO(self); 25179 setTopDoubleO(self, 2); 25180 setValO(p2, 2); 25181 r = equalSmallIntO(self, p2); 25182 ck_assert(r); 25183 // json int 25184 freeO(self); 25185 setTopIntO(self, 2); 25186 r = equalSmallIntO(self, p2); 25187 ck_assert(r); 25188 // json string 25189 freeO(self); 25190 setTopSO(self, "3"); 25191 setValO(p2, 3); 25192 r = equalSmallIntO(self, p2); 25193 ck_assert(r); 25194 freeO(self); 25195 setTopSO(self, "1.0"); 25196 setValO(p2, 1); 25197 r = equalSmallIntO(self, p2); 25198 ck_assert(!r); 25199 freeO(self); 25200 setTopSO(self, "qwe"); 25201 r = equalSmallIntO(self, p2); 25202 ck_assert(!r); 25203 // empty smallInt 25204 freeO(p2); 25205 ck_assert(!equalSmallIntO(self, p2)); 25206 // non smallInt 25207 terminateO(p2); 25208 p2 = (smallIntt*) allocSmallBool(false); 25209 ck_assert(!equalSmallIntO(self, p2)); 25210 // null 25211 ck_assert(!equalSmallIntO(self, null)); 25212 terminateO(p2); 25213 terminateO(self); 25214 25215 } 25216 25217 25218 void equalSmallJsonSmallJsonT(void) { 25219 25220 bool r; 25221 smallJsont* self = allocG(rtSmallJsont); 25222 smallJsont* p2 = allocSmallJson(); 25223 25224 // empty json 25225 r = equalSmallJsonO(self, p2); 25226 ck_assert(!r); 25227 // undefined 25228 setTypeUndefinedO(p2); 25229 ck_assert(!equalSmallJsonO(self, p2)); 25230 setTypeUndefinedO(self); 25231 ck_assert(equalSmallJsonO(self, p2)); 25232 // bool 25233 freeO(self); 25234 freeO(p2); 25235 setTopBoolO(self, true); 25236 setTopBoolO(p2, true); 25237 ck_assert(equalSmallJsonO(self, p2)); 25238 // double 25239 freeO(self); 25240 freeO(p2); 25241 setTopDoubleO(self, 2.3); 25242 setTopDoubleO(p2, 2.3); 25243 ck_assert(equalSmallJsonO(self, p2)); 25244 // int 25245 freeO(self); 25246 freeO(p2); 25247 setTopIntO(self, 2); 25248 setTopIntO(p2, 2); 25249 ck_assert(equalSmallJsonO(self, p2)); 25250 // string 25251 freeO(self); 25252 freeO(p2); 25253 setTopSO(self, ""); 25254 setTopSO(p2, ""); 25255 ck_assert(equalSmallJsonO(self, p2)); 25256 // dict 25257 freeO(self); 25258 freeO(p2); 25259 setTypeDictO(self); 25260 setTypeDictO(p2); 25261 ck_assert(equalSmallJsonO(self, p2)); 25262 // array 25263 freeO(self); 25264 freeO(p2); 25265 setTypeArrayO(self); 25266 setTypeArrayO(p2); 25267 ck_assert(equalSmallJsonO(self, p2)); 25268 // empty smallJson 25269 freeO(p2); 25270 ck_assert(!equalSmallJsonO(self, p2)); 25271 // non smallJson 25272 terminateO(p2); 25273 p2 = (smallJsont*) allocSmallBool(false); 25274 ck_assert(!equalSmallJsonO(self, p2)); 25275 // null 25276 ck_assert(!equalSmallJsonO(self, null)); 25277 terminateO(p2); 25278 terminateO(self); 25279 25280 } 25281 25282 25283 void equalSmallJsonSmallStringT(void) { 25284 25285 bool r; 25286 smallJsont* self = allocG(rtSmallJsont); 25287 smallStringt* p2 = allocSmallString(""); 25288 25289 // empty json 25290 r = equalSmallStringO(self, p2); 25291 ck_assert(!r); 25292 // json bool 25293 setTypeBoolO(self); 25294 setValO(p2, "false"); 25295 r = equalSmallStringO(self, p2); 25296 ck_assert(r); 25297 setValO(p2, "true"); 25298 r = equalSmallStringO(self, p2); 25299 ck_assert(!r); 25300 freeO(self); 25301 setTopBoolO(self, true); 25302 setValO(p2, "false"); 25303 r = equalSmallStringO(self, p2); 25304 ck_assert(!r); 25305 setValO(p2, "true"); 25306 r = equalSmallStringO(self, p2); 25307 ck_assert(r); 25308 setValO(p2, " true"); 25309 r = equalSmallStringO(self, p2); 25310 ck_assert(!r); 25311 // json double 25312 freeO(self); 25313 setTopDoubleO(self, 2.2); 25314 setValO(p2, "2.2"); 25315 r = equalSmallStringO(self, p2); 25316 ck_assert(r); 25317 freeO(self); 25318 setTopDoubleO(self, 2); 25319 r = equalSmallStringO(self, p2); 25320 ck_assert(!r); 25321 setValO(p2, "2"); 25322 r = equalSmallStringO(self, p2); 25323 ck_assert(!r); 25324 setValO(p2, "asd"); 25325 r = equalSmallStringO(self, p2); 25326 ck_assert(!r); 25327 // json int 25328 freeO(self); 25329 setTopIntO(self, 2); 25330 setValO(p2, "2"); 25331 r = equalSmallStringO(self, p2); 25332 ck_assert(r); 25333 setValO(p2, "3"); 25334 r = equalSmallStringO(self, p2); 25335 ck_assert(!r); 25336 setValO(p2, "2.0"); 25337 r = equalSmallStringO(self, p2); 25338 ck_assert(!r); 25339 setValO(p2, "asd"); 25340 r = equalSmallStringO(self, p2); 25341 ck_assert(!r); 25342 // json string 25343 freeO(self); 25344 setTopSO(self, ""); 25345 r = equalSmallStringO(self, p2); 25346 ck_assert(!r); 25347 freeO(self); 25348 setTopSO(self, "asd"); 25349 r = equalSmallStringO(self, p2); 25350 ck_assert(r); 25351 // empty strings 25352 freeO(self); 25353 setValO(p2, ""); 25354 r = equalSmallStringO(self, p2); 25355 ck_assert(!r); 25356 // empty smallString 25357 freeO(p2); 25358 ck_assert(!equalSmallStringO(self, p2)); 25359 // non smallString 25360 terminateO(p2); 25361 p2 = (smallStringt*) allocSmallBool(false); 25362 ck_assert(!equalSmallStringO(self, p2)); 25363 // null 25364 ck_assert(!equalSmallStringO(self, null)); 25365 terminateO(p2); 25366 terminateO(self); 25367 25368 } 25369 25370 25371 void equalSmallJsonSmallDictT(void) { 25372 25373 bool r; 25374 smallJsont* self = allocG(rtSmallJsont); 25375 smallDictt* p2 = allocSmallDict(); 25376 25377 // empty json 25378 r = self->f->equalSmallDict(self, p2); 25379 ck_assert(!r); 25380 setTypeDictO(self); 25381 r = self->f->equalSmallDict(self, p2); 25382 ck_assert(!r); 25383 // equal 25384 self->f->setInt(self, "a", 1); 25385 self->f->setInt(self, "b", 2); 25386 self->f->setInt(self, "c", 3); 25387 p2->f->setInt(p2, "b", 2); 25388 p2->f->setInt(p2, "a", 1); 25389 p2->f->setInt(p2, "c", 3); 25390 r = self->f->equalSmallDict(self, p2); 25391 ck_assert(r); 25392 // non equal 25393 p2->f->setInt(p2, "b", 1); 25394 r = self->f->equalSmallDict(self, p2); 25395 ck_assert(!r); 25396 p2->f->del(p2, "b"); 25397 r = self->f->equalSmallDict(self, p2); 25398 ck_assert(!r); 25399 // empty smallDict 25400 freeO(p2); 25401 ck_assert(!self->f->equalSmallDict(self, p2)); 25402 // non smallDict 25403 terminateO(p2); 25404 p2 = (smallDictt*) allocSmallBool(false); 25405 ck_assert(!self->f->equalSmallDict(self, p2)); 25406 // null 25407 ck_assert(!self->f->equalSmallDict(self, null)); 25408 terminateO(p2); 25409 terminateO(self); 25410 25411 } 25412 25413 25414 void icEqualSmallJsonSmallArrayT(void) { 25415 25416 bool r; 25417 smallJsont *self = allocG(rtSmallJsont); 25418 smallArrayt *array = allocSmallArray(); 25419 25420 // empty arrays 25421 setTypeArrayO(self); 25422 r = self->f->icEqualSmallArray(self, array); 25423 ck_assert(r); 25424 // empty self, non empty array 25425 array->f->pushInt(array, 1); 25426 r = self->f->icEqualSmallArray(self, array); 25427 ck_assert(!r); 25428 // non empty self, empty array 25429 emptyO(array); 25430 self->f->pushInt(self, 1); 25431 r = self->f->icEqualSmallArray(self, array); 25432 ck_assert(!r); 25433 // different lengths 25434 array->f->pushInt(array, 1); 25435 self->f->pushS(self, "a"); 25436 r = self->f->icEqualSmallArray(self, array); 25437 ck_assert(!r); 25438 // equal arrays 25439 array->f->pushS(array, "A"); 25440 r = self->f->icEqualSmallArray(self, array); 25441 ck_assert(r); 25442 // different int value 25443 self->f->setAtInt(self, 1, 1); 25444 array->f->setAtInt(array, 1, 2); 25445 r = self->f->icEqualSmallArray(self, array); 25446 ck_assert(!r); 25447 // array same length with a null element in self 25448 smallIntt *i = self->f->getAtSmallInt(self, 1); 25449 removeElemIndexO(self, 1); 25450 terminateO(i); 25451 r = self->f->icEqualSmallArray(self, array); 25452 ck_assert(!r); 25453 // array same length with a null element in both arrays 25454 i = array->f->getAtSmallInt(array, 1); 25455 removeElemO(array, 1); 25456 terminateO(i); 25457 r = self->f->icEqualSmallArray(self, array); 25458 ck_assert(r); 25459 // elements of different types 25460 self->f->setAtBool(self, 1, true); 25461 array->f->setAtInt(array, 1, 1); 25462 r = self->f->icEqualSmallArray(self, array); 25463 ck_assert(!r); 25464 // compare bool 25465 array->f->setAtBool(array, 1, true); 25466 r = self->f->icEqualSmallArray(self, array); 25467 ck_assert(r); 25468 array->f->setAtBool(array, 1, false); 25469 r = self->f->icEqualSmallArray(self, array); 25470 ck_assert(!r); 25471 // compare dict 25472 createSmallDict(d1); 25473 createSmallDict(d2); 25474 self->f->setAtDict(self, 1, &d1); 25475 array->f->setAtDict(array, 1, &d2); 25476 r = self->f->icEqualSmallArray(self, array); 25477 ck_assert(r); 25478 // reuse dict container, the data is in self already 25479 resetO(&d1); 25480 (&d1)->f->setInt(&d1, "a", 1); 25481 self->f->setAtDict(self, 1, &d1); 25482 r = self->f->icEqualSmallArray(self, array); 25483 ck_assert(!r); 25484 // compare double 25485 self->f->setAtDouble(self, 1, 0); 25486 array->f->setAtDouble(array, 1, 0); 25487 r = self->f->icEqualSmallArray(self, array); 25488 ck_assert(r); 25489 array->f->setAtDouble(array, 1, 10.5); 25490 r = self->f->icEqualSmallArray(self, array); 25491 ck_assert(!r); 25492 // compare string 25493 self->f->setAtS(self, 1, ""); 25494 array->f->setAtS(array, 1, ""); 25495 r = self->f->icEqualSmallArray(self, array); 25496 ck_assert(r); 25497 array->f->setAtS(array, 1, "NO"); 25498 r = self->f->icEqualSmallArray(self, array); 25499 ck_assert(!r); 25500 // compare array elements 25501 createSmallArray(a1); 25502 createSmallArray(a2); 25503 self->f->setAtArray(self, 1, &a1); 25504 array->f->setAtArray(array, 1, &a2); 25505 r = self->f->icEqualSmallArray(self, array); 25506 ck_assert(r); 25507 // reuse Array container, the data is in self already 25508 resetO(&a1); 25509 (&a1)->f->pushInt(&a1, 1); 25510 self->f->setAtArray(self, 1, &a1); 25511 r = self->f->icEqualSmallArray(self, array); 25512 ck_assert(!r); 25513 // compare bytes 25514 createSmallBytes(b1); 25515 createSmallBytes(b2); 25516 self->f->setAtSmallBytes(self, 1, &b1); 25517 array->f->setAtSmallBytes(array, 1, &b2); 25518 r = self->f->icEqualSmallArray(self, array); 25519 ck_assert(r); 25520 // reuse SmallBytes container, the data is in self already 25521 b1.B = null; 25522 pushBufferO(&b1, &self, 2); 25523 self->f->setAtSmallBytes(self, 1, &b1); 25524 r = self->f->icEqualSmallArray(self, array); 25525 ck_assert(!r); 25526 // compare data in both smallBytes elements 25527 b2.B = null; 25528 pushBufferO(&b2, (char*)(&self) + 4, 2); 25529 array->f->setAtSmallBytes(array, 1, &b2); 25530 r = self->f->icEqualSmallArray(self, array); 25531 ck_assert(!r); 25532 // non smallArray object 25533 terminateO(array); 25534 array = (smallArrayt*) allocSmallInt(2); 25535 r = self->f->icEqualSmallArray(self, array); 25536 ck_assert(!r); 25537 // NULL array 25538 r = self->f->icEqualSmallArray(self, NULL); 25539 ck_assert(!r); 25540 // non json array 25541 freeO(self); 25542 setTypeDictO(self); 25543 ck_assert(!self->f->icEqualSmallArray(self, array)); 25544 // non smallArray array 25545 freeO(self); 25546 setTypeArrayO(self); 25547 terminateO(array); 25548 array = (smallArrayt*) allocSmallInt(2); 25549 r = self->f->icEqualSmallArray(self, array); 25550 ck_assert(!r); 25551 terminateO(array); 25552 terminateO(self); 25553 25554 } 25555 25556 25557 void icEqualSmallJsonArrayT(void) { 25558 25559 bool r; 25560 smallJsont *self = allocG(rtSmallJsont); 25561 char ** p2 = NULL; 25562 25563 // empty arrays 25564 setTypeArrayO(self); 25565 r = self->f->icEqualArray(self, NULL); 25566 ck_assert(r); 25567 // empty self, non empty array 25568 p2 = listCreateS("a"); 25569 r = self->f->icEqualArray(self, p2); 25570 ck_assert(!r); 25571 // non empty self, empty array 25572 self->f->pushInt(self, 1); 25573 listFreeS(p2); 25574 listEmptyS(p2); 25575 r = self->f->icEqualArray(self, p2); 25576 ck_assert(!r); 25577 // different lengths 25578 listPushS(&p2, "a"); 25579 self->f->pushInt(self, 2); 25580 r = self->f->icEqualArray(self, p2); 25581 ck_assert(!r); 25582 // equal arrays 25583 emptyO(self); 25584 self->f->pushS(self, "A"); 25585 r = self->f->icEqualArray(self, p2); 25586 ck_assert(r); 25587 // not string type in self 25588 self->f->setAtInt(self, 0, 0); 25589 r = self->f->icEqualArray(self, p2); 25590 ck_assert(!r); 25591 // array same length with a null element in self 25592 smallIntt *i = self->f->getAtSmallInt(self, 0); 25593 terminateO(i); 25594 removeElemIndexO(self, 0); 25595 r = self->f->icEqualArray(self, p2); 25596 ck_assert(!r); 25597 // different strings 25598 self->f->setAtS(self, 0, "bb"); 25599 r = self->f->icEqualArray(self, p2); 25600 ck_assert(!r); 25601 // non json array 25602 freeO(self); 25603 setTypeBoolO(self); 25604 ck_assert(!self->f->icEqualArray(self, p2)); 25605 listFreeS(p2); 25606 terminateO(self); 25607 25608 } 25609 25610 25611 void icEqualSmallJsonBaseT(void) { 25612 25613 bool r; 25614 smallJsont *self = allocG(rtSmallJsont); 25615 baset* p2; 25616 25617 // json bool 25618 setTopBoolO(self, false); 25619 p2 = (baset*) allocSmallBool(false); 25620 r = self->f->icEqualBase(self, p2); 25621 ck_assert(r); 25622 freeO(self); 25623 setTopBoolO(self, true); 25624 r = self->f->icEqualBase(self, p2); 25625 ck_assert(!r); 25626 terminateO(p2); 25627 p2 = (baset*) allocSmallBool(true); 25628 r = self->f->icEqualBase(self, p2); 25629 ck_assert(r); 25630 // non equal 25631 terminateO(p2); 25632 p2 = (baset*) allocSmallString("true "); 25633 r = self->f->icEqualBase(self, p2); 25634 ck_assert(!r); 25635 // json double 25636 freeO(self); 25637 setTopDoubleO(self, 2.2); 25638 terminateO(p2); 25639 p2 = (baset*) allocSmallString("2.2"); 25640 r = self->f->icEqualBase(self, p2); 25641 ck_assert(r); 25642 freeO(self); 25643 setTopDoubleO(self, 2); 25644 r = self->f->icEqualBase(self, p2); 25645 ck_assert(!r); 25646 terminateO(p2); 25647 // p2 is an int so not equal to double (int)2 != (double)2 25648 // TODO is this reasonable? 25649 p2 = (baset*) allocSmallInt(2); 25650 r = self->f->icEqualBase(self, p2); 25651 ck_assert(!r); 25652 terminateO(p2); 25653 p2 = (baset*) allocSmallString("asd"); 25654 r = self->f->icEqualBase(self, p2); 25655 ck_assert(!r); 25656 // json int 25657 freeO(self); 25658 setTopIntO(self, 2); 25659 terminateO(p2); 25660 p2 = (baset*) allocSmallString("2"); 25661 r = self->f->icEqualBase(self, p2); 25662 ck_assert(r); 25663 terminateO(p2); 25664 p2 = (baset*) allocSmallString("3"); 25665 r = self->f->icEqualBase(self, p2); 25666 ck_assert(!r); 25667 terminateO(p2); 25668 p2 = (baset*) allocSmallDouble(2); 25669 r = self->f->icEqualBase(self, p2); 25670 ck_assert(!r); 25671 terminateO(p2); 25672 p2 = (baset*) allocSmallString("asd"); 25673 r = self->f->icEqualBase(self, p2); 25674 ck_assert(!r); 25675 // json string 25676 freeO(self); 25677 setTopSO(self, "asd"); 25678 terminateO(p2); 25679 p2 = (baset*) allocSmallString("ASD"); 25680 r = self->f->icEqualBase(self, p2); 25681 ck_assert(r); 25682 // empty self 25683 freeO(self); 25684 r = self->f->icEqualBase(self, p2); 25685 ck_assert(!r); 25686 // non smallString p2 25687 setTopSO(self, "asd"); 25688 terminateO(p2); 25689 p2 = (baset*) allocSmallBool(false); 25690 r = self->f->icEqualBase(self, p2); 25691 ck_assert(!r); 25692 // json dict 25693 freeO(self); 25694 setTypeDictO(self); 25695 self->f->setS(self, "1", "a"); 25696 terminateO(p2); 25697 p2 = (baset*) allocSmallInt(12); 25698 r = self->f->icEqualBase(self, p2); 25699 ck_assert(!r); 25700 terminateO(p2); 25701 smallDictt *d = allocSmallDict(); 25702 d->f->setS(d, "1", "A"); 25703 p2 = (baset*) d; 25704 r = self->f->icEqualBase(self, p2); 25705 ck_assert(r); 25706 // json array 25707 freeO(self); 25708 setTypeArrayO(self); 25709 self->f->pushS(self, "a"); 25710 terminateO(p2); 25711 p2 = (baset*) allocSmallInt(12); 25712 r = self->f->icEqualBase(self, p2); 25713 ck_assert(!r); 25714 r = self->f->icEqualBase(self, p2); 25715 ck_assert(!r); 25716 terminateO(p2); 25717 smallArrayt *a = allocSmallArray(); 25718 a->f->pushS(a, "A"); 25719 p2 = (baset*) a; 25720 r = self->f->icEqualBase(self, p2); 25721 ck_assert(r); 25722 // null object 25723 freeO(self); 25724 setTopSO(self, "qwe"); 25725 r = self->f->icEqualBase(self, null); 25726 ck_assert(!r); 25727 terminateO(p2); 25728 terminateO(self); 25729 25730 } 25731 25732 25733 void icEqualSmallJsonSmallDictT(void) { 25734 25735 bool r; 25736 smallJsont* self = allocG(rtSmallJsont); 25737 smallDictt* p2 = allocSmallDict(); 25738 25739 // empty json 25740 r = self->f->icEqualSmallDict(self, p2); 25741 ck_assert(!r); 25742 setTypeDictO(self); 25743 r = self->f->icEqualSmallDict(self, p2); 25744 ck_assert(!r); 25745 // equal 25746 self->f->setS(self, "a", "a"); 25747 self->f->setInt(self, "b", 2); 25748 self->f->setInt(self, "c", 3); 25749 p2->f->setInt(p2, "b", 2); 25750 p2->f->setS(p2, "a", "A"); 25751 p2->f->setInt(p2, "c", 3); 25752 r = self->f->icEqualSmallDict(self, p2); 25753 ck_assert(r); 25754 // non equal 25755 p2->f->setInt(p2, "b", 1); 25756 r = self->f->icEqualSmallDict(self, p2); 25757 ck_assert(!r); 25758 p2->f->del(p2, "b"); 25759 r = self->f->icEqualSmallDict(self, p2); 25760 ck_assert(!r); 25761 // empty smallDict 25762 freeO(p2); 25763 ck_assert(!self->f->icEqualSmallDict(self, p2)); 25764 // non smallDict 25765 terminateO(p2); 25766 p2 = (smallDictt*) allocSmallBool(false); 25767 ck_assert(!self->f->icEqualSmallDict(self, p2)); 25768 // null 25769 ck_assert(!self->f->icEqualSmallDict(self, null)); 25770 terminateO(p2); 25771 terminateO(self); 25772 25773 } 25774 25775 25776 void icEqualSmallJsonSmallJsonT(void) { 25777 25778 bool r; 25779 smallJsont *self = allocG(rtSmallJsont); 25780 smallJsont *string = allocSmallJson(); 25781 25782 // empty json 25783 setTopSO(string, "qwe"); 25784 r = icEqualSmallJsonO(self, string); 25785 ck_assert(!r); 25786 // equal 25787 setTopSO(self, "QWE"); 25788 r = icEqualSmallJsonO(self, string); 25789 ck_assert(r); 25790 // different length 25791 freeO(self); 25792 setTopSO(self, "QWE "); 25793 r = icEqualSmallJsonO(self, string); 25794 ck_assert(!r); 25795 // non json string 25796 terminateO(string); 25797 string = (smallJsont*) allocSmallBool(true); 25798 r = icEqualSmallJsonO(self, string); 25799 ck_assert(!r); 25800 // null 25801 r = icEqualSmallJsonO(self, null); 25802 ck_assert(!r); 25803 terminateO(string); 25804 terminateO(self); 25805 25806 } 25807 25808 25809 void icEqualSmallJsonSmallStringT(void) { 25810 25811 bool r; 25812 smallJsont *self = allocG(rtSmallJsont); 25813 smallStringt *string = allocSmallString("qwe"); 25814 25815 // empty json 25816 r = icEqualSmallStringO(self, string); 25817 ck_assert(!r); 25818 // equal 25819 setTopSO(self, "QWE"); 25820 r = icEqualSmallStringO(self, string); 25821 ck_assert(r); 25822 // different length 25823 freeO(self); 25824 setTopSO(self, "QWE "); 25825 r = icEqualSmallStringO(self, string); 25826 ck_assert(!r); 25827 // empty string 25828 freeO(string); 25829 r = icEqualSmallStringO(self, string); 25830 ck_assert(!r); 25831 // non json string 25832 terminateO(string); 25833 string = (smallStringt*) allocSmallBool(true); 25834 r = icEqualSmallStringO(self, string); 25835 ck_assert(!r); 25836 // null 25837 r = icEqualSmallStringO(self, null); 25838 ck_assert(!r); 25839 terminateO(string); 25840 terminateO(self); 25841 25842 } 25843 25844 25845 void icEqualSSmallJsonT(void) { 25846 25847 bool r; 25848 smallJsont *self = allocG(rtSmallJsont); 25849 25850 // empty json 25851 r = icEqualSO(self, "qwe"); 25852 ck_assert(!r); 25853 // equal 25854 setTopSO(self, "QWE"); 25855 r = icEqualSO(self, "qwe"); 25856 ck_assert(r); 25857 // different length 25858 r = icEqualSO(self, "qwe "); 25859 ck_assert(!r); 25860 // null 25861 r = icEqualSO(self, null); 25862 ck_assert(!r); 25863 terminateO(self); 25864 25865 } 25866 25867 25868 void icEqualCharSmallJsonT(void) { 25869 25870 bool r; 25871 smallJsont *self = allocG(rtSmallJsont); 25872 setTopSO(self, ""); 25873 25874 r = icEqualCharO(self,'q'); 25875 ck_assert(!r); 25876 freeO(self); 25877 setTopSO(self, "q"); 25878 r = icEqualCharO(self,'Q'); 25879 ck_assert(r); 25880 // empty strings 25881 freeO(self); 25882 r = icEqualCharO(self, ' '); 25883 ck_assert(!r); 25884 // json int 25885 freeO(self); 25886 setTopIntO(self, 1); 25887 r = icEqualCharO(self,'1'); 25888 ck_assert(r); 25889 r = icEqualCharO(self,'2'); 25890 ck_assert(!r); 25891 r = icEqualCharO(self,'q'); 25892 ck_assert(!r); 25893 // non json string or int 25894 freeO(self); 25895 setTypeBoolO(self); 25896 r = icEqualCharO(self,'2'); 25897 ck_assert(!r); 25898 terminateO(self); 25899 25900 } 25901 25902 25903 void equalISSmallJsonT(void) { 25904 25905 smallJsont *self = allocSmallJson(); 25906 setTopSO(self, "Ashee|"); 25907 25908 // identical strings 25909 ck_assert(equalISO(self, "shee", 1)); 25910 freeO(self); 25911 setTopSO(self, "Ashee"); 25912 ck_assert(equalISO(self, "shee", -4)); 25913 // string at index shorter than string2 25914 ck_assert(!equalISO(self, "shee", 2)); 25915 // empty string 25916 freeO(self); 25917 setTopSO(self, ""); 25918 ck_assert(!equalISO(self, "shee", 0)); 25919 ck_assert(equalISO(self, "", 0)); 25920 freeO(self); 25921 setTopSO(self, "Ashee"); 25922 ck_assert(!equalISO(self, "", 0)); 25923 // index mismatch 25924 ck_assert(!equalISO(self, "shee", 0)); 25925 // index outside 25926 ck_assert(!equalISO(self, "shee", 10)); 25927 ck_assert(!equalISO(self, "shee", -10)); 25928 // different strings 25929 ck_assert(!equalISO(self, "SH",0)); 25930 // empty self 25931 freeO(self); 25932 ck_assert(!equalISO(self, "SH",0)); 25933 // NULL string 25934 freeO(self); 25935 setTopSO(self, "Ashee"); 25936 ck_assert(!equalISO(self, NULL, 0)); 25937 terminateO(self); 25938 25939 } 25940 25941 25942 void equalICharSmallJsonT(void) { 25943 25944 smallJsont *self = allocSmallJson(); 25945 setTopSO(self, "Ashee"); 25946 25947 // identical strings 25948 ck_assert(equalICharO(self, 's', 1)); 25949 ck_assert(equalICharO(self, 's', -4)); 25950 ck_assert(!equalICharO(self, 's', 2)); 25951 // empty string 25952 freeO(self); 25953 setTopSO(self, ""); 25954 ck_assert(!equalICharO(self, 's', 0)); 25955 ck_assert(equalICharO(self, 0, 0)); 25956 freeO(self); 25957 setTopSO(self, "Ashee"); 25958 ck_assert(!equalICharO(self, 0, 0)); 25959 // index mismatch 25960 ck_assert(!equalICharO(self, 's', 0)); 25961 // index outside 25962 ck_assert(!equalICharO(self, 's', 10)); 25963 ck_assert(!equalICharO(self, 's', -10)); 25964 // different strings 25965 freeO(self); 25966 setTopSO(self, "shee"); 25967 ck_assert(!equalICharO(self, 'S',0)); 25968 // NULL string 25969 ck_assert(!equalICharO(self, 0, 0)); 25970 // empty self 25971 freeO(self); 25972 ck_assert(!equalICharO(self, 'S',0)); 25973 terminateO(self); 25974 25975 } 25976 25977 25978 void equalIJsonSmallJsonT(void) { 25979 25980 smallJsont *self = allocSmallJson(); 25981 setTopSO(self, "Ashee|"); 25982 smallJsont *string = allocSmallJson(); 25983 25984 // identical strings 25985 setTopSO(string, "shee"); 25986 ck_assert(equalIJsonO(self, string, 1)); 25987 freeO(self); 25988 setTopSO(self, "Ashee"); 25989 ck_assert(equalIJsonO(self, string, -4)); 25990 // string at index shorter than string2 25991 ck_assert(!equalIJsonO(self, string, 2)); 25992 // empty string 25993 freeO(self); 25994 setTopSO(self, ""); 25995 ck_assert(!equalIJsonO(self, string, 0)); 25996 freeO(string); 25997 setTopSO(string, ""); 25998 ck_assert(equalIJsonO(self, string, 0)); 25999 freeO(self); 26000 setTopSO(self, "Ashee"); 26001 ck_assert(!equalIJsonO(self, string, 0)); 26002 // index mismatch 26003 freeO(string); 26004 setTopSO(string, "shee"); 26005 ck_assert(!equalIJsonO(self, string, 0)); 26006 // index outside 26007 ck_assert(!equalIJsonO(self, string, 10)); 26008 ck_assert(!equalIJsonO(self, string, -10)); 26009 // different strings 26010 freeO(string); 26011 setTopSO(string, "SH"); 26012 ck_assert(!equalIJsonO(self, string,0)); 26013 // non json string 26014 freeO(string); 26015 setTopIntO(string, 1); 26016 ck_assert(!equalIJsonO(self, string,0)); 26017 // non json object 26018 terminateO(string); 26019 string = (smallJsont*) allocSmallInt(2); 26020 ck_assert(!equalIJsonO(self, string,0)); 26021 // empty self 26022 terminateO(string); 26023 string = allocSmallJson(); 26024 setTopSO(string, "SH"); 26025 freeO(self); 26026 ck_assert(!equalIJsonO(self, string,0)); 26027 // NULL string 26028 freeO(self); 26029 setTopSO(self, "Ashee"); 26030 ck_assert(!equalIJsonO(self, NULL, 0)); 26031 terminateO(string); 26032 terminateO(self); 26033 26034 } 26035 26036 26037 void equalISmallStringSmallJsonT(void) { 26038 26039 smallJsont *self = allocSmallJson(); 26040 setTopSO(self, "Ashee|"); 26041 smallStringt *string = allocSmallString("shee"); 26042 26043 // identical strings 26044 ck_assert(equalISmallStringO(self, string, 1)); 26045 freeO(self); 26046 setTopSO(self, "Ashee"); 26047 ck_assert(equalISmallStringO(self, string, -4)); 26048 // string at index shorter than string2 26049 ck_assert(!equalISmallStringO(self, string, 2)); 26050 // empty string 26051 freeO(self); 26052 setTopSO(self, ""); 26053 ck_assert(!equalISmallStringO(self, string, 0)); 26054 setValO(string, ""); 26055 ck_assert(equalISmallStringO(self, string, 0)); 26056 freeO(self); 26057 setTopSO(self, "Ashee"); 26058 ck_assert(!equalISmallStringO(self, string, 0)); 26059 // index mismatch 26060 freeO(string); 26061 setValO(string, "shee"); 26062 ck_assert(!equalISmallStringO(self, string, 0)); 26063 // index outside 26064 ck_assert(!equalISmallStringO(self, string, 10)); 26065 ck_assert(!equalISmallStringO(self, string, -10)); 26066 // different strings 26067 setValO(string, "SH"); 26068 ck_assert(!equalISmallStringO(self, string,0)); 26069 // non smallString object 26070 terminateO(string); 26071 string = (smallStringt*) allocSmallInt(2); 26072 ck_assert(!equalISmallStringO(self, string,0)); 26073 // empty self 26074 terminateO(string); 26075 string = allocSmallString("SH"); 26076 freeO(self); 26077 ck_assert(!equalISmallStringO(self, string,0)); 26078 // NULL string 26079 freeO(self); 26080 setTopSO(self, "Ashee"); 26081 ck_assert(!equalISmallStringO(self, NULL, 0)); 26082 terminateO(string); 26083 terminateO(self); 26084 26085 } 26086 26087 26088 void startsWithSSmallJsonT(void) { 26089 26090 smallJsont *self = allocSmallJson(); 26091 setTopSO(self, "shee"); 26092 26093 // identical strings 26094 ck_assert(startsWithSO(self, "shee")); 26095 freeO(self); 26096 setTopSO(self, "sheepy"); 26097 ck_assert(startsWithSO(self, "shee")); 26098 // different strings 26099 freeO(self); 26100 setTopSO(self, "shee"); 26101 ck_assert(!startsWithSO(self, "SH")); 26102 ck_assert(!startsWithSO(self, "sheep")); 26103 freeO(self); 26104 setTopSO(self, "-shee"); 26105 ck_assert(!startsWithSO(self, "shee")); 26106 // NULL string 26107 ck_assert(!startsWithSO(self, NULL)); 26108 // empty self 26109 freeO(self); 26110 ck_assert(!startsWithSO(self, "shee")); 26111 terminateO(self); 26112 26113 } 26114 26115 26116 void startsWithCharSmallJsonT(void) { 26117 26118 smallJsont *self = allocSmallJson(); 26119 setTopSO(self, "shee"); 26120 26121 // identical strings 26122 ck_assert(startsWithCharO(self, 's')); 26123 freeO(self); 26124 setTopSO(self, "sheepy"); 26125 ck_assert(startsWithCharO(self, 's')); 26126 freeO(self); 26127 setTopSO(self, ""); 26128 ck_assert(startsWithCharO(self, 0)); 26129 // different strings 26130 freeO(self); 26131 setTopSO(self, "shee"); 26132 ck_assert(!startsWithCharO(self, 'S')); 26133 freeO(self); 26134 setTopSO(self, "-shee"); 26135 ck_assert(!startsWithCharO(self, 's')); 26136 freeO(self); 26137 setTopSO(self, ""); 26138 ck_assert(!startsWithCharO(self, '0')); 26139 // NULL string 26140 freeO(self); 26141 setTopSO(self, "shee"); 26142 ck_assert(!startsWithCharO(self, 0)); 26143 // empty self 26144 freeO(self); 26145 ck_assert(!startsWithCharO(self, '0')); 26146 terminateO(self); 26147 26148 } 26149 26150 26151 void startsWithSmallStringSmallJsonT(void) { 26152 26153 smallJsont *self = allocSmallJson(); 26154 setTopSO(self, "shee"); 26155 smallStringt *string = allocSmallString("shee"); 26156 26157 // identical strings 26158 ck_assert(startsWithSmallStringO(self, string)); 26159 freeO(self); 26160 setTopSO(self, "sheepy"); 26161 ck_assert(startsWithSmallStringO(self, string)); 26162 // different strings 26163 freeO(self); 26164 setTopSO(self, "shee"); 26165 setValO(string, "SH"); 26166 ck_assert(!startsWithSmallStringO(self, string)); 26167 setValO(string, "sheep"); 26168 ck_assert(!startsWithSmallStringO(self, string)); 26169 freeO(self); 26170 setTopSO(self, "-shee"); 26171 setValO(string, "shee"); 26172 ck_assert(!startsWithSmallStringO(self, string)); 26173 // non smallString object 26174 terminateO(string); 26175 string = (smallStringt*) allocSmallInt(1); 26176 ck_assert(!startsWithSmallStringO(self, string)); 26177 terminateO(string); 26178 string = allocSmallString("shee"); 26179 // NULL string 26180 ck_assert(!startsWithSmallStringO(self, NULL)); 26181 // empty self 26182 freeO(self); 26183 ck_assert(!startsWithSmallStringO(self, string)); 26184 terminateO(string); 26185 terminateO(self); 26186 26187 } 26188 26189 26190 void startsWithJsonSmallJsonT(void) { 26191 26192 smallJsont *self = allocSmallJson(); 26193 setTopSO(self, "shee"); 26194 smallJsont *string = allocSmallJson(); 26195 26196 // identical strings 26197 setTopSO(string, "shee"); 26198 ck_assert(startsWithJsonO(self, string)); 26199 freeO(self); 26200 setTopSO(self, "sheepy"); 26201 ck_assert(startsWithJsonO(self, string)); 26202 // different strings 26203 freeO(self); 26204 setTopSO(self, "shee"); 26205 freeO(string); 26206 setTopSO(string, "SH"); 26207 ck_assert(!startsWithJsonO(self, string)); 26208 freeO(string); 26209 setTopSO(string, "sheep"); 26210 ck_assert(!startsWithJsonO(self, string)); 26211 freeO(self); 26212 setTopSO(self, "-shee"); 26213 freeO(string); 26214 setTopSO(string, "shee"); 26215 ck_assert(!startsWithJsonO(self, string)); 26216 // non json string 26217 freeO(string); 26218 setTopIntO(string, 1); 26219 ck_assert(!startsWithJsonO(self, string)); 26220 // non json object 26221 terminateO(string); 26222 string = (smallJsont*) allocSmallInt(1); 26223 ck_assert(!startsWithJsonO(self, string)); 26224 terminateO(string); 26225 string = allocSmallJson(); 26226 // NULL string 26227 ck_assert(!startsWithJsonO(self, NULL)); 26228 // empty self 26229 freeO(self); 26230 setTopSO(string, "shee"); 26231 ck_assert(!startsWithJsonO(self, string)); 26232 terminateO(string); 26233 terminateO(self); 26234 26235 } 26236 26237 26238 void endsWithSSmallJsonT(void) { 26239 26240 smallJsont *self = allocSmallJson(); 26241 setTopSO(self, "shee"); 26242 26243 // identical strings 26244 ck_assert(endsWithSO(self, "shee")); 26245 freeO(self); 26246 setTopSO(self, "sheepy"); 26247 ck_assert(endsWithSO(self, "eepy")); 26248 // different strings 26249 freeO(self); 26250 setTopSO(self, "shee"); 26251 ck_assert(!endsWithSO(self, "SH")); 26252 ck_assert(!endsWithSO(self, "sheep")); 26253 freeO(self); 26254 setTopSO(self, "shee-"); 26255 ck_assert(!endsWithSO(self, "shee")); 26256 // NULL string 26257 ck_assert(!endsWithSO(self, NULL)); 26258 // empty self 26259 freeO(self); 26260 ck_assert(!endsWithSO(self, "shee")); 26261 terminateO(self); 26262 26263 } 26264 26265 26266 void endsWithCharSmallJsonT(void) { 26267 26268 smallJsont *self = allocSmallJson(); 26269 setTopSO(self, "shee"); 26270 26271 // identical strings 26272 ck_assert(endsWithCharO(self, 'e')); 26273 freeO(self); 26274 setTopSO(self, "sheepy"); 26275 ck_assert(endsWithCharO(self, 'y')); 26276 freeO(self); 26277 setTopSO(self, ""); 26278 ck_assert(endsWithCharO(self, 0)); 26279 // different strings 26280 freeO(self); 26281 setTopSO(self, "shee"); 26282 ck_assert(!endsWithCharO(self, 'E')); 26283 ck_assert(!endsWithCharO(self, 'p')); 26284 freeO(self); 26285 setTopSO(self, "shee-"); 26286 ck_assert(!endsWithCharO(self, 'e')); 26287 freeO(self); 26288 setTopSO(self, ""); 26289 ck_assert(!endsWithCharO(self, '0')); 26290 // NULL string 26291 freeO(self); 26292 setTopSO(self, "a"); 26293 ck_assert(!endsWithCharO(self, 0)); 26294 // empty self 26295 freeO(self); 26296 ck_assert(!endsWithCharO(self, '0')); 26297 terminateO(self); 26298 26299 } 26300 26301 26302 void endsWithSmallStringSmallJsonT(void) { 26303 26304 smallJsont *self = allocSmallJson(); 26305 setTopSO(self, "shee"); 26306 smallStringt *string = allocSmallString("shee"); 26307 26308 // identical strings 26309 ck_assert(endsWithSmallStringO(self, string)); 26310 freeO(self); 26311 setTopSO(self, "sheepy"); 26312 setValO(string, "eepy"); 26313 ck_assert(endsWithSmallStringO(self, string)); 26314 // different strings 26315 freeO(self); 26316 setTopSO(self, "shee"); 26317 ck_assert(!endsWithSmallStringO(self, string)); 26318 setValO(string, "sheep"); 26319 ck_assert(!endsWithSmallStringO(self, string)); 26320 freeO(self); 26321 setTopSO(self, "shee-"); 26322 setValO(string, "shee"); 26323 ck_assert(!endsWithSmallStringO(self, string)); 26324 // non smallString object 26325 terminateO(string); 26326 string = (smallStringt*) allocSmallInt(1); 26327 ck_assert(!endsWithSmallStringO(self, string)); 26328 terminateO(string); 26329 string = allocSmallString("shee"); 26330 // NULL string 26331 ck_assert(!endsWithSmallStringO(self, NULL)); 26332 // empty self 26333 freeO(self); 26334 ck_assert(!endsWithSmallStringO(self, string)); 26335 terminateO(string); 26336 terminateO(self); 26337 26338 } 26339 26340 26341 void endsWithJsonSmallJsonT(void) { 26342 26343 smallJsont *self = allocSmallJson(); 26344 setTopSO(self, "shee"); 26345 smallJsont *string = allocSmallJson(); 26346 26347 // identical strings 26348 setTopSO(string, "shee"); 26349 ck_assert(endsWithJsonO(self, string)); 26350 freeO(self); 26351 setTopSO(self, "sheepy"); 26352 freeO(string); 26353 setTopSO(string, "eepy"); 26354 ck_assert(endsWithJsonO(self, string)); 26355 // different strings 26356 freeO(self); 26357 setTopSO(self, "shee"); 26358 freeO(string); 26359 setTopSO(string, "SH"); 26360 ck_assert(!endsWithJsonO(self, string)); 26361 freeO(string); 26362 setTopSO(string, "sheep"); 26363 ck_assert(!endsWithJsonO(self, string)); 26364 freeO(self); 26365 setTopSO(self, "shee-"); 26366 freeO(string); 26367 setTopSO(string, "shee"); 26368 ck_assert(!endsWithJsonO(self, string)); 26369 // non json string 26370 freeO(string); 26371 setTopIntO(string, 1); 26372 ck_assert(!endsWithJsonO(self, string)); 26373 // non json object 26374 terminateO(string); 26375 string = (smallJsont*) allocSmallInt(1); 26376 ck_assert(!endsWithJsonO(self, string)); 26377 terminateO(string); 26378 string = allocSmallJson(); 26379 setTopSO(string, "shee"); 26380 // NULL string 26381 ck_assert(!endsWithJsonO(self, NULL)); 26382 // empty self 26383 freeO(self); 26384 ck_assert(!endsWithJsonO(self, string)); 26385 terminateO(string); 26386 terminateO(self); 26387 26388 } 26389 26390 26391 void countSSmallJsonT(void) { 26392 26393 smallJsont *self = allocSmallJson(); 26394 setTopSO(self, "sheepy"); 26395 26396 // positive count 26397 ck_assert_int_eq(countSO(self, "shee"), 1); 26398 freeO(self); 26399 setTopSO(self, "aaa aaa"); 26400 ck_assert_int_eq(countSO(self, "a"), 6); 26401 ck_assert_int_eq(countSO(self, "aa"), 2); 26402 // 0 count 26403 freeO(self); 26404 setTopSO(self, "shee"); 26405 ck_assert_int_eq(countSO(self, "SH"), 0); 26406 ck_assert_int_eq(countSO(self, "sheepy"), 0); 26407 freeO(self); 26408 setTopSO(self, "aaa aaa"); 26409 ck_assert_int_eq(countSO(self, "ab"), 0); 26410 // empty string 26411 ck_assert_int_eq(countSO(self, ""), -1); 26412 // NULL string 26413 ck_assert_int_eq(countSO(self, NULL), -1); 26414 // empty self 26415 freeO(self); 26416 ck_assert_int_eq(countSO(self, "ab"), -1); 26417 terminateO(self); 26418 26419 } 26420 26421 26422 void countCharSmallJsonT(void) { 26423 26424 smallJsont *self = allocSmallJson(); 26425 setTopSO(self, "shee"); 26426 26427 // positive count 26428 ck_assert_int_eq(countCharO(self, 's'), 1); 26429 freeO(self); 26430 setTopSO(self, "aaa aaa"); 26431 ck_assert_int_eq(countCharO(self, 'a'), 6); 26432 // 0 count 26433 freeO(self); 26434 setTopSO(self, "shee"); 26435 ck_assert_int_eq(countCharO(self, 'S'), 0); 26436 ck_assert_int_eq(countCharO(self, 'y'), 0); 26437 freeO(self); 26438 setTopSO(self, "aaa aaa"); 26439 ck_assert_int_eq(countCharO(self, 'b'), 0); 26440 // empty string 26441 freeO(self); 26442 setTopSO(self, ""); 26443 ck_assert_int_eq(countCharO(self, 'a'), 0); 26444 ck_assert_int_eq(countCharO(self, 0), -1); 26445 // NULL string 26446 freeO(self); 26447 setTopSO(self, "a"); 26448 ck_assert_int_eq(countCharO(self, 0), -1); 26449 // empty self 26450 freeO(self); 26451 ck_assert_int_eq(countCharO(self, 'a'), -1); 26452 terminateO(self); 26453 26454 } 26455 26456 26457 void countSmallStringSmallJsonT(void) { 26458 26459 smallJsont *self = allocSmallJson(); 26460 setTopSO(self, "sheepy"); 26461 smallStringt *string = allocSmallString("shee"); 26462 26463 // positive count 26464 ck_assert_int_eq(countSmallStringO(self, string), 1); 26465 freeO(self); 26466 setTopSO(self, "aaa aaa"); 26467 setValO(string, "a"); 26468 ck_assert_int_eq(countSmallStringO(self, string), 6); 26469 setValO(string, "aa"); 26470 ck_assert_int_eq(countSmallStringO(self, string), 2); 26471 // 0 count 26472 freeO(self); 26473 setTopSO(self, "shee"); 26474 setValO(string, "SH"); 26475 ck_assert_int_eq(countSmallStringO(self, string), 0); 26476 setValO(string, "sheepy"); 26477 ck_assert_int_eq(countSmallStringO(self, string), 0); 26478 freeO(self); 26479 setTopSO(self, "aaa aaa"); 26480 setValO(string, "ab"); 26481 ck_assert_int_eq(countSmallStringO(self, string), 0); 26482 // non json object 26483 terminateO(string); 26484 string = (smallStringt*) allocSmallInt(1); 26485 ck_assert_int_eq(countSmallStringO(self, string), -1); 26486 terminateO(string); 26487 string = allocSmallString(""); 26488 // empty string 26489 ck_assert_int_eq(countSmallStringO(self, string), -1); 26490 freeO(string); 26491 ck_assert_int_eq(countSmallStringO(self, string), -1); 26492 // NULL string 26493 ck_assert_int_eq(countSmallStringO(self, NULL), -1); 26494 // empty self 26495 freeO(self); 26496 setValO(string, "ab"); 26497 ck_assert_int_eq(countSmallStringO(self, string), -1); 26498 terminateO(string); 26499 terminateO(self); 26500 26501 } 26502 26503 26504 void countJsonSmallJsonT(void) { 26505 26506 smallJsont *self = allocSmallJson(); 26507 setTopSO(self, "sheepy"); 26508 smallJsont *string = allocSmallJson(); 26509 26510 // positive count 26511 setTopSO(string, "shee"); 26512 ck_assert_int_eq(countJsonO(self, string), 1); 26513 freeO(self); 26514 setTopSO(self, "aaa aaa"); 26515 freeO(string); 26516 setTopSO(string, "a"); 26517 ck_assert_int_eq(countJsonO(self, string), 6); 26518 freeO(string); 26519 setTopSO(string, "aa"); 26520 ck_assert_int_eq(countJsonO(self, string), 2); 26521 // 0 count 26522 freeO(self); 26523 setTopSO(self, "shee"); 26524 freeO(string); 26525 setTopSO(string, "SH"); 26526 ck_assert_int_eq(countJsonO(self, string), 0); 26527 freeO(string); 26528 setTopSO(string, "sheepy"); 26529 ck_assert_int_eq(countJsonO(self, string), 0); 26530 freeO(self); 26531 setTopSO(self, "aaa aaa"); 26532 freeO(string); 26533 setTopSO(string, "ab"); 26534 ck_assert_int_eq(countJsonO(self, string), 0); 26535 // non json string 26536 freeO(string); 26537 setTopIntO(string, -1); 26538 ck_assert_int_eq(countJsonO(self, string), -1); 26539 // non json object 26540 terminateO(string); 26541 string = (smallJsont*) allocSmallInt(1); 26542 ck_assert_int_eq(countJsonO(self, string), -1); 26543 terminateO(string); 26544 string = allocSmallJson(); 26545 // empty string 26546 setTopSO(string, ""); 26547 ck_assert_int_eq(countJsonO(self, string), -1); 26548 // NULL string 26549 ck_assert_int_eq(countJsonO(self, NULL), -1); 26550 // empty self 26551 freeO(self); 26552 freeO(string); 26553 setTopSO(string, "ab"); 26554 ck_assert_int_eq(countJsonO(self, string), -1); 26555 terminateO(string); 26556 terminateO(self); 26557 26558 } 26559 26560 26561 void icStartsWithSSmallJsonT(void) { 26562 26563 smallJsont *self = allocSmallJson(); 26564 setTopSO(self, "shee"); 26565 26566 // identical strings 26567 ck_assert(icStartsWithSO(self, "shee")); 26568 freeO(self); 26569 setTopSO(self, "sheepy"); 26570 ck_assert(icStartsWithSO(self, "shee")); 26571 // different strings 26572 freeO(self); 26573 setTopSO(self, "shee"); 26574 ck_assert(icStartsWithSO(self, "SH")); 26575 ck_assert(!icStartsWithSO(self, "sheep")); 26576 freeO(self); 26577 setTopSO(self, "-shee"); 26578 ck_assert(!icStartsWithSO(self, "shee")); 26579 // NULL string 26580 ck_assert(!icStartsWithSO(self, NULL)); 26581 // empty self 26582 freeO(self); 26583 ck_assert(!icStartsWithSO(self, "shee")); 26584 terminateO(self); 26585 26586 } 26587 26588 26589 void icStartsWithCharSmallJsonT(void) { 26590 26591 smallJsont *self = allocSmallJson(); 26592 setTopSO(self, "shee"); 26593 26594 // identical strings 26595 ck_assert(icStartsWithCharO(self, 's')); 26596 freeO(self); 26597 setTopSO(self, "sheepy"); 26598 ck_assert(icStartsWithCharO(self, 's')); 26599 freeO(self); 26600 setTopSO(self, ""); 26601 ck_assert(icStartsWithCharO(self, 0)); 26602 // different strings 26603 freeO(self); 26604 setTopSO(self, "shee"); 26605 ck_assert(icStartsWithCharO(self, 'S')); 26606 freeO(self); 26607 setTopSO(self, "-shee"); 26608 ck_assert(!icStartsWithCharO(self, 's')); 26609 freeO(self); 26610 setTopSO(self, ""); 26611 ck_assert(!icStartsWithCharO(self, '0')); 26612 // NULL string 26613 freeO(self); 26614 setTopSO(self, "shee"); 26615 ck_assert(!icStartsWithCharO(self, 0)); 26616 // empty self 26617 freeO(self); 26618 ck_assert(!icStartsWithCharO(self, '0')); 26619 terminateO(self); 26620 26621 } 26622 26623 26624 void icStartsWithSmallStringSmallJsonT(void) { 26625 26626 smallJsont *self = allocSmallJson(); 26627 setTopSO(self, "shee"); 26628 smallStringt *string = allocSmallString("shee"); 26629 26630 // identical strings 26631 ck_assert(icStartsWithSmallStringO(self, string)); 26632 freeO(self); 26633 setTopSO(self, "sheepy"); 26634 ck_assert(icStartsWithSmallStringO(self, string)); 26635 // different strings 26636 freeO(self); 26637 setTopSO(self, "shee"); 26638 setValO(string, "SH"); 26639 ck_assert(icStartsWithSmallStringO(self, string)); 26640 setValO(string, "sheep"); 26641 ck_assert(!icStartsWithSmallStringO(self, string)); 26642 freeO(self); 26643 setTopSO(self, "-shee"); 26644 setValO(string, "shee"); 26645 ck_assert(!icStartsWithSmallStringO(self, string)); 26646 // non smallString object 26647 terminateO(string); 26648 string = (smallStringt*) allocSmallInt(1); 26649 ck_assert(!icStartsWithSmallStringO(self, string)); 26650 terminateO(string); 26651 string = allocSmallString("shee"); 26652 // NULL string 26653 ck_assert(!icStartsWithSmallStringO(self, NULL)); 26654 // empty self 26655 freeO(self); 26656 ck_assert(!icStartsWithSmallStringO(self, string)); 26657 terminateO(string); 26658 terminateO(self); 26659 26660 } 26661 26662 26663 void icStartsWithJsonSmallJsonT(void) { 26664 26665 smallJsont *self = allocSmallJson(); 26666 setTopSO(self, "shee"); 26667 smallJsont *string = allocSmallJson(); 26668 26669 // identical strings 26670 setTopSO(string, "shee"); 26671 ck_assert(icStartsWithJsonO(self, string)); 26672 freeO(self); 26673 setTopSO(self, "sheepy"); 26674 ck_assert(icStartsWithJsonO(self, string)); 26675 // different strings 26676 freeO(self); 26677 setTopSO(self, "shee"); 26678 freeO(string); 26679 setTopSO(string, "SH"); 26680 ck_assert(icStartsWithJsonO(self, string)); 26681 freeO(string); 26682 setTopSO(string, "sheep"); 26683 ck_assert(!icStartsWithJsonO(self, string)); 26684 freeO(self); 26685 setTopSO(self, "-shee"); 26686 freeO(string); 26687 setTopSO(string, "shee"); 26688 ck_assert(!icStartsWithJsonO(self, string)); 26689 // non json string 26690 freeO(string); 26691 setTopIntO(string, 1); 26692 ck_assert(!icStartsWithJsonO(self, string)); 26693 // non json object 26694 terminateO(string); 26695 string = (smallJsont*) allocSmallInt(1); 26696 ck_assert(!icStartsWithJsonO(self, string)); 26697 terminateO(string); 26698 string = allocSmallJson(); 26699 // NULL string 26700 ck_assert(!icStartsWithJsonO(self, NULL)); 26701 // empty self 26702 freeO(self); 26703 setTopSO(string, "shee"); 26704 ck_assert(!icStartsWithJsonO(self, string)); 26705 terminateO(string); 26706 terminateO(self); 26707 26708 } 26709 26710 26711 void icEndsWithSSmallJsonT(void) { 26712 26713 smallJsont *self = allocSmallJson(); 26714 setTopSO(self, "shee"); 26715 26716 // identical strings 26717 ck_assert(icEndsWithSO(self, "shee")); 26718 freeO(self); 26719 setTopSO(self, "sheepy"); 26720 ck_assert(icEndsWithSO(self, "EEPY")); 26721 // different strings 26722 freeO(self); 26723 setTopSO(self, "shee"); 26724 ck_assert(!icEndsWithSO(self, "SH")); 26725 ck_assert(!icEndsWithSO(self, "sheep")); 26726 freeO(self); 26727 setTopSO(self, "shee-"); 26728 ck_assert(!icEndsWithSO(self, "shee")); 26729 // NULL string 26730 ck_assert(!icEndsWithSO(self, NULL)); 26731 // empty self 26732 freeO(self); 26733 ck_assert(!icEndsWithSO(self, "shee")); 26734 terminateO(self); 26735 26736 } 26737 26738 26739 void icEndsWithCharSmallJsonT(void) { 26740 26741 smallJsont *self = allocSmallJson(); 26742 setTopSO(self, "shee"); 26743 26744 // identical strings 26745 ck_assert(icEndsWithCharO(self, 'e')); 26746 freeO(self); 26747 setTopSO(self, "sheepy"); 26748 ck_assert(icEndsWithCharO(self, 'y')); 26749 freeO(self); 26750 setTopSO(self, ""); 26751 ck_assert(icEndsWithCharO(self, 0)); 26752 // different strings 26753 freeO(self); 26754 setTopSO(self, "shee"); 26755 ck_assert(icEndsWithCharO(self, 'E')); 26756 ck_assert(!icEndsWithCharO(self, 'p')); 26757 freeO(self); 26758 setTopSO(self, "shee-"); 26759 ck_assert(!icEndsWithCharO(self, 'e')); 26760 freeO(self); 26761 setTopSO(self, ""); 26762 ck_assert(!icEndsWithCharO(self, '0')); 26763 // NULL string 26764 freeO(self); 26765 setTopSO(self, "a"); 26766 ck_assert(!icEndsWithCharO(self, 0)); 26767 // empty self 26768 freeO(self); 26769 ck_assert(!icEndsWithCharO(self, '0')); 26770 terminateO(self); 26771 26772 } 26773 26774 26775 void icEndsWithSmallStringSmallJsonT(void) { 26776 26777 smallJsont *self = allocSmallJson(); 26778 setTopSO(self, "shee"); 26779 smallStringt *string = allocSmallString("shee"); 26780 26781 // identical strings 26782 ck_assert(icEndsWithSmallStringO(self, string)); 26783 freeO(self); 26784 setTopSO(self, "sheepy"); 26785 setValO(string, "EEPY"); 26786 ck_assert(icEndsWithSmallStringO(self, string)); 26787 // different strings 26788 freeO(self); 26789 setTopSO(self, "shee"); 26790 ck_assert(!icEndsWithSmallStringO(self, string)); 26791 setValO(string, "sheep"); 26792 ck_assert(!icEndsWithSmallStringO(self, string)); 26793 freeO(self); 26794 setTopSO(self, "shee-"); 26795 setValO(string, "shee"); 26796 ck_assert(!icEndsWithSmallStringO(self, string)); 26797 // non smallString object 26798 terminateO(string); 26799 string = (smallStringt*) allocSmallInt(1); 26800 ck_assert(!icEndsWithSmallStringO(self, string)); 26801 terminateO(string); 26802 string = allocSmallString("shee"); 26803 // NULL string 26804 ck_assert(!icEndsWithSmallStringO(self, NULL)); 26805 // empty self 26806 freeO(self); 26807 ck_assert(!icEndsWithSmallStringO(self, string)); 26808 terminateO(string); 26809 terminateO(self); 26810 26811 } 26812 26813 26814 void icEndsWithJsonSmallJsonT(void) { 26815 26816 smallJsont *self = allocSmallJson(); 26817 setTopSO(self, "shee"); 26818 smallJsont *string = allocSmallJson(); 26819 26820 // identical strings 26821 setTopSO(string, "shee"); 26822 ck_assert(icEndsWithJsonO(self, string)); 26823 freeO(self); 26824 setTopSO(self, "sheepy"); 26825 freeO(string); 26826 setTopSO(string, "EEPY"); 26827 ck_assert(icEndsWithJsonO(self, string)); 26828 // different strings 26829 freeO(self); 26830 setTopSO(self, "shee"); 26831 freeO(string); 26832 setTopSO(string, "SH"); 26833 ck_assert(!icEndsWithJsonO(self, string)); 26834 freeO(string); 26835 setTopSO(string, "sheep"); 26836 ck_assert(!icEndsWithJsonO(self, string)); 26837 freeO(self); 26838 setTopSO(self, "shee-"); 26839 freeO(string); 26840 setTopSO(string, "shee"); 26841 ck_assert(!icEndsWithJsonO(self, string)); 26842 // non json string 26843 freeO(string); 26844 setTopIntO(string, 1); 26845 ck_assert(!icEndsWithJsonO(self, string)); 26846 // non json object 26847 terminateO(string); 26848 string = (smallJsont*) allocSmallInt(1); 26849 ck_assert(!icEndsWithJsonO(self, string)); 26850 terminateO(string); 26851 string = allocSmallJson(); 26852 setTopSO(string, "shee"); 26853 // NULL string 26854 ck_assert(!icEndsWithJsonO(self, NULL)); 26855 // empty self 26856 freeO(self); 26857 ck_assert(!icEndsWithJsonO(self, string)); 26858 terminateO(string); 26859 terminateO(self); 26860 26861 } 26862 26863 26864 void icCountSSmallJsonT(void) { 26865 26866 smallJsont *self = allocSmallJson(); 26867 setTopSO(self, "sheepy"); 26868 26869 // positive count 26870 ck_assert_int_eq(icCountSO(self, "shee"), 1); 26871 freeO(self); 26872 setTopSO(self, "aaa aaa"); 26873 ck_assert_int_eq(icCountSO(self, "a"), 6); 26874 ck_assert_int_eq(icCountSO(self, "Aa"), 2); 26875 // 0 icCount 26876 freeO(self); 26877 setTopSO(self, "shee"); 26878 ck_assert_int_eq(icCountSO(self, "SH"), 1); 26879 ck_assert_int_eq(icCountSO(self, "sheepy"), 0); 26880 freeO(self); 26881 setTopSO(self, "aaa aaa"); 26882 ck_assert_int_eq(icCountSO(self, "ab"), 0); 26883 // empty string 26884 ck_assert_int_eq(icCountSO(self, ""), -1); 26885 // NULL string 26886 ck_assert_int_eq(icCountSO(self, NULL), -1); 26887 // empty self 26888 freeO(self); 26889 ck_assert_int_eq(icCountSO(self, "ab"), -1); 26890 terminateO(self); 26891 26892 } 26893 26894 26895 void icCountCharSmallJsonT(void) { 26896 26897 smallJsont *self = allocSmallJson(); 26898 setTopSO(self, "shee"); 26899 26900 // positive count 26901 ck_assert_int_eq(icCountCharO(self, 's'), 1); 26902 freeO(self); 26903 setTopSO(self, "aaa aaa"); 26904 ck_assert_int_eq(icCountCharO(self, 'a'), 6); 26905 // 0 icCount 26906 freeO(self); 26907 setTopSO(self, "shee"); 26908 ck_assert_int_eq(icCountCharO(self, 'S'), 1); 26909 ck_assert_int_eq(icCountCharO(self, 'y'), 0); 26910 freeO(self); 26911 setTopSO(self, "aaa aaa"); 26912 ck_assert_int_eq(icCountCharO(self, 'b'), 0); 26913 // empty string 26914 freeO(self); 26915 setTopSO(self, ""); 26916 ck_assert_int_eq(icCountCharO(self, 'a'), 0); 26917 ck_assert_int_eq(icCountCharO(self, 0), -1); 26918 // NULL string 26919 freeO(self); 26920 setTopSO(self, "a"); 26921 ck_assert_int_eq(icCountCharO(self, 0), -1); 26922 // empty self 26923 freeO(self); 26924 ck_assert_int_eq(icCountCharO(self, 'a'), -1); 26925 terminateO(self); 26926 26927 } 26928 26929 26930 void icCountSmallStringSmallJsonT(void) { 26931 26932 smallJsont *self = allocSmallJson(); 26933 setTopSO(self, "sheepy"); 26934 smallStringt *string = allocSmallString("shee"); 26935 26936 // positive count 26937 ck_assert_int_eq(icCountSmallStringO(self, string), 1); 26938 freeO(self); 26939 setTopSO(self, "aaa aaa"); 26940 setValO(string, "a"); 26941 ck_assert_int_eq(icCountSmallStringO(self, string), 6); 26942 setValO(string, "aa"); 26943 ck_assert_int_eq(icCountSmallStringO(self, string), 2); 26944 // 0 icCount 26945 freeO(self); 26946 setTopSO(self, "shee"); 26947 setValO(string, "SH"); 26948 ck_assert_int_eq(icCountSmallStringO(self, string), 1); 26949 setValO(string, "sheepy"); 26950 ck_assert_int_eq(icCountSmallStringO(self, string), 0); 26951 freeO(self); 26952 setTopSO(self, "aaa aaa"); 26953 setValO(string, "ab"); 26954 ck_assert_int_eq(icCountSmallStringO(self, string), 0); 26955 // non json object 26956 terminateO(string); 26957 string = (smallStringt*) allocSmallInt(1); 26958 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 26959 terminateO(string); 26960 string = allocSmallString(""); 26961 // empty string 26962 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 26963 freeO(string); 26964 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 26965 // NULL string 26966 ck_assert_int_eq(icCountSmallStringO(self, NULL), -1); 26967 // empty self 26968 freeO(self); 26969 setValO(string, "ab"); 26970 ck_assert_int_eq(icCountSmallStringO(self, string), -1); 26971 terminateO(string); 26972 terminateO(self); 26973 26974 } 26975 26976 26977 void icCountJsonSmallJsonT(void) { 26978 26979 smallJsont *self = allocSmallJson(); 26980 setTopSO(self, "sheepy"); 26981 smallJsont *string = allocSmallJson(); 26982 26983 // positive count 26984 setTopSO(string, "shee"); 26985 ck_assert_int_eq(icCountJsonO(self, string), 1); 26986 freeO(self); 26987 setTopSO(self, "aaa aaa"); 26988 freeO(string); 26989 setTopSO(string, "a"); 26990 ck_assert_int_eq(icCountJsonO(self, string), 6); 26991 freeO(string); 26992 setTopSO(string, "aa"); 26993 ck_assert_int_eq(icCountJsonO(self, string), 2); 26994 // 0 icCount 26995 freeO(self); 26996 setTopSO(self, "shee"); 26997 freeO(string); 26998 setTopSO(string, "SH"); 26999 ck_assert_int_eq(icCountJsonO(self, string), 1); 27000 freeO(string); 27001 setTopSO(string, "sheepy"); 27002 ck_assert_int_eq(icCountJsonO(self, string), 0); 27003 freeO(self); 27004 setTopSO(self, "aaa aaa"); 27005 freeO(string); 27006 setTopSO(string, "ab"); 27007 ck_assert_int_eq(icCountJsonO(self, string), 0); 27008 // non json string 27009 freeO(string); 27010 setTopIntO(string, -1); 27011 ck_assert_int_eq(icCountJsonO(self, string), -1); 27012 // non json object 27013 terminateO(string); 27014 string = (smallJsont*) allocSmallInt(1); 27015 ck_assert_int_eq(icCountJsonO(self, string), -1); 27016 terminateO(string); 27017 string = allocSmallJson(); 27018 // empty string 27019 setTopSO(string, ""); 27020 ck_assert_int_eq(icCountJsonO(self, string), -1); 27021 // NULL string 27022 ck_assert_int_eq(icCountJsonO(self, NULL), -1); 27023 // empty self 27024 freeO(self); 27025 freeO(string); 27026 setTopSO(string, "ab"); 27027 ck_assert_int_eq(icCountJsonO(self, string), -1); 27028 terminateO(string); 27029 terminateO(self); 27030 27031 } 27032 27033 27034 void isNumberSmallJsonT(void) { 27035 27036 smallJsont *self = allocSmallJson(); 27037 setTopSO(self, ""); 27038 27039 // number 27040 freeO(self); 27041 setTopSO(self, "-12.3"); 27042 ck_assert(isNumberO(self)); 27043 freeO(self); 27044 setTopSO(self, "-123"); 27045 ck_assert(isNumberO(self)); 27046 freeO(self); 27047 setTopSO(self, "123"); 27048 ck_assert(isNumberO(self)); 27049 freeO(self); 27050 setTopSO(self, "1e23"); 27051 ck_assert(isNumberO(self)); 27052 freeO(self); 27053 setTopSO(self, "12E-3"); 27054 ck_assert(isNumberO(self)); 27055 freeO(self); 27056 setTopSO(self, ".123"); 27057 ck_assert(isNumberO(self)); 27058 freeO(self); 27059 setTopSO(self, "-.123"); 27060 ck_assert(isNumberO(self)); 27061 freeO(self); 27062 setTopSO(self, "1E+32"); 27063 ck_assert(isNumberO(self)); 27064 // not a number 27065 freeO(self); 27066 setTopSO(self, ".12e3"); 27067 ck_assert(!isNumberO(self)); 27068 freeO(self); 27069 setTopSO(self, "-.12e3"); 27070 ck_assert(!isNumberO(self)); 27071 freeO(self); 27072 setTopSO(self, "-1-23"); 27073 ck_assert(!isNumberO(self)); 27074 freeO(self); 27075 setTopSO(self, "123-"); 27076 ck_assert(!isNumberO(self)); 27077 freeO(self); 27078 setTopSO(self, "-"); 27079 ck_assert(!isNumberO(self)); 27080 freeO(self); 27081 setTopSO(self, "-123."); 27082 ck_assert(!isNumberO(self)); 27083 freeO(self); 27084 setTopSO(self, "-1.2.3"); 27085 ck_assert(!isNumberO(self)); 27086 freeO(self); 27087 setTopSO(self, "1-2.3"); 27088 ck_assert(!isNumberO(self)); 27089 freeO(self); 27090 setTopSO(self, "12..3"); 27091 ck_assert(!isNumberO(self)); 27092 freeO(self); 27093 setTopSO(self, ".12.3"); 27094 ck_assert(!isNumberO(self)); 27095 freeO(self); 27096 setTopSO(self, "."); 27097 ck_assert(!isNumberO(self)); 27098 freeO(self); 27099 setTopSO(self, "E12"); 27100 ck_assert(!isNumberO(self)); 27101 freeO(self); 27102 setTopSO(self, "E1E2"); 27103 ck_assert(!isNumberO(self)); 27104 freeO(self); 27105 setTopSO(self, "E1.2"); 27106 ck_assert(!isNumberO(self)); 27107 freeO(self); 27108 setTopSO(self, "1E"); 27109 ck_assert(!isNumberO(self)); 27110 freeO(self); 27111 setTopSO(self, "1E2.3"); 27112 ck_assert(!isNumberO(self)); 27113 freeO(self); 27114 setTopSO(self, "1-"); 27115 ck_assert(!isNumberO(self)); 27116 freeO(self); 27117 setTopSO(self, "1E-"); 27118 ck_assert(!isNumberO(self)); 27119 freeO(self); 27120 setTopSO(self, "lib123sheepy"); 27121 ck_assert(!isNumberO(self)); 27122 // string without number 27123 freeO(self); 27124 setTopSO(self, "s"); 27125 ck_assert(!isNumberO(self)); 27126 // empty string 27127 freeO(self); 27128 setTopSO(self, ""); 27129 ck_assert(!isNumberO(self)); 27130 // NULL string 27131 freeO(self); 27132 ck_assert(!isNumberO(self)); 27133 terminateO(self); 27134 27135 } 27136 27137 27138 void isIntSmallJsonT(void) { 27139 27140 smallJsont *self = allocSmallJson(); 27141 setTopSO(self, ""); 27142 27143 // integer 27144 freeO(self); 27145 setTopSO(self, "-123"); 27146 ck_assert(isIntO(self)); 27147 freeO(self); 27148 setTopSO(self, "123"); 27149 ck_assert(isIntO(self)); 27150 // not a integer 27151 freeO(self); 27152 setTopSO(self, "1e23"); 27153 ck_assert(!isIntO(self)); 27154 freeO(self); 27155 setTopSO(self, "12E-3"); 27156 ck_assert(!isIntO(self)); 27157 freeO(self); 27158 setTopSO(self, "-12.3"); 27159 ck_assert(!isIntO(self)); 27160 freeO(self); 27161 setTopSO(self, "-1-23"); 27162 ck_assert(!isIntO(self)); 27163 freeO(self); 27164 setTopSO(self, "123-"); 27165 ck_assert(!isIntO(self)); 27166 freeO(self); 27167 setTopSO(self, "-"); 27168 ck_assert(!isIntO(self)); 27169 freeO(self); 27170 setTopSO(self, "-123."); 27171 ck_assert(!isIntO(self)); 27172 freeO(self); 27173 setTopSO(self, ".123"); 27174 ck_assert(!isIntO(self)); 27175 freeO(self); 27176 setTopSO(self, "-1.2.3"); 27177 ck_assert(!isIntO(self)); 27178 freeO(self); 27179 setTopSO(self, "1-2.3"); 27180 ck_assert(!isIntO(self)); 27181 freeO(self); 27182 setTopSO(self, "12..3"); 27183 ck_assert(!isIntO(self)); 27184 freeO(self); 27185 setTopSO(self, "."); 27186 ck_assert(!isIntO(self)); 27187 freeO(self); 27188 setTopSO(self, "1E"); 27189 ck_assert(!isIntO(self)); 27190 freeO(self); 27191 setTopSO(self, "1-"); 27192 ck_assert(!isIntO(self)); 27193 freeO(self); 27194 setTopSO(self, "1E-"); 27195 ck_assert(!isIntO(self)); 27196 freeO(self); 27197 setTopSO(self, "lib123sheepy"); 27198 ck_assert(!isIntO(self)); 27199 // string without number 27200 freeO(self); 27201 setTopSO(self, "s"); 27202 ck_assert(!isIntO(self)); 27203 // empty string 27204 freeO(self); 27205 setTopSO(self, ""); 27206 ck_assert(!isIntO(self)); 27207 // NULL string 27208 freeO(self); 27209 ck_assert(!isIntO(self)); 27210 terminateO(self); 27211 27212 } 27213 27214 27215 void parseIntSmallJsonT(void) { 27216 27217 smallJsont *self = allocSmallJson(); 27218 setTopSO(self, ""); 27219 27220 // number 27221 freeO(self); 27222 setTopSO(self, "123sheepy"); 27223 ck_assert_int_eq(parseIntO(self), 123); 27224 freeO(self); 27225 setTopSO(self, "lib123sheepy"); 27226 ck_assert_int_eq(parseIntO(self), 123); 27227 freeO(self); 27228 setTopSO(self, "-123"); 27229 ck_assert_int_eq(parseIntO(self), -123); 27230 // out of range - TODO check stderr 27231 freeO(self); 27232 setTopSO(self, "999999999999999999999999999999999999999"); 27233 parseIntO(self); 27234 // string without number 27235 freeO(self); 27236 setTopSO(self, "sheepy"); 27237 ck_assert_int_eq(parseIntO(self), 0); 27238 // NULL string 27239 freeO(self); 27240 ck_assert_int_eq(parseIntO(self), 0); 27241 terminateO(self); 27242 27243 } 27244 27245 27246 void parseDoubleSmallJsonT(void) { 27247 27248 smallJsont *self = allocSmallJson(); 27249 setTopSO(self, ""); 27250 27251 // number 27252 freeO(self); 27253 setTopSO(self, "123.2sheepy"); 27254 ck_assert_int_eq(parseDoubleO(self), 123); 27255 freeO(self); 27256 setTopSO(self, "lib123sheepy"); 27257 ck_assert_int_eq(parseDoubleO(self), 123); 27258 freeO(self); 27259 setTopSO(self, "-123"); 27260 ck_assert_int_eq(parseDoubleO(self), -123); 27261 // out of range - TODO check stderr 27262 freeO(self); 27263 setTopSO(self, "999999999999999999999999999999999999999"); 27264 parseDoubleO(self); 27265 // string without number 27266 freeO(self); 27267 setTopSO(self, "sheepy"); 27268 ck_assert_int_eq(parseDoubleO(self), 0); 27269 // NULL string 27270 freeO(self); 27271 ck_assert_int_eq(parseDoubleO(self), 0); 27272 terminateO(self); 27273 27274 } 27275 27276 27277 void intToSmallJsonT(void) { 27278 27279 smallJsont* r; 27280 smallJsont *self = allocSmallJson(); 27281 setTopSO(self, ""); 27282 27283 // number 27284 r = intToO(self, 123); 27285 ck_assert_ptr_ne(r, null); 27286 char *s = toStringO(r); 27287 ck_assert_str_eq(s, "123"); 27288 free(s); 27289 r = intToO(self, -465464123); 27290 ck_assert_ptr_ne(r, null); 27291 s = toStringO(r); 27292 ck_assert_str_eq(s, "-465464123"); 27293 free(s); 27294 terminateO(self); 27295 27296 } 27297 27298 27299 void doubleToSmallJsonT(void) { 27300 27301 smallJsont* r; 27302 smallJsont *self = allocSmallJson(); 27303 setTopSO(self, ""); 27304 27305 // number 27306 r = doubleToO(self, 123.4); 27307 ck_assert_ptr_ne(r, null); 27308 char *s = toStringO(r); 27309 ck_assert_str_eq(s, "1.234000e+02"); 27310 free(s); 27311 r = doubleToO(self, -4652445e5); 27312 ck_assert_ptr_ne(r, null); 27313 s = toStringO(r); 27314 ck_assert_str_eq(s, "-4.652445e+11"); 27315 free(s); 27316 terminateO(self); 27317 27318 } 27319 27320 27321 void upperSmallJsonT(void) { 27322 27323 smallJsont* r; 27324 smallJsont *self = allocSmallJson(); 27325 setTopSO(self, "sheepy"); 27326 27327 // string 27328 r = upperO(self); 27329 ck_assert_ptr_ne(r, null); 27330 char *s = toStringO(r); 27331 ck_assert_str_eq(s, "SHEEPY"); 27332 free(s); 27333 // NULL string 27334 freeO(self); 27335 ck_assert_ptr_eq(upperO(self), NULL); 27336 terminateO(self); 27337 27338 } 27339 27340 27341 void lowerSmallJsonT(void) { 27342 27343 smallJsont* r; 27344 smallJsont *self = allocSmallJson(); 27345 setTopSO(self, "SHeePY"); 27346 27347 // string 27348 r = lowerO(self); 27349 ck_assert_ptr_ne(r, null); 27350 char *s = toStringO(r); 27351 ck_assert_str_eq(s, "sheepy"); 27352 free(s); 27353 // NULL string 27354 freeO(self); 27355 ck_assert_ptr_eq(lowerO(self), NULL); 27356 terminateO(self); 27357 27358 } 27359 27360 27361 void trimSmallJsonT(void) { 27362 27363 smallJsont* r; 27364 smallJsont *self = allocSmallJson(); 27365 setTopSO(self, ""); 27366 27367 // no spaces 27368 freeO(self); 27369 setTopSO(self, "SHeePY"); 27370 r = trimO(self); 27371 ck_assert_ptr_ne(r, null); 27372 char *s = toStringO(r); 27373 ck_assert_str_eq(s, "SHeePY"); 27374 free(s); 27375 // heading spaces 27376 freeO(self); 27377 setTopSO(self, " SHeePY"); 27378 r = trimO(self); 27379 ck_assert_ptr_ne(r, null); 27380 s = toStringO(r); 27381 ck_assert_str_eq(s, "SHeePY"); 27382 free(s); 27383 // trailing spaces 27384 freeO(self); 27385 setTopSO(self, "SHeePY "); 27386 r = trimO(self); 27387 ck_assert_ptr_ne(r, null); 27388 s = toStringO(r); 27389 ck_assert_str_eq(s, "SHeePY"); 27390 free(s); 27391 // string with spaces in the middle 27392 freeO(self); 27393 setTopSO(self, " SHe ePY "); 27394 r = trimO(self); 27395 ck_assert_ptr_ne(r, null); 27396 s = toStringO(r); 27397 ck_assert_str_eq(s, "SHe ePY"); 27398 free(s); 27399 // all spaces 27400 freeO(self); 27401 setTopSO(self, " "); 27402 r = trimO(self); 27403 ck_assert_ptr_ne(r, null); 27404 s = toStringO(r); 27405 ck_assert_str_eq(s, ""); 27406 free(s); 27407 // empty string 27408 freeO(self); 27409 setTopSO(self, ""); 27410 r = trimO(self); 27411 ck_assert_ptr_ne(r, null); 27412 s = toStringO(r); 27413 ck_assert_str_eq(s, ""); 27414 free(s); 27415 // NULL string 27416 freeO(self); 27417 ck_assert_ptr_eq(trimO(self), NULL); 27418 // json dict 27419 freeO(self); 27420 // empty self 27421 setTypeDictO(self); 27422 r = trimO(self); 27423 ck_assert_ptr_ne(r, null); 27424 self->f->setS(self, "1", "2"); 27425 self->f->setS(self, "3", "4"); 27426 self->f->delElem(self, "3"); 27427 r = trimO(self); 27428 ck_assert_ptr_ne(r, null); 27429 ck_assert_int_eq(lenO(self), 1); 27430 s = toStringO(r); 27431 ck_assert_str_eq(s, "{\"1\":\"2\"}"); 27432 free(s); 27433 self->f->delElem(self, "1"); 27434 r = trimO(self); 27435 ck_assert_ptr_ne(r, null); 27436 ck_assert_int_eq(lenO(self), 0); 27437 s = toStringO(r); 27438 ck_assert_str_eq(s, "{}"); 27439 free(s); 27440 // json array 27441 freeO(self); 27442 self->f->pushS(self, "qwe"); 27443 self->f->pushUndefined(self); 27444 self->f->pushInt(self, 123); 27445 ck_assert_uint_eq(lenO(self), 3); 27446 delElemIndexO(self, 0); 27447 delElemIndexO(self, 1); 27448 r = trimO(self); 27449 ck_assert_uint_eq(lenO(self), 1); 27450 ck_assert_ptr_ne(r, null); 27451 s = toStringO(r); 27452 ck_assert_str_eq(s, "[123]"); 27453 free(s); 27454 terminateO(self); 27455 27456 } 27457 27458 27459 void lTrimSmallJsonT(void) { 27460 27461 smallJsont* r; 27462 smallJsont *self = allocSmallJson(); 27463 setTopSO(self, ""); 27464 27465 // no spaces 27466 freeO(self); 27467 setTopSO(self, "SHeePY"); 27468 r = lTrimO(self); 27469 ck_assert_ptr_ne(r, null); 27470 char *s = toStringO(r); 27471 ck_assert_str_eq(s, "SHeePY"); 27472 free(s); 27473 // heading spaces 27474 freeO(self); 27475 setTopSO(self, " SHeePY"); 27476 r = lTrimO(self); 27477 ck_assert_ptr_ne(r, null); 27478 s = toStringO(r); 27479 ck_assert_str_eq(s, "SHeePY"); 27480 free(s); 27481 // trailing spaces 27482 freeO(self); 27483 setTopSO(self, "SHeePY "); 27484 r = lTrimO(self); 27485 ck_assert_ptr_ne(r, null); 27486 s = toStringO(r); 27487 ck_assert_str_eq(s, "SHeePY "); 27488 free(s); 27489 // string with spaces in the middle 27490 freeO(self); 27491 setTopSO(self, " SHe ePY "); 27492 r = lTrimO(self); 27493 ck_assert_ptr_ne(r, null); 27494 s = toStringO(r); 27495 ck_assert_str_eq(s, "SHe ePY "); 27496 free(s); 27497 // all spaces 27498 freeO(self); 27499 setTopSO(self, " "); 27500 r = lTrimO(self); 27501 ck_assert_ptr_ne(r, null); 27502 s = toStringO(r); 27503 ck_assert_str_eq(s, ""); 27504 free(s); 27505 freeO(self); 27506 setTopSO(self, ""); 27507 r = lTrimO(self); 27508 ck_assert_ptr_ne(r, null); 27509 s = toStringO(r); 27510 ck_assert_str_eq(s, ""); 27511 free(s); 27512 // NULL string 27513 freeO(self); 27514 ck_assert_ptr_eq(lTrimO(self), NULL); 27515 terminateO(self); 27516 27517 } 27518 27519 27520 void rTrimSmallJsonT(void) { 27521 27522 smallJsont* r; 27523 smallJsont *self = allocSmallJson(); 27524 setTopSO(self, ""); 27525 27526 // no spaces 27527 freeO(self); 27528 setTopSO(self, "SHeePY"); 27529 r = rTrimO(self); 27530 ck_assert_ptr_ne(r, null); 27531 char *s = toStringO(r); 27532 ck_assert_str_eq(s, "SHeePY"); 27533 free(s); 27534 // heading spaces 27535 freeO(self); 27536 setTopSO(self, " SHeePY"); 27537 r = rTrimO(self); 27538 ck_assert_ptr_ne(r, null); 27539 s = toStringO(r); 27540 ck_assert_str_eq(s, " SHeePY"); 27541 free(s); 27542 // trailing spaces 27543 freeO(self); 27544 setTopSO(self, "SHeePY "); 27545 r = rTrimO(self); 27546 ck_assert_ptr_ne(r, null); 27547 s = toStringO(r); 27548 ck_assert_str_eq(s, "SHeePY"); 27549 free(s); 27550 // string with spaces in the middle 27551 freeO(self); 27552 setTopSO(self, " SHe ePY "); 27553 r = rTrimO(self); 27554 ck_assert_ptr_ne(r, null); 27555 s = toStringO(r); 27556 ck_assert_str_eq(s, " SHe ePY"); 27557 free(s); 27558 // all spaces 27559 freeO(self); 27560 setTopSO(self, " "); 27561 r = rTrimO(self); 27562 ck_assert_ptr_ne(r, null); 27563 s = toStringO(r); 27564 ck_assert_str_eq(s, ""); 27565 free(s); 27566 // empty string 27567 freeO(self); 27568 setTopSO(self, ""); 27569 r = rTrimO(self); 27570 ck_assert_ptr_ne(r, null); 27571 s = toStringO(r); 27572 ck_assert_str_eq(s, ""); 27573 free(s); 27574 // NULL string 27575 freeO(self); 27576 ck_assert_ptr_eq(rTrimO(self), NULL); 27577 terminateO(self); 27578 27579 } 27580 27581 27582 void keysSmallJsonT(void) { 27583 27584 char** r; 27585 smallJsont *self = allocG(rtSmallJsont); 27586 27587 self->f->setS(self, "1", "2"); 27588 self->f->setS(self, "3", "4"); 27589 r = keysO(self); 27590 ck_assert_ptr_ne(r, null); 27591 char *s = toStringListSGF(r); 27592 ck_assert_str_eq(s, "[\"1\",\"3\"]"); 27593 free(s); 27594 listFreeS(r); 27595 // empty self 27596 freeO(self); 27597 r = keysO(self); 27598 ck_assert_ptr_eq(r, null); 27599 setTypeDictO(self); 27600 r = keysO(self); 27601 ck_assert_ptr_eq(r, null); 27602 terminateO(self); 27603 27604 } 27605 27606 27607 void keysSmallStringSmallJsonT(void) { 27608 27609 smallArrayt* r; 27610 smallJsont *self = allocSmallJson(); 27611 27612 self->f->setS(self, "1", "2"); 27613 self->f->setS(self, "3", "4"); 27614 r = keysSmallStringO(self); 27615 ck_assert_ptr_ne(r, null); 27616 char *s = toStringO(r); 27617 ck_assert_str_eq(s, "[\"1\",\"3\"]"); 27618 free(s); 27619 terminateO(r); 27620 // empty self 27621 freeO(self); 27622 r = keysSmallStringO(self); 27623 ck_assert_ptr_ne(r, null); 27624 s = toStringO(r); 27625 ck_assert_str_eq(s, "[]"); 27626 free(s); 27627 terminateO(r); 27628 terminateO(self); 27629 27630 } 27631 27632 27633 void valuesSmallJsonT(void) { 27634 27635 smallArrayt* r; 27636 smallJsont *self = allocG(rtSmallJsont); 27637 27638 // empty json 27639 r = valuesO(self); 27640 ck_assert_ptr_eq(r, null); 27641 setTypeDictO(self); 27642 r = valuesO(self); 27643 ck_assert_ptr_eq(r, null); 27644 // values 27645 self->f->setUndefined(self, "qwe"); 27646 self->f->setS(self, "123", "sheepy"); 27647 r = valuesO(self); 27648 ck_assert_ptr_ne(r, null); 27649 char *s = toStringO(r); 27650 ck_assert_str_eq(s, "[null,\"sheepy\"]"); 27651 free(s); 27652 smashO(r); 27653 terminateO(self); 27654 27655 } 27656 27657 27658 void compactSmallJsonT(void) { 27659 27660 smallJsont* r; 27661 smallJsont *self = allocSmallJson(); 27662 27663 r = compactO(self); 27664 ck_assert_ptr_eq(r, NULL); 27665 // add and remove elements 27666 self->f->pushUndefined(self); 27667 // null element 27668 self->f->pushUndefined(self); 27669 delElemIndexO(self, 1); 27670 self->f->pushBool(self, true); 27671 createSmallContainer(c); 27672 self->f->pushSmallContainer(self, &c); 27673 // empty dict 27674 createSmallDict(d); 27675 self->f->pushDict(self, &d); 27676 resetO(&d); 27677 (&d)->f->setInt(&d, "a", 1); 27678 self->f->pushDict(self, &d); 27679 self->f->pushDouble(self, 2); 27680 self->f->pushInt(self, 5); 27681 self->f->pushS(self, " "); 27682 self->f->pushS(self, "asd"); 27683 // empty Array 27684 createSmallArray(a); 27685 self->f->pushArray(self, &a); 27686 resetO(&a); 27687 (&a)->f->pushInt(&a, 1); 27688 self->f->pushArray(self, &a); 27689 // empty bytes 27690 createSmallBytes(b); 27691 self->f->pushSmallBytes(self, &b); 27692 smallBytest *B = allocSmallBytes("asd", 4); 27693 self->f->pushNFreeSmallBytes(self, B); 27694 r = compactO(self); 27695 ck_assert_ptr_ne(r, NULL); 27696 ck_assert_int_eq(lenO(r), 8); 27697 char *s = toStringO(r); 27698 ck_assert_str_eq(s, "[true,\"<data container>\",{\"a\":1},2.000000e+00,5,\"asd\",[1],[0x61,0x73,0x64,0x00]]"); 27699 free(s); 27700 // array with blank elements becomes empty after compact 27701 // self->topA should not be null 27702 // self->topA should an empty sArray to avoid issues with the setP function 27703 self->f->free(self); 27704 self->f->pushS(self, " "); 27705 self->f->pushS(self, ""); 27706 r = compactO(self); 27707 ck_assert_ptr_ne(r, NULL); 27708 ck_assert_ptr_ne(r->topA, NULL); 27709 ck_assert_int_eq(lenO(r), 0); 27710 s = toStringO(r); 27711 ck_assert_str_eq(s, "[]"); 27712 free(s); 27713 // empty array 27714 emptyO(self); 27715 r = compactO(self); 27716 ck_assert_ptr_eq(r, NULL); 27717 terminateO(self); 27718 27719 } 27720 27721 27722 void isEmptySmallJsonT(void) { 27723 27724 bool r; 27725 smallJsont *self = allocSmallJson(); 27726 27727 r = isEmptyO(self); 27728 ck_assert(r); 27729 self->f->setInt(self, "a", 1); 27730 r = isEmptyO(self); 27731 ck_assert(!r); 27732 self->f->delElem(self, "a"); 27733 r = isEmptyO(self); 27734 ck_assert(r); 27735 terminateO(self); 27736 27737 } 27738 27739 27740 void isBlankSmallJsonT(void) { 27741 27742 bool r; 27743 smallJsont *self = allocSmallJson(); 27744 27745 // json dict 27746 setTypeDictO(self); 27747 r = isBlankO(self); 27748 ck_assert(r); 27749 // json string 27750 freeO(self); 27751 setTopSO(self, " "); 27752 r = isBlankO(self); 27753 ck_assert(r); 27754 // json array 27755 freeO(self); 27756 // bool 27757 self->f->pushBool(self, true); 27758 r = isBlankO(self); 27759 ck_assert(!r); 27760 // container 27761 emptyO(self); 27762 createSmallContainer(c); 27763 self->f->pushSmallContainer(self, &c); 27764 r = isBlankO(self); 27765 ck_assert(!r); 27766 // blank dict 27767 emptyO(self); 27768 createSmallDict(d); 27769 self->f->pushDict(self, &d); 27770 r = isBlankO(self); 27771 ck_assert(r); 27772 // dict 27773 emptyO(self); 27774 resetO(&d); 27775 (&d)->f->setInt(&d, "a", 1); 27776 self->f->pushDict(self, &d); 27777 r = isBlankO(self); 27778 ck_assert(!r); 27779 // double 27780 emptyO(self); 27781 self->f->pushDouble(self, 0); 27782 r = isBlankO(self); 27783 ck_assert(!r); 27784 // int 27785 emptyO(self); 27786 self->f->pushInt(self, 0); 27787 r = isBlankO(self); 27788 ck_assert(!r); 27789 // blank string 27790 emptyO(self); 27791 self->f->pushS(self, " "); 27792 r = isBlankO(self); 27793 ck_assert(r); 27794 // string 27795 emptyO(self); 27796 self->f->pushS(self, "asd"); 27797 r = isBlankO(self); 27798 ck_assert(!r); 27799 // blank dict 27800 emptyO(self); 27801 createSmallArray(a); 27802 self->f->pushArray(self, &a); 27803 r = isBlankO(self); 27804 ck_assert(r); 27805 // dict 27806 emptyO(self); 27807 resetO(&a); 27808 (&a)->f->pushInt(&a, 1); 27809 self->f->pushArray(self, &a); 27810 r = isBlankO(self); 27811 ck_assert(!r); 27812 // blank Bytes 27813 emptyO(self); 27814 createSmallBytes(b); 27815 self->f->pushSmallBytes(self, &b); 27816 r = isBlankO(self); 27817 ck_assert(r); 27818 // Bytes 27819 emptyO(self); 27820 smallBytest *B = allocSmallBytes("asd", 4); 27821 self->f->pushNFreeSmallBytes(self, B); 27822 r = isBlankO(self); 27823 ck_assert(!r); 27824 // empty array 27825 emptyO(self); 27826 r = isBlankO(self); 27827 ck_assert(r); 27828 terminateO(self); 27829 27830 } 27831 27832 27833 bool fef(void *closure UNUSED, baset *e) { 27834 bool r = true; 27835 if (isOUndefined(e)) r = true; 27836 elif (isOSmallInt(e)) r = false; 27837 else { 27838 static u16 c; 27839 r = !c; 27840 c++; 27841 } 27842 return r; 27843 } 27844 27845 void forEachSmallJsonFT(void) { 27846 27847 smallJsont *self = allocSmallJson(); 27848 27849 // empty array 27850 // direct return 27851 self->f->forEach(self, NULL, fef); 27852 setTypeArrayO(self); 27853 self->f->forEach(self, NULL, fef); 27854 // array with elements 27855 self->f->pushUndefined(self); 27856 self->f->pushBool(self, true); 27857 // base class 27858 createAllocateSmallInt(i); 27859 i->type = "userclass"; 27860 self->f->push(self, (baset*)i); 27861 createAllocateSmallInt(j); 27862 j->type = "userclass"; 27863 self->f->push(self, (baset*)j); 27864 delElemIndexO(self, 1); 27865 self->f->pushInt(self, 2); 27866 self->f->forEach(self, NULL, fef); 27867 self->f->del(self, 2, 4); 27868 self->f->forEach(self, NULL, fef); 27869 terminateO(self); 27870 27871 } 27872 27873 27874 bool ef(void *closure UNUSED, u64 i UNUSED, baset *e) { 27875 bool r = true; 27876 if (isOUndefined(e)) r = true; 27877 elif (isOSmallInt(e)) r = false; 27878 else { 27879 static u16 c; 27880 r = !c; 27881 c++; 27882 } 27883 return r; 27884 } 27885 27886 void enumerateSmallJsonFT(void) { 27887 27888 smallJsont *self = allocSmallJson(); 27889 27890 // empty array 27891 // direct return 27892 self->f->enumerate(self, NULL, ef); 27893 setTypeArrayO(self); 27894 self->f->enumerate(self, NULL, ef); 27895 // enumerate elements 27896 self->f->pushUndefined(self); 27897 self->f->pushBool(self, true); 27898 // base class 27899 createAllocateSmallInt(i); 27900 i->type = "userclass"; 27901 self->f->push(self, (baset*)i); 27902 createAllocateSmallInt(j); 27903 j->type = "userclass"; 27904 self->f->push(self, (baset*)j); 27905 delElemIndexO(self, 1); 27906 self->f->pushInt(self, 2); 27907 self->f->enumerate(self, NULL, ef); 27908 self->f->del(self, 2, 4); 27909 self->f->enumerate(self, NULL, ef); 27910 terminateO(self); 27911 27912 } 27913 27914 27915 bool enumerateElement(void *closure, char *key UNUSED, baset *element UNUSED) { 27916 int *c = closure; 27917 (*c)++; 27918 return *c != 2 ? true : false; 27919 } 27920 27921 void enumerateDictSmallJsonT(void) { 27922 27923 smallJsont *self = allocSmallJson(); 27924 int closure = 0; 27925 27926 self->f->enumerateDict(self, &closure, enumerateElement); 27927 self->f->setInt(self, "a", 1); 27928 self->f->setInt(self, "b", 2); 27929 self->f->setInt(self, "c", 3); 27930 self->f->delElem(self, "a"); 27931 self->f->enumerateDict(self, &closure, enumerateElement); 27932 ck_assert_int_eq(closure, 2); 27933 // baset object in container 27934 closure = -2; 27935 smallIntt *i = allocSmallInt(2); 27936 i->type = "randomClass"; 27937 self->f->set(self, "d", (baset*)i); 27938 i = allocSmallInt(3); 27939 i->type = "randomClass"; 27940 self->f->set(self, "e", (baset*)i); 27941 self->f->enumerateDict(self, &closure, enumerateElement); 27942 ck_assert_int_eq(closure, 2); 27943 terminateO(self); 27944 27945 } 27946 27947 27948 void joinSmallJsonT(void) { 27949 27950 smallStringt* r; 27951 smallJsont *self = allocSmallJson(); 27952 27953 // join non string objects 27954 self->f->pushUndefined(self); 27955 self->f->pushInt(self, 123); 27956 r = joinO(self, ";"); 27957 ck_assert_ptr_ne(r, NULL); 27958 char *s = toStringO(r); 27959 terminateO(r); 27960 ck_assert_str_eq(s, "null;123"); 27961 free(s); 27962 // join strings 27963 emptyO(self); 27964 self->f->pushS(self, "a"); 27965 self->f->pushS(self, "b"); 27966 self->f->pushS(self, "c"); 27967 self->f->pushS(self, "d"); 27968 delElemIndexO(self, 1); 27969 r = joinO(self, ";"); 27970 ck_assert_ptr_ne(r, NULL); 27971 s = toStringO(r); 27972 terminateO(r); 27973 ck_assert_str_eq(s, "a;c;d"); 27974 free(s); 27975 // null delimiter 27976 r = joinO(self, NULL); 27977 ck_assert_ptr_eq(r, NULL); 27978 // empty array 27979 emptyO(self); 27980 r = joinO(self, ";"); 27981 ck_assert_ptr_eq(r, NULL); 27982 freeO(self); 27983 r = joinO(self, ";"); 27984 ck_assert_ptr_eq(r, NULL); 27985 terminateO(self); 27986 27987 } 27988 27989 27990 void joinCharSmallJsonT(void) { 27991 27992 smallStringt* r; 27993 smallJsont *self = allocSmallJson(); 27994 27995 // join non string objects 27996 self->f->pushUndefined(self); 27997 self->f->pushInt(self, 123); 27998 r = joinCharO(self, ';'); 27999 ck_assert_ptr_ne(r, NULL); 28000 char *s = toStringO(r); 28001 terminateO(r); 28002 ck_assert_str_eq(s, "null;123"); 28003 free(s); 28004 // join strings 28005 emptyO(self); 28006 self->f->pushS(self, "a"); 28007 self->f->pushS(self, "b"); 28008 self->f->pushS(self, "c"); 28009 self->f->pushS(self, "d"); 28010 delElemIndexO(self, 1); 28011 r = joinCharO(self, ';'); 28012 ck_assert_ptr_ne(r, NULL); 28013 s = toStringO(r); 28014 terminateO(r); 28015 ck_assert_str_eq(s, "a;c;d"); 28016 free(s); 28017 // empty array 28018 emptyO(self); 28019 r = joinCharO(self, ';'); 28020 ck_assert_ptr_eq(r, NULL); 28021 terminateO(self); 28022 28023 } 28024 28025 28026 void joinSmallJsonSmallJsonT(void) { 28027 28028 smallStringt* r; 28029 smallJsont *self = allocSmallJson(); 28030 smallJsont* delim = allocSmallJson(); 28031 28032 // join non string objects 28033 setTopSO(delim, ";"); 28034 self->f->pushUndefined(self); 28035 self->f->pushInt(self, 123); 28036 r = self->f->joinSmallJson(self, delim); 28037 ck_assert_ptr_ne(r, NULL); 28038 char *s = toStringO(r); 28039 terminateO(r); 28040 ck_assert_str_eq(s, "null;123"); 28041 free(s); 28042 // join strings 28043 emptyO(self); 28044 self->f->pushS(self, "a"); 28045 self->f->pushS(self, "b"); 28046 self->f->pushS(self, "c"); 28047 self->f->pushS(self, "d"); 28048 delElemIndexO(self, 1); 28049 r = self->f->joinSmallJson(self, delim); 28050 ck_assert_ptr_ne(r, NULL); 28051 s = toStringO(r); 28052 terminateO(r); 28053 ck_assert_str_eq(s, "a;c;d"); 28054 free(s); 28055 // delimiter not a string 28056 freeO(delim); 28057 setTopIntO(delim, 1); 28058 r = self->f->joinSmallJson(self, delim); 28059 ck_assert_ptr_eq(r, NULL); 28060 // non smallJson object 28061 terminateO(delim); 28062 delim = (smallJsont*) allocSmallInt(2); 28063 r = self->f->joinSmallJson(self, delim); 28064 ck_assert_ptr_eq(r, NULL); 28065 // null delimiter 28066 r = self->f->joinSmallJson(self, NULL); 28067 ck_assert_ptr_eq(r, NULL); 28068 // empty array 28069 emptyO(self); 28070 freeO(delim); 28071 setTopSO(delim, ";"); 28072 r = self->f->joinSmallJson(self, delim); 28073 ck_assert_ptr_eq(r, NULL); 28074 terminateO(self); 28075 terminateO(delim); 28076 28077 } 28078 28079 28080 void joinSmallStringSmallJsonT(void) { 28081 28082 smallStringt* r; 28083 smallJsont *self = allocSmallJson(); 28084 smallStringt* delim = allocSmallString(";"); 28085 28086 // join non string objects 28087 self->f->pushUndefined(self); 28088 self->f->pushInt(self, 123); 28089 r = joinSmallStringO(self, delim); 28090 ck_assert_ptr_ne(r, NULL); 28091 char *s = toStringO(r); 28092 terminateO(r); 28093 ck_assert_str_eq(s, "null;123"); 28094 free(s); 28095 // join strings 28096 emptyO(self); 28097 self->f->pushS(self, "a"); 28098 self->f->pushS(self, "b"); 28099 self->f->pushS(self, "c"); 28100 self->f->pushS(self, "d"); 28101 delElemIndexO(self, 1); 28102 r = joinSmallStringO(self, delim); 28103 ck_assert_ptr_ne(r, NULL); 28104 s = toStringO(r); 28105 terminateO(r); 28106 ck_assert_str_eq(s, "a;c;d"); 28107 free(s); 28108 // delimiter with no string 28109 freeO(delim); 28110 r = joinSmallStringO(self, delim); 28111 ck_assert_ptr_eq(r, NULL); 28112 // non smallString delim 28113 terminateO(delim); 28114 delim = (smallStringt*) allocSmallInt(0); 28115 r = joinSmallStringO(self, delim); 28116 ck_assert_ptr_eq(r, NULL); 28117 terminateO(delim); 28118 // null delimiter 28119 r = joinSmallStringO(self, NULL); 28120 ck_assert_ptr_eq(r, NULL); 28121 // empty array 28122 emptyO(self); 28123 delim = allocSmallString(";"); 28124 r = joinSmallStringO(self, delim); 28125 ck_assert_ptr_eq(r, NULL); 28126 terminateO(self); 28127 terminateO(delim); 28128 28129 } 28130 28131 28132 void joinSSmallJsonT(void) { 28133 28134 char* r; 28135 smallJsont *self = allocSmallJson(); 28136 28137 // join non string objects 28138 self->f->pushUndefined(self); 28139 self->f->pushInt(self, 123); 28140 r = self->f->joinS(self, ";"); 28141 ck_assert_ptr_ne(r, NULL); 28142 ck_assert_str_eq(r, "null;123"); 28143 free(r); 28144 // join strings 28145 emptyO(self); 28146 self->f->pushS(self, "a"); 28147 self->f->pushS(self, "b"); 28148 self->f->pushS(self, "c"); 28149 self->f->pushS(self, "d"); 28150 delElemIndexO(self, 1); 28151 r = self->f->joinS(self, ";"); 28152 ck_assert_ptr_ne(r, NULL); 28153 ck_assert_str_eq(r, "a;c;d"); 28154 free(r); 28155 // null delimiter 28156 r = self->f->joinS(self, NULL); 28157 ck_assert_ptr_eq(r, NULL); 28158 // empty array 28159 emptyO(self); 28160 r = self->f->joinS(self, ";"); 28161 ck_assert_ptr_eq(r, NULL); 28162 terminateO(self); 28163 28164 } 28165 28166 28167 void joinCharSSmallJsonT(void) { 28168 28169 char* r; 28170 smallJsont *self = allocSmallJson(); 28171 28172 // join non string objects 28173 self->f->pushUndefined(self); 28174 self->f->pushInt(self, 123); 28175 r = joinCharSO(self, ';'); 28176 ck_assert_ptr_ne(r, NULL); 28177 ck_assert_str_eq(r, "null;123"); 28178 free(r); 28179 // join strings 28180 emptyO(self); 28181 self->f->pushS(self, "a"); 28182 self->f->pushS(self, "b"); 28183 self->f->pushS(self, "c"); 28184 self->f->pushS(self, "d"); 28185 delElemIndexO(self, 1); 28186 r = joinCharSO(self, ';'); 28187 ck_assert_ptr_ne(r, NULL); 28188 ck_assert_str_eq(r, "a;c;d"); 28189 free(r); 28190 // empty array 28191 emptyO(self); 28192 r = joinCharSO(self, ';'); 28193 ck_assert_ptr_eq(r, NULL); 28194 terminateO(self); 28195 28196 } 28197 28198 28199 void joinSmallJsonSSmallJsonT(void) { 28200 28201 char* r; 28202 smallJsont *self = allocSmallJson(); 28203 smallJsont* delim = allocSmallJson(); 28204 28205 // join non string objects 28206 setTopSO(delim, ";"); 28207 self->f->pushUndefined(self); 28208 self->f->pushInt(self, 123); 28209 r = joinSmallJsonSO(self, delim); 28210 ck_assert_ptr_ne(r, NULL); 28211 ck_assert_str_eq(r, "null;123"); 28212 free(r); 28213 // join strings 28214 emptyO(self); 28215 self->f->pushS(self, "a"); 28216 self->f->pushS(self, "b"); 28217 self->f->pushS(self, "c"); 28218 self->f->pushS(self, "d"); 28219 delElemIndexO(self, 1); 28220 r = joinSmallJsonSO(self, delim); 28221 ck_assert_ptr_ne(r, NULL); 28222 ck_assert_str_eq(r, "a;c;d"); 28223 free(r); 28224 // delimiter not a string 28225 freeO(delim); 28226 setTopIntO(delim, 1); 28227 r = joinSmallJsonSO(self, delim); 28228 ck_assert_ptr_eq(r, NULL); 28229 // non smallJson object 28230 terminateO(delim); 28231 delim = (smallJsont*) allocSmallInt(2); 28232 r = joinSmallJsonSO(self, delim); 28233 ck_assert_ptr_eq(r, NULL); 28234 // null delimiter 28235 r = joinSmallJsonSO(self, NULL); 28236 ck_assert_ptr_eq(r, NULL); 28237 // empty array 28238 emptyO(self); 28239 freeO(delim); 28240 setTopSO(delim, ";"); 28241 r = joinSmallJsonSO(self, delim); 28242 ck_assert_ptr_eq(r, NULL); 28243 terminateO(self); 28244 terminateO(delim); 28245 28246 } 28247 28248 28249 void joinSmallStringSSmallJsonT(void) { 28250 28251 char* r; 28252 smallJsont *self = allocSmallJson(); 28253 smallStringt* delim = allocSmallString(";"); 28254 28255 // join non string objects 28256 self->f->pushUndefined(self); 28257 self->f->pushInt(self, 123); 28258 r = joinSmallStringSO(self, delim); 28259 ck_assert_ptr_ne(r, NULL); 28260 ck_assert_str_eq(r, "null;123"); 28261 free(r); 28262 // join strings 28263 emptyO(self); 28264 self->f->pushS(self, "a"); 28265 self->f->pushS(self, "b"); 28266 self->f->pushS(self, "c"); 28267 self->f->pushS(self, "d"); 28268 delElemIndexO(self, 1); 28269 r = joinSmallStringSO(self, delim); 28270 ck_assert_ptr_ne(r, NULL); 28271 ck_assert_str_eq(r, "a;c;d"); 28272 free(r); 28273 // delimiter with no string 28274 freeO(delim); 28275 r = joinSmallStringSO(self, delim); 28276 ck_assert_ptr_eq(r, NULL); 28277 // non smallString delim 28278 terminateO(delim); 28279 delim = (smallStringt*) allocSmallInt(0); 28280 r = joinSmallStringSO(self, delim); 28281 ck_assert_ptr_eq(r, NULL); 28282 terminateO(delim); 28283 // null delimiter 28284 r = joinSmallStringSO(self, NULL); 28285 ck_assert_ptr_eq(r, NULL); 28286 // empty array 28287 emptyO(self); 28288 delim = allocSmallString(";"); 28289 r = joinSmallStringSO(self, delim); 28290 ck_assert_ptr_eq(r, NULL); 28291 terminateO(self); 28292 terminateO(delim); 28293 28294 } 28295 28296 28297 void splitSmallJsonT(void) { 28298 28299 smallJsont* r; 28300 smallJsont *self = allocSmallJson(); 28301 setTopSO(self, ""); 28302 28303 // string 28304 freeO(self); 28305 setTopSO(self, "one/two"); 28306 r = splitO(self, "/"); 28307 ck_assert_ptr_ne(r, null); 28308 char *s = toStringO(r); 28309 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 28310 free(s); 28311 terminateO(r); 28312 // delimiter on the edge 28313 freeO(self); 28314 setTopSO(self, "/one"); 28315 r = splitO(self, "/"); 28316 ck_assert_ptr_ne(r, null); 28317 s = toStringO(r); 28318 ck_assert_str_eq(s, "[\"\",\"one\"]"); 28319 free(s); 28320 terminateO(r); 28321 freeO(self); 28322 setTopSO(self, "one/"); 28323 r = splitO(self, "/"); 28324 ck_assert_ptr_ne(r, null); 28325 s = toStringO(r); 28326 ck_assert_str_eq(s, "[\"one\",\"\"]"); 28327 free(s); 28328 terminateO(r); 28329 // delimiter not found 28330 freeO(self); 28331 setTopSO(self, "one/two"); 28332 r = splitO(self, "||"); 28333 ck_assert_ptr_ne(r, null); 28334 s = toStringO(r); 28335 ck_assert_str_eq(s, "[\"one/two\"]"); 28336 free(s); 28337 terminateO(r); 28338 // split with several delimiters after each other 28339 freeO(self); 28340 setTopSO(self, "one/two three "); 28341 r = splitO(self, " "); 28342 ck_assert_ptr_ne(r, null); 28343 s = toStringO(r); 28344 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 28345 free(s); 28346 terminateO(r); 28347 // multiple character delimiter 28348 freeO(self); 28349 setTopSO(self, "AAe three extract"); 28350 r = splitO(self, "e "); 28351 ck_assert_ptr_ne(r, null); 28352 s = toStringO(r); 28353 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 28354 free(s); 28355 terminateO(r); 28356 // empty delimiter 28357 freeO(self); 28358 setTopSO(self, "AAd"); 28359 r = splitO(self, ""); 28360 ck_assert_ptr_ne(r, null); 28361 s = toStringO(r); 28362 ck_assert_str_eq(s, "[\"AAd\"]"); 28363 free(s); 28364 terminateO(r); 28365 // empty string 28366 emptyO(self); 28367 r = splitO(self, "$"); 28368 ck_assert_ptr_ne(r, null); 28369 s = toStringO(r); 28370 ck_assert_str_eq(s, "[\"\"]"); 28371 free(s); 28372 terminateO(r); 28373 // NULL list 28374 freeO(self); 28375 ck_assert_ptr_eq(splitO(self, ";"), NULL); 28376 // NULL delimiter 28377 freeO(self); 28378 setTopSO(self, "test"); 28379 ck_assert_ptr_eq(splitO(self, NULL), NULL); 28380 terminateO(self); 28381 28382 } 28383 28384 28385 void splitCharSmallJsonT(void) { 28386 28387 smallJsont* r; 28388 smallJsont *self = allocSmallJson(); 28389 setTopSO(self, ""); 28390 28391 // string 28392 freeO(self); 28393 setTopSO(self, "one/two"); 28394 r = splitCharO(self, '/'); 28395 ck_assert_ptr_ne(r, null); 28396 char *s = toStringO(r); 28397 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 28398 free(s); 28399 terminateO(r); 28400 // delimiter on the edge 28401 freeO(self); 28402 setTopSO(self, "/one"); 28403 r = splitCharO(self, '/'); 28404 ck_assert_ptr_ne(r, null); 28405 s = toStringO(r); 28406 ck_assert_str_eq(s, "[\"\",\"one\"]"); 28407 free(s); 28408 terminateO(r); 28409 freeO(self); 28410 setTopSO(self, "one/"); 28411 r = splitCharO(self, '/'); 28412 ck_assert_ptr_ne(r, null); 28413 s = toStringO(r); 28414 ck_assert_str_eq(s, "[\"one\",\"\"]"); 28415 free(s); 28416 terminateO(r); 28417 // delimiter not found 28418 freeO(self); 28419 setTopSO(self, "one/two"); 28420 r = splitCharO(self, '|'); 28421 ck_assert_ptr_ne(r, null); 28422 s = toStringO(r); 28423 ck_assert_str_eq(s, "[\"one/two\"]"); 28424 free(s); 28425 terminateO(r); 28426 // split with several delimiters after each other 28427 freeO(self); 28428 setTopSO(self, "one/two three "); 28429 r = splitCharO(self, ' '); 28430 ck_assert_ptr_ne(r, null); 28431 s = toStringO(r); 28432 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 28433 free(s); 28434 terminateO(r); 28435 // empty string 28436 emptyO(self); 28437 r = splitCharO(self, '$'); 28438 ck_assert_ptr_ne(r, null); 28439 s = toStringO(r); 28440 ck_assert_str_eq(s, "[\"\"]"); 28441 free(s); 28442 terminateO(r); 28443 // NULL list 28444 freeO(self); 28445 ck_assert_ptr_eq(splitCharO(self, ';'), NULL); 28446 terminateO(self); 28447 28448 } 28449 28450 28451 void splitSmallJsonSmallJsonT(void) { 28452 28453 smallJsont* r; 28454 smallJsont *self = allocSmallJson(); 28455 setTopSO(self, ""); 28456 smallJsont *delim = allocSmallJson(); 28457 28458 // string 28459 freeO(self); 28460 setTopSO(self, "one/two"); 28461 setTopSO(delim, "/"); 28462 r = self->f->splitSmallJson(self, delim); 28463 ck_assert_ptr_ne(r, null); 28464 char *s = toStringO(r); 28465 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 28466 free(s); 28467 terminateO(r); 28468 // delimiter on the edge 28469 freeO(self); 28470 setTopSO(self, "/one"); 28471 r = self->f->splitSmallJson(self, delim); 28472 ck_assert_ptr_ne(r, null); 28473 s = toStringO(r); 28474 ck_assert_str_eq(s, "[\"\",\"one\"]"); 28475 free(s); 28476 terminateO(r); 28477 freeO(self); 28478 setTopSO(self, "one/"); 28479 r = self->f->splitSmallJson(self, delim); 28480 ck_assert_ptr_ne(r, null); 28481 s = toStringO(r); 28482 ck_assert_str_eq(s, "[\"one\",\"\"]"); 28483 free(s); 28484 terminateO(r); 28485 // delimiter not found 28486 freeO(self); 28487 setTopSO(self, "one/two"); 28488 freeO(delim); 28489 setTopSO(delim, "||"); 28490 r = self->f->splitSmallJson(self, delim); 28491 ck_assert_ptr_ne(r, null); 28492 s = toStringO(r); 28493 ck_assert_str_eq(s, "[\"one/two\"]"); 28494 free(s); 28495 terminateO(r); 28496 // split with several delimiters after each other 28497 freeO(self); 28498 setTopSO(self, "one/two three "); 28499 freeO(delim); 28500 setTopSO(delim, " "); 28501 r = self->f->splitSmallJson(self, delim); 28502 ck_assert_ptr_ne(r, null); 28503 s = toStringO(r); 28504 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 28505 free(s); 28506 terminateO(r); 28507 // multiple character delimiter 28508 freeO(self); 28509 setTopSO(self, "AAe three extract"); 28510 freeO(delim); 28511 setTopSO(delim, "e "); 28512 r = self->f->splitSmallJson(self, delim); 28513 ck_assert_ptr_ne(r, null); 28514 s = toStringO(r); 28515 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 28516 free(s); 28517 terminateO(r); 28518 // empty delimiter 28519 freeO(self); 28520 setTopSO(self, "AAd"); 28521 freeO(delim); 28522 setTopSO(delim, ""); 28523 r = self->f->splitSmallJson(self, delim); 28524 ck_assert_ptr_ne(r, null); 28525 s = toStringO(r); 28526 ck_assert_str_eq(s, "[\"AAd\"]"); 28527 free(s); 28528 terminateO(r); 28529 // empty string 28530 emptyO(self); 28531 freeO(delim); 28532 setTopSO(delim, "$"); 28533 r = self->f->splitSmallJson(self, delim); 28534 ck_assert_ptr_ne(r, null); 28535 s = toStringO(r); 28536 ck_assert_str_eq(s, "[\"\"]"); 28537 free(s); 28538 terminateO(r); 28539 // non json string delimiter 28540 freeO(delim); 28541 ck_assert_ptr_eq(self->f->splitSmallJson(self, delim), NULL); 28542 // non json object delimiter 28543 terminateO(delim); 28544 delim = (smallJsont*) allocSmallInt(1); 28545 ck_assert_ptr_eq(self->f->splitSmallJson(self, delim), NULL); 28546 terminateO(delim); 28547 delim = allocSmallJson(); 28548 // NULL list 28549 freeO(self); 28550 freeO(delim); 28551 setTopSO(delim, ";"); 28552 ck_assert_ptr_eq(self->f->splitSmallJson(self, delim), NULL); 28553 // NULL delimiter 28554 freeO(self); 28555 setTopSO(self, "test"); 28556 ck_assert_ptr_eq(self->f->splitSmallJson(self, NULL), NULL); 28557 terminateO(delim); 28558 terminateO(self); 28559 28560 } 28561 28562 28563 void splitSmallStringSmallJsonT(void) { 28564 28565 smallJsont* r; 28566 smallJsont *self = allocSmallJson(); 28567 setTopSO(self, ""); 28568 smallStringt *delim = allocSmallString("/"); 28569 28570 // string 28571 freeO(self); 28572 setTopSO(self, "one/two"); 28573 r = self->f->splitSmallString(self, delim); 28574 ck_assert_ptr_ne(r, null); 28575 char *s = toStringO(r); 28576 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 28577 free(s); 28578 terminateO(r); 28579 // delimiter on the edge 28580 freeO(self); 28581 setTopSO(self, "/one"); 28582 r = self->f->splitSmallString(self, delim); 28583 ck_assert_ptr_ne(r, null); 28584 s = toStringO(r); 28585 ck_assert_str_eq(s, "[\"\",\"one\"]"); 28586 free(s); 28587 terminateO(r); 28588 freeO(self); 28589 setTopSO(self, "one/"); 28590 r = self->f->splitSmallString(self, delim); 28591 ck_assert_ptr_ne(r, null); 28592 s = toStringO(r); 28593 ck_assert_str_eq(s, "[\"one\",\"\"]"); 28594 free(s); 28595 terminateO(r); 28596 // delimiter not found 28597 freeO(self); 28598 setTopSO(self, "one/two"); 28599 setValO(delim, "||"); 28600 r = self->f->splitSmallString(self, delim); 28601 ck_assert_ptr_ne(r, null); 28602 s = toStringO(r); 28603 ck_assert_str_eq(s, "[\"one/two\"]"); 28604 free(s); 28605 terminateO(r); 28606 // split with several delimiters after each other 28607 freeO(self); 28608 setTopSO(self, "one/two three "); 28609 setValO(delim, " "); 28610 r = self->f->splitSmallString(self, delim); 28611 ck_assert_ptr_ne(r, null); 28612 s = toStringO(r); 28613 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 28614 free(s); 28615 terminateO(r); 28616 // multiple character delimiter 28617 freeO(self); 28618 setTopSO(self, "AAe three extract"); 28619 setValO(delim, "e "); 28620 r = self->f->splitSmallString(self, delim); 28621 ck_assert_ptr_ne(r, null); 28622 s = toStringO(r); 28623 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 28624 free(s); 28625 terminateO(r); 28626 // empty delimiter 28627 freeO(self); 28628 setTopSO(self, "AAd"); 28629 setValO(delim, ""); 28630 r = self->f->splitSmallString(self, delim); 28631 ck_assert_ptr_ne(r, null); 28632 s = toStringO(r); 28633 ck_assert_str_eq(s, "[\"AAd\"]"); 28634 free(s); 28635 terminateO(r); 28636 // empty string 28637 emptyO(self); 28638 setValO(delim, "$"); 28639 r = self->f->splitSmallString(self, delim); 28640 ck_assert_ptr_ne(r, null); 28641 s = toStringO(r); 28642 ck_assert_str_eq(s, "[\"\"]"); 28643 free(s); 28644 terminateO(r); 28645 // null string delimiter 28646 freeO(delim); 28647 ck_assert_ptr_eq(self->f->splitSmallString(self, delim), NULL); 28648 // non json object delimiter 28649 terminateO(delim); 28650 delim = (smallStringt*) allocSmallInt(1); 28651 ck_assert_ptr_eq(self->f->splitSmallString(self, delim), NULL); 28652 terminateO(delim); 28653 // NULL list 28654 freeO(self); 28655 delim = allocSmallString(";"); 28656 ck_assert_ptr_eq(self->f->splitSmallString(self, delim), NULL); 28657 // NULL delimiter 28658 freeO(self); 28659 setTopSO(self, "test"); 28660 ck_assert_ptr_eq(self->f->splitSmallString(self, NULL), NULL); 28661 terminateO(delim); 28662 terminateO(self); 28663 28664 } 28665 28666 28667 void splitSSmallJsonT(void) { 28668 28669 char** r; 28670 smallJsont *self = allocSmallJson(); 28671 setTopSO(self, ""); 28672 28673 // string 28674 freeO(self); 28675 setTopSO(self, "one/two"); 28676 r = splitSO(self, "/"); 28677 ck_assert_uint_eq(listLengthS(r),2); 28678 ck_assert_str_eq(r[0], "one"); 28679 ck_assert_str_eq(r[1], "two"); 28680 listFreeS(r); 28681 // delimiter on the edge 28682 freeO(self); 28683 setTopSO(self, "/one"); 28684 r = splitSO(self, "/"); 28685 ck_assert_uint_eq(listLengthS(r),2); 28686 ck_assert_str_eq(r[0], ""); 28687 ck_assert_str_eq(r[1], "one"); 28688 listFreeS(r); 28689 freeO(self); 28690 setTopSO(self, "one/"); 28691 r = splitSO(self, "/"); 28692 ck_assert_uint_eq(listLengthS(r),2); 28693 ck_assert_str_eq(r[0], "one"); 28694 ck_assert_str_eq(r[1], ""); 28695 listFreeS(r); 28696 // delimiter not found 28697 freeO(self); 28698 setTopSO(self, "one/two"); 28699 r = splitSO(self, "||"); 28700 ck_assert_uint_eq(listLengthS(r),1); 28701 ck_assert_str_eq(r[0], "one/two"); 28702 listFreeS(r); 28703 // split with several delimiters after each other 28704 freeO(self); 28705 setTopSO(self, "one/two three "); 28706 r = splitSO(self, " "); 28707 ck_assert_uint_eq(listLengthS(r),4); 28708 ck_assert_str_eq(r[0], "one/two"); 28709 ck_assert_str_eq(r[1], ""); 28710 ck_assert_str_eq(r[2], "three"); 28711 ck_assert_str_eq(r[3], ""); 28712 listFreeS(r); 28713 // multiple character delimiter 28714 freeO(self); 28715 setTopSO(self, "AAe three extract"); 28716 r = splitSO(self, "e "); 28717 ck_assert_uint_eq(listLengthS(r),3); 28718 ck_assert_str_eq(r[0], "AA"); 28719 ck_assert_str_eq(r[1], "thre"); 28720 ck_assert_str_eq(r[2], "extract"); 28721 listFreeS(r); 28722 // empty delimiter 28723 freeO(self); 28724 setTopSO(self, "AAd"); 28725 r = splitSO(self, ""); 28726 ck_assert_uint_eq(listLengthS(r),1); 28727 ck_assert_str_eq(r[0], "AAd"); 28728 listFreeS(r); 28729 // empty string 28730 emptyO(self); 28731 r = splitSO(self, "$"); 28732 ck_assert_uint_eq(listLengthS(r),1); 28733 ck_assert_str_eq(r[0], ""); 28734 listFreeS(r); 28735 // NULL list 28736 freeO(self); 28737 ck_assert_ptr_eq(splitSO(self, ";"), NULL); 28738 // NULL delimiter 28739 freeO(self); 28740 setTopSO(self, "test"); 28741 ck_assert_ptr_eq(splitSO(self, NULL), NULL); 28742 terminateO(self); 28743 28744 } 28745 28746 28747 void splitCharSSmallJsonT(void) { 28748 28749 char** r; 28750 smallJsont *self = allocSmallJson(); 28751 setTopSO(self, ""); 28752 28753 // string 28754 freeO(self); 28755 setTopSO(self, "one/two"); 28756 r = splitCharSO(self, '/'); 28757 ck_assert_uint_eq(listLengthS(r),2); 28758 ck_assert_str_eq(r[0], "one"); 28759 ck_assert_str_eq(r[1], "two"); 28760 listFreeS(r); 28761 // delimiter on the edge 28762 freeO(self); 28763 setTopSO(self, "/one"); 28764 r = splitCharSO(self, '/'); 28765 ck_assert_uint_eq(listLengthS(r),2); 28766 ck_assert_str_eq(r[0], ""); 28767 ck_assert_str_eq(r[1], "one"); 28768 listFreeS(r); 28769 freeO(self); 28770 setTopSO(self, "one/"); 28771 r = splitCharSO(self, '/'); 28772 ck_assert_uint_eq(listLengthS(r),2); 28773 ck_assert_str_eq(r[0], "one"); 28774 ck_assert_str_eq(r[1], ""); 28775 listFreeS(r); 28776 // delimiter not found 28777 freeO(self); 28778 setTopSO(self, "one/two"); 28779 r = splitCharSO(self, '|'); 28780 ck_assert_uint_eq(listLengthS(r),1); 28781 ck_assert_str_eq(r[0], "one/two"); 28782 listFreeS(r); 28783 // split with several delimiters after each other 28784 freeO(self); 28785 setTopSO(self, "one/two three "); 28786 r = splitCharSO(self, ' '); 28787 ck_assert_uint_eq(listLengthS(r),4); 28788 ck_assert_str_eq(r[0], "one/two"); 28789 ck_assert_str_eq(r[1], ""); 28790 ck_assert_str_eq(r[2], "three"); 28791 ck_assert_str_eq(r[3], ""); 28792 listFreeS(r); 28793 // empty string 28794 emptyO(self); 28795 r = splitCharSO(self, '$'); 28796 ck_assert_uint_eq(listLengthS(r),1); 28797 ck_assert_str_eq(r[0], ""); 28798 listFreeS(r); 28799 // NULL list 28800 freeO(self); 28801 ck_assert_ptr_eq(splitCharSO(self, ';'), NULL); 28802 terminateO(self); 28803 28804 } 28805 28806 28807 void splitSmallJsonSSmallJsonT(void) { 28808 28809 char** r; 28810 smallJsont *self = allocSmallJson(); 28811 setTopSO(self, ""); 28812 smallJsont *delim = allocSmallJson(); 28813 28814 // string 28815 freeO(self); 28816 setTopSO(self, "one/two"); 28817 setTopSO(delim, "/"); 28818 r = splitSmallJsonSO(self, delim); 28819 ck_assert_uint_eq(listLengthS(r),2); 28820 ck_assert_str_eq(r[0], "one"); 28821 ck_assert_str_eq(r[1], "two"); 28822 listFreeS(r); 28823 // delimiter on the edge 28824 freeO(self); 28825 setTopSO(self, "/one"); 28826 r = splitSmallJsonSO(self, delim); 28827 ck_assert_uint_eq(listLengthS(r),2); 28828 ck_assert_str_eq(r[0], ""); 28829 ck_assert_str_eq(r[1], "one"); 28830 listFreeS(r); 28831 freeO(self); 28832 setTopSO(self, "one/"); 28833 r = splitSmallJsonSO(self, delim); 28834 ck_assert_uint_eq(listLengthS(r),2); 28835 ck_assert_str_eq(r[0], "one"); 28836 ck_assert_str_eq(r[1], ""); 28837 listFreeS(r); 28838 // delimiter not found 28839 freeO(self); 28840 setTopSO(self, "one/two"); 28841 freeO(delim); 28842 setTopSO(delim, "||"); 28843 r = splitSmallJsonSO(self, delim); 28844 ck_assert_uint_eq(listLengthS(r),1); 28845 ck_assert_str_eq(r[0], "one/two"); 28846 listFreeS(r); 28847 // split with several delimiters after each other 28848 freeO(self); 28849 setTopSO(self, "one/two three "); 28850 freeO(delim); 28851 setTopSO(delim, " "); 28852 r = splitSmallJsonSO(self, delim); 28853 ck_assert_uint_eq(listLengthS(r),4); 28854 ck_assert_str_eq(r[0], "one/two"); 28855 ck_assert_str_eq(r[1], ""); 28856 ck_assert_str_eq(r[2], "three"); 28857 ck_assert_str_eq(r[3], ""); 28858 listFreeS(r); 28859 // multiple character delimiter 28860 freeO(self); 28861 setTopSO(self, "AAe three extract"); 28862 freeO(delim); 28863 setTopSO(delim, "e "); 28864 r = splitSmallJsonSO(self, delim); 28865 ck_assert_uint_eq(listLengthS(r),3); 28866 ck_assert_str_eq(r[0], "AA"); 28867 ck_assert_str_eq(r[1], "thre"); 28868 ck_assert_str_eq(r[2], "extract"); 28869 listFreeS(r); 28870 // empty delimiter 28871 freeO(self); 28872 setTopSO(self, "AAd"); 28873 freeO(delim); 28874 setTopSO(delim, ""); 28875 r = splitSmallJsonSO(self, delim); 28876 ck_assert_uint_eq(listLengthS(r),1); 28877 ck_assert_str_eq(r[0], "AAd"); 28878 listFreeS(r); 28879 // empty string 28880 emptyO(self); 28881 freeO(delim); 28882 setTopSO(delim, "$"); 28883 r = splitSmallJsonSO(self, delim); 28884 ck_assert_uint_eq(listLengthS(r),1); 28885 ck_assert_str_eq(r[0], ""); 28886 listFreeS(r); 28887 // non json string delimiter 28888 freeO(delim); 28889 ck_assert_ptr_eq(splitSmallJsonSO(self, delim), NULL); 28890 // non json object delimiter 28891 terminateO(delim); 28892 delim = (smallJsont*) allocSmallInt(1); 28893 ck_assert_ptr_eq(splitSmallJsonSO(self, delim), NULL); 28894 terminateO(delim); 28895 delim = allocSmallJson(); 28896 // NULL list 28897 freeO(self); 28898 freeO(delim); 28899 setTopSO(delim, ";"); 28900 ck_assert_ptr_eq(splitSmallJsonSO(self, delim), NULL); 28901 // NULL delimiter 28902 freeO(self); 28903 setTopSO(self, "test"); 28904 ck_assert_ptr_eq(splitSmallJsonSO(self, NULL), NULL); 28905 terminateO(delim); 28906 terminateO(self); 28907 28908 } 28909 28910 28911 void splitSmallStringSSmallJsonT(void) { 28912 28913 char** r; 28914 smallJsont *self = allocSmallJson(); 28915 setTopSO(self, ""); 28916 smallStringt *delim = allocSmallString("/"); 28917 28918 // string 28919 freeO(self); 28920 setTopSO(self, "one/two"); 28921 r = splitSmallStringSO(self, delim); 28922 ck_assert_uint_eq(listLengthS(r),2); 28923 ck_assert_str_eq(r[0], "one"); 28924 ck_assert_str_eq(r[1], "two"); 28925 listFreeS(r); 28926 // delimiter on the edge 28927 freeO(self); 28928 setTopSO(self, "/one"); 28929 r = splitSmallStringSO(self, delim); 28930 ck_assert_uint_eq(listLengthS(r),2); 28931 ck_assert_str_eq(r[0], ""); 28932 ck_assert_str_eq(r[1], "one"); 28933 listFreeS(r); 28934 freeO(self); 28935 setTopSO(self, "one/"); 28936 r = splitSmallStringSO(self, delim); 28937 ck_assert_uint_eq(listLengthS(r),2); 28938 ck_assert_str_eq(r[0], "one"); 28939 ck_assert_str_eq(r[1], ""); 28940 listFreeS(r); 28941 // delimiter not found 28942 freeO(self); 28943 setTopSO(self, "one/two"); 28944 setValO(delim, "||"); 28945 r = splitSmallStringSO(self, delim); 28946 ck_assert_uint_eq(listLengthS(r),1); 28947 ck_assert_str_eq(r[0], "one/two"); 28948 listFreeS(r); 28949 // split with several delimiters after each other 28950 freeO(self); 28951 setTopSO(self, "one/two three "); 28952 setValO(delim, " "); 28953 r = splitSmallStringSO(self, delim); 28954 ck_assert_uint_eq(listLengthS(r),4); 28955 ck_assert_str_eq(r[0], "one/two"); 28956 ck_assert_str_eq(r[1], ""); 28957 ck_assert_str_eq(r[2], "three"); 28958 ck_assert_str_eq(r[3], ""); 28959 listFreeS(r); 28960 // multiple character delimiter 28961 freeO(self); 28962 setTopSO(self, "AAe three extract"); 28963 setValO(delim, "e "); 28964 r = splitSmallStringSO(self, delim); 28965 ck_assert_uint_eq(listLengthS(r),3); 28966 ck_assert_str_eq(r[0], "AA"); 28967 ck_assert_str_eq(r[1], "thre"); 28968 ck_assert_str_eq(r[2], "extract"); 28969 listFreeS(r); 28970 // empty delimiter 28971 freeO(self); 28972 setTopSO(self, "AAd"); 28973 setValO(delim, ""); 28974 r = splitSmallStringSO(self, delim); 28975 ck_assert_uint_eq(listLengthS(r),1); 28976 ck_assert_str_eq(r[0], "AAd"); 28977 listFreeS(r); 28978 // empty string 28979 emptyO(self); 28980 setValO(delim, "$"); 28981 r = splitSmallStringSO(self, delim); 28982 ck_assert_uint_eq(listLengthS(r),1); 28983 ck_assert_str_eq(r[0], ""); 28984 listFreeS(r); 28985 // non smallString object delimiter 28986 terminateO(delim); 28987 delim = (smallStringt*) allocSmallInt(1); 28988 ck_assert_ptr_eq(splitSmallStringSO(self, delim), NULL); 28989 terminateO(delim); 28990 // NULL list 28991 freeO(self); 28992 delim = allocSmallString(";"); 28993 ck_assert_ptr_eq(splitSmallStringSO(self, delim), NULL); 28994 // NULL delimiter 28995 freeO(self); 28996 setTopSO(self, "test"); 28997 ck_assert_ptr_eq(splitSmallStringSO(self, NULL), NULL); 28998 terminateO(delim); 28999 terminateO(self); 29000 29001 } 29002 29003 29004 void extractSmallJsonT(void) { 29005 29006 smallJsont* r; 29007 smallJsont *self = allocSmallJson(); 29008 setTopSO(self, ""); 29009 29010 // string 29011 freeO(self); 29012 setTopSO(self, "one/two|"); 29013 r = extractO(self, "/", "|"); 29014 ck_assert_ptr_ne(r, null); 29015 char *s = toStringO(r); 29016 ck_assert_str_eq(s, "[\"two\"]"); 29017 free(s); 29018 terminateO(r); 29019 // delimiter not found 29020 freeO(self); 29021 setTopSO(self, "one/two"); 29022 r = extractO(self, "||", "/"); 29023 ck_assert_ptr_eq(r, NULL); 29024 // extractO with several delimiters after each other 29025 freeO(self); 29026 setTopSO(self, "one/ two /three "); 29027 r = extractO(self, "/", " "); 29028 ck_assert_ptr_ne(r, null); 29029 s = toStringO(r); 29030 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29031 free(s); 29032 terminateO(r); 29033 // multiple character delimiter 29034 freeO(self); 29035 setTopSO(self, "AAe thre|e extract"); 29036 r = extractO(self, "e ", "|"); 29037 ck_assert_ptr_ne(r, null); 29038 s = toStringO(r); 29039 ck_assert_str_eq(s, "[\"thre\"]"); 29040 free(s); 29041 terminateO(r); 29042 // empty delimiter 29043 freeO(self); 29044 setTopSO(self, "AAd"); 29045 r = extractO(self, "", "Ad"); 29046 ck_assert_ptr_eq(r, NULL); 29047 freeO(self); 29048 setTopSO(self, "AAd"); 29049 r = extractO(self, "A", ""); 29050 ck_assert_ptr_eq(r, NULL); 29051 // empty string 29052 freeO(self); 29053 setTopSO(self, ""); 29054 r = extractO(self, "$", "#"); 29055 ck_assert_ptr_eq(r, NULL); 29056 // delim1 = delim2 29057 freeO(self); 29058 setTopSO(self, ""); 29059 r = extractO(self, "$", "$"); 29060 ck_assert_ptr_eq(r, NULL); 29061 // NULL string 29062 freeO(self); 29063 ck_assert_ptr_eq(extractO(self, ";", ","), NULL); 29064 // NULL delimiter 29065 freeO(self); 29066 setTopSO(self, "test"); 29067 ck_assert_ptr_eq(extractO(self, NULL, ","), NULL); 29068 ck_assert_ptr_eq(extractO(self, ",", NULL), NULL); 29069 terminateO(self); 29070 29071 } 29072 29073 29074 void extractCharSSmallJsonT(void) { 29075 29076 smallJsont* r; 29077 smallJsont *self = allocSmallJson(); 29078 setTopSO(self, ""); 29079 29080 // string 29081 freeO(self); 29082 setTopSO(self, "one/two|"); 29083 r = extractCharSO(self, '/', "|"); 29084 ck_assert_ptr_ne(r, null); 29085 char *s = toStringO(r); 29086 ck_assert_str_eq(s, "[\"two\"]"); 29087 free(s); 29088 terminateO(r); 29089 // delimiter not found 29090 freeO(self); 29091 setTopSO(self, "one/two"); 29092 r = extractCharSO(self, '|', "/"); 29093 ck_assert_ptr_eq(r, NULL); 29094 // extractCharSO with several delimiters after each other 29095 freeO(self); 29096 setTopSO(self, "one/ two /three "); 29097 r = extractCharSO(self, '/', " "); 29098 ck_assert_ptr_ne(r, null); 29099 s = toStringO(r); 29100 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29101 free(s); 29102 terminateO(r); 29103 // multiple character delimiter 29104 freeO(self); 29105 setTopSO(self, "AAe thre|e extract"); 29106 r = extractCharSO(self, ' ', "|e"); 29107 ck_assert_ptr_ne(r, null); 29108 s = toStringO(r); 29109 ck_assert_str_eq(s, "[\"thre\"]"); 29110 free(s); 29111 terminateO(r); 29112 // empty delimiter 29113 freeO(self); 29114 setTopSO(self, "AAd"); 29115 r = extractCharSO(self, 'A', ""); 29116 ck_assert_ptr_eq(r, NULL); 29117 // empty string 29118 freeO(self); 29119 setTopSO(self, ""); 29120 r = extractCharSO(self, '$', "#"); 29121 ck_assert_ptr_eq(r, NULL); 29122 // delim1 = delim2 29123 freeO(self); 29124 setTopSO(self, ""); 29125 r = extractCharSO(self, '$', "$"); 29126 ck_assert_ptr_eq(r, NULL); 29127 // NULL string 29128 freeO(self); 29129 ck_assert_ptr_eq(extractCharSO(self, ';', ","), NULL); 29130 // NULL delimiter 29131 freeO(self); 29132 setTopSO(self, "test"); 29133 ck_assert_ptr_eq(extractCharSO(self, ',', NULL), NULL); 29134 terminateO(self); 29135 29136 } 29137 29138 29139 void extractSCharSmallJsonT(void) { 29140 29141 smallJsont* r; 29142 smallJsont *self = allocSmallJson(); 29143 setTopSO(self, ""); 29144 29145 // string 29146 freeO(self); 29147 setTopSO(self, "one/two|"); 29148 r = extractSCharO(self, "/", '|'); 29149 ck_assert_ptr_ne(r, null); 29150 char *s = toStringO(r); 29151 ck_assert_str_eq(s, "[\"two\"]"); 29152 free(s); 29153 terminateO(r); 29154 // delimiter not found 29155 freeO(self); 29156 setTopSO(self, "one/two"); 29157 r = extractSCharO(self, "||", '/'); 29158 ck_assert_ptr_eq(r, NULL); 29159 // extractSCharO with several delimiters after each other 29160 freeO(self); 29161 setTopSO(self, "one/ two /three "); 29162 r = extractSCharO(self, "/", ' '); 29163 ck_assert_ptr_ne(r, null); 29164 s = toStringO(r); 29165 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29166 free(s); 29167 terminateO(r); 29168 // multiple character delimiter 29169 freeO(self); 29170 setTopSO(self, "AAe thre|e extract"); 29171 r = extractSCharO(self, "e ", '|'); 29172 ck_assert_ptr_ne(r, null); 29173 s = toStringO(r); 29174 ck_assert_str_eq(s, "[\"thre\"]"); 29175 free(s); 29176 terminateO(r); 29177 // empty delimiter 29178 freeO(self); 29179 setTopSO(self, "AAd"); 29180 r = extractSCharO(self, "", 'A'); 29181 ck_assert_ptr_eq(r, NULL); 29182 // empty string 29183 freeO(self); 29184 setTopSO(self, ""); 29185 r = extractSCharO(self, "$", '#'); 29186 ck_assert_ptr_eq(r, NULL); 29187 // delim1 = delim2 29188 freeO(self); 29189 setTopSO(self, ""); 29190 r = extractSCharO(self, "$", '$'); 29191 ck_assert_ptr_eq(r, NULL); 29192 // NULL string 29193 freeO(self); 29194 ck_assert_ptr_eq(extractSCharO(self, ";", ','), NULL); 29195 // NULL delimiter 29196 freeO(self); 29197 setTopSO(self, "test"); 29198 ck_assert_ptr_eq(extractSCharO(self, NULL, ','), NULL); 29199 terminateO(self); 29200 29201 } 29202 29203 29204 void extractCharCharSmallJsonT(void) { 29205 29206 smallJsont* r; 29207 smallJsont *self = allocSmallJson(); 29208 setTopSO(self, ""); 29209 29210 // string 29211 freeO(self); 29212 setTopSO(self, "one/two|"); 29213 r = extractCharCharO(self, '/', '|'); 29214 ck_assert_ptr_ne(r, null); 29215 char *s = toStringO(r); 29216 ck_assert_str_eq(s, "[\"two\"]"); 29217 free(s); 29218 terminateO(r); 29219 // delimiter not found 29220 freeO(self); 29221 setTopSO(self, "one/two"); 29222 r = extractCharCharO(self, '|', '/'); 29223 ck_assert_ptr_eq(r, NULL); 29224 // extractCharCharO with several delimiters after each other 29225 freeO(self); 29226 setTopSO(self, "one/ two /three "); 29227 r = extractCharCharO(self, '/', ' '); 29228 ck_assert_ptr_ne(r, null); 29229 s = toStringO(r); 29230 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29231 free(s); 29232 terminateO(r); 29233 // multiple character delimiter 29234 freeO(self); 29235 setTopSO(self, "AAe thre|e extract"); 29236 r = extractCharCharO(self, ' ', '|'); 29237 ck_assert_ptr_ne(r, null); 29238 s = toStringO(r); 29239 ck_assert_str_eq(s, "[\"thre\"]"); 29240 free(s); 29241 terminateO(r); 29242 // empty string 29243 freeO(self); 29244 setTopSO(self, ""); 29245 r = extractCharCharO(self, '$', '#'); 29246 ck_assert_ptr_eq(r, NULL); 29247 // delim1 = delim2 29248 freeO(self); 29249 setTopSO(self, ""); 29250 r = extractCharCharO(self, '$', '$'); 29251 ck_assert_ptr_eq(r, NULL); 29252 // NULL string 29253 freeO(self); 29254 ck_assert_ptr_eq(extractCharCharO(self, ';', ','), NULL); 29255 terminateO(self); 29256 29257 } 29258 29259 29260 void extractSmallJsonSmallJsonSmallJsonT(void) { 29261 29262 smallJsont* r; 29263 smallJsont *self = allocSmallJson(); 29264 setTopSO(self, ""); 29265 smallJsont* delim1 = allocSmallJson(); 29266 smallJsont* delim2 = allocSmallJson(); 29267 29268 // string 29269 freeO(self); 29270 setTopSO(self, "one/two|"); 29271 setTopSO(delim1, "/"); 29272 setTopSO(delim2, "|"); 29273 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29274 ck_assert_ptr_ne(r, null); 29275 char *s = toStringO(r); 29276 ck_assert_str_eq(s, "[\"two\"]"); 29277 free(s); 29278 terminateO(r); 29279 // delimiter not found 29280 freeO(self); 29281 setTopSO(self, "one/two"); 29282 freeO(delim1); 29283 freeO(delim2); 29284 setTopSO(delim1, "||"); 29285 setTopSO(delim2, "/"); 29286 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29287 ck_assert_ptr_eq(r, NULL); 29288 // extractSmallJsonSmallJsonO with several delimiters after each other 29289 freeO(self); 29290 setTopSO(self, "one/ two /three "); 29291 freeO(delim1); 29292 freeO(delim2); 29293 setTopSO(delim1, "/"); 29294 setTopSO(delim2, " "); 29295 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29296 ck_assert_ptr_ne(r, null); 29297 s = toStringO(r); 29298 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29299 free(s); 29300 terminateO(r); 29301 // multiple character delimiter 29302 freeO(self); 29303 setTopSO(self, "AAe thre|e extract"); 29304 freeO(delim1); 29305 freeO(delim2); 29306 setTopSO(delim1, "e "); 29307 setTopSO(delim2, "|"); 29308 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29309 ck_assert_ptr_ne(r, null); 29310 s = toStringO(r); 29311 ck_assert_str_eq(s, "[\"thre\"]"); 29312 free(s); 29313 terminateO(r); 29314 // empty delimiter 29315 freeO(self); 29316 setTopSO(self, "AAd"); 29317 freeO(delim1); 29318 freeO(delim2); 29319 setTopSO(delim1, ""); 29320 setTopSO(delim2, "Ad"); 29321 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29322 ck_assert_ptr_eq(r, NULL); 29323 freeO(self); 29324 setTopSO(self, "AAd"); 29325 freeO(delim1); 29326 freeO(delim2); 29327 setTopSO(delim1, "A"); 29328 setTopSO(delim2, ""); 29329 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29330 ck_assert_ptr_eq(r, NULL); 29331 // empty string 29332 freeO(self); 29333 setTopSO(self, ""); 29334 freeO(delim1); 29335 freeO(delim2); 29336 setTopSO(delim1, "$"); 29337 setTopSO(delim2, "#"); 29338 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29339 ck_assert_ptr_eq(r, NULL); 29340 // delim1 = delim2 29341 freeO(self); 29342 setTopSO(self, "$qwe$"); 29343 freeO(delim1); 29344 freeO(delim2); 29345 setTopSO(delim1, "$"); 29346 setTopSO(delim2, "$"); 29347 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29348 ck_assert_ptr_eq(r, NULL); 29349 // non json string 29350 freeO(delim1); 29351 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29352 ck_assert_ptr_eq(r, NULL); 29353 setTopSO(delim1, "$"); 29354 freeO(delim2); 29355 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29356 ck_assert_ptr_eq(r, NULL); 29357 // non json object 29358 terminateO(delim1); 29359 delim1 = (smallJsont*) allocSmallInt(1); 29360 setTopSO(delim2, "$"); 29361 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29362 ck_assert_ptr_eq(r, NULL); 29363 terminateO(delim1); 29364 delim1 = allocSmallJson(); 29365 setTopSO(delim1, ";"); 29366 terminateO(delim2); 29367 delim2 = (smallJsont*) allocSmallInt(1); 29368 r = extractSmallJsonSmallJsonO(self, delim1, delim2); 29369 ck_assert_ptr_eq(r, NULL); 29370 terminateO(delim2); 29371 delim2 = allocSmallJson(); 29372 // NULL string 29373 freeO(self); 29374 freeO(delim1); 29375 freeO(delim2); 29376 setTopSO(delim1, ";"); 29377 setTopSO(delim2, ","); 29378 ck_assert_ptr_eq(extractSmallJsonSmallJsonO(self, delim1, delim2), NULL); 29379 // NULL delimiter 29380 freeO(self); 29381 setTopSO(self, "test"); 29382 ck_assert_ptr_eq(extractSmallJsonSmallJsonO(self, NULL, delim2), NULL); 29383 ck_assert_ptr_eq(extractSmallJsonSmallJsonO(self, delim1, NULL), NULL); 29384 terminateO(delim1); 29385 terminateO(delim2); 29386 terminateO(self); 29387 29388 } 29389 29390 29391 void extractSmallJsonSmallStringSmallJsonT(void) { 29392 29393 smallJsont* r; 29394 smallJsont *self = allocSmallJson(); 29395 setTopSO(self, ""); 29396 smallJsont* delim1 = allocSmallJson(); 29397 smallStringt* delim2 = allocSmallString("|"); 29398 29399 // string 29400 freeO(self); 29401 setTopSO(self, "one/two|"); 29402 setTopSO(delim1, "/"); 29403 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29404 ck_assert_ptr_ne(r, null); 29405 char *s = toStringO(r); 29406 ck_assert_str_eq(s, "[\"two\"]"); 29407 free(s); 29408 terminateO(r); 29409 // delimiter not found 29410 freeO(self); 29411 setTopSO(self, "one/two"); 29412 freeO(delim1); 29413 setTopSO(delim1, "||"); 29414 setValO(delim2, "/"); 29415 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29416 ck_assert_ptr_eq(r, NULL); 29417 // extractSmallJsonSmallStringO with several delimiters after each other 29418 freeO(self); 29419 setTopSO(self, "one/ two /three "); 29420 freeO(delim1); 29421 setTopSO(delim1, "/"); 29422 setValO(delim2, " "); 29423 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29424 ck_assert_ptr_ne(r, null); 29425 s = toStringO(r); 29426 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29427 free(s); 29428 terminateO(r); 29429 // multiple character delimiter 29430 freeO(self); 29431 setTopSO(self, "AAe thre|e extract"); 29432 freeO(delim1); 29433 setTopSO(delim1, "e "); 29434 setValO(delim2, "|"); 29435 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29436 ck_assert_ptr_ne(r, null); 29437 s = toStringO(r); 29438 ck_assert_str_eq(s, "[\"thre\"]"); 29439 free(s); 29440 terminateO(r); 29441 // empty delimiter 29442 freeO(self); 29443 setTopSO(self, "AAd"); 29444 freeO(delim1); 29445 setTopSO(delim1, ""); 29446 setValO(delim2, "Ad"); 29447 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29448 ck_assert_ptr_eq(r, NULL); 29449 freeO(self); 29450 setTopSO(self, "AAd"); 29451 freeO(delim1); 29452 setTopSO(delim1, "A"); 29453 setValO(delim2, ""); 29454 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29455 ck_assert_ptr_eq(r, NULL); 29456 // empty string 29457 freeO(self); 29458 setTopSO(self, ""); 29459 freeO(delim1); 29460 setTopSO(delim1, "$"); 29461 setValO(delim2, "#"); 29462 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29463 ck_assert_ptr_eq(r, NULL); 29464 // delim1 = delim2 29465 freeO(self); 29466 setTopSO(self, "$qwe$"); 29467 freeO(delim1); 29468 setTopSO(delim1, "$"); 29469 setValO(delim2, "$"); 29470 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29471 ck_assert_ptr_eq(r, NULL); 29472 // non json string 29473 freeO(delim1); 29474 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29475 ck_assert_ptr_eq(r, NULL); 29476 // non json object 29477 terminateO(delim1); 29478 delim1 = (smallJsont*) allocSmallInt(1); 29479 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29480 ck_assert_ptr_eq(r, NULL); 29481 terminateO(delim1); 29482 delim1 = allocSmallJson(); 29483 setTopSO(delim1, ";"); 29484 terminateO(delim2); 29485 delim2 = (smallStringt*) allocSmallInt(1); 29486 r = extractSmallJsonSmallStringO(self, delim1, delim2); 29487 ck_assert_ptr_eq(r, NULL); 29488 terminateO(delim2); 29489 delim2 = allocSmallString(","); 29490 // NULL string 29491 freeO(self); 29492 freeO(delim1); 29493 setTopSO(delim1, ";"); 29494 ck_assert_ptr_eq(extractSmallJsonSmallStringO(self, delim1, delim2), NULL); 29495 // NULL delimiter 29496 freeO(self); 29497 setTopSO(self, "test"); 29498 ck_assert_ptr_eq(extractSmallJsonSmallStringO(self, NULL, delim2), NULL); 29499 ck_assert_ptr_eq(extractSmallJsonSmallStringO(self, delim1, NULL), NULL); 29500 terminateO(delim1); 29501 terminateO(delim2); 29502 terminateO(self); 29503 29504 } 29505 29506 29507 void extractSmallJsonSSmallJsonT(void) { 29508 29509 smallJsont* r; 29510 smallJsont *self = allocSmallJson(); 29511 setTopSO(self, ""); 29512 smallJsont* delim1 = allocSmallJson(); 29513 29514 // string 29515 freeO(self); 29516 setTopSO(self, "one/two|"); 29517 setTopSO(delim1, "/"); 29518 r = extractSmallJsonSO(self, delim1, "|"); 29519 ck_assert_ptr_ne(r, null); 29520 char *s = toStringO(r); 29521 ck_assert_str_eq(s, "[\"two\"]"); 29522 free(s); 29523 terminateO(r); 29524 // delimiter not found 29525 freeO(self); 29526 setTopSO(self, "one/two"); 29527 freeO(delim1); 29528 setTopSO(delim1, "||"); 29529 r = extractSmallJsonSO(self, delim1, "/"); 29530 ck_assert_ptr_eq(r, NULL); 29531 // extractSmallJsonSO with several delimiters after each other 29532 freeO(self); 29533 setTopSO(self, "one/ two /three "); 29534 freeO(delim1); 29535 setTopSO(delim1, "/"); 29536 r = extractSmallJsonSO(self, delim1, " "); 29537 ck_assert_ptr_ne(r, null); 29538 s = toStringO(r); 29539 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29540 free(s); 29541 terminateO(r); 29542 // multiple character delimiter 29543 freeO(self); 29544 setTopSO(self, "AAe thre|e extract"); 29545 freeO(delim1); 29546 setTopSO(delim1, "e "); 29547 r = extractSmallJsonSO(self, delim1, "|"); 29548 ck_assert_ptr_ne(r, null); 29549 s = toStringO(r); 29550 ck_assert_str_eq(s, "[\"thre\"]"); 29551 free(s); 29552 terminateO(r); 29553 // empty delimiter 29554 freeO(self); 29555 setTopSO(self, "AAd"); 29556 freeO(delim1); 29557 setTopSO(delim1, ""); 29558 r = extractSmallJsonSO(self, delim1, "Ad"); 29559 ck_assert_ptr_eq(r, NULL); 29560 freeO(self); 29561 setTopSO(self, "AAd"); 29562 freeO(delim1); 29563 setTopSO(delim1, "A"); 29564 r = extractSmallJsonSO(self, delim1, ""); 29565 ck_assert_ptr_eq(r, NULL); 29566 // empty string 29567 freeO(self); 29568 setTopSO(self, ""); 29569 freeO(delim1); 29570 setTopSO(delim1, "$"); 29571 r = extractSmallJsonSO(self, delim1, "#"); 29572 ck_assert_ptr_eq(r, NULL); 29573 // delim1 = delim2 29574 freeO(self); 29575 setTopSO(self, "$qwe$"); 29576 freeO(delim1); 29577 setTopSO(delim1, "$"); 29578 r = extractSmallJsonSO(self, delim1, "$"); 29579 ck_assert_ptr_eq(r, NULL); 29580 // non json string 29581 freeO(delim1); 29582 r = extractSmallJsonSO(self, delim1, "$"); 29583 ck_assert_ptr_eq(r, NULL); 29584 // non json object 29585 terminateO(delim1); 29586 delim1 = (smallJsont*) allocSmallInt(1); 29587 r = extractSmallJsonSO(self, delim1, "$"); 29588 ck_assert_ptr_eq(r, NULL); 29589 terminateO(delim1); 29590 delim1 = allocSmallJson(); 29591 // NULL string 29592 freeO(self); 29593 freeO(delim1); 29594 setTopSO(delim1, ";"); 29595 ck_assert_ptr_eq(extractSmallJsonSO(self, delim1, ","), NULL); 29596 // NULL delimiter 29597 freeO(self); 29598 setTopSO(self, "test"); 29599 ck_assert_ptr_eq(extractSmallJsonSO(self, NULL, ","), NULL); 29600 ck_assert_ptr_eq(extractSmallJsonSO(self, delim1, NULL), NULL); 29601 terminateO(delim1); 29602 terminateO(self); 29603 29604 } 29605 29606 29607 void extractSmallJsonCharSmallJsonT(void) { 29608 29609 smallJsont* r; 29610 smallJsont *self = allocSmallJson(); 29611 setTopSO(self, ""); 29612 smallJsont* delim1 = allocSmallJson(); 29613 29614 // string 29615 freeO(self); 29616 setTopSO(self, "one/two|"); 29617 setTopSO(delim1, "/"); 29618 r = extractSmallJsonCharO(self, delim1, '|'); 29619 ck_assert_ptr_ne(r, null); 29620 char *s = toStringO(r); 29621 ck_assert_str_eq(s, "[\"two\"]"); 29622 free(s); 29623 terminateO(r); 29624 // delimiter not found 29625 freeO(self); 29626 setTopSO(self, "one/two"); 29627 freeO(delim1); 29628 setTopSO(delim1, "||"); 29629 r = extractSmallJsonCharO(self, delim1, '/'); 29630 ck_assert_ptr_eq(r, NULL); 29631 // extractSmallJsonCharO with several delimiters after each other 29632 freeO(self); 29633 setTopSO(self, "one/ two /three "); 29634 freeO(delim1); 29635 setTopSO(delim1, "/"); 29636 r = extractSmallJsonCharO(self, delim1, ' '); 29637 ck_assert_ptr_ne(r, null); 29638 s = toStringO(r); 29639 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29640 free(s); 29641 terminateO(r); 29642 // multiple character delimiter 29643 freeO(self); 29644 setTopSO(self, "AAe thre|e extract"); 29645 freeO(delim1); 29646 setTopSO(delim1, "e "); 29647 r = extractSmallJsonCharO(self, delim1, '|'); 29648 ck_assert_ptr_ne(r, null); 29649 s = toStringO(r); 29650 ck_assert_str_eq(s, "[\"thre\"]"); 29651 free(s); 29652 terminateO(r); 29653 // empty delimiter 29654 freeO(self); 29655 setTopSO(self, "AAd"); 29656 freeO(delim1); 29657 setTopSO(delim1, ""); 29658 r = extractSmallJsonCharO(self, delim1, 'd'); 29659 ck_assert_ptr_eq(r, NULL); 29660 freeO(self); 29661 setTopSO(self, "AAd"); 29662 // empty string 29663 freeO(self); 29664 setTopSO(self, ""); 29665 freeO(delim1); 29666 setTopSO(delim1, "$"); 29667 r = extractSmallJsonCharO(self, delim1, '#'); 29668 ck_assert_ptr_eq(r, NULL); 29669 // delim1 = delim2 29670 freeO(self); 29671 setTopSO(self, "$qwe$"); 29672 freeO(delim1); 29673 setTopSO(delim1, "$"); 29674 r = extractSmallJsonCharO(self, delim1, '$'); 29675 ck_assert_ptr_eq(r, NULL); 29676 // non json string 29677 freeO(delim1); 29678 r = extractSmallJsonCharO(self, delim1, '$'); 29679 ck_assert_ptr_eq(r, NULL); 29680 // non json object 29681 terminateO(delim1); 29682 delim1 = (smallJsont*) allocSmallInt(1); 29683 r = extractSmallJsonCharO(self, delim1, '$'); 29684 ck_assert_ptr_eq(r, NULL); 29685 terminateO(delim1); 29686 delim1 = allocSmallJson(); 29687 // NULL string 29688 freeO(self); 29689 freeO(delim1); 29690 setTopSO(delim1, ";"); 29691 ck_assert_ptr_eq(extractSmallJsonCharO(self, delim1, ','), NULL); 29692 // NULL delimiter 29693 freeO(self); 29694 setTopSO(self, "test"); 29695 ck_assert_ptr_eq(extractSmallJsonCharO(self, NULL, ','), NULL); 29696 terminateO(delim1); 29697 terminateO(self); 29698 29699 } 29700 29701 29702 void extractSmallStringSmallJsonSmallJsonT(void) { 29703 29704 smallJsont* r; 29705 smallJsont *self = allocSmallJson(); 29706 setTopSO(self, ""); 29707 smallStringt* delim1 = allocSmallString("/"); 29708 smallJsont* delim2 = allocSmallJson(); 29709 29710 // string 29711 freeO(self); 29712 setTopSO(self, "one/two|"); 29713 setTopSO(delim2, "|"); 29714 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29715 ck_assert_ptr_ne(r, null); 29716 char *s = toStringO(r); 29717 ck_assert_str_eq(s, "[\"two\"]"); 29718 free(s); 29719 terminateO(r); 29720 // delimiter not found 29721 freeO(self); 29722 setTopSO(self, "one/two"); 29723 freeO(delim2); 29724 setValO(delim1, "||"); 29725 setTopSO(delim2, "/"); 29726 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29727 ck_assert_ptr_eq(r, NULL); 29728 // extractSmallStringSmallJsonO with several delimiters after each other 29729 freeO(self); 29730 setTopSO(self, "one/ two /three "); 29731 freeO(delim2); 29732 setValO(delim1, "/"); 29733 setTopSO(delim2, " "); 29734 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29735 ck_assert_ptr_ne(r, null); 29736 s = toStringO(r); 29737 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29738 free(s); 29739 terminateO(r); 29740 // multiple character delimiter 29741 freeO(self); 29742 setTopSO(self, "AAe thre|e extract"); 29743 freeO(delim2); 29744 setValO(delim1, "e "); 29745 setTopSO(delim2, "|"); 29746 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29747 ck_assert_ptr_ne(r, null); 29748 s = toStringO(r); 29749 ck_assert_str_eq(s, "[\"thre\"]"); 29750 free(s); 29751 terminateO(r); 29752 // empty delimiter 29753 freeO(self); 29754 setTopSO(self, "AAd"); 29755 freeO(delim2); 29756 setValO(delim1, ""); 29757 setTopSO(delim2, "Ad"); 29758 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29759 ck_assert_ptr_eq(r, NULL); 29760 freeO(self); 29761 setTopSO(self, "AAd"); 29762 freeO(delim2); 29763 setValO(delim1, "A"); 29764 setTopSO(delim2, ""); 29765 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29766 ck_assert_ptr_eq(r, NULL); 29767 // empty string 29768 freeO(self); 29769 setTopSO(self, ""); 29770 freeO(delim2); 29771 setValO(delim1, "$"); 29772 setTopSO(delim2, "#"); 29773 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29774 ck_assert_ptr_eq(r, NULL); 29775 // delim1 = delim2 29776 freeO(self); 29777 setTopSO(self, "$qwe$"); 29778 freeO(delim2); 29779 setValO(delim1, "$"); 29780 setTopSO(delim2, "$"); 29781 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29782 ck_assert_ptr_eq(r, NULL); 29783 // non json string 29784 freeO(delim2); 29785 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29786 ck_assert_ptr_eq(r, NULL); 29787 // non json object 29788 terminateO(delim1); 29789 delim1 = (smallStringt*) allocSmallInt(1); 29790 setTopSO(delim2, "$"); 29791 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29792 ck_assert_ptr_eq(r, NULL); 29793 terminateO(delim1); 29794 delim1 = allocSmallString(";"); 29795 terminateO(delim2); 29796 delim2 = (smallJsont*) allocSmallInt(1); 29797 r = extractSmallStringSmallJsonO(self, delim1, delim2); 29798 ck_assert_ptr_eq(r, NULL); 29799 terminateO(delim2); 29800 delim2 = allocSmallJson(); 29801 // NULL string 29802 freeO(self); 29803 freeO(delim2); 29804 setValO(delim1, ";"); 29805 setTopSO(delim2, ","); 29806 ck_assert_ptr_eq(extractSmallStringSmallJsonO(self, delim1, delim2), NULL); 29807 // NULL delimiter 29808 freeO(self); 29809 setTopSO(self, "test"); 29810 ck_assert_ptr_eq(extractSmallStringSmallJsonO(self, NULL, delim2), NULL); 29811 ck_assert_ptr_eq(extractSmallStringSmallJsonO(self, delim1, NULL), NULL); 29812 terminateO(delim1); 29813 terminateO(delim2); 29814 terminateO(self); 29815 29816 } 29817 29818 29819 void extractSmallStringSmallStringSmallJsonT(void) { 29820 29821 smallJsont* r; 29822 smallJsont *self = allocSmallJson(); 29823 setTopSO(self, ""); 29824 smallStringt* delim1 = allocSmallString("/"); 29825 smallStringt* delim2 = allocSmallString("|"); 29826 29827 // string 29828 freeO(self); 29829 setTopSO(self, "one/two|"); 29830 setValO(delim2, "|"); 29831 r = extractSmallStringSmallStringO(self, delim1, delim2); 29832 ck_assert_ptr_ne(r, null); 29833 char *s = toStringO(r); 29834 ck_assert_str_eq(s, "[\"two\"]"); 29835 free(s); 29836 terminateO(r); 29837 // delimiter not found 29838 freeO(self); 29839 setTopSO(self, "one/two"); 29840 setValO(delim1, "||"); 29841 setValO(delim2, "/"); 29842 r = extractSmallStringSmallStringO(self, delim1, delim2); 29843 ck_assert_ptr_eq(r, NULL); 29844 // extractSmallStringSmallStringO with several delimiters after each other 29845 freeO(self); 29846 setTopSO(self, "one/ two /three "); 29847 setValO(delim1, "/"); 29848 setValO(delim2, " "); 29849 r = extractSmallStringSmallStringO(self, delim1, delim2); 29850 ck_assert_ptr_ne(r, null); 29851 s = toStringO(r); 29852 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29853 free(s); 29854 terminateO(r); 29855 // multiple character delimiter 29856 freeO(self); 29857 setTopSO(self, "AAe thre|e extract"); 29858 setValO(delim1, "e "); 29859 setValO(delim2, "|"); 29860 r = extractSmallStringSmallStringO(self, delim1, delim2); 29861 ck_assert_ptr_ne(r, null); 29862 s = toStringO(r); 29863 ck_assert_str_eq(s, "[\"thre\"]"); 29864 free(s); 29865 terminateO(r); 29866 // empty delimiter 29867 freeO(self); 29868 setTopSO(self, "AAd"); 29869 setValO(delim1, ""); 29870 setValO(delim2, "Ad"); 29871 r = extractSmallStringSmallStringO(self, delim1, delim2); 29872 ck_assert_ptr_eq(r, NULL); 29873 freeO(self); 29874 setTopSO(self, "AAd"); 29875 setValO(delim1, "A"); 29876 setValO(delim2, ""); 29877 r = extractSmallStringSmallStringO(self, delim1, delim2); 29878 ck_assert_ptr_eq(r, NULL); 29879 // empty string 29880 freeO(self); 29881 setTopSO(self, ""); 29882 setValO(delim1, "$"); 29883 setValO(delim2, "#"); 29884 r = extractSmallStringSmallStringO(self, delim1, delim2); 29885 ck_assert_ptr_eq(r, NULL); 29886 // delim1 = delim2 29887 freeO(self); 29888 setTopSO(self, "$qwe$"); 29889 setValO(delim1, "$"); 29890 setValO(delim2, "$"); 29891 r = extractSmallStringSmallStringO(self, delim1, delim2); 29892 ck_assert_ptr_eq(r, NULL); 29893 // non json object 29894 terminateO(delim1); 29895 delim1 = (smallStringt*) allocSmallInt(1); 29896 r = extractSmallStringSmallStringO(self, delim1, delim2); 29897 ck_assert_ptr_eq(r, NULL); 29898 terminateO(delim1); 29899 delim1 = allocSmallString(";"); 29900 terminateO(delim2); 29901 delim2 = (smallStringt*) allocSmallInt(1); 29902 r = extractSmallStringSmallStringO(self, delim1, delim2); 29903 ck_assert_ptr_eq(r, NULL); 29904 terminateO(delim2); 29905 delim2 = allocSmallString(","); 29906 // NULL string 29907 freeO(self); 29908 setValO(delim1, ";"); 29909 ck_assert_ptr_eq(extractSmallStringSmallStringO(self, delim1, delim2), NULL); 29910 // NULL delimiter 29911 freeO(self); 29912 setTopSO(self, "test"); 29913 ck_assert_ptr_eq(extractSmallStringSmallStringO(self, NULL, delim2), NULL); 29914 ck_assert_ptr_eq(extractSmallStringSmallStringO(self, delim1, NULL), NULL); 29915 terminateO(delim1); 29916 terminateO(delim2); 29917 terminateO(self); 29918 29919 } 29920 29921 29922 void extractSmallStringSSmallJsonT(void) { 29923 29924 smallJsont* r; 29925 smallJsont *self = allocSmallJson(); 29926 setTopSO(self, ""); 29927 smallStringt* delim1 = allocSmallString("/"); 29928 29929 // string 29930 freeO(self); 29931 setTopSO(self, "one/two|"); 29932 r = extractSmallStringSO(self, delim1, "|"); 29933 ck_assert_ptr_ne(r, null); 29934 char *s = toStringO(r); 29935 ck_assert_str_eq(s, "[\"two\"]"); 29936 free(s); 29937 terminateO(r); 29938 // delimiter not found 29939 freeO(self); 29940 setTopSO(self, "one/two"); 29941 setValO(delim1, "||"); 29942 r = extractSmallStringSO(self, delim1, "/"); 29943 ck_assert_ptr_eq(r, NULL); 29944 // extractSmallStringSO with several delimiters after each other 29945 freeO(self); 29946 setTopSO(self, "one/ two /three "); 29947 setValO(delim1, "/"); 29948 r = extractSmallStringSO(self, delim1, " "); 29949 ck_assert_ptr_ne(r, null); 29950 s = toStringO(r); 29951 ck_assert_str_eq(s, "[\"\",\"three\"]"); 29952 free(s); 29953 terminateO(r); 29954 // multiple character delimiter 29955 freeO(self); 29956 setTopSO(self, "AAe thre|e extract"); 29957 setValO(delim1, "e "); 29958 r = extractSmallStringSO(self, delim1, "|"); 29959 ck_assert_ptr_ne(r, null); 29960 s = toStringO(r); 29961 ck_assert_str_eq(s, "[\"thre\"]"); 29962 free(s); 29963 terminateO(r); 29964 // empty delimiter 29965 freeO(self); 29966 setTopSO(self, "AAd"); 29967 setValO(delim1, ""); 29968 r = extractSmallStringSO(self, delim1, "Ad"); 29969 ck_assert_ptr_eq(r, NULL); 29970 freeO(self); 29971 setTopSO(self, "AAd"); 29972 setValO(delim1, "A"); 29973 r = extractSmallStringSO(self, delim1, ""); 29974 ck_assert_ptr_eq(r, NULL); 29975 // empty string 29976 freeO(self); 29977 setTopSO(self, ""); 29978 setValO(delim1, "$"); 29979 r = extractSmallStringSO(self, delim1, "#"); 29980 ck_assert_ptr_eq(r, NULL); 29981 // delim1 = delim2 29982 freeO(self); 29983 setTopSO(self, "$qwe$"); 29984 setValO(delim1, "$"); 29985 r = extractSmallStringSO(self, delim1, "$"); 29986 ck_assert_ptr_eq(r, NULL); 29987 // non json object 29988 terminateO(delim1); 29989 delim1 = (smallStringt*) allocSmallInt(1); 29990 r = extractSmallStringSO(self, delim1, "$"); 29991 ck_assert_ptr_eq(r, NULL); 29992 terminateO(delim1); 29993 delim1 = allocSmallString(";"); 29994 // NULL string 29995 freeO(self); 29996 setValO(delim1, ";"); 29997 ck_assert_ptr_eq(extractSmallStringSO(self, delim1, ","), NULL); 29998 // NULL delimiter 29999 freeO(self); 30000 setTopSO(self, "test"); 30001 ck_assert_ptr_eq(extractSmallStringSO(self, NULL, ","), NULL); 30002 ck_assert_ptr_eq(extractSmallStringSO(self, delim1, NULL), NULL); 30003 terminateO(delim1); 30004 terminateO(self); 30005 30006 } 30007 30008 30009 void extractSmallStringCharSmallJsonT(void) { 30010 30011 smallJsont* r; 30012 smallJsont *self = allocSmallJson(); 30013 setTopSO(self, ""); 30014 smallStringt* delim1 = allocSmallString("/"); 30015 30016 // string 30017 freeO(self); 30018 setTopSO(self, "one/two|"); 30019 r = extractSmallStringCharO(self, delim1, '|'); 30020 ck_assert_ptr_ne(r, null); 30021 char *s = toStringO(r); 30022 ck_assert_str_eq(s, "[\"two\"]"); 30023 free(s); 30024 terminateO(r); 30025 // delimiter not found 30026 freeO(self); 30027 setTopSO(self, "one/two"); 30028 setValO(delim1, "||"); 30029 r = extractSmallStringCharO(self, delim1, '/'); 30030 ck_assert_ptr_eq(r, NULL); 30031 // extractSmallStringCharO with several delimiters after each other 30032 freeO(self); 30033 setTopSO(self, "one/ two /three "); 30034 setValO(delim1, "/"); 30035 r = extractSmallStringCharO(self, delim1, ' '); 30036 ck_assert_ptr_ne(r, null); 30037 s = toStringO(r); 30038 ck_assert_str_eq(s, "[\"\",\"three\"]"); 30039 free(s); 30040 terminateO(r); 30041 // multiple character delimiter 30042 freeO(self); 30043 setTopSO(self, "AAe thre|e extract"); 30044 setValO(delim1, "e "); 30045 r = extractSmallStringCharO(self, delim1, '|'); 30046 ck_assert_ptr_ne(r, null); 30047 s = toStringO(r); 30048 ck_assert_str_eq(s, "[\"thre\"]"); 30049 free(s); 30050 terminateO(r); 30051 // empty delimiter 30052 freeO(self); 30053 setTopSO(self, "AAd"); 30054 setValO(delim1, ""); 30055 r = extractSmallStringCharO(self, delim1, 'A'); 30056 ck_assert_ptr_eq(r, NULL); 30057 freeO(self); 30058 setTopSO(self, "AAd"); 30059 setValO(delim1, "A"); 30060 // empty string 30061 freeO(self); 30062 setTopSO(self, ""); 30063 setValO(delim1, "$"); 30064 r = extractSmallStringCharO(self, delim1, '#'); 30065 ck_assert_ptr_eq(r, NULL); 30066 // delim1 = delim2 30067 freeO(self); 30068 setTopSO(self, "$qwe$"); 30069 setValO(delim1, "$"); 30070 r = extractSmallStringCharO(self, delim1, '$'); 30071 ck_assert_ptr_eq(r, NULL); 30072 // non json object 30073 terminateO(delim1); 30074 delim1 = (smallStringt*) allocSmallInt(1); 30075 r = extractSmallStringCharO(self, delim1, '$'); 30076 ck_assert_ptr_eq(r, NULL); 30077 terminateO(delim1); 30078 delim1 = allocSmallString(";"); 30079 // NULL string 30080 freeO(self); 30081 setValO(delim1, ";"); 30082 ck_assert_ptr_eq(extractSmallStringCharO(self, delim1, ','), NULL); 30083 // NULL delimiter 30084 freeO(self); 30085 setTopSO(self, "test"); 30086 ck_assert_ptr_eq(extractSmallStringCharO(self, NULL, ','), NULL); 30087 terminateO(delim1); 30088 terminateO(self); 30089 30090 } 30091 30092 30093 void extractSSmallJsonSmallJsonT(void) { 30094 30095 smallJsont* r; 30096 smallJsont *self = allocSmallJson(); 30097 setTopSO(self, ""); 30098 smallJsont* delim2 = allocSmallJson(); 30099 30100 // string 30101 freeO(self); 30102 setTopSO(self, "one/two|"); 30103 setTopSO(delim2, "|"); 30104 r = extractSSmallJsonO(self, "/", delim2); 30105 ck_assert_ptr_ne(r, null); 30106 char *s = toStringO(r); 30107 ck_assert_str_eq(s, "[\"two\"]"); 30108 free(s); 30109 terminateO(r); 30110 // delimiter not found 30111 freeO(self); 30112 setTopSO(self, "one/two"); 30113 freeO(delim2); 30114 setTopSO(delim2, "/"); 30115 r = extractSSmallJsonO(self, "||", delim2); 30116 ck_assert_ptr_eq(r, NULL); 30117 // extractSSmallJsonO with several delimiters after each other 30118 freeO(self); 30119 setTopSO(self, "one/ two /three "); 30120 freeO(delim2); 30121 setTopSO(delim2, " "); 30122 r = extractSSmallJsonO(self, "/", delim2); 30123 ck_assert_ptr_ne(r, null); 30124 s = toStringO(r); 30125 ck_assert_str_eq(s, "[\"\",\"three\"]"); 30126 free(s); 30127 terminateO(r); 30128 // multiple character delimiter 30129 freeO(self); 30130 setTopSO(self, "AAe thre|e extract"); 30131 freeO(delim2); 30132 setTopSO(delim2, "|"); 30133 r = extractSSmallJsonO(self, "e ", delim2); 30134 ck_assert_ptr_ne(r, null); 30135 s = toStringO(r); 30136 ck_assert_str_eq(s, "[\"thre\"]"); 30137 free(s); 30138 terminateO(r); 30139 // empty delimiter 30140 freeO(self); 30141 setTopSO(self, "AAd"); 30142 freeO(delim2); 30143 setTopSO(delim2, "Ad"); 30144 r = extractSSmallJsonO(self, "", delim2); 30145 ck_assert_ptr_eq(r, NULL); 30146 freeO(self); 30147 setTopSO(self, "AAd"); 30148 freeO(delim2); 30149 setTopSO(delim2, ""); 30150 r = extractSSmallJsonO(self, "A", delim2); 30151 ck_assert_ptr_eq(r, NULL); 30152 // empty string 30153 freeO(self); 30154 setTopSO(self, ""); 30155 freeO(delim2); 30156 setTopSO(delim2, "#"); 30157 r = extractSSmallJsonO(self, "$", delim2); 30158 ck_assert_ptr_eq(r, NULL); 30159 // delim1 = delim2 30160 freeO(self); 30161 setTopSO(self, "$qwe$"); 30162 freeO(delim2); 30163 setTopSO(delim2, "$"); 30164 r = extractSSmallJsonO(self, "$", delim2); 30165 ck_assert_ptr_eq(r, NULL); 30166 // non json string 30167 freeO(delim2); 30168 r = extractSSmallJsonO(self, "$", delim2); 30169 ck_assert_ptr_eq(r, NULL); 30170 // non json object 30171 terminateO(delim2); 30172 delim2 = (smallJsont*) allocSmallInt(1); 30173 r = extractSSmallJsonO(self, ";", delim2); 30174 ck_assert_ptr_eq(r, NULL); 30175 terminateO(delim2); 30176 delim2 = allocSmallJson(); 30177 // NULL string 30178 freeO(self); 30179 freeO(delim2); 30180 setTopSO(delim2, ","); 30181 ck_assert_ptr_eq(extractSSmallJsonO(self, ";", delim2), NULL); 30182 // NULL delimiter 30183 freeO(self); 30184 setTopSO(self, "test"); 30185 ck_assert_ptr_eq(extractSSmallJsonO(self, NULL, delim2), NULL); 30186 ck_assert_ptr_eq(extractSSmallJsonO(self, ";", NULL), NULL); 30187 terminateO(delim2); 30188 terminateO(self); 30189 30190 } 30191 30192 30193 void extractSSmallStringSmallJsonT(void) { 30194 30195 smallJsont* r; 30196 smallJsont *self = allocSmallJson(); 30197 setTopSO(self, ""); 30198 smallStringt* delim2 = allocSmallString("|"); 30199 30200 // string 30201 freeO(self); 30202 setTopSO(self, "one/two|"); 30203 setValO(delim2, "|"); 30204 r = extractSSmallStringO(self, "/", delim2); 30205 ck_assert_ptr_ne(r, null); 30206 char *s = toStringO(r); 30207 ck_assert_str_eq(s, "[\"two\"]"); 30208 free(s); 30209 terminateO(r); 30210 // delimiter not found 30211 freeO(self); 30212 setTopSO(self, "one/two"); 30213 setValO(delim2, "/"); 30214 r = extractSSmallStringO(self, "||", delim2); 30215 ck_assert_ptr_eq(r, NULL); 30216 // extractSSmallStringO with several delimiters after each other 30217 freeO(self); 30218 setTopSO(self, "one/ two /three "); 30219 setValO(delim2, " "); 30220 r = extractSSmallStringO(self, "/", delim2); 30221 ck_assert_ptr_ne(r, null); 30222 s = toStringO(r); 30223 ck_assert_str_eq(s, "[\"\",\"three\"]"); 30224 free(s); 30225 terminateO(r); 30226 // multiple character delimiter 30227 freeO(self); 30228 setTopSO(self, "AAe thre|e extract"); 30229 setValO(delim2, "|"); 30230 r = extractSSmallStringO(self, "e ", delim2); 30231 ck_assert_ptr_ne(r, null); 30232 s = toStringO(r); 30233 ck_assert_str_eq(s, "[\"thre\"]"); 30234 free(s); 30235 terminateO(r); 30236 // empty delimiter 30237 freeO(self); 30238 setTopSO(self, "AAd"); 30239 setValO(delim2, "Ad"); 30240 r = extractSSmallStringO(self, "", delim2); 30241 ck_assert_ptr_eq(r, NULL); 30242 freeO(self); 30243 setTopSO(self, "AAd"); 30244 setValO(delim2, ""); 30245 r = extractSSmallStringO(self, "A", delim2); 30246 ck_assert_ptr_eq(r, NULL); 30247 // empty string 30248 freeO(self); 30249 setTopSO(self, ""); 30250 setValO(delim2, "#"); 30251 r = extractSSmallStringO(self, "$", delim2); 30252 ck_assert_ptr_eq(r, NULL); 30253 // delim1 = delim2 30254 freeO(self); 30255 setTopSO(self, "$qwe$"); 30256 setValO(delim2, "$"); 30257 r = extractSSmallStringO(self, "$", delim2); 30258 ck_assert_ptr_eq(r, NULL); 30259 // non json object 30260 terminateO(delim2); 30261 delim2 = (smallStringt*) allocSmallInt(1); 30262 r = extractSSmallStringO(self, ";", delim2); 30263 ck_assert_ptr_eq(r, NULL); 30264 terminateO(delim2); 30265 delim2 = allocSmallString(","); 30266 // NULL string 30267 freeO(self); 30268 ck_assert_ptr_eq(extractSSmallStringO(self, ";", delim2), NULL); 30269 // NULL delimiter 30270 freeO(self); 30271 setTopSO(self, "test"); 30272 ck_assert_ptr_eq(extractSSmallStringO(self, NULL, delim2), NULL); 30273 ck_assert_ptr_eq(extractSSmallStringO(self, ";", NULL), NULL); 30274 terminateO(delim2); 30275 terminateO(self); 30276 30277 } 30278 30279 30280 void extractCharSmallJsonSmallJsonT(void) { 30281 30282 smallJsont* r; 30283 smallJsont *self = allocSmallJson(); 30284 setTopSO(self, ""); 30285 smallJsont* delim2 = allocSmallJson(); 30286 30287 // string 30288 freeO(self); 30289 setTopSO(self, "one/two|"); 30290 setTopSO(delim2, "|"); 30291 r = extractCharSmallJsonO(self, '/', delim2); 30292 ck_assert_ptr_ne(r, null); 30293 char *s = toStringO(r); 30294 ck_assert_str_eq(s, "[\"two\"]"); 30295 free(s); 30296 terminateO(r); 30297 // delimiter not found 30298 freeO(self); 30299 setTopSO(self, "one/two"); 30300 freeO(delim2); 30301 setTopSO(delim2, "/"); 30302 r = extractCharSmallJsonO(self, '|', delim2); 30303 ck_assert_ptr_eq(r, NULL); 30304 // extractCharSmallJsonO with several delimiters after each other 30305 freeO(self); 30306 setTopSO(self, "one/ two /three "); 30307 freeO(delim2); 30308 setTopSO(delim2, " "); 30309 r = extractCharSmallJsonO(self, '/', delim2); 30310 ck_assert_ptr_ne(r, null); 30311 s = toStringO(r); 30312 ck_assert_str_eq(s, "[\"\",\"three\"]"); 30313 free(s); 30314 terminateO(r); 30315 // multiple character delimiter 30316 freeO(self); 30317 setTopSO(self, "AAe thre|e extract"); 30318 freeO(delim2); 30319 setTopSO(delim2, "|"); 30320 r = extractCharSmallJsonO(self, ' ', delim2); 30321 ck_assert_ptr_ne(r, null); 30322 s = toStringO(r); 30323 ck_assert_str_eq(s, "[\"thre\"]"); 30324 free(s); 30325 terminateO(r); 30326 // empty delimiter 30327 freeO(self); 30328 setTopSO(self, "AAd"); 30329 freeO(delim2); 30330 setTopSO(delim2, ""); 30331 r = extractCharSmallJsonO(self, 'A', delim2); 30332 ck_assert_ptr_eq(r, NULL); 30333 // empty string 30334 freeO(self); 30335 setTopSO(self, ""); 30336 freeO(delim2); 30337 setTopSO(delim2, "#"); 30338 r = extractCharSmallJsonO(self, '$', delim2); 30339 ck_assert_ptr_eq(r, NULL); 30340 // delim1 = delim2 30341 freeO(self); 30342 setTopSO(self, "$qwe$"); 30343 freeO(delim2); 30344 setTopSO(delim2, "$"); 30345 r = extractCharSmallJsonO(self, '$', delim2); 30346 ck_assert_ptr_eq(r, NULL); 30347 // non json string 30348 freeO(delim2); 30349 r = extractCharSmallJsonO(self, '$', delim2); 30350 ck_assert_ptr_eq(r, NULL); 30351 // non json object 30352 terminateO(delim2); 30353 delim2 = (smallJsont*) allocSmallInt(1); 30354 r = extractCharSmallJsonO(self, ';', delim2); 30355 ck_assert_ptr_eq(r, NULL); 30356 terminateO(delim2); 30357 delim2 = allocSmallJson(); 30358 // NULL string 30359 freeO(self); 30360 freeO(delim2); 30361 setTopSO(delim2, ","); 30362 ck_assert_ptr_eq(extractCharSmallJsonO(self, ';', delim2), NULL); 30363 // NULL delimiter 30364 freeO(self); 30365 setTopSO(self, "test"); 30366 ck_assert_ptr_eq(extractCharSmallJsonO(self, ';', NULL), NULL); 30367 terminateO(delim2); 30368 terminateO(self); 30369 30370 } 30371 30372 30373 void extractCharSmallStringSmallJsonT(void) { 30374 30375 smallJsont* r; 30376 smallJsont *self = allocSmallJson(); 30377 setTopSO(self, ""); 30378 smallStringt* delim2 = allocSmallString("|"); 30379 30380 // string 30381 freeO(self); 30382 setTopSO(self, "one/two|"); 30383 setValO(delim2, "|"); 30384 r = extractCharSmallStringO(self, '/', delim2); 30385 ck_assert_ptr_ne(r, null); 30386 char *s = toStringO(r); 30387 ck_assert_str_eq(s, "[\"two\"]"); 30388 free(s); 30389 terminateO(r); 30390 // delimiter not found 30391 freeO(self); 30392 setTopSO(self, "one/two"); 30393 setValO(delim2, "/"); 30394 r = extractCharSmallStringO(self, '|', delim2); 30395 ck_assert_ptr_eq(r, NULL); 30396 // extractCharSmallStringO with several delimiters after each other 30397 freeO(self); 30398 setTopSO(self, "one/ two /three "); 30399 setValO(delim2, " "); 30400 r = extractCharSmallStringO(self, '/', delim2); 30401 ck_assert_ptr_ne(r, null); 30402 s = toStringO(r); 30403 ck_assert_str_eq(s, "[\"\",\"three\"]"); 30404 free(s); 30405 terminateO(r); 30406 // multiple character delimiter 30407 freeO(self); 30408 setTopSO(self, "AAe thre|e extract"); 30409 setValO(delim2, "|e"); 30410 r = extractCharSmallStringO(self, ' ', delim2); 30411 ck_assert_ptr_ne(r, null); 30412 s = toStringO(r); 30413 ck_assert_str_eq(s, "[\"thre\"]"); 30414 free(s); 30415 terminateO(r); 30416 // empty delimiter 30417 freeO(self); 30418 setTopSO(self, "AAd"); 30419 setValO(delim2, ""); 30420 r = extractCharSmallStringO(self, 'A', delim2); 30421 ck_assert_ptr_eq(r, NULL); 30422 // empty string 30423 freeO(self); 30424 setTopSO(self, ""); 30425 setValO(delim2, "#"); 30426 r = extractCharSmallStringO(self, '$', delim2); 30427 ck_assert_ptr_eq(r, NULL); 30428 // delim1 = delim2 30429 freeO(self); 30430 setTopSO(self, "$qwe$"); 30431 setValO(delim2, "$"); 30432 r = extractCharSmallStringO(self, '$', delim2); 30433 ck_assert_ptr_eq(r, NULL); 30434 // non json object 30435 terminateO(delim2); 30436 delim2 = (smallStringt*) allocSmallInt(1); 30437 r = extractCharSmallStringO(self, ';', delim2); 30438 ck_assert_ptr_eq(r, NULL); 30439 terminateO(delim2); 30440 delim2 = allocSmallString(","); 30441 // NULL string 30442 freeO(self); 30443 ck_assert_ptr_eq(extractCharSmallStringO(self, ';', delim2), NULL); 30444 // NULL delimiter 30445 freeO(self); 30446 setTopSO(self, "test"); 30447 ck_assert_ptr_eq(extractCharSmallStringO(self, ';', NULL), NULL); 30448 terminateO(delim2); 30449 terminateO(self); 30450 30451 } 30452 30453 30454 void icSplitSmallJsonT(void) { 30455 30456 smallJsont* r; 30457 smallJsont *self = allocSmallJson(); 30458 setTopSO(self, ""); 30459 30460 // string 30461 freeO(self); 30462 setTopSO(self, "one/two"); 30463 r = icSplitO(self, "/"); 30464 ck_assert_ptr_ne(r, null); 30465 char *s = toStringO(r); 30466 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 30467 free(s); 30468 terminateO(r); 30469 // delimiter on the edge 30470 freeO(self); 30471 setTopSO(self, "/one"); 30472 r = icSplitO(self, "/"); 30473 ck_assert_ptr_ne(r, null); 30474 s = toStringO(r); 30475 ck_assert_str_eq(s, "[\"\",\"one\"]"); 30476 free(s); 30477 terminateO(r); 30478 freeO(self); 30479 setTopSO(self, "one/"); 30480 r = icSplitO(self, "/"); 30481 ck_assert_ptr_ne(r, null); 30482 s = toStringO(r); 30483 ck_assert_str_eq(s, "[\"one\",\"\"]"); 30484 free(s); 30485 terminateO(r); 30486 // delimiter not found 30487 freeO(self); 30488 setTopSO(self, "one/two"); 30489 r = icSplitO(self, "||"); 30490 ck_assert_ptr_ne(r, null); 30491 s = toStringO(r); 30492 ck_assert_str_eq(s, "[\"one/two\"]"); 30493 free(s); 30494 terminateO(r); 30495 // icSplit with several delimiters after each other 30496 freeO(self); 30497 setTopSO(self, "one/two three "); 30498 r = icSplitO(self, " "); 30499 ck_assert_ptr_ne(r, null); 30500 s = toStringO(r); 30501 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 30502 free(s); 30503 terminateO(r); 30504 // multiple character delimiter 30505 freeO(self); 30506 setTopSO(self, "AAe three extract"); 30507 r = icSplitO(self, "E "); 30508 ck_assert_ptr_ne(r, null); 30509 s = toStringO(r); 30510 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 30511 free(s); 30512 terminateO(r); 30513 // empty delimiter 30514 freeO(self); 30515 setTopSO(self, "AAd"); 30516 r = icSplitO(self, ""); 30517 ck_assert_ptr_ne(r, null); 30518 s = toStringO(r); 30519 ck_assert_str_eq(s, "[\"AAd\"]"); 30520 free(s); 30521 terminateO(r); 30522 // empty string 30523 emptyO(self); 30524 r = icSplitO(self, "$"); 30525 ck_assert_ptr_ne(r, null); 30526 s = toStringO(r); 30527 ck_assert_str_eq(s, "[\"\"]"); 30528 free(s); 30529 terminateO(r); 30530 // NULL list 30531 freeO(self); 30532 ck_assert_ptr_eq(icSplitO(self, ";"), NULL); 30533 // NULL delimiter 30534 freeO(self); 30535 setTopSO(self, "test"); 30536 ck_assert_ptr_eq(icSplitO(self, NULL), NULL); 30537 terminateO(self); 30538 30539 } 30540 30541 30542 void icSplitCharSmallJsonT(void) { 30543 30544 smallJsont* r; 30545 smallJsont *self = allocSmallJson(); 30546 setTopSO(self, ""); 30547 30548 // string 30549 freeO(self); 30550 setTopSO(self, "one/two"); 30551 r = icSplitCharO(self, 'T'); 30552 ck_assert_ptr_ne(r, null); 30553 char *s = toStringO(r); 30554 ck_assert_str_eq(s, "[\"one/\",\"wo\"]"); 30555 free(s); 30556 terminateO(r); 30557 // delimiter on the edge 30558 freeO(self); 30559 setTopSO(self, "/one"); 30560 r = icSplitCharO(self, '/'); 30561 ck_assert_ptr_ne(r, null); 30562 s = toStringO(r); 30563 ck_assert_str_eq(s, "[\"\",\"one\"]"); 30564 free(s); 30565 terminateO(r); 30566 freeO(self); 30567 setTopSO(self, "one/"); 30568 r = icSplitCharO(self, '/'); 30569 ck_assert_ptr_ne(r, null); 30570 s = toStringO(r); 30571 ck_assert_str_eq(s, "[\"one\",\"\"]"); 30572 free(s); 30573 terminateO(r); 30574 // delimiter not found 30575 freeO(self); 30576 setTopSO(self, "one/two"); 30577 r = icSplitCharO(self, '|'); 30578 ck_assert_ptr_ne(r, null); 30579 s = toStringO(r); 30580 ck_assert_str_eq(s, "[\"one/two\"]"); 30581 free(s); 30582 terminateO(r); 30583 // icSplit with several delimiters after each other 30584 freeO(self); 30585 setTopSO(self, "one/two three "); 30586 r = icSplitCharO(self, ' '); 30587 ck_assert_ptr_ne(r, null); 30588 s = toStringO(r); 30589 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 30590 free(s); 30591 terminateO(r); 30592 // empty string 30593 emptyO(self); 30594 r = icSplitCharO(self, '$'); 30595 ck_assert_ptr_ne(r, null); 30596 s = toStringO(r); 30597 ck_assert_str_eq(s, "[\"\"]"); 30598 free(s); 30599 terminateO(r); 30600 // NULL list 30601 freeO(self); 30602 ck_assert_ptr_eq(icSplitCharO(self, ';'), NULL); 30603 terminateO(self); 30604 30605 } 30606 30607 30608 void icSplitSmallJsonSmallJsonT(void) { 30609 30610 smallJsont* r; 30611 smallJsont *self = allocSmallJson(); 30612 setTopSO(self, ""); 30613 smallJsont *delim = allocSmallJson(); 30614 30615 // string 30616 freeO(self); 30617 setTopSO(self, "one/two"); 30618 setTopSO(delim, "/"); 30619 r = self->f->icSplitSmallJson(self, delim); 30620 ck_assert_ptr_ne(r, null); 30621 char *s = toStringO(r); 30622 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 30623 free(s); 30624 terminateO(r); 30625 // delimiter on the edge 30626 freeO(self); 30627 setTopSO(self, "/one"); 30628 r = self->f->icSplitSmallJson(self, delim); 30629 ck_assert_ptr_ne(r, null); 30630 s = toStringO(r); 30631 ck_assert_str_eq(s, "[\"\",\"one\"]"); 30632 free(s); 30633 terminateO(r); 30634 freeO(self); 30635 setTopSO(self, "one/"); 30636 r = self->f->icSplitSmallJson(self, delim); 30637 ck_assert_ptr_ne(r, null); 30638 s = toStringO(r); 30639 ck_assert_str_eq(s, "[\"one\",\"\"]"); 30640 free(s); 30641 terminateO(r); 30642 // delimiter not found 30643 freeO(self); 30644 setTopSO(self, "one/two"); 30645 freeO(delim); 30646 setTopSO(delim, "||"); 30647 r = self->f->icSplitSmallJson(self, delim); 30648 ck_assert_ptr_ne(r, null); 30649 s = toStringO(r); 30650 ck_assert_str_eq(s, "[\"one/two\"]"); 30651 free(s); 30652 terminateO(r); 30653 // icSplit with several delimiters after each other 30654 freeO(self); 30655 setTopSO(self, "one/two three "); 30656 freeO(delim); 30657 setTopSO(delim, " "); 30658 r = self->f->icSplitSmallJson(self, delim); 30659 ck_assert_ptr_ne(r, null); 30660 s = toStringO(r); 30661 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 30662 free(s); 30663 terminateO(r); 30664 // multiple character delimiter 30665 freeO(self); 30666 setTopSO(self, "AAe three extract"); 30667 freeO(delim); 30668 setTopSO(delim, "E "); 30669 r = self->f->icSplitSmallJson(self, delim); 30670 ck_assert_ptr_ne(r, null); 30671 s = toStringO(r); 30672 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 30673 free(s); 30674 terminateO(r); 30675 // empty delimiter 30676 freeO(self); 30677 setTopSO(self, "AAd"); 30678 freeO(delim); 30679 setTopSO(delim, ""); 30680 r = self->f->icSplitSmallJson(self, delim); 30681 ck_assert_ptr_ne(r, null); 30682 s = toStringO(r); 30683 ck_assert_str_eq(s, "[\"AAd\"]"); 30684 free(s); 30685 terminateO(r); 30686 // empty string 30687 emptyO(self); 30688 freeO(delim); 30689 setTopSO(delim, "$"); 30690 r = self->f->icSplitSmallJson(self, delim); 30691 ck_assert_ptr_ne(r, null); 30692 s = toStringO(r); 30693 ck_assert_str_eq(s, "[\"\"]"); 30694 free(s); 30695 terminateO(r); 30696 // non json string delimiter 30697 freeO(delim); 30698 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, delim), NULL); 30699 // non json object delimiter 30700 terminateO(delim); 30701 delim = (smallJsont*) allocSmallInt(1); 30702 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, delim), NULL); 30703 terminateO(delim); 30704 delim = allocSmallJson(); 30705 // NULL list 30706 freeO(self); 30707 freeO(delim); 30708 setTopSO(delim, ";"); 30709 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, delim), NULL); 30710 // NULL delimiter 30711 freeO(self); 30712 setTopSO(self, "test"); 30713 ck_assert_ptr_eq(self->f->icSplitSmallJson(self, NULL), NULL); 30714 terminateO(delim); 30715 terminateO(self); 30716 30717 } 30718 30719 30720 void icSplitSmallStringSmallJsonT(void) { 30721 30722 smallJsont* r; 30723 smallJsont *self = allocSmallJson(); 30724 setTopSO(self, ""); 30725 smallStringt *delim = allocSmallString("/"); 30726 30727 // string 30728 freeO(self); 30729 setTopSO(self, "one/two"); 30730 r = self->f->icSplitSmallString(self, delim); 30731 ck_assert_ptr_ne(r, null); 30732 char *s = toStringO(r); 30733 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 30734 free(s); 30735 terminateO(r); 30736 // delimiter on the edge 30737 freeO(self); 30738 setTopSO(self, "/one"); 30739 r = self->f->icSplitSmallString(self, delim); 30740 ck_assert_ptr_ne(r, null); 30741 s = toStringO(r); 30742 ck_assert_str_eq(s, "[\"\",\"one\"]"); 30743 free(s); 30744 terminateO(r); 30745 freeO(self); 30746 setTopSO(self, "one/"); 30747 r = self->f->icSplitSmallString(self, delim); 30748 ck_assert_ptr_ne(r, null); 30749 s = toStringO(r); 30750 ck_assert_str_eq(s, "[\"one\",\"\"]"); 30751 free(s); 30752 terminateO(r); 30753 // delimiter not found 30754 freeO(self); 30755 setTopSO(self, "one/two"); 30756 setValO(delim, "||"); 30757 r = self->f->icSplitSmallString(self, delim); 30758 ck_assert_ptr_ne(r, null); 30759 s = toStringO(r); 30760 ck_assert_str_eq(s, "[\"one/two\"]"); 30761 free(s); 30762 terminateO(r); 30763 // icSplit with several delimiters after each other 30764 freeO(self); 30765 setTopSO(self, "one/two three "); 30766 setValO(delim, " "); 30767 r = self->f->icSplitSmallString(self, delim); 30768 ck_assert_ptr_ne(r, null); 30769 s = toStringO(r); 30770 ck_assert_str_eq(s, "[\"one/two\",\"\",\"three\",\"\"]"); 30771 free(s); 30772 terminateO(r); 30773 // multiple character delimiter 30774 freeO(self); 30775 setTopSO(self, "AAe three extract"); 30776 setValO(delim, "E "); 30777 r = self->f->icSplitSmallString(self, delim); 30778 ck_assert_ptr_ne(r, null); 30779 s = toStringO(r); 30780 ck_assert_str_eq(s, "[\"AA\",\"thre\",\"extract\"]"); 30781 free(s); 30782 terminateO(r); 30783 // empty delimiter 30784 freeO(self); 30785 setTopSO(self, "AAd"); 30786 setValO(delim, ""); 30787 r = self->f->icSplitSmallString(self, delim); 30788 ck_assert_ptr_ne(r, null); 30789 s = toStringO(r); 30790 ck_assert_str_eq(s, "[\"AAd\"]"); 30791 free(s); 30792 terminateO(r); 30793 // empty string 30794 emptyO(self); 30795 setValO(delim, "$"); 30796 r = self->f->icSplitSmallString(self, delim); 30797 ck_assert_ptr_ne(r, null); 30798 s = toStringO(r); 30799 ck_assert_str_eq(s, "[\"\"]"); 30800 free(s); 30801 terminateO(r); 30802 // null string delimiter 30803 freeO(delim); 30804 ck_assert_ptr_eq(self->f->icSplitSmallString(self, delim), NULL); 30805 // non json object delimiter 30806 terminateO(delim); 30807 delim = (smallStringt*) allocSmallInt(1); 30808 ck_assert_ptr_eq(self->f->icSplitSmallString(self, delim), NULL); 30809 terminateO(delim); 30810 // NULL list 30811 freeO(self); 30812 delim = allocSmallString(";"); 30813 ck_assert_ptr_eq(self->f->icSplitSmallString(self, delim), NULL); 30814 // NULL delimiter 30815 freeO(self); 30816 setTopSO(self, "test"); 30817 ck_assert_ptr_eq(self->f->icSplitSmallString(self, NULL), NULL); 30818 terminateO(delim); 30819 terminateO(self); 30820 30821 } 30822 30823 30824 void icSplitSSmallJsonT(void) { 30825 30826 char** r; 30827 smallJsont *self = allocSmallJson(); 30828 setTopSO(self, ""); 30829 30830 // string 30831 freeO(self); 30832 setTopSO(self, "one/two"); 30833 r = icSplitSO(self, "/"); 30834 ck_assert_uint_eq(listLengthS(r),2); 30835 ck_assert_str_eq(r[0], "one"); 30836 ck_assert_str_eq(r[1], "two"); 30837 listFreeS(r); 30838 // delimiter on the edge 30839 freeO(self); 30840 setTopSO(self, "/one"); 30841 r = icSplitSO(self, "/"); 30842 ck_assert_uint_eq(listLengthS(r),2); 30843 ck_assert_str_eq(r[0], ""); 30844 ck_assert_str_eq(r[1], "one"); 30845 listFreeS(r); 30846 freeO(self); 30847 setTopSO(self, "one/"); 30848 r = icSplitSO(self, "/"); 30849 ck_assert_uint_eq(listLengthS(r),2); 30850 ck_assert_str_eq(r[0], "one"); 30851 ck_assert_str_eq(r[1], ""); 30852 listFreeS(r); 30853 // delimiter not found 30854 freeO(self); 30855 setTopSO(self, "one/two"); 30856 r = icSplitSO(self, "||"); 30857 ck_assert_uint_eq(listLengthS(r),1); 30858 ck_assert_str_eq(r[0], "one/two"); 30859 listFreeS(r); 30860 // icSplit with several delimiters after each other 30861 freeO(self); 30862 setTopSO(self, "one/two three "); 30863 r = icSplitSO(self, " "); 30864 ck_assert_uint_eq(listLengthS(r),4); 30865 ck_assert_str_eq(r[0], "one/two"); 30866 ck_assert_str_eq(r[1], ""); 30867 ck_assert_str_eq(r[2], "three"); 30868 ck_assert_str_eq(r[3], ""); 30869 listFreeS(r); 30870 // multiple character delimiter 30871 freeO(self); 30872 setTopSO(self, "AAe three extract"); 30873 r = icSplitSO(self, "E "); 30874 ck_assert_uint_eq(listLengthS(r),3); 30875 ck_assert_str_eq(r[0], "AA"); 30876 ck_assert_str_eq(r[1], "thre"); 30877 ck_assert_str_eq(r[2], "extract"); 30878 listFreeS(r); 30879 // empty delimiter 30880 freeO(self); 30881 setTopSO(self, "AAd"); 30882 r = icSplitSO(self, ""); 30883 ck_assert_uint_eq(listLengthS(r),1); 30884 ck_assert_str_eq(r[0], "AAd"); 30885 listFreeS(r); 30886 // empty string 30887 emptyO(self); 30888 r = icSplitSO(self, "$"); 30889 ck_assert_uint_eq(listLengthS(r),1); 30890 ck_assert_str_eq(r[0], ""); 30891 listFreeS(r); 30892 // NULL list 30893 freeO(self); 30894 ck_assert_ptr_eq(icSplitSO(self, ";"), NULL); 30895 // NULL delimiter 30896 freeO(self); 30897 setTopSO(self, "test"); 30898 ck_assert_ptr_eq(icSplitSO(self, NULL), NULL); 30899 terminateO(self); 30900 30901 } 30902 30903 30904 void icSplitCharSSmallJsonT(void) { 30905 30906 char** r; 30907 smallJsont *self = allocSmallJson(); 30908 setTopSO(self, ""); 30909 30910 // string 30911 freeO(self); 30912 setTopSO(self, "one/two"); 30913 r = icSplitCharSO(self, 'T'); 30914 ck_assert_uint_eq(listLengthS(r),2); 30915 ck_assert_str_eq(r[0], "one/"); 30916 ck_assert_str_eq(r[1], "wo"); 30917 listFreeS(r); 30918 // delimiter on the edge 30919 freeO(self); 30920 setTopSO(self, "/one"); 30921 r = icSplitCharSO(self, '/'); 30922 ck_assert_uint_eq(listLengthS(r),2); 30923 ck_assert_str_eq(r[0], ""); 30924 ck_assert_str_eq(r[1], "one"); 30925 listFreeS(r); 30926 freeO(self); 30927 setTopSO(self, "one/"); 30928 r = icSplitCharSO(self, '/'); 30929 ck_assert_uint_eq(listLengthS(r),2); 30930 ck_assert_str_eq(r[0], "one"); 30931 ck_assert_str_eq(r[1], ""); 30932 listFreeS(r); 30933 // delimiter not found 30934 freeO(self); 30935 setTopSO(self, "one/two"); 30936 r = icSplitCharSO(self, '|'); 30937 ck_assert_uint_eq(listLengthS(r),1); 30938 ck_assert_str_eq(r[0], "one/two"); 30939 listFreeS(r); 30940 // icSplit with several delimiters after each other 30941 freeO(self); 30942 setTopSO(self, "one/two three "); 30943 r = icSplitCharSO(self, ' '); 30944 ck_assert_uint_eq(listLengthS(r),4); 30945 ck_assert_str_eq(r[0], "one/two"); 30946 ck_assert_str_eq(r[1], ""); 30947 ck_assert_str_eq(r[2], "three"); 30948 ck_assert_str_eq(r[3], ""); 30949 listFreeS(r); 30950 // empty string 30951 emptyO(self); 30952 r = icSplitCharSO(self, '$'); 30953 ck_assert_uint_eq(listLengthS(r),1); 30954 ck_assert_str_eq(r[0], ""); 30955 listFreeS(r); 30956 // NULL list 30957 freeO(self); 30958 ck_assert_ptr_eq(icSplitCharSO(self, ';'), NULL); 30959 terminateO(self); 30960 30961 } 30962 30963 30964 void icSplitSmallJsonSSmallJsonT(void) { 30965 30966 char** r; 30967 smallJsont *self = allocSmallJson(); 30968 setTopSO(self, ""); 30969 smallJsont *delim = allocSmallJson(); 30970 30971 // string 30972 freeO(self); 30973 setTopSO(self, "one/two"); 30974 setTopSO(delim, "/"); 30975 r = icSplitSmallJsonSO(self, delim); 30976 ck_assert_uint_eq(listLengthS(r),2); 30977 ck_assert_str_eq(r[0], "one"); 30978 ck_assert_str_eq(r[1], "two"); 30979 listFreeS(r); 30980 // delimiter on the edge 30981 freeO(self); 30982 setTopSO(self, "/one"); 30983 r = icSplitSmallJsonSO(self, delim); 30984 ck_assert_uint_eq(listLengthS(r),2); 30985 ck_assert_str_eq(r[0], ""); 30986 ck_assert_str_eq(r[1], "one"); 30987 listFreeS(r); 30988 freeO(self); 30989 setTopSO(self, "one/"); 30990 r = icSplitSmallJsonSO(self, delim); 30991 ck_assert_uint_eq(listLengthS(r),2); 30992 ck_assert_str_eq(r[0], "one"); 30993 ck_assert_str_eq(r[1], ""); 30994 listFreeS(r); 30995 // delimiter not found 30996 freeO(self); 30997 setTopSO(self, "one/two"); 30998 freeO(delim); 30999 setTopSO(delim, "||"); 31000 r = icSplitSmallJsonSO(self, delim); 31001 ck_assert_uint_eq(listLengthS(r),1); 31002 ck_assert_str_eq(r[0], "one/two"); 31003 listFreeS(r); 31004 // icSplit with several delimiters after each other 31005 freeO(self); 31006 setTopSO(self, "one/two three "); 31007 freeO(delim); 31008 setTopSO(delim, " "); 31009 r = icSplitSmallJsonSO(self, delim); 31010 ck_assert_uint_eq(listLengthS(r),4); 31011 ck_assert_str_eq(r[0], "one/two"); 31012 ck_assert_str_eq(r[1], ""); 31013 ck_assert_str_eq(r[2], "three"); 31014 ck_assert_str_eq(r[3], ""); 31015 listFreeS(r); 31016 // multiple character delimiter 31017 freeO(self); 31018 setTopSO(self, "AAe three extract"); 31019 freeO(delim); 31020 setTopSO(delim, "E "); 31021 r = icSplitSmallJsonSO(self, delim); 31022 ck_assert_uint_eq(listLengthS(r),3); 31023 ck_assert_str_eq(r[0], "AA"); 31024 ck_assert_str_eq(r[1], "thre"); 31025 ck_assert_str_eq(r[2], "extract"); 31026 listFreeS(r); 31027 // empty delimiter 31028 freeO(self); 31029 setTopSO(self, "AAd"); 31030 freeO(delim); 31031 setTopSO(delim, ""); 31032 r = icSplitSmallJsonSO(self, delim); 31033 ck_assert_uint_eq(listLengthS(r),1); 31034 ck_assert_str_eq(r[0], "AAd"); 31035 listFreeS(r); 31036 // empty string 31037 emptyO(self); 31038 freeO(delim); 31039 setTopSO(delim, "$"); 31040 r = icSplitSmallJsonSO(self, delim); 31041 ck_assert_uint_eq(listLengthS(r),1); 31042 ck_assert_str_eq(r[0], ""); 31043 listFreeS(r); 31044 // non json string delimiter 31045 freeO(delim); 31046 ck_assert_ptr_eq(icSplitSmallJsonSO(self, delim), NULL); 31047 // non json object delimiter 31048 terminateO(delim); 31049 delim = (smallJsont*) allocSmallInt(1); 31050 ck_assert_ptr_eq(icSplitSmallJsonSO(self, delim), NULL); 31051 terminateO(delim); 31052 delim = allocSmallJson(); 31053 // NULL list 31054 freeO(self); 31055 freeO(delim); 31056 setTopSO(delim, ";"); 31057 ck_assert_ptr_eq(icSplitSmallJsonSO(self, delim), NULL); 31058 // NULL delimiter 31059 freeO(self); 31060 setTopSO(self, "test"); 31061 ck_assert_ptr_eq(icSplitSmallJsonSO(self, NULL), NULL); 31062 terminateO(delim); 31063 terminateO(self); 31064 31065 } 31066 31067 31068 void icSplitSmallStringSSmallJsonT(void) { 31069 31070 char** r; 31071 smallJsont *self = allocSmallJson(); 31072 setTopSO(self, ""); 31073 smallStringt *delim = allocSmallString("/"); 31074 31075 // string 31076 freeO(self); 31077 setTopSO(self, "one/two"); 31078 r = icSplitSmallStringSO(self, delim); 31079 ck_assert_uint_eq(listLengthS(r),2); 31080 ck_assert_str_eq(r[0], "one"); 31081 ck_assert_str_eq(r[1], "two"); 31082 listFreeS(r); 31083 // delimiter on the edge 31084 freeO(self); 31085 setTopSO(self, "/one"); 31086 r = icSplitSmallStringSO(self, delim); 31087 ck_assert_uint_eq(listLengthS(r),2); 31088 ck_assert_str_eq(r[0], ""); 31089 ck_assert_str_eq(r[1], "one"); 31090 listFreeS(r); 31091 freeO(self); 31092 setTopSO(self, "one/"); 31093 r = icSplitSmallStringSO(self, delim); 31094 ck_assert_uint_eq(listLengthS(r),2); 31095 ck_assert_str_eq(r[0], "one"); 31096 ck_assert_str_eq(r[1], ""); 31097 listFreeS(r); 31098 // delimiter not found 31099 freeO(self); 31100 setTopSO(self, "one/two"); 31101 setValO(delim, "||"); 31102 r = icSplitSmallStringSO(self, delim); 31103 ck_assert_uint_eq(listLengthS(r),1); 31104 ck_assert_str_eq(r[0], "one/two"); 31105 listFreeS(r); 31106 // icSplit with several delimiters after each other 31107 freeO(self); 31108 setTopSO(self, "one/two three "); 31109 setValO(delim, " "); 31110 r = icSplitSmallStringSO(self, delim); 31111 ck_assert_uint_eq(listLengthS(r),4); 31112 ck_assert_str_eq(r[0], "one/two"); 31113 ck_assert_str_eq(r[1], ""); 31114 ck_assert_str_eq(r[2], "three"); 31115 ck_assert_str_eq(r[3], ""); 31116 listFreeS(r); 31117 // multiple character delimiter 31118 freeO(self); 31119 setTopSO(self, "AAe three extract"); 31120 setValO(delim, "E "); 31121 r = icSplitSmallStringSO(self, delim); 31122 ck_assert_uint_eq(listLengthS(r),3); 31123 ck_assert_str_eq(r[0], "AA"); 31124 ck_assert_str_eq(r[1], "thre"); 31125 ck_assert_str_eq(r[2], "extract"); 31126 listFreeS(r); 31127 // empty delimiter 31128 freeO(self); 31129 setTopSO(self, "AAd"); 31130 setValO(delim, ""); 31131 r = icSplitSmallStringSO(self, delim); 31132 ck_assert_uint_eq(listLengthS(r),1); 31133 ck_assert_str_eq(r[0], "AAd"); 31134 listFreeS(r); 31135 // empty string 31136 emptyO(self); 31137 setValO(delim, "$"); 31138 r = icSplitSmallStringSO(self, delim); 31139 ck_assert_uint_eq(listLengthS(r),1); 31140 ck_assert_str_eq(r[0], ""); 31141 listFreeS(r); 31142 // non smallString object delimiter 31143 terminateO(delim); 31144 delim = (smallStringt*) allocSmallInt(1); 31145 ck_assert_ptr_eq(icSplitSmallStringSO(self, delim), NULL); 31146 terminateO(delim); 31147 // NULL list 31148 freeO(self); 31149 delim = allocSmallString(";"); 31150 ck_assert_ptr_eq(icSplitSmallStringSO(self, delim), NULL); 31151 // NULL delimiter 31152 freeO(self); 31153 setTopSO(self, "test"); 31154 ck_assert_ptr_eq(icSplitSmallStringSO(self, NULL), NULL); 31155 terminateO(delim); 31156 terminateO(self); 31157 31158 } 31159 31160 31161 void icExtractSmallJsonT(void) { 31162 31163 smallJsont* r; 31164 smallJsont *self = allocSmallJson(); 31165 setTopSO(self, ""); 31166 31167 // string 31168 freeO(self); 31169 setTopSO(self, "one/twos"); 31170 r = icExtractO(self, "E", "S"); 31171 ck_assert_ptr_ne(r, null); 31172 char *s = toStringO(r); 31173 ck_assert_str_eq(s, "[\"/two\"]"); 31174 free(s); 31175 terminateO(r); 31176 // delimiter not found 31177 freeO(self); 31178 setTopSO(self, "one/two"); 31179 r = icExtractO(self, "||", "/"); 31180 ck_assert_ptr_eq(r, NULL); 31181 // icExtractO with several delimiters after each other 31182 freeO(self); 31183 setTopSO(self, "one/ two /three "); 31184 r = icExtractO(self, "/", " "); 31185 ck_assert_ptr_ne(r, null); 31186 s = toStringO(r); 31187 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31188 free(s); 31189 terminateO(r); 31190 // multiple character delimiter 31191 freeO(self); 31192 setTopSO(self, "AAe thre|e icExtract"); 31193 r = icExtractO(self, "e ", "|"); 31194 ck_assert_ptr_ne(r, null); 31195 s = toStringO(r); 31196 ck_assert_str_eq(s, "[\"thre\"]"); 31197 free(s); 31198 terminateO(r); 31199 // empty delimiter 31200 freeO(self); 31201 setTopSO(self, "AAd"); 31202 r = icExtractO(self, "", "Ad"); 31203 ck_assert_ptr_eq(r, NULL); 31204 freeO(self); 31205 setTopSO(self, "AAd"); 31206 r = icExtractO(self, "A", ""); 31207 ck_assert_ptr_eq(r, NULL); 31208 // empty string 31209 freeO(self); 31210 setTopSO(self, ""); 31211 r = icExtractO(self, "$", "#"); 31212 ck_assert_ptr_eq(r, NULL); 31213 // delim1 = delim2 31214 freeO(self); 31215 setTopSO(self, ""); 31216 r = icExtractO(self, "$", "$"); 31217 ck_assert_ptr_eq(r, NULL); 31218 // NULL string 31219 freeO(self); 31220 ck_assert_ptr_eq(icExtractO(self, ";", ","), NULL); 31221 // NULL delimiter 31222 freeO(self); 31223 setTopSO(self, "test"); 31224 ck_assert_ptr_eq(icExtractO(self, NULL, ","), NULL); 31225 ck_assert_ptr_eq(icExtractO(self, ",", NULL), NULL); 31226 terminateO(self); 31227 31228 } 31229 31230 31231 void icExtractCharSSmallJsonT(void) { 31232 31233 smallJsont* r; 31234 smallJsont *self = allocSmallJson(); 31235 setTopSO(self, ""); 31236 31237 // string 31238 freeO(self); 31239 setTopSO(self, "one/twos"); 31240 r = icExtractCharSO(self, 'E', "S"); 31241 ck_assert_ptr_ne(r, null); 31242 char *s = toStringO(r); 31243 ck_assert_str_eq(s, "[\"/two\"]"); 31244 free(s); 31245 terminateO(r); 31246 // delimiter not found 31247 freeO(self); 31248 setTopSO(self, "one/two"); 31249 r = icExtractCharSO(self, '|', "/"); 31250 ck_assert_ptr_eq(r, NULL); 31251 // icExtractCharSO with several delimiters after each other 31252 freeO(self); 31253 setTopSO(self, "one/ two /three "); 31254 r = icExtractCharSO(self, '/', " "); 31255 ck_assert_ptr_ne(r, null); 31256 s = toStringO(r); 31257 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31258 free(s); 31259 terminateO(r); 31260 // multiple character delimiter 31261 freeO(self); 31262 setTopSO(self, "AAe thre|e icExtract"); 31263 r = icExtractCharSO(self, ' ', "|e"); 31264 ck_assert_ptr_ne(r, null); 31265 s = toStringO(r); 31266 ck_assert_str_eq(s, "[\"thre\"]"); 31267 free(s); 31268 terminateO(r); 31269 // empty delimiter 31270 freeO(self); 31271 setTopSO(self, "AAd"); 31272 r = icExtractCharSO(self, 'A', ""); 31273 ck_assert_ptr_eq(r, NULL); 31274 // empty string 31275 freeO(self); 31276 setTopSO(self, ""); 31277 r = icExtractCharSO(self, '$', "#"); 31278 ck_assert_ptr_eq(r, NULL); 31279 // delim1 = delim2 31280 freeO(self); 31281 setTopSO(self, ""); 31282 r = icExtractCharSO(self, '$', "$"); 31283 ck_assert_ptr_eq(r, NULL); 31284 // NULL string 31285 freeO(self); 31286 ck_assert_ptr_eq(icExtractCharSO(self, ';', ","), NULL); 31287 // NULL delimiter 31288 freeO(self); 31289 setTopSO(self, "test"); 31290 ck_assert_ptr_eq(icExtractCharSO(self, ',', NULL), NULL); 31291 terminateO(self); 31292 31293 } 31294 31295 31296 void icExtractSCharSmallJsonT(void) { 31297 31298 smallJsont* r; 31299 smallJsont *self = allocSmallJson(); 31300 setTopSO(self, ""); 31301 31302 // string 31303 freeO(self); 31304 setTopSO(self, "one/twos"); 31305 r = icExtractSCharO(self, "E", 'S'); 31306 ck_assert_ptr_ne(r, null); 31307 char *s = toStringO(r); 31308 ck_assert_str_eq(s, "[\"/two\"]"); 31309 free(s); 31310 terminateO(r); 31311 // delimiter not found 31312 freeO(self); 31313 setTopSO(self, "one/two"); 31314 r = icExtractSCharO(self, "||", '/'); 31315 ck_assert_ptr_eq(r, NULL); 31316 // icExtractSCharO with several delimiters after each other 31317 freeO(self); 31318 setTopSO(self, "one/ two /three "); 31319 r = icExtractSCharO(self, "/", ' '); 31320 ck_assert_ptr_ne(r, null); 31321 s = toStringO(r); 31322 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31323 free(s); 31324 terminateO(r); 31325 // multiple character delimiter 31326 freeO(self); 31327 setTopSO(self, "AAe thre|e icExtract"); 31328 r = icExtractSCharO(self, "e ", '|'); 31329 ck_assert_ptr_ne(r, null); 31330 s = toStringO(r); 31331 ck_assert_str_eq(s, "[\"thre\"]"); 31332 free(s); 31333 terminateO(r); 31334 // empty delimiter 31335 freeO(self); 31336 setTopSO(self, "AAd"); 31337 r = icExtractSCharO(self, "", 'A'); 31338 ck_assert_ptr_eq(r, NULL); 31339 // empty string 31340 freeO(self); 31341 setTopSO(self, ""); 31342 r = icExtractSCharO(self, "$", '#'); 31343 ck_assert_ptr_eq(r, NULL); 31344 // delim1 = delim2 31345 freeO(self); 31346 setTopSO(self, ""); 31347 r = icExtractSCharO(self, "$", '$'); 31348 ck_assert_ptr_eq(r, NULL); 31349 // NULL string 31350 freeO(self); 31351 ck_assert_ptr_eq(icExtractSCharO(self, ";", ','), NULL); 31352 // NULL delimiter 31353 freeO(self); 31354 setTopSO(self, "test"); 31355 ck_assert_ptr_eq(icExtractSCharO(self, NULL, ','), NULL); 31356 terminateO(self); 31357 31358 } 31359 31360 31361 void icExtractCharCharSmallJsonT(void) { 31362 31363 smallJsont* r; 31364 smallJsont *self = allocSmallJson(); 31365 setTopSO(self, ""); 31366 31367 // string 31368 freeO(self); 31369 setTopSO(self, "one/twos"); 31370 r = icExtractCharCharO(self, 'E', 'S'); 31371 ck_assert_ptr_ne(r, null); 31372 char *s = toStringO(r); 31373 ck_assert_str_eq(s, "[\"/two\"]"); 31374 free(s); 31375 terminateO(r); 31376 // delimiter not found 31377 freeO(self); 31378 setTopSO(self, "one/two"); 31379 r = icExtractCharCharO(self, '|', '/'); 31380 ck_assert_ptr_eq(r, NULL); 31381 // icExtractCharCharO with several delimiters after each other 31382 freeO(self); 31383 setTopSO(self, "one/ two /three "); 31384 r = icExtractCharCharO(self, '/', ' '); 31385 ck_assert_ptr_ne(r, null); 31386 s = toStringO(r); 31387 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31388 free(s); 31389 terminateO(r); 31390 // multiple character delimiter 31391 freeO(self); 31392 setTopSO(self, "AAe thre|e icExtract"); 31393 r = icExtractCharCharO(self, ' ', '|'); 31394 ck_assert_ptr_ne(r, null); 31395 s = toStringO(r); 31396 ck_assert_str_eq(s, "[\"thre\"]"); 31397 free(s); 31398 terminateO(r); 31399 // empty string 31400 freeO(self); 31401 setTopSO(self, ""); 31402 r = icExtractCharCharO(self, '$', '#'); 31403 ck_assert_ptr_eq(r, NULL); 31404 // delim1 = delim2 31405 freeO(self); 31406 setTopSO(self, ""); 31407 r = icExtractCharCharO(self, '$', '$'); 31408 ck_assert_ptr_eq(r, NULL); 31409 // NULL string 31410 freeO(self); 31411 ck_assert_ptr_eq(icExtractCharCharO(self, ';', ','), NULL); 31412 terminateO(self); 31413 31414 } 31415 31416 31417 void icExtractSmallJsonSmallJsonSmallJsonT(void) { 31418 31419 smallJsont* r; 31420 smallJsont *self = allocSmallJson(); 31421 setTopSO(self, ""); 31422 smallJsont* delim1 = allocSmallJson(); 31423 smallJsont* delim2 = allocSmallJson(); 31424 31425 // string 31426 freeO(self); 31427 setTopSO(self, "one/twos"); 31428 setTopSO(delim1, "E"); 31429 setTopSO(delim2, "S"); 31430 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31431 ck_assert_ptr_ne(r, null); 31432 char *s = toStringO(r); 31433 ck_assert_str_eq(s, "[\"/two\"]"); 31434 free(s); 31435 terminateO(r); 31436 // delimiter not found 31437 freeO(self); 31438 setTopSO(self, "one/two"); 31439 freeO(delim1); 31440 freeO(delim2); 31441 setTopSO(delim1, "||"); 31442 setTopSO(delim2, "/"); 31443 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31444 ck_assert_ptr_eq(r, NULL); 31445 // icExtractSmallJsonSmallJsonO with several delimiters after each other 31446 freeO(self); 31447 setTopSO(self, "one/ two /three "); 31448 freeO(delim1); 31449 freeO(delim2); 31450 setTopSO(delim1, "/"); 31451 setTopSO(delim2, " "); 31452 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31453 ck_assert_ptr_ne(r, null); 31454 s = toStringO(r); 31455 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31456 free(s); 31457 terminateO(r); 31458 // multiple character delimiter 31459 freeO(self); 31460 setTopSO(self, "AAe thre|e icExtract"); 31461 freeO(delim1); 31462 freeO(delim2); 31463 setTopSO(delim1, "e "); 31464 setTopSO(delim2, "|"); 31465 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31466 ck_assert_ptr_ne(r, null); 31467 s = toStringO(r); 31468 ck_assert_str_eq(s, "[\"thre\"]"); 31469 free(s); 31470 terminateO(r); 31471 // empty delimiter 31472 freeO(self); 31473 setTopSO(self, "AAd"); 31474 freeO(delim1); 31475 freeO(delim2); 31476 setTopSO(delim1, ""); 31477 setTopSO(delim2, "Ad"); 31478 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31479 ck_assert_ptr_eq(r, NULL); 31480 freeO(self); 31481 setTopSO(self, "AAd"); 31482 freeO(delim1); 31483 freeO(delim2); 31484 setTopSO(delim1, "A"); 31485 setTopSO(delim2, ""); 31486 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31487 ck_assert_ptr_eq(r, NULL); 31488 // empty string 31489 freeO(self); 31490 setTopSO(self, ""); 31491 freeO(delim1); 31492 freeO(delim2); 31493 setTopSO(delim1, "$"); 31494 setTopSO(delim2, "#"); 31495 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31496 ck_assert_ptr_eq(r, NULL); 31497 // delim1 = delim2 31498 freeO(self); 31499 setTopSO(self, "$qwe$"); 31500 freeO(delim1); 31501 freeO(delim2); 31502 setTopSO(delim1, "$"); 31503 setTopSO(delim2, "$"); 31504 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31505 ck_assert_ptr_eq(r, NULL); 31506 // non json string 31507 freeO(delim1); 31508 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31509 ck_assert_ptr_eq(r, NULL); 31510 setTopSO(delim1, "$"); 31511 freeO(delim2); 31512 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31513 ck_assert_ptr_eq(r, NULL); 31514 // non json object 31515 terminateO(delim1); 31516 delim1 = (smallJsont*) allocSmallInt(1); 31517 setTopSO(delim2, "$"); 31518 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31519 ck_assert_ptr_eq(r, NULL); 31520 terminateO(delim1); 31521 delim1 = allocSmallJson(); 31522 setTopSO(delim1, ";"); 31523 terminateO(delim2); 31524 delim2 = (smallJsont*) allocSmallInt(1); 31525 r = icExtractSmallJsonSmallJsonO(self, delim1, delim2); 31526 ck_assert_ptr_eq(r, NULL); 31527 terminateO(delim2); 31528 delim2 = allocSmallJson(); 31529 // NULL string 31530 freeO(self); 31531 freeO(delim1); 31532 freeO(delim2); 31533 setTopSO(delim1, ";"); 31534 setTopSO(delim2, ","); 31535 ck_assert_ptr_eq(icExtractSmallJsonSmallJsonO(self, delim1, delim2), NULL); 31536 // NULL delimiter 31537 freeO(self); 31538 setTopSO(self, "test"); 31539 ck_assert_ptr_eq(icExtractSmallJsonSmallJsonO(self, NULL, delim2), NULL); 31540 ck_assert_ptr_eq(icExtractSmallJsonSmallJsonO(self, delim1, NULL), NULL); 31541 terminateO(delim1); 31542 terminateO(delim2); 31543 terminateO(self); 31544 31545 } 31546 31547 31548 void icExtractSmallJsonSmallStringSmallJsonT(void) { 31549 31550 smallJsont* r; 31551 smallJsont *self = allocSmallJson(); 31552 setTopSO(self, ""); 31553 smallJsont* delim1 = allocSmallJson(); 31554 smallStringt* delim2 = allocSmallString("S"); 31555 31556 // string 31557 freeO(self); 31558 setTopSO(self, "one/twos"); 31559 setTopSO(delim1, "E"); 31560 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31561 ck_assert_ptr_ne(r, null); 31562 char *s = toStringO(r); 31563 ck_assert_str_eq(s, "[\"/two\"]"); 31564 free(s); 31565 terminateO(r); 31566 // delimiter not found 31567 freeO(self); 31568 setTopSO(self, "one/two"); 31569 freeO(delim1); 31570 setTopSO(delim1, "||"); 31571 setValO(delim2, "/"); 31572 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31573 ck_assert_ptr_eq(r, NULL); 31574 // icExtractSmallJsonSmallStringO with several delimiters after each other 31575 freeO(self); 31576 setTopSO(self, "one/ two /three "); 31577 freeO(delim1); 31578 setTopSO(delim1, "/"); 31579 setValO(delim2, " "); 31580 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31581 ck_assert_ptr_ne(r, null); 31582 s = toStringO(r); 31583 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31584 free(s); 31585 terminateO(r); 31586 // multiple character delimiter 31587 freeO(self); 31588 setTopSO(self, "AAe thre|e icExtract"); 31589 freeO(delim1); 31590 setTopSO(delim1, "e "); 31591 setValO(delim2, "|"); 31592 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31593 ck_assert_ptr_ne(r, null); 31594 s = toStringO(r); 31595 ck_assert_str_eq(s, "[\"thre\"]"); 31596 free(s); 31597 terminateO(r); 31598 // empty delimiter 31599 freeO(self); 31600 setTopSO(self, "AAd"); 31601 freeO(delim1); 31602 setTopSO(delim1, ""); 31603 setValO(delim2, "Ad"); 31604 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31605 ck_assert_ptr_eq(r, NULL); 31606 freeO(self); 31607 setTopSO(self, "AAd"); 31608 freeO(delim1); 31609 setTopSO(delim1, "A"); 31610 setValO(delim2, ""); 31611 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31612 ck_assert_ptr_eq(r, NULL); 31613 // empty string 31614 freeO(self); 31615 setTopSO(self, ""); 31616 freeO(delim1); 31617 setTopSO(delim1, "$"); 31618 setValO(delim2, "#"); 31619 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31620 ck_assert_ptr_eq(r, NULL); 31621 // delim1 = delim2 31622 freeO(self); 31623 setTopSO(self, "$qwe$"); 31624 freeO(delim1); 31625 setTopSO(delim1, "$"); 31626 setValO(delim2, "$"); 31627 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31628 ck_assert_ptr_eq(r, NULL); 31629 // non json string 31630 freeO(delim1); 31631 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31632 ck_assert_ptr_eq(r, NULL); 31633 // non json object 31634 terminateO(delim1); 31635 delim1 = (smallJsont*) allocSmallInt(1); 31636 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31637 ck_assert_ptr_eq(r, NULL); 31638 terminateO(delim1); 31639 delim1 = allocSmallJson(); 31640 setTopSO(delim1, ";"); 31641 terminateO(delim2); 31642 delim2 = (smallStringt*) allocSmallInt(1); 31643 r = icExtractSmallJsonSmallStringO(self, delim1, delim2); 31644 ck_assert_ptr_eq(r, NULL); 31645 terminateO(delim2); 31646 delim2 = allocSmallString(","); 31647 // NULL string 31648 freeO(self); 31649 freeO(delim1); 31650 setTopSO(delim1, ";"); 31651 ck_assert_ptr_eq(icExtractSmallJsonSmallStringO(self, delim1, delim2), NULL); 31652 // NULL delimiter 31653 freeO(self); 31654 setTopSO(self, "test"); 31655 ck_assert_ptr_eq(icExtractSmallJsonSmallStringO(self, NULL, delim2), NULL); 31656 ck_assert_ptr_eq(icExtractSmallJsonSmallStringO(self, delim1, NULL), NULL); 31657 terminateO(delim1); 31658 terminateO(delim2); 31659 terminateO(self); 31660 31661 } 31662 31663 31664 void icExtractSmallJsonSSmallJsonT(void) { 31665 31666 smallJsont* r; 31667 smallJsont *self = allocSmallJson(); 31668 setTopSO(self, ""); 31669 smallJsont* delim1 = allocSmallJson(); 31670 31671 // string 31672 freeO(self); 31673 setTopSO(self, "one/twos"); 31674 setTopSO(delim1, "E"); 31675 r = icExtractSmallJsonSO(self, delim1, "S"); 31676 ck_assert_ptr_ne(r, null); 31677 char *s = toStringO(r); 31678 ck_assert_str_eq(s, "[\"/two\"]"); 31679 free(s); 31680 terminateO(r); 31681 // delimiter not found 31682 freeO(self); 31683 setTopSO(self, "one/two"); 31684 freeO(delim1); 31685 setTopSO(delim1, "||"); 31686 r = icExtractSmallJsonSO(self, delim1, "/"); 31687 ck_assert_ptr_eq(r, NULL); 31688 // icExtractSmallJsonSO with several delimiters after each other 31689 freeO(self); 31690 setTopSO(self, "one/ two /three "); 31691 freeO(delim1); 31692 setTopSO(delim1, "/"); 31693 r = icExtractSmallJsonSO(self, delim1, " "); 31694 ck_assert_ptr_ne(r, null); 31695 s = toStringO(r); 31696 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31697 free(s); 31698 terminateO(r); 31699 // multiple character delimiter 31700 freeO(self); 31701 setTopSO(self, "AAe thre|e icExtract"); 31702 freeO(delim1); 31703 setTopSO(delim1, "e "); 31704 r = icExtractSmallJsonSO(self, delim1, "|"); 31705 ck_assert_ptr_ne(r, null); 31706 s = toStringO(r); 31707 ck_assert_str_eq(s, "[\"thre\"]"); 31708 free(s); 31709 terminateO(r); 31710 // empty delimiter 31711 freeO(self); 31712 setTopSO(self, "AAd"); 31713 freeO(delim1); 31714 setTopSO(delim1, ""); 31715 r = icExtractSmallJsonSO(self, delim1, "Ad"); 31716 ck_assert_ptr_eq(r, NULL); 31717 freeO(self); 31718 setTopSO(self, "AAd"); 31719 freeO(delim1); 31720 setTopSO(delim1, "A"); 31721 r = icExtractSmallJsonSO(self, delim1, ""); 31722 ck_assert_ptr_eq(r, NULL); 31723 // empty string 31724 freeO(self); 31725 setTopSO(self, ""); 31726 freeO(delim1); 31727 setTopSO(delim1, "$"); 31728 r = icExtractSmallJsonSO(self, delim1, "#"); 31729 ck_assert_ptr_eq(r, NULL); 31730 // delim1 = delim2 31731 freeO(self); 31732 setTopSO(self, "$qwe$"); 31733 freeO(delim1); 31734 setTopSO(delim1, "$"); 31735 r = icExtractSmallJsonSO(self, delim1, "$"); 31736 ck_assert_ptr_eq(r, NULL); 31737 // non json string 31738 freeO(delim1); 31739 r = icExtractSmallJsonSO(self, delim1, "$"); 31740 ck_assert_ptr_eq(r, NULL); 31741 // non json object 31742 terminateO(delim1); 31743 delim1 = (smallJsont*) allocSmallInt(1); 31744 r = icExtractSmallJsonSO(self, delim1, "$"); 31745 ck_assert_ptr_eq(r, NULL); 31746 terminateO(delim1); 31747 delim1 = allocSmallJson(); 31748 // NULL string 31749 freeO(self); 31750 freeO(delim1); 31751 setTopSO(delim1, ";"); 31752 ck_assert_ptr_eq(icExtractSmallJsonSO(self, delim1, ","), NULL); 31753 // NULL delimiter 31754 freeO(self); 31755 setTopSO(self, "test"); 31756 ck_assert_ptr_eq(icExtractSmallJsonSO(self, NULL, ","), NULL); 31757 ck_assert_ptr_eq(icExtractSmallJsonSO(self, delim1, NULL), NULL); 31758 terminateO(delim1); 31759 terminateO(self); 31760 31761 } 31762 31763 31764 void icExtractSmallJsonCharSmallJsonT(void) { 31765 31766 smallJsont* r; 31767 smallJsont *self = allocSmallJson(); 31768 setTopSO(self, ""); 31769 smallJsont* delim1 = allocSmallJson(); 31770 31771 // string 31772 freeO(self); 31773 setTopSO(self, "one/twos"); 31774 setTopSO(delim1, "E"); 31775 r = icExtractSmallJsonCharO(self, delim1, 'S'); 31776 ck_assert_ptr_ne(r, null); 31777 char *s = toStringO(r); 31778 ck_assert_str_eq(s, "[\"/two\"]"); 31779 free(s); 31780 terminateO(r); 31781 // delimiter not found 31782 freeO(self); 31783 setTopSO(self, "one/two"); 31784 freeO(delim1); 31785 setTopSO(delim1, "||"); 31786 r = icExtractSmallJsonCharO(self, delim1, '/'); 31787 ck_assert_ptr_eq(r, NULL); 31788 // icExtractSmallJsonCharO with several delimiters after each other 31789 freeO(self); 31790 setTopSO(self, "one/ two /three "); 31791 freeO(delim1); 31792 setTopSO(delim1, "/"); 31793 r = icExtractSmallJsonCharO(self, delim1, ' '); 31794 ck_assert_ptr_ne(r, null); 31795 s = toStringO(r); 31796 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31797 free(s); 31798 terminateO(r); 31799 // multiple character delimiter 31800 freeO(self); 31801 setTopSO(self, "AAe thre|e icExtract"); 31802 freeO(delim1); 31803 setTopSO(delim1, "e "); 31804 r = icExtractSmallJsonCharO(self, delim1, '|'); 31805 ck_assert_ptr_ne(r, null); 31806 s = toStringO(r); 31807 ck_assert_str_eq(s, "[\"thre\"]"); 31808 free(s); 31809 terminateO(r); 31810 // empty delimiter 31811 freeO(self); 31812 setTopSO(self, "AAd"); 31813 freeO(delim1); 31814 setTopSO(delim1, ""); 31815 r = icExtractSmallJsonCharO(self, delim1, 'd'); 31816 ck_assert_ptr_eq(r, NULL); 31817 freeO(self); 31818 setTopSO(self, "AAd"); 31819 // empty string 31820 freeO(self); 31821 setTopSO(self, ""); 31822 freeO(delim1); 31823 setTopSO(delim1, "$"); 31824 r = icExtractSmallJsonCharO(self, delim1, '#'); 31825 ck_assert_ptr_eq(r, NULL); 31826 // delim1 = delim2 31827 freeO(self); 31828 setTopSO(self, "$qwe$"); 31829 freeO(delim1); 31830 setTopSO(delim1, "$"); 31831 r = icExtractSmallJsonCharO(self, delim1, '$'); 31832 ck_assert_ptr_eq(r, NULL); 31833 // non json string 31834 freeO(delim1); 31835 r = icExtractSmallJsonCharO(self, delim1, '$'); 31836 ck_assert_ptr_eq(r, NULL); 31837 // non json object 31838 terminateO(delim1); 31839 delim1 = (smallJsont*) allocSmallInt(1); 31840 r = icExtractSmallJsonCharO(self, delim1, '$'); 31841 ck_assert_ptr_eq(r, NULL); 31842 terminateO(delim1); 31843 delim1 = allocSmallJson(); 31844 // NULL string 31845 freeO(self); 31846 freeO(delim1); 31847 setTopSO(delim1, ";"); 31848 ck_assert_ptr_eq(icExtractSmallJsonCharO(self, delim1, ','), NULL); 31849 // NULL delimiter 31850 freeO(self); 31851 setTopSO(self, "test"); 31852 ck_assert_ptr_eq(icExtractSmallJsonCharO(self, NULL, ','), NULL); 31853 terminateO(delim1); 31854 terminateO(self); 31855 31856 } 31857 31858 31859 void icExtractSmallStringSmallJsonSmallJsonT(void) { 31860 31861 smallJsont* r; 31862 smallJsont *self = allocSmallJson(); 31863 setTopSO(self, ""); 31864 smallStringt* delim1 = allocSmallString("E"); 31865 smallJsont* delim2 = allocSmallJson(); 31866 31867 // string 31868 freeO(self); 31869 setTopSO(self, "one/twos"); 31870 setTopSO(delim2, "S"); 31871 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31872 ck_assert_ptr_ne(r, null); 31873 char *s = toStringO(r); 31874 ck_assert_str_eq(s, "[\"/two\"]"); 31875 free(s); 31876 terminateO(r); 31877 // delimiter not found 31878 freeO(self); 31879 setTopSO(self, "one/two"); 31880 freeO(delim2); 31881 setValO(delim1, "||"); 31882 setTopSO(delim2, "/"); 31883 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31884 ck_assert_ptr_eq(r, NULL); 31885 // icExtractSmallStringSmallJsonO with several delimiters after each other 31886 freeO(self); 31887 setTopSO(self, "one/ two /three "); 31888 freeO(delim2); 31889 setValO(delim1, "/"); 31890 setTopSO(delim2, " "); 31891 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31892 ck_assert_ptr_ne(r, null); 31893 s = toStringO(r); 31894 ck_assert_str_eq(s, "[\"\",\"three\"]"); 31895 free(s); 31896 terminateO(r); 31897 // multiple character delimiter 31898 freeO(self); 31899 setTopSO(self, "AAe thre|e icExtract"); 31900 freeO(delim2); 31901 setValO(delim1, "e "); 31902 setTopSO(delim2, "|"); 31903 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31904 ck_assert_ptr_ne(r, null); 31905 s = toStringO(r); 31906 ck_assert_str_eq(s, "[\"thre\"]"); 31907 free(s); 31908 terminateO(r); 31909 // empty delimiter 31910 freeO(self); 31911 setTopSO(self, "AAd"); 31912 freeO(delim2); 31913 setValO(delim1, ""); 31914 setTopSO(delim2, "Ad"); 31915 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31916 ck_assert_ptr_eq(r, NULL); 31917 freeO(self); 31918 setTopSO(self, "AAd"); 31919 freeO(delim2); 31920 setValO(delim1, "A"); 31921 setTopSO(delim2, ""); 31922 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31923 ck_assert_ptr_eq(r, NULL); 31924 // empty string 31925 freeO(self); 31926 setTopSO(self, ""); 31927 freeO(delim2); 31928 setValO(delim1, "$"); 31929 setTopSO(delim2, "#"); 31930 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31931 ck_assert_ptr_eq(r, NULL); 31932 // delim1 = delim2 31933 freeO(self); 31934 setTopSO(self, "$qwe$"); 31935 freeO(delim2); 31936 setValO(delim1, "$"); 31937 setTopSO(delim2, "$"); 31938 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31939 ck_assert_ptr_eq(r, NULL); 31940 // non json string 31941 freeO(delim2); 31942 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31943 ck_assert_ptr_eq(r, NULL); 31944 // non json object 31945 terminateO(delim1); 31946 delim1 = (smallStringt*) allocSmallInt(1); 31947 setTopSO(delim2, "$"); 31948 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31949 ck_assert_ptr_eq(r, NULL); 31950 terminateO(delim1); 31951 delim1 = allocSmallString(";"); 31952 terminateO(delim2); 31953 delim2 = (smallJsont*) allocSmallInt(1); 31954 r = icExtractSmallStringSmallJsonO(self, delim1, delim2); 31955 ck_assert_ptr_eq(r, NULL); 31956 terminateO(delim2); 31957 delim2 = allocSmallJson(); 31958 // NULL string 31959 freeO(self); 31960 freeO(delim2); 31961 setValO(delim1, ";"); 31962 setTopSO(delim2, ","); 31963 ck_assert_ptr_eq(icExtractSmallStringSmallJsonO(self, delim1, delim2), NULL); 31964 // NULL delimiter 31965 freeO(self); 31966 setTopSO(self, "test"); 31967 ck_assert_ptr_eq(icExtractSmallStringSmallJsonO(self, NULL, delim2), NULL); 31968 ck_assert_ptr_eq(icExtractSmallStringSmallJsonO(self, delim1, NULL), NULL); 31969 terminateO(delim1); 31970 terminateO(delim2); 31971 terminateO(self); 31972 31973 } 31974 31975 31976 void icExtractSmallStringSmallStringSmallJsonT(void) { 31977 31978 smallJsont* r; 31979 smallJsont *self = allocSmallJson(); 31980 setTopSO(self, ""); 31981 smallStringt* delim1 = allocSmallString("E"); 31982 smallStringt* delim2 = allocSmallString("|"); 31983 31984 // string 31985 freeO(self); 31986 setTopSO(self, "one/twos"); 31987 setValO(delim2, "S"); 31988 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 31989 ck_assert_ptr_ne(r, null); 31990 char *s = toStringO(r); 31991 ck_assert_str_eq(s, "[\"/two\"]"); 31992 free(s); 31993 terminateO(r); 31994 // delimiter not found 31995 freeO(self); 31996 setTopSO(self, "one/two"); 31997 setValO(delim1, "||"); 31998 setValO(delim2, "/"); 31999 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32000 ck_assert_ptr_eq(r, NULL); 32001 // icExtractSmallStringSmallStringO with several delimiters after each other 32002 freeO(self); 32003 setTopSO(self, "one/ two /three "); 32004 setValO(delim1, "/"); 32005 setValO(delim2, " "); 32006 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32007 ck_assert_ptr_ne(r, null); 32008 s = toStringO(r); 32009 ck_assert_str_eq(s, "[\"\",\"three\"]"); 32010 free(s); 32011 terminateO(r); 32012 // multiple character delimiter 32013 freeO(self); 32014 setTopSO(self, "AAe thre|e icExtract"); 32015 setValO(delim1, "e "); 32016 setValO(delim2, "|"); 32017 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32018 ck_assert_ptr_ne(r, null); 32019 s = toStringO(r); 32020 ck_assert_str_eq(s, "[\"thre\"]"); 32021 free(s); 32022 terminateO(r); 32023 // empty delimiter 32024 freeO(self); 32025 setTopSO(self, "AAd"); 32026 setValO(delim1, ""); 32027 setValO(delim2, "Ad"); 32028 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32029 ck_assert_ptr_eq(r, NULL); 32030 freeO(self); 32031 setTopSO(self, "AAd"); 32032 setValO(delim1, "A"); 32033 setValO(delim2, ""); 32034 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32035 ck_assert_ptr_eq(r, NULL); 32036 // empty string 32037 freeO(self); 32038 setTopSO(self, ""); 32039 setValO(delim1, "$"); 32040 setValO(delim2, "#"); 32041 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32042 ck_assert_ptr_eq(r, NULL); 32043 // delim1 = delim2 32044 freeO(self); 32045 setTopSO(self, "$qwe$"); 32046 setValO(delim1, "$"); 32047 setValO(delim2, "$"); 32048 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32049 ck_assert_ptr_eq(r, NULL); 32050 // non json object 32051 terminateO(delim1); 32052 delim1 = (smallStringt*) allocSmallInt(1); 32053 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32054 ck_assert_ptr_eq(r, NULL); 32055 terminateO(delim1); 32056 delim1 = allocSmallString(";"); 32057 terminateO(delim2); 32058 delim2 = (smallStringt*) allocSmallInt(1); 32059 r = icExtractSmallStringSmallStringO(self, delim1, delim2); 32060 ck_assert_ptr_eq(r, NULL); 32061 terminateO(delim2); 32062 delim2 = allocSmallString(","); 32063 // NULL string 32064 freeO(self); 32065 setValO(delim1, ";"); 32066 ck_assert_ptr_eq(icExtractSmallStringSmallStringO(self, delim1, delim2), NULL); 32067 // NULL delimiter 32068 freeO(self); 32069 setTopSO(self, "test"); 32070 ck_assert_ptr_eq(icExtractSmallStringSmallStringO(self, NULL, delim2), NULL); 32071 ck_assert_ptr_eq(icExtractSmallStringSmallStringO(self, delim1, NULL), NULL); 32072 terminateO(delim1); 32073 terminateO(delim2); 32074 terminateO(self); 32075 32076 } 32077 32078 32079 void icExtractSmallStringSSmallJsonT(void) { 32080 32081 smallJsont* r; 32082 smallJsont *self = allocSmallJson(); 32083 setTopSO(self, ""); 32084 smallStringt* delim1 = allocSmallString("E"); 32085 32086 // string 32087 freeO(self); 32088 setTopSO(self, "one/twos"); 32089 r = icExtractSmallStringSO(self, delim1, "S"); 32090 ck_assert_ptr_ne(r, null); 32091 char *s = toStringO(r); 32092 ck_assert_str_eq(s, "[\"/two\"]"); 32093 free(s); 32094 terminateO(r); 32095 // delimiter not found 32096 freeO(self); 32097 setTopSO(self, "one/two"); 32098 setValO(delim1, "||"); 32099 r = icExtractSmallStringSO(self, delim1, "/"); 32100 ck_assert_ptr_eq(r, NULL); 32101 // icExtractSmallStringSO with several delimiters after each other 32102 freeO(self); 32103 setTopSO(self, "one/ two /three "); 32104 setValO(delim1, "/"); 32105 r = icExtractSmallStringSO(self, delim1, " "); 32106 ck_assert_ptr_ne(r, null); 32107 s = toStringO(r); 32108 ck_assert_str_eq(s, "[\"\",\"three\"]"); 32109 free(s); 32110 terminateO(r); 32111 // multiple character delimiter 32112 freeO(self); 32113 setTopSO(self, "AAe thre|e icExtract"); 32114 setValO(delim1, "e "); 32115 r = icExtractSmallStringSO(self, delim1, "|"); 32116 ck_assert_ptr_ne(r, null); 32117 s = toStringO(r); 32118 ck_assert_str_eq(s, "[\"thre\"]"); 32119 free(s); 32120 terminateO(r); 32121 // empty delimiter 32122 freeO(self); 32123 setTopSO(self, "AAd"); 32124 setValO(delim1, ""); 32125 r = icExtractSmallStringSO(self, delim1, "Ad"); 32126 ck_assert_ptr_eq(r, NULL); 32127 freeO(self); 32128 setTopSO(self, "AAd"); 32129 setValO(delim1, "A"); 32130 r = icExtractSmallStringSO(self, delim1, ""); 32131 ck_assert_ptr_eq(r, NULL); 32132 // empty string 32133 freeO(self); 32134 setTopSO(self, ""); 32135 setValO(delim1, "$"); 32136 r = icExtractSmallStringSO(self, delim1, "#"); 32137 ck_assert_ptr_eq(r, NULL); 32138 // delim1 = delim2 32139 freeO(self); 32140 setTopSO(self, "$qwe$"); 32141 setValO(delim1, "$"); 32142 r = icExtractSmallStringSO(self, delim1, "$"); 32143 ck_assert_ptr_eq(r, NULL); 32144 // non json object 32145 terminateO(delim1); 32146 delim1 = (smallStringt*) allocSmallInt(1); 32147 r = icExtractSmallStringSO(self, delim1, "$"); 32148 ck_assert_ptr_eq(r, NULL); 32149 terminateO(delim1); 32150 delim1 = allocSmallString(";"); 32151 // NULL string 32152 freeO(self); 32153 setValO(delim1, ";"); 32154 ck_assert_ptr_eq(icExtractSmallStringSO(self, delim1, ","), NULL); 32155 // NULL delimiter 32156 freeO(self); 32157 setTopSO(self, "test"); 32158 ck_assert_ptr_eq(icExtractSmallStringSO(self, NULL, ","), NULL); 32159 ck_assert_ptr_eq(icExtractSmallStringSO(self, delim1, NULL), NULL); 32160 terminateO(delim1); 32161 terminateO(self); 32162 32163 } 32164 32165 32166 void icExtractSmallStringCharSmallJsonT(void) { 32167 32168 smallJsont* r; 32169 smallJsont *self = allocSmallJson(); 32170 setTopSO(self, ""); 32171 smallStringt* delim1 = allocSmallString("E"); 32172 32173 // string 32174 freeO(self); 32175 setTopSO(self, "one/twos"); 32176 r = icExtractSmallStringCharO(self, delim1, 'S'); 32177 ck_assert_ptr_ne(r, null); 32178 char *s = toStringO(r); 32179 ck_assert_str_eq(s, "[\"/two\"]"); 32180 free(s); 32181 terminateO(r); 32182 // delimiter not found 32183 freeO(self); 32184 setTopSO(self, "one/two"); 32185 setValO(delim1, "||"); 32186 r = icExtractSmallStringCharO(self, delim1, '/'); 32187 ck_assert_ptr_eq(r, NULL); 32188 // icExtractSmallStringCharO with several delimiters after each other 32189 freeO(self); 32190 setTopSO(self, "one/ two /three "); 32191 setValO(delim1, "/"); 32192 r = icExtractSmallStringCharO(self, delim1, ' '); 32193 ck_assert_ptr_ne(r, null); 32194 s = toStringO(r); 32195 ck_assert_str_eq(s, "[\"\",\"three\"]"); 32196 free(s); 32197 terminateO(r); 32198 // multiple character delimiter 32199 freeO(self); 32200 setTopSO(self, "AAe thre|e icExtract"); 32201 setValO(delim1, "e "); 32202 r = icExtractSmallStringCharO(self, delim1, '|'); 32203 ck_assert_ptr_ne(r, null); 32204 s = toStringO(r); 32205 ck_assert_str_eq(s, "[\"thre\"]"); 32206 free(s); 32207 terminateO(r); 32208 // empty delimiter 32209 freeO(self); 32210 setTopSO(self, "AAd"); 32211 setValO(delim1, ""); 32212 r = icExtractSmallStringCharO(self, delim1, 'A'); 32213 ck_assert_ptr_eq(r, NULL); 32214 freeO(self); 32215 setTopSO(self, "AAd"); 32216 setValO(delim1, "A"); 32217 // empty string 32218 freeO(self); 32219 setTopSO(self, ""); 32220 setValO(delim1, "$"); 32221 r = icExtractSmallStringCharO(self, delim1, '#'); 32222 ck_assert_ptr_eq(r, NULL); 32223 // delim1 = delim2 32224 freeO(self); 32225 setTopSO(self, "$qwe$"); 32226 setValO(delim1, "$"); 32227 r = icExtractSmallStringCharO(self, delim1, '$'); 32228 ck_assert_ptr_eq(r, NULL); 32229 // non json object 32230 terminateO(delim1); 32231 delim1 = (smallStringt*) allocSmallInt(1); 32232 r = icExtractSmallStringCharO(self, delim1, '$'); 32233 ck_assert_ptr_eq(r, NULL); 32234 terminateO(delim1); 32235 delim1 = allocSmallString(";"); 32236 // NULL string 32237 freeO(self); 32238 setValO(delim1, ";"); 32239 ck_assert_ptr_eq(icExtractSmallStringCharO(self, delim1, ','), NULL); 32240 // NULL delimiter 32241 freeO(self); 32242 setTopSO(self, "test"); 32243 ck_assert_ptr_eq(icExtractSmallStringCharO(self, NULL, ','), NULL); 32244 terminateO(delim1); 32245 terminateO(self); 32246 32247 } 32248 32249 32250 void icExtractSSmallJsonSmallJsonT(void) { 32251 32252 smallJsont* r; 32253 smallJsont *self = allocSmallJson(); 32254 setTopSO(self, ""); 32255 smallJsont* delim2 = allocSmallJson(); 32256 32257 // string 32258 freeO(self); 32259 setTopSO(self, "one/twos"); 32260 setTopSO(delim2, "S"); 32261 r = icExtractSSmallJsonO(self, "E", delim2); 32262 ck_assert_ptr_ne(r, null); 32263 char *s = toStringO(r); 32264 ck_assert_str_eq(s, "[\"/two\"]"); 32265 free(s); 32266 terminateO(r); 32267 // delimiter not found 32268 freeO(self); 32269 setTopSO(self, "one/two"); 32270 freeO(delim2); 32271 setTopSO(delim2, "/"); 32272 r = icExtractSSmallJsonO(self, "||", delim2); 32273 ck_assert_ptr_eq(r, NULL); 32274 // icExtractSSmallJsonO with several delimiters after each other 32275 freeO(self); 32276 setTopSO(self, "one/ two /three "); 32277 freeO(delim2); 32278 setTopSO(delim2, " "); 32279 r = icExtractSSmallJsonO(self, "/", delim2); 32280 ck_assert_ptr_ne(r, null); 32281 s = toStringO(r); 32282 ck_assert_str_eq(s, "[\"\",\"three\"]"); 32283 free(s); 32284 terminateO(r); 32285 // multiple character delimiter 32286 freeO(self); 32287 setTopSO(self, "AAe thre|e icExtract"); 32288 freeO(delim2); 32289 setTopSO(delim2, "|"); 32290 r = icExtractSSmallJsonO(self, "e ", delim2); 32291 ck_assert_ptr_ne(r, null); 32292 s = toStringO(r); 32293 ck_assert_str_eq(s, "[\"thre\"]"); 32294 free(s); 32295 terminateO(r); 32296 // empty delimiter 32297 freeO(self); 32298 setTopSO(self, "AAd"); 32299 freeO(delim2); 32300 setTopSO(delim2, "Ad"); 32301 r = icExtractSSmallJsonO(self, "", delim2); 32302 ck_assert_ptr_eq(r, NULL); 32303 freeO(self); 32304 setTopSO(self, "AAd"); 32305 freeO(delim2); 32306 setTopSO(delim2, ""); 32307 r = icExtractSSmallJsonO(self, "A", delim2); 32308 ck_assert_ptr_eq(r, NULL); 32309 // empty string 32310 freeO(self); 32311 setTopSO(self, ""); 32312 freeO(delim2); 32313 setTopSO(delim2, "#"); 32314 r = icExtractSSmallJsonO(self, "$", delim2); 32315 ck_assert_ptr_eq(r, NULL); 32316 // delim1 = delim2 32317 freeO(self); 32318 setTopSO(self, "$qwe$"); 32319 freeO(delim2); 32320 setTopSO(delim2, "$"); 32321 r = icExtractSSmallJsonO(self, "$", delim2); 32322 ck_assert_ptr_eq(r, NULL); 32323 // non json string 32324 freeO(delim2); 32325 r = icExtractSSmallJsonO(self, "$", delim2); 32326 ck_assert_ptr_eq(r, NULL); 32327 // non json object 32328 terminateO(delim2); 32329 delim2 = (smallJsont*) allocSmallInt(1); 32330 r = icExtractSSmallJsonO(self, ";", delim2); 32331 ck_assert_ptr_eq(r, NULL); 32332 terminateO(delim2); 32333 delim2 = allocSmallJson(); 32334 // NULL string 32335 freeO(self); 32336 freeO(delim2); 32337 setTopSO(delim2, ","); 32338 ck_assert_ptr_eq(icExtractSSmallJsonO(self, ";", delim2), NULL); 32339 // NULL delimiter 32340 freeO(self); 32341 setTopSO(self, "test"); 32342 ck_assert_ptr_eq(icExtractSSmallJsonO(self, NULL, delim2), NULL); 32343 ck_assert_ptr_eq(icExtractSSmallJsonO(self, ";", NULL), NULL); 32344 terminateO(delim2); 32345 terminateO(self); 32346 32347 } 32348 32349 32350 void icExtractSSmallStringSmallJsonT(void) { 32351 32352 smallJsont* r; 32353 smallJsont *self = allocSmallJson(); 32354 setTopSO(self, ""); 32355 smallStringt* delim2 = allocSmallString("|"); 32356 32357 // string 32358 freeO(self); 32359 setTopSO(self, "one/twos"); 32360 setValO(delim2, "S"); 32361 r = icExtractSSmallStringO(self, "E", delim2); 32362 ck_assert_ptr_ne(r, null); 32363 char *s = toStringO(r); 32364 ck_assert_str_eq(s, "[\"/two\"]"); 32365 free(s); 32366 terminateO(r); 32367 // delimiter not found 32368 freeO(self); 32369 setTopSO(self, "one/two"); 32370 setValO(delim2, "/"); 32371 r = icExtractSSmallStringO(self, "||", delim2); 32372 ck_assert_ptr_eq(r, NULL); 32373 // icExtractSSmallStringO with several delimiters after each other 32374 freeO(self); 32375 setTopSO(self, "one/ two /three "); 32376 setValO(delim2, " "); 32377 r = icExtractSSmallStringO(self, "/", delim2); 32378 ck_assert_ptr_ne(r, null); 32379 s = toStringO(r); 32380 ck_assert_str_eq(s, "[\"\",\"three\"]"); 32381 free(s); 32382 terminateO(r); 32383 // multiple character delimiter 32384 freeO(self); 32385 setTopSO(self, "AAe thre|e icExtract"); 32386 setValO(delim2, "|"); 32387 r = icExtractSSmallStringO(self, "e ", delim2); 32388 ck_assert_ptr_ne(r, null); 32389 s = toStringO(r); 32390 ck_assert_str_eq(s, "[\"thre\"]"); 32391 free(s); 32392 terminateO(r); 32393 // empty delimiter 32394 freeO(self); 32395 setTopSO(self, "AAd"); 32396 setValO(delim2, "Ad"); 32397 r = icExtractSSmallStringO(self, "", delim2); 32398 ck_assert_ptr_eq(r, NULL); 32399 freeO(self); 32400 setTopSO(self, "AAd"); 32401 setValO(delim2, ""); 32402 r = icExtractSSmallStringO(self, "A", delim2); 32403 ck_assert_ptr_eq(r, NULL); 32404 // empty string 32405 freeO(self); 32406 setTopSO(self, ""); 32407 setValO(delim2, "#"); 32408 r = icExtractSSmallStringO(self, "$", delim2); 32409 ck_assert_ptr_eq(r, NULL); 32410 // delim1 = delim2 32411 freeO(self); 32412 setTopSO(self, "$qwe$"); 32413 setValO(delim2, "$"); 32414 r = icExtractSSmallStringO(self, "$", delim2); 32415 ck_assert_ptr_eq(r, NULL); 32416 // non json object 32417 terminateO(delim2); 32418 delim2 = (smallStringt*) allocSmallInt(1); 32419 r = icExtractSSmallStringO(self, ";", delim2); 32420 ck_assert_ptr_eq(r, NULL); 32421 terminateO(delim2); 32422 delim2 = allocSmallString(","); 32423 // NULL string 32424 freeO(self); 32425 ck_assert_ptr_eq(icExtractSSmallStringO(self, ";", delim2), NULL); 32426 // NULL delimiter 32427 freeO(self); 32428 setTopSO(self, "test"); 32429 ck_assert_ptr_eq(icExtractSSmallStringO(self, NULL, delim2), NULL); 32430 ck_assert_ptr_eq(icExtractSSmallStringO(self, ";", NULL), NULL); 32431 terminateO(delim2); 32432 terminateO(self); 32433 32434 } 32435 32436 32437 void icExtractCharSmallJsonSmallJsonT(void) { 32438 32439 smallJsont* r; 32440 smallJsont *self = allocSmallJson(); 32441 setTopSO(self, ""); 32442 smallJsont* delim2 = allocSmallJson(); 32443 32444 // string 32445 freeO(self); 32446 setTopSO(self, "one/twos"); 32447 setTopSO(delim2, "S"); 32448 r = icExtractCharSmallJsonO(self, 'E', delim2); 32449 ck_assert_ptr_ne(r, null); 32450 char *s = toStringO(r); 32451 ck_assert_str_eq(s, "[\"/two\"]"); 32452 free(s); 32453 terminateO(r); 32454 // delimiter not found 32455 freeO(self); 32456 setTopSO(self, "one/two"); 32457 freeO(delim2); 32458 setTopSO(delim2, "/"); 32459 r = icExtractCharSmallJsonO(self, '|', delim2); 32460 ck_assert_ptr_eq(r, NULL); 32461 // icExtractCharSmallJsonO with several delimiters after each other 32462 freeO(self); 32463 setTopSO(self, "one/ two /three "); 32464 freeO(delim2); 32465 setTopSO(delim2, " "); 32466 r = icExtractCharSmallJsonO(self, '/', delim2); 32467 ck_assert_ptr_ne(r, null); 32468 s = toStringO(r); 32469 ck_assert_str_eq(s, "[\"\",\"three\"]"); 32470 free(s); 32471 terminateO(r); 32472 // multiple character delimiter 32473 freeO(self); 32474 setTopSO(self, "AAe thre|e icExtract"); 32475 freeO(delim2); 32476 setTopSO(delim2, "|"); 32477 r = icExtractCharSmallJsonO(self, ' ', delim2); 32478 ck_assert_ptr_ne(r, null); 32479 s = toStringO(r); 32480 ck_assert_str_eq(s, "[\"thre\"]"); 32481 free(s); 32482 terminateO(r); 32483 // empty delimiter 32484 freeO(self); 32485 setTopSO(self, "AAd"); 32486 freeO(delim2); 32487 setTopSO(delim2, ""); 32488 r = icExtractCharSmallJsonO(self, 'A', delim2); 32489 ck_assert_ptr_eq(r, NULL); 32490 // empty string 32491 freeO(self); 32492 setTopSO(self, ""); 32493 freeO(delim2); 32494 setTopSO(delim2, "#"); 32495 r = icExtractCharSmallJsonO(self, '$', delim2); 32496 ck_assert_ptr_eq(r, NULL); 32497 // delim1 = delim2 32498 freeO(self); 32499 setTopSO(self, "$qwe$"); 32500 freeO(delim2); 32501 setTopSO(delim2, "$"); 32502 r = icExtractCharSmallJsonO(self, '$', delim2); 32503 ck_assert_ptr_eq(r, NULL); 32504 // non json string 32505 freeO(delim2); 32506 r = icExtractCharSmallJsonO(self, '$', delim2); 32507 ck_assert_ptr_eq(r, NULL); 32508 // non json object 32509 terminateO(delim2); 32510 delim2 = (smallJsont*) allocSmallInt(1); 32511 r = icExtractCharSmallJsonO(self, ';', delim2); 32512 ck_assert_ptr_eq(r, NULL); 32513 terminateO(delim2); 32514 delim2 = allocSmallJson(); 32515 // NULL string 32516 freeO(self); 32517 freeO(delim2); 32518 setTopSO(delim2, ","); 32519 ck_assert_ptr_eq(icExtractCharSmallJsonO(self, ';', delim2), NULL); 32520 // NULL delimiter 32521 freeO(self); 32522 setTopSO(self, "test"); 32523 ck_assert_ptr_eq(icExtractCharSmallJsonO(self, ';', NULL), NULL); 32524 terminateO(delim2); 32525 terminateO(self); 32526 32527 } 32528 32529 32530 void icExtractCharSmallStringSmallJsonT(void) { 32531 32532 smallJsont* r; 32533 smallJsont *self = allocSmallJson(); 32534 setTopSO(self, ""); 32535 smallStringt* delim2 = allocSmallString("|"); 32536 32537 // string 32538 freeO(self); 32539 setTopSO(self, "one/twos"); 32540 setValO(delim2, "S"); 32541 r = icExtractCharSmallStringO(self, 'E', delim2); 32542 ck_assert_ptr_ne(r, null); 32543 char *s = toStringO(r); 32544 ck_assert_str_eq(s, "[\"/two\"]"); 32545 free(s); 32546 terminateO(r); 32547 // delimiter not found 32548 freeO(self); 32549 setTopSO(self, "one/two"); 32550 setValO(delim2, "/"); 32551 r = icExtractCharSmallStringO(self, '|', delim2); 32552 ck_assert_ptr_eq(r, NULL); 32553 // icExtractCharSmallStringO with several delimiters after each other 32554 freeO(self); 32555 setTopSO(self, "one/ two /three "); 32556 setValO(delim2, " "); 32557 r = icExtractCharSmallStringO(self, '/', delim2); 32558 ck_assert_ptr_ne(r, null); 32559 s = toStringO(r); 32560 ck_assert_str_eq(s, "[\"\",\"three\"]"); 32561 free(s); 32562 terminateO(r); 32563 // multiple character delimiter 32564 freeO(self); 32565 setTopSO(self, "AAe thre|e icExtract"); 32566 setValO(delim2, "|e"); 32567 r = icExtractCharSmallStringO(self, ' ', delim2); 32568 ck_assert_ptr_ne(r, null); 32569 s = toStringO(r); 32570 ck_assert_str_eq(s, "[\"thre\"]"); 32571 free(s); 32572 terminateO(r); 32573 // empty delimiter 32574 freeO(self); 32575 setTopSO(self, "AAd"); 32576 setValO(delim2, ""); 32577 r = icExtractCharSmallStringO(self, 'A', delim2); 32578 ck_assert_ptr_eq(r, NULL); 32579 // empty string 32580 freeO(self); 32581 setTopSO(self, ""); 32582 setValO(delim2, "#"); 32583 r = icExtractCharSmallStringO(self, '$', delim2); 32584 ck_assert_ptr_eq(r, NULL); 32585 // delim1 = delim2 32586 freeO(self); 32587 setTopSO(self, "$qwe$"); 32588 setValO(delim2, "$"); 32589 r = icExtractCharSmallStringO(self, '$', delim2); 32590 ck_assert_ptr_eq(r, NULL); 32591 // non json object 32592 terminateO(delim2); 32593 delim2 = (smallStringt*) allocSmallInt(1); 32594 r = icExtractCharSmallStringO(self, ';', delim2); 32595 ck_assert_ptr_eq(r, NULL); 32596 terminateO(delim2); 32597 delim2 = allocSmallString(","); 32598 // NULL string 32599 freeO(self); 32600 ck_assert_ptr_eq(icExtractCharSmallStringO(self, ';', delim2), NULL); 32601 // NULL delimiter 32602 freeO(self); 32603 setTopSO(self, "test"); 32604 ck_assert_ptr_eq(icExtractCharSmallStringO(self, ';', NULL), NULL); 32605 terminateO(delim2); 32606 terminateO(self); 32607 32608 } 32609 32610 32611 void colorSmallJsonT(void) { 32612 32613 smallJsont* r; 32614 smallJsont *self = allocSmallJson(); 32615 setTopSO(self, "qwe"); 32616 32617 r = colorO(self, RED); 32618 ck_assert_ptr_ne(r, null); 32619 char *s = toStringO(r); 32620 ck_assert_str_eq(s, RED"qwe"RST); 32621 free(s); 32622 // null color 32623 r = colorO(self, null); 32624 ck_assert_ptr_eq(r, NULL); 32625 // empty self 32626 freeO(self); 32627 r = colorO(self, RED); 32628 ck_assert_ptr_eq(r, NULL); 32629 terminateO(self); 32630 32631 } 32632 32633 32634 void colordSmallJsonT(void) { 32635 32636 char* r; 32637 smallJsont *self = allocSmallJson(); 32638 setTopSO(self, "qwe"); 32639 32640 r = colordO(self, RED); 32641 ck_assert_ptr_ne(r, null); 32642 ck_assert_str_eq(r, RED"qwe"RST); 32643 free(r); 32644 // empty string 32645 emptyO(self); 32646 r = colordO(self, RED); 32647 ck_assert_ptr_ne(r, null); 32648 ck_assert_str_eq(r, ""); 32649 free(r); 32650 // null color 32651 r = colordO(self, null); 32652 ck_assert_ptr_eq(r, NULL); 32653 // empty self 32654 freeO(self); 32655 r = colordO(self, RED); 32656 ck_assert_ptr_eq(r, NULL); 32657 terminateO(self); 32658 32659 } 32660 32661 32662 void zipSmallJsonT(void) { 32663 32664 smallJsont* r; 32665 smallJsont *self = allocSmallJson(); 32666 smallArrayt *array1 = allocSmallArray(); 32667 smallArrayt *array2 = allocSmallArray(); 32668 32669 // non json array or dict 32670 setTypeBoolO(self); 32671 r = zipO(self, array1, array2); 32672 ck_assert_ptr_eq(r, NULL); 32673 // json array 32674 // zip arrays 32675 // empty self 32676 freeO(self); 32677 array1->f->pushS(array1, "a"); 32678 array2->f->pushInt(array2, 1); 32679 r = zipO(self, array1, array2); 32680 ck_assert_ptr_ne(r, NULL); 32681 char *s = toStringO(r); 32682 ck_assert_str_eq(s, "[[\"a\",1]]"); 32683 free(s); 32684 disposeO(array1); 32685 disposeO(array2); 32686 freeO(self); 32687 // add an element to self 32688 // array1 has 2 elements 32689 // array2 has 3 elements 32690 // only 2 elements are zipped 32691 self->f->pushS(self, "qwe"); 32692 array1->f->pushS(array1, "a"); 32693 array1->f->pushS(array1, "b"); 32694 array2->f->pushInt(array2, 1); 32695 array2->f->pushInt(array2, 2); 32696 array2->f->pushInt(array2, 3); 32697 r = zipO(self, array1, array2); 32698 ck_assert_ptr_ne(r, NULL); 32699 s = toStringO(r); 32700 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32701 free(s); 32702 // delete the element not in self 32703 delElemO(array2, 2); 32704 // empty arrays 32705 disposeO(array2); 32706 r = zipO(self, array1, array2); 32707 ck_assert_ptr_ne(r, NULL); 32708 s = toStringO(r); 32709 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32710 free(s); 32711 disposeO(array1); 32712 r = zipO(self, array1, array2); 32713 ck_assert_ptr_ne(r, NULL); 32714 s = toStringO(r); 32715 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32716 free(s); 32717 // array1 and array2 same element count 32718 array1->f->pushS(array1, "aa"); 32719 array1->f->pushS(array1, "bb"); 32720 array2->f->pushInt(array2, 11); 32721 array2->f->pushInt(array2, 22); 32722 delElemO(array1, 1); 32723 r = zipO(self, array1, array2); 32724 delElemO(array2, 1); 32725 ck_assert_ptr_ne(r, NULL); 32726 // some elements were zipped 32727 s = toStringO(self); 32728 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"aa\",11]]"); 32729 free(s); 32730 // but an element is NULL 32731 // non smallArray objects 32732 smashO(array1); 32733 array1 = (smallArrayt*) allocSmallInt(2); 32734 r = zipO(self, array1, array2); 32735 ck_assert_ptr_eq(r, NULL); 32736 terminateO(array1); 32737 array1 = allocSmallArray(); 32738 smashO(array2); 32739 array2 = (smallArrayt*) allocSmallInt(2); 32740 r = zipO(self, array1, array2); 32741 ck_assert_ptr_eq(r, NULL); 32742 terminateO(array2); 32743 array2 = allocSmallArray(); 32744 // NULL arrays 32745 r = zipO(self, NULL, array2); 32746 ck_assert_ptr_eq(r, NULL); 32747 r = zipO(self, array1, NULL); 32748 ck_assert_ptr_eq(r, NULL); 32749 terminateO(self); 32750 smashO(array1); 32751 smashO(array2); 32752 // json dict 32753 self = allocSmallJson(); 32754 setTypeDictO(self); 32755 smallArrayt *keys = allocSmallArray(); 32756 smallArrayt *values = allocSmallArray(); 32757 self->f->setInt(self, "", 1); 32758 // 3 elements in keys 32759 // 2 elements in values 32760 // only 2 key/values are zipped 32761 keys->f->pushS(keys, "a"); 32762 keys->f->pushS(keys, "b"); 32763 keys->f->pushS(keys, "c"); 32764 values->f->pushInt(values, 1); 32765 values->f->pushInt(values, 2); 32766 r = zipO(self, keys, values); 32767 terminateO(keys); 32768 smashO(values); 32769 ck_assert_ptr_ne(r, NULL); 32770 s = toStringO(r); 32771 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 32772 free(s); 32773 // keys array with non string objects 32774 keys = allocSmallArray(); 32775 values = allocSmallArray(); 32776 keys->f->pushInt(keys, 1); 32777 values->f->pushInt(values, 1); 32778 r = zipO(self, keys, values); 32779 ck_assert_ptr_eq(r, NULL); 32780 terminateO(keys); 32781 terminateO(values); 32782 // empty values 32783 keys = allocSmallArray(); 32784 values = allocSmallArray(); 32785 keys->f->pushInt(keys, 1); 32786 r = zipO(self, keys, values); 32787 ck_assert_ptr_eq(r, self); 32788 terminateO(keys); 32789 terminateO(values); 32790 terminateO(self); 32791 32792 } 32793 32794 32795 void zipArraySmallJsonT(void) { 32796 32797 smallJsont* r; 32798 smallJsont *self = allocSmallJson(); 32799 char** array1; 32800 smallArrayt *array2 = allocSmallArray(); 32801 32802 // non json array or dict 32803 setTypeBoolO(self); 32804 array1 = listCreateS("a"); 32805 r = zipArrayO(self, array1, array2); 32806 ck_assert_ptr_eq(r, NULL); 32807 // json array 32808 // zip arrays 32809 // empty self 32810 freeO(self); 32811 array2->f->pushInt(array2, 1); 32812 r = zipArrayO(self, array1, array2); 32813 ck_assert_ptr_ne(r, NULL); 32814 char *s = toStringO(r); 32815 ck_assert_str_eq(s, "[[\"a\",1]]"); 32816 free(s); 32817 freen(array1); 32818 disposeO(array2); 32819 freeO(self); 32820 // add an element to self 32821 // array1 has 2 elements 32822 // array2 has 3 elements 32823 // only 2 elements are zipped 32824 self->f->pushS(self, "qwe"); 32825 array1 = listCreateS("a", "b"); 32826 array2->f->pushInt(array2, 1); 32827 array2->f->pushInt(array2, 2); 32828 array2->f->pushInt(array2, 3); 32829 r = zipArrayO(self, array1, array2); 32830 ck_assert_ptr_ne(r, NULL); 32831 s = toStringO(r); 32832 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32833 free(s); 32834 // delete the element not in self 32835 delElemO(array2, 2); 32836 // empty arrays 32837 disposeO(array2); 32838 r = zipArrayO(self, array1, array2); 32839 ck_assert_ptr_ne(r, NULL); 32840 s = toStringO(r); 32841 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32842 free(s); 32843 iListRemoveS(&array1, 0, 2); 32844 r = zipArrayO(self, array1, array2); 32845 free(array1); 32846 ck_assert_ptr_ne(r, NULL); 32847 s = toStringO(r); 32848 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32849 free(s); 32850 // array1 and array2 same element count 32851 array1 = listCreateS("aa", "bb"); 32852 array2->f->pushInt(array2, 11); 32853 array2->f->pushInt(array2, 22); 32854 iListDelElemS(&array1, 1); 32855 r = zipArrayO(self, array1, array2); 32856 delElemO(array2, 1); 32857 ck_assert_ptr_ne(r, NULL); 32858 // some elements were zipped 32859 s = toStringO(self); 32860 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"aa\",11]]"); 32861 free(s); 32862 // but an element is NULL 32863 // non smallArray objects 32864 smashO(array2); 32865 array2 = (smallArrayt*) allocSmallInt(2); 32866 r = zipArrayO(self, array1, array2); 32867 ck_assert_ptr_eq(r, NULL); 32868 terminateO(array2); 32869 array2 = allocSmallArray(); 32870 // NULL arrays 32871 r = zipArrayO(self, NULL, array2); 32872 ck_assert_ptr_eq(r, NULL); 32873 r = zipArrayO(self, array1, NULL); 32874 ck_assert_ptr_eq(r, NULL); 32875 terminateO(self); 32876 free(array1); 32877 smashO(array2); 32878 // json dict 32879 self = allocSmallJson(); 32880 char** keys; 32881 smallArrayt *values = allocSmallArray(); 32882 self->f->setInt(self, "", 1); 32883 // 3 elements in keys 32884 // 2 elements in values 32885 // only 2 key/values are zipped 32886 keys = listCreateS("a", "b", "c"); 32887 values->f->pushInt(values, 1); 32888 values->f->pushInt(values, 2); 32889 r = zipArrayO(self, keys, values); 32890 listFreeS(keys); 32891 smashO(values); 32892 ck_assert_ptr_ne(r, NULL); 32893 s = toStringO(r); 32894 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 32895 free(s); 32896 // empty values 32897 keys = listCreateS("a"); 32898 values = allocSmallArray(); 32899 r = zipArrayO(self, keys, values); 32900 ck_assert_ptr_eq(r, self); 32901 listFreeS(keys); 32902 terminateO(values); 32903 terminateO(self); 32904 32905 } 32906 32907 32908 void zipCArraySmallJsonT(void) { 32909 32910 smallJsont* r; 32911 smallJsont *self = allocSmallJson(); 32912 const char* array1[] = {"a", "b", null}; 32913 smallArrayt *array2 = allocSmallArray(); 32914 32915 // non json array or dict 32916 setTypeBoolO(self); 32917 r = zipCArrayO(self, array1, array2); 32918 ck_assert_ptr_eq(r, NULL); 32919 // json array 32920 // zip arrays 32921 // empty self 32922 freeO(self); 32923 array2->f->pushInt(array2, 1); 32924 r = zipCArrayO(self, array1, array2); 32925 ck_assert_ptr_ne(r, NULL); 32926 char *s = toStringO(r); 32927 ck_assert_str_eq(s, "[[\"a\",1]]"); 32928 free(s); 32929 disposeO(array2); 32930 freeO(self); 32931 // add an element to self 32932 // array1 has 2 elements 32933 // array2 has 3 elements 32934 // only 2 elements are zipped 32935 self->f->pushS(self, "qwe"); 32936 array2->f->pushInt(array2, 1); 32937 array2->f->pushInt(array2, 2); 32938 array2->f->pushInt(array2, 3); 32939 r = zipCArrayO(self, array1, array2); 32940 ck_assert_ptr_ne(r, NULL); 32941 s = toStringO(r); 32942 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32943 free(s); 32944 // delete the element not in self 32945 delElemO(array2, 2); 32946 // empty arrays 32947 disposeO(array2); 32948 r = zipCArrayO(self, array1, array2); 32949 ck_assert_ptr_ne(r, NULL); 32950 s = toStringO(r); 32951 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32952 free(s); 32953 array1[0] = null; 32954 r = zipCArrayO(self, array1, array2); 32955 ck_assert_ptr_ne(r, NULL); 32956 s = toStringO(r); 32957 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 32958 free(s); 32959 // array1 and array2 same element count 32960 array1[0] = "aa"; 32961 array1[1] = null; 32962 array2->f->pushInt(array2, 11); 32963 array2->f->pushInt(array2, 22); 32964 r = zipCArrayO(self, array1, array2); 32965 delElemO(array2, 1); 32966 ck_assert_ptr_ne(r, NULL); 32967 // some elements were zipped 32968 s = toStringO(self); 32969 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"aa\",11]]"); 32970 free(s); 32971 // but an element is NULL 32972 // non smallArray objects 32973 smashO(array2); 32974 array2 = (smallArrayt*) allocSmallInt(2); 32975 r = zipCArrayO(self, array1, array2); 32976 ck_assert_ptr_eq(r, NULL); 32977 terminateO(array2); 32978 array2 = allocSmallArray(); 32979 // NULL arrays 32980 r = zipCArrayO(self, NULL, array2); 32981 ck_assert_ptr_eq(r, NULL); 32982 r = zipCArrayO(self, array1, NULL); 32983 ck_assert_ptr_eq(r, NULL); 32984 terminateO(self); 32985 smashO(array2); 32986 // json dict 32987 self = allocSmallJson(); 32988 const char* keys[] = {"a", "b", "c", null}; 32989 smallArrayt *values = allocSmallArray(); 32990 self->f->setInt(self, "", 1); 32991 // 3 elements in keys 32992 // 2 elements in values 32993 // only 2 key/values are zipped 32994 values->f->pushInt(values, 1); 32995 values->f->pushInt(values, 2); 32996 r = zipCArrayO(self, keys, values); 32997 smashO(values); 32998 ck_assert_ptr_ne(r, NULL); 32999 s = toStringO(r); 33000 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 33001 free(s); 33002 // empty values 33003 values = allocSmallArray(); 33004 r = zipCArrayO(self, keys, values); 33005 ck_assert_ptr_eq(r, self); 33006 terminateO(values); 33007 terminateO(self); 33008 33009 } 33010 33011 33012 void zipCharSmallJsonT(void) { 33013 33014 smallJsont* r; 33015 smallJsont *self = allocSmallJson(); 33016 smallArrayt *array1 = allocSmallArray(); 33017 char** array2; 33018 33019 // non json array or dict 33020 setTypeBoolO(self); 33021 array2 = listCreateS("1"); 33022 r = zipCharO(self, array1, array2); 33023 ck_assert_ptr_eq(r, NULL); 33024 // json array 33025 // zip arrays 33026 // empty self 33027 freeO(self); 33028 array1->f->pushS(array1, "a"); 33029 r = zipCharO(self, array1, array2); 33030 ck_assert_ptr_ne(r, NULL); 33031 char *s = toStringO(r); 33032 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 33033 free(s); 33034 disposeO(array1); 33035 freen(array2); 33036 freeO(self); 33037 // add an element to self 33038 // array1 has 2 elements 33039 // array2 has 3 elements 33040 // only 2 elements are zipped 33041 self->f->pushS(self, "qwe"); 33042 array1->f->pushS(array1, "a"); 33043 array1->f->pushS(array1, "b"); 33044 array2 = listCreateS("1", "2", "3"); 33045 r = zipCharO(self, array1, array2); 33046 ck_assert_ptr_ne(r, NULL); 33047 s = toStringO(r); 33048 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33049 free(s); 33050 // delete the element not in self 33051 iListDelElemS(&array2, 2); 33052 // empty arrays 33053 iListRemoveS(&array2, 0, 2); 33054 r = zipCharO(self, array1, array2); 33055 ck_assert_ptr_ne(r, NULL); 33056 s = toStringO(r); 33057 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33058 free(s); 33059 disposeO(array1); 33060 r = zipCharO(self, array1, array2); 33061 ck_assert_ptr_ne(r, NULL); 33062 s = toStringO(r); 33063 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33064 free(s); 33065 free(array2); 33066 // array1 and array2 same element count 33067 array1->f->pushS(array1, "aa"); 33068 array1->f->pushS(array1, "bb"); 33069 array2 = listCreateS("11", "22"); 33070 delElemO(array1, 1); 33071 r = zipCharO(self, array1, array2); 33072 iListDelElemS(&array2, 1); 33073 ck_assert_ptr_ne(r, NULL); 33074 // some elements were zipped 33075 s = toStringO(self); 33076 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 33077 free(s); 33078 // but an element is NULL 33079 // non smallJson objects 33080 smashO(array1); 33081 array1 = (smallArrayt*) allocSmallInt(2); 33082 r = zipCharO(self, array1, array2); 33083 ck_assert_ptr_eq(r, NULL); 33084 terminateO(array1); 33085 array1 = allocSmallArray(); 33086 // NULL arrays 33087 r = zipCharO(self, NULL, array2); 33088 ck_assert_ptr_eq(r, NULL); 33089 r = zipCharO(self, array1, NULL); 33090 ck_assert_ptr_eq(r, NULL); 33091 terminateO(self); 33092 smashO(array1); 33093 free(array2); 33094 // json dict 33095 self = allocSmallJson(); 33096 smallArrayt *keys = allocSmallArray(); 33097 char** values; 33098 self->f->setInt(self, "", 1); 33099 // 3 elements in keys 33100 // 2 elements in values 33101 // only 2 key/values are zipped 33102 keys->f->pushS(keys, "a"); 33103 keys->f->pushS(keys, "b"); 33104 keys->f->pushS(keys, "c"); 33105 values = listCreateS("1", "2"); 33106 r = zipCharO(self, keys, values); 33107 terminateO(keys); 33108 listFreeS(values); 33109 ck_assert_ptr_ne(r, NULL); 33110 s = toStringO(r); 33111 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 33112 free(s); 33113 // keys array with non string objects 33114 keys = allocSmallArray(); 33115 keys->f->pushInt(keys, 1); 33116 values = listCreateS("1"); 33117 r = zipCharO(self, keys, values); 33118 ck_assert_ptr_eq(r, NULL); 33119 terminateO(keys); 33120 listFreeS(values); 33121 // empty values 33122 keys = allocSmallArray(); 33123 keys->f->pushInt(keys, 1); 33124 listEmptyS(values); 33125 r = zipCharO(self, keys, values); 33126 ck_assert_ptr_eq(r, self); 33127 terminateO(keys); 33128 listFreeS(values); 33129 terminateO(self); 33130 33131 } 33132 33133 33134 void zipCCharSmallJsonT(void) { 33135 33136 smallJsont* r; 33137 smallJsont *self = allocSmallJson(); 33138 smallArrayt *array1 = allocSmallArray(); 33139 const char* array2[] = {"1", "2", "3", null}; 33140 33141 // non json array or dict 33142 setTypeBoolO(self); 33143 r = zipCCharO(self, array1, array2); 33144 ck_assert_ptr_eq(r, NULL); 33145 // json array 33146 // zip arrays 33147 // empty self 33148 freeO(self); 33149 array1->f->pushS(array1, "a"); 33150 r = zipCCharO(self, array1, array2); 33151 ck_assert_ptr_ne(r, NULL); 33152 char *s = toStringO(r); 33153 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 33154 free(s); 33155 disposeO(array1); 33156 freeO(self); 33157 // add an element to self 33158 // array1 has 2 elements 33159 // array2 has 3 elements 33160 // only 2 elements are zipped 33161 self->f->pushS(self, "qwe"); 33162 array1->f->pushS(array1, "a"); 33163 array1->f->pushS(array1, "b"); 33164 r = zipCCharO(self, array1, array2); 33165 ck_assert_ptr_ne(r, NULL); 33166 s = toStringO(r); 33167 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33168 free(s); 33169 // empty arrays 33170 array2[0] = null; 33171 r = zipCCharO(self, array1, array2); 33172 ck_assert_ptr_ne(r, NULL); 33173 s = toStringO(r); 33174 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33175 free(s); 33176 disposeO(array1); 33177 array2[0] = "1"; 33178 r = zipCCharO(self, array1, array2); 33179 ck_assert_ptr_ne(r, NULL); 33180 s = toStringO(r); 33181 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33182 free(s); 33183 // array1 and array2 same element count 33184 array1->f->pushS(array1, "aa"); 33185 array1->f->pushS(array1, "bb"); 33186 array2[0] = "11"; 33187 array2[1] = "22"; 33188 array2[2] = null; 33189 delElemO(array1, 1); 33190 r = zipCCharO(self, array1, array2); 33191 ck_assert_ptr_ne(r, NULL); 33192 // some elements were zipped 33193 s = toStringO(self); 33194 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 33195 free(s); 33196 // but an element is NULL 33197 // non smallJson objects 33198 smashO(array1); 33199 array1 = (smallArrayt*) allocSmallInt(2); 33200 r = zipCCharO(self, array1, array2); 33201 ck_assert_ptr_eq(r, NULL); 33202 terminateO(array1); 33203 array1 = allocSmallArray(); 33204 // NULL arrays 33205 r = zipCCharO(self, NULL, array2); 33206 ck_assert_ptr_eq(r, NULL); 33207 r = zipCCharO(self, array1, NULL); 33208 ck_assert_ptr_eq(r, NULL); 33209 terminateO(self); 33210 smashO(array1); 33211 // json dict 33212 self = allocSmallJson(); 33213 smallArrayt *keys = allocSmallArray(); 33214 const char* values[] = {"1", "2", null}; 33215 self->f->setInt(self, "", 1); 33216 // 3 elements in keys 33217 // 2 elements in values 33218 // only 2 key/values are zipped 33219 keys->f->pushS(keys, "a"); 33220 keys->f->pushS(keys, "b"); 33221 keys->f->pushS(keys, "c"); 33222 r = zipCCharO(self, keys, values); 33223 terminateO(keys); 33224 ck_assert_ptr_ne(r, NULL); 33225 s = toStringO(r); 33226 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 33227 free(s); 33228 // keys array with non string objects 33229 keys = allocSmallArray(); 33230 keys->f->pushInt(keys, 1); 33231 r = zipCCharO(self, keys, values); 33232 ck_assert_ptr_eq(r, NULL); 33233 terminateO(keys); 33234 // empty values 33235 keys = allocSmallArray(); 33236 keys->f->pushInt(keys, 1); 33237 values[0] = null; 33238 r = zipCCharO(self, keys, values); 33239 ck_assert_ptr_eq(r, self); 33240 terminateO(keys); 33241 terminateO(self); 33242 33243 } 33244 33245 33246 void zipArrayCharSmallJsonT(void) { 33247 33248 smallJsont* r; 33249 smallJsont *self = allocSmallJson(); 33250 char** array1; 33251 char** array2; 33252 33253 // non json array or dict 33254 setTypeBoolO(self); 33255 array1 = listCreateS("a"); 33256 array2 = listCreateS("1"); 33257 r = zipArrayCharO(self, array1, array2); 33258 ck_assert_ptr_eq(r, NULL); 33259 // json array 33260 // zip arrays 33261 // empty self 33262 freeO(self); 33263 r = zipArrayCharO(self, array1, array2); 33264 ck_assert_ptr_ne(r, NULL); 33265 char *s = toStringO(r); 33266 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 33267 free(s); 33268 freen(array1); 33269 freen(array2); 33270 freeO(self); 33271 // add an element to self 33272 // array1 has 2 elements 33273 // array2 has 3 elements 33274 // only 2 elements are zipped 33275 self->f->pushS(self, "qwe"); 33276 array1 = listCreateS("a", "b"); 33277 array2 = listCreateS("1", "2", "3"); 33278 r = zipArrayCharO(self, array1, array2); 33279 ck_assert_ptr_ne(r, NULL); 33280 s = toStringO(r); 33281 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33282 free(s); 33283 // delete the element not in self 33284 iListDelElemS(&array2, 2); 33285 // empty arrays 33286 iListRemoveS(&array2, 0, 2); 33287 r = zipArrayCharO(self, array1, array2); 33288 ck_assert_ptr_ne(r, NULL); 33289 s = toStringO(r); 33290 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33291 free(s); 33292 iListRemoveS(&array1, 0, 2); 33293 r = zipArrayCharO(self, array1, array2); 33294 ck_assert_ptr_ne(r, NULL); 33295 s = toStringO(r); 33296 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33297 free(s); 33298 free(array1); 33299 free(array2); 33300 // array1 and array2 same element count 33301 array1 = listCreateS("aa", "bb"); 33302 array2 = listCreateS("11", "22"); 33303 iListDelElemS(&array1, 1); 33304 r = zipArrayCharO(self, array1, array2); 33305 iListDelElemS(&array2, 1); 33306 ck_assert_ptr_ne(r, NULL); 33307 // some elements were zipped 33308 s = toStringO(self); 33309 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 33310 free(s); 33311 // but an element is NULL 33312 // NULL arrays 33313 r = zipArrayCharO(self, NULL, array2); 33314 ck_assert_ptr_eq(r, NULL); 33315 r = zipArrayCharO(self, array1, NULL); 33316 ck_assert_ptr_eq(r, NULL); 33317 terminateO(self); 33318 free(array1); 33319 free(array2); 33320 // json dict 33321 self = allocSmallJson(); 33322 char** keys; 33323 char** values; 33324 self->f->setInt(self, "", 1); 33325 // 3 elements in keys 33326 // 2 elements in values 33327 // only 2 key/values are zipped 33328 keys = listCreateS("a", "b", "c"); 33329 values = listCreateS("1", "2"); 33330 r = zipArrayCharO(self, keys, values); 33331 listFreeS(keys); 33332 listFreeS(values); 33333 ck_assert_ptr_ne(r, NULL); 33334 s = toStringO(r); 33335 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 33336 free(s); 33337 // empty values 33338 keys = listCreateS("a", "b", "c"); 33339 listEmptyS(values); 33340 r = zipArrayCharO(self, keys, values); 33341 ck_assert_ptr_eq(r, self); 33342 listFreeS(keys); 33343 listFreeS(values); 33344 terminateO(self); 33345 33346 } 33347 33348 33349 void zipCArrayCharSmallJsonT(void) { 33350 33351 smallJsont* r; 33352 smallJsont *self = allocSmallJson(); 33353 const char* array1[] = {"a", "b", null}; 33354 char** array2; 33355 33356 // non json array or dict 33357 setTypeBoolO(self); 33358 array2 = listCreateS("1"); 33359 r = zipCArrayCharO(self, array1, array2); 33360 ck_assert_ptr_eq(r, NULL); 33361 // json array 33362 // zip arrays 33363 // empty self 33364 freeO(self); 33365 r = zipCArrayCharO(self, array1, array2); 33366 ck_assert_ptr_ne(r, NULL); 33367 char *s = toStringO(r); 33368 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 33369 free(s); 33370 freen(array2); 33371 freeO(self); 33372 // add an element to self 33373 // array1 has 2 elements 33374 // array2 has 3 elements 33375 // only 2 elements are zipped 33376 self->f->pushS(self, "qwe"); 33377 array2 = listCreateS("1", "2", "3"); 33378 r = zipCArrayCharO(self, array1, array2); 33379 ck_assert_ptr_ne(r, NULL); 33380 s = toStringO(r); 33381 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33382 free(s); 33383 // delete the element not in self 33384 iListDelElemS(&array2, 2); 33385 // empty arrays 33386 iListRemoveS(&array2, 0, 2); 33387 r = zipCArrayCharO(self, array1, array2); 33388 ck_assert_ptr_ne(r, NULL); 33389 s = toStringO(r); 33390 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33391 free(s); 33392 array1[0] = null; 33393 r = zipCArrayCharO(self, array1, array2); 33394 ck_assert_ptr_ne(r, NULL); 33395 s = toStringO(r); 33396 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33397 free(s); 33398 free(array2); 33399 // array1 and array2 same element count 33400 array1[0] = "aa"; 33401 array1[1] = null; 33402 array2 = listCreateS("11", "22"); 33403 r = zipCArrayCharO(self, array1, array2); 33404 iListDelElemS(&array2, 1); 33405 ck_assert_ptr_ne(r, NULL); 33406 // some elements were zipped 33407 s = toStringO(self); 33408 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 33409 free(s); 33410 // but an element is NULL 33411 // NULL arrays 33412 r = zipCArrayCharO(self, NULL, array2); 33413 ck_assert_ptr_eq(r, NULL); 33414 r = zipCArrayCharO(self, array1, NULL); 33415 ck_assert_ptr_eq(r, NULL); 33416 terminateO(self); 33417 free(array2); 33418 // json dict 33419 self = allocSmallJson(); 33420 const char* keys[] = {"a", "b", "c", null}; 33421 char** values; 33422 self->f->setInt(self, "", 1); 33423 // 3 elements in keys 33424 // 2 elements in values 33425 // only 2 key/values are zipped 33426 values = listCreateS("1", "2"); 33427 r = zipCArrayCharO(self, keys, values); 33428 listFreeS(values); 33429 ck_assert_ptr_ne(r, NULL); 33430 s = toStringO(r); 33431 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 33432 free(s); 33433 // empty values 33434 listEmptyS(values); 33435 r = zipCArrayCharO(self, keys, values); 33436 ck_assert_ptr_eq(r, self); 33437 listFreeS(values); 33438 terminateO(self); 33439 33440 } 33441 33442 33443 void zipArrayCCharSmallJsonT(void) { 33444 33445 smallJsont* r; 33446 smallJsont *self = allocSmallJson(); 33447 char** array1; 33448 const char* array2[] = {"1", "2", "3", null}; 33449 33450 // non json array or dict 33451 setTypeBoolO(self); 33452 array1 = listCreateS("a"); 33453 r = zipArrayCCharO(self, array1, array2); 33454 ck_assert_ptr_eq(r, NULL); 33455 // json array 33456 // zip arrays 33457 // empty self 33458 freeO(self); 33459 r = zipArrayCCharO(self, array1, array2); 33460 ck_assert_ptr_ne(r, NULL); 33461 char *s = toStringO(r); 33462 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 33463 free(s); 33464 freen(array1); 33465 freeO(self); 33466 // add an element to self 33467 // array1 has 2 elements 33468 // array2 has 3 elements 33469 // only 2 elements are zipped 33470 self->f->pushS(self, "qwe"); 33471 array1 = listCreateS("a", "b"); 33472 r = zipArrayCCharO(self, array1, array2); 33473 ck_assert_ptr_ne(r, NULL); 33474 s = toStringO(r); 33475 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33476 free(s); 33477 // empty arrays 33478 array2[0] = null; 33479 r = zipArrayCCharO(self, array1, array2); 33480 ck_assert_ptr_ne(r, NULL); 33481 s = toStringO(r); 33482 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33483 free(s); 33484 iListRemoveS(&array1, 0, 2); 33485 array2[0] = "11"; 33486 r = zipArrayCCharO(self, array1, array2); 33487 ck_assert_ptr_ne(r, NULL); 33488 s = toStringO(r); 33489 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33490 free(s); 33491 free(array1); 33492 // array1 and array2 same element count 33493 array1 = listCreateS("aa", "bb"); 33494 array2[1] = "22"; 33495 iListDelElemS(&array1, 1); 33496 r = zipArrayCCharO(self, array1, array2); 33497 ck_assert_ptr_ne(r, NULL); 33498 // some elements were zipped 33499 s = toStringO(self); 33500 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 33501 free(s); 33502 // but an element is NULL 33503 // NULL arrays 33504 r = zipArrayCCharO(self, NULL, array2); 33505 ck_assert_ptr_eq(r, NULL); 33506 r = zipArrayCCharO(self, array1, NULL); 33507 ck_assert_ptr_eq(r, NULL); 33508 terminateO(self); 33509 free(array1); 33510 // json dict 33511 self = allocSmallJson(); 33512 char** keys; 33513 const char* values[] = {"1", "2", null}; 33514 self->f->setInt(self, "", 1); 33515 // 3 elements in keys 33516 // 2 elements in values 33517 // only 2 key/values are zipped 33518 keys = listCreateS("a", "b", "c"); 33519 r = zipArrayCCharO(self, keys, values); 33520 listFreeS(keys); 33521 ck_assert_ptr_ne(r, NULL); 33522 s = toStringO(r); 33523 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 33524 free(s); 33525 // empty values 33526 keys = listCreateS("a", "b", "c"); 33527 values[0] = null; 33528 r = zipArrayCCharO(self, keys, values); 33529 ck_assert_ptr_eq(r, self); 33530 listFreeS(keys); 33531 terminateO(self); 33532 33533 } 33534 33535 33536 void zipCArrayCCharSmallJsonT(void) { 33537 33538 smallJsont* r; 33539 smallJsont *self = allocSmallJson(); 33540 const char* array1[] = {"a", "b", null}; 33541 const char* array2[] = {"1", "2", "3", null}; 33542 33543 // non json array or dict 33544 setTypeBoolO(self); 33545 r = zipCArrayCCharO(self, array1, array2); 33546 ck_assert_ptr_eq(r, NULL); 33547 // json array 33548 // zip arrays 33549 // empty self 33550 freeO(self); 33551 array1[1] = null; 33552 r = zipCArrayCCharO(self, array1, array2); 33553 ck_assert_ptr_ne(r, NULL); 33554 char *s = toStringO(r); 33555 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 33556 free(s); 33557 freeO(self); 33558 // add an element to self 33559 // array1 has 2 elements 33560 // array2 has 3 elements 33561 // only 2 elements are zipped 33562 self->f->pushS(self, "qwe"); 33563 array1[1] = "b"; 33564 r = zipCArrayCCharO(self, array1, array2); 33565 ck_assert_ptr_ne(r, NULL); 33566 s = toStringO(r); 33567 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33568 free(s); 33569 // empty arrays 33570 array2[0] = null; 33571 r = zipCArrayCCharO(self, array1, array2); 33572 ck_assert_ptr_ne(r, NULL); 33573 s = toStringO(r); 33574 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33575 free(s); 33576 array1[0] = null; 33577 array2[0] = "11"; 33578 r = zipCArrayCCharO(self, array1, array2); 33579 ck_assert_ptr_ne(r, NULL); 33580 s = toStringO(r); 33581 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33582 free(s); 33583 // array1 and array2 same element count 33584 array1[0] = "aa"; 33585 array1[1] = null; 33586 array2[1] = "22"; 33587 r = zipCArrayCCharO(self, array1, array2); 33588 ck_assert_ptr_ne(r, NULL); 33589 // some elements were zipped 33590 s = toStringO(self); 33591 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 33592 free(s); 33593 // but an element is NULL 33594 // NULL arrays 33595 r = zipCArrayCCharO(self, NULL, array2); 33596 ck_assert_ptr_eq(r, NULL); 33597 r = zipCArrayCCharO(self, array1, NULL); 33598 ck_assert_ptr_eq(r, NULL); 33599 terminateO(self); 33600 // json dict 33601 self = allocSmallJson(); 33602 const char* keys[] = {"a", "b", "c", null}; 33603 const char* values[] = {"1", "2", null}; 33604 self->f->setInt(self, "", 1); 33605 // 3 elements in keys 33606 // 2 elements in values 33607 // only 2 key/values are zipped 33608 r = zipCArrayCCharO(self, keys, values); 33609 ck_assert_ptr_ne(r, NULL); 33610 s = toStringO(r); 33611 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 33612 free(s); 33613 // empty values 33614 values[0] = null; 33615 r = zipCArrayCCharO(self, keys, values); 33616 ck_assert_ptr_eq(r, self); 33617 terminateO(self); 33618 33619 } 33620 33621 33622 void zipJsonSmallJsonT(void) { 33623 33624 smallJsont* r; 33625 smallJsont *self = allocSmallJson(); 33626 smallJsont *keys = allocSmallJson(); 33627 smallJsont *values = allocSmallJson(); 33628 33629 // non json array or dict 33630 setTypeBoolO(self); 33631 r = self->f->zipJson(self, keys, values); 33632 ck_assert_ptr_eq(r, NULL); 33633 freeO(self); 33634 // json array 33635 smallJsont *array1 = allocSmallJson(); 33636 smallJsont *array2 = allocSmallJson(); 33637 // zip arrays 33638 // empty self 33639 array1->f->pushS(array1, "a"); 33640 array2->f->pushInt(array2, 1); 33641 r = self->f->zipJson(self, array1, array2); 33642 ck_assert_ptr_ne(r, NULL); 33643 char *s = toStringO(r); 33644 ck_assert_str_eq(s, "[[\"a\",1]]"); 33645 free(s); 33646 disposeO(array1); 33647 disposeO(array2); 33648 freeO(self); 33649 // add an element to self 33650 // array1 has 2 elements 33651 // array2 has 3 elements 33652 // only 2 elements are zipped 33653 self->f->pushS(self, "qwe"); 33654 array1->f->pushS(array1, "a"); 33655 array1->f->pushS(array1, "b"); 33656 array2->f->pushInt(array2, 1); 33657 array2->f->pushInt(array2, 2); 33658 array2->f->pushInt(array2, 3); 33659 r = self->f->zipJson(self, array1, array2); 33660 ck_assert_ptr_ne(r, NULL); 33661 s = toStringO(r); 33662 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 33663 free(s); 33664 // delete the element not in self 33665 delElemIndexO(array2, 2); 33666 // empty arrays 33667 disposeO(array1); 33668 r = self->f->zipJson(self, array1, array2); 33669 ck_assert_ptr_eq(r, NULL); 33670 disposeO(array2); 33671 array1->f->pushS(array1, "a"); 33672 r = self->f->zipJson(self, array1, array2); 33673 ck_assert_ptr_eq(r, NULL); 33674 array2->f->pushInt(array2, 1); 33675 delElemIndexO(array2, 0); 33676 r = self->f->zipJson(self, array1, array2); 33677 ck_assert_ptr_ne(r, NULL); 33678 s = toStringO(r); 33679 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"a\"]]"); 33680 free(s); 33681 disposeO(array1); 33682 trimO(array2); 33683 // array1 and array2 same element count 33684 array1->f->pushS(array1, "aa"); 33685 array1->f->pushS(array1, "bb"); 33686 array2->f->pushInt(array2, 11); 33687 array2->f->pushInt(array2, 22); 33688 delElemIndexO(array1, 1); 33689 r = self->f->zipJson(self, array1, array2); 33690 delElemIndexO(array2, 1); 33691 ck_assert_ptr_ne(r, NULL); 33692 // some elements were zipped 33693 s = toStringO(self); 33694 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"a\"],[\"aa\",11]]"); 33695 free(s); 33696 // but an element is NULL 33697 // non smallJson objects 33698 smashO(array1); 33699 array1 = (smallJsont*) allocSmallInt(2); 33700 r = self->f->zipJson(self, array1, array2); 33701 ck_assert_ptr_eq(r, NULL); 33702 terminateO(array1); 33703 array1 = allocSmallJson(); 33704 smashO(array2); 33705 array2 = (smallJsont*) allocSmallInt(2); 33706 r = self->f->zipJson(self, array1, array2); 33707 ck_assert_ptr_eq(r, NULL); 33708 terminateO(array2); 33709 array2 = allocSmallJson(); 33710 // NULL arrays 33711 r = self->f->zipJson(self, NULL, array2); 33712 ck_assert_ptr_eq(r, NULL); 33713 r = self->f->zipJson(self, array1, NULL); 33714 ck_assert_ptr_eq(r, NULL); 33715 terminateO(self); 33716 smashO(array1); 33717 smashO(array2); 33718 // json dict 33719 self = allocSmallJson(); 33720 // zip arrays 33721 self->f->setInt(self, "", 1); 33722 // 3 elements in keys 33723 // 2 elements in values 33724 // only 2 key/values are zipped 33725 keys->f->pushS(keys, "a"); 33726 keys->f->pushS(keys, "b"); 33727 keys->f->pushS(keys, "c"); 33728 values->f->pushInt(values, 1); 33729 values->f->pushInt(values, 2); 33730 r = self->f->zipJson(self, keys, values); 33731 terminateO(keys); 33732 smashO(values); 33733 ck_assert_ptr_ne(r, NULL); 33734 s = toStringO(r); 33735 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 33736 free(s); 33737 // keys array with non string objects 33738 keys = allocSmallJson(); 33739 values = allocSmallJson(); 33740 keys->f->pushInt(keys, 1); 33741 values->f->pushInt(values, 1); 33742 r = self->f->zipJson(self, keys, values); 33743 ck_assert_ptr_eq(r, NULL); 33744 terminateO(keys); 33745 terminateO(values); 33746 // empty values 33747 keys = allocSmallJson(); 33748 values = allocSmallJson(); 33749 keys->f->pushInt(keys, 1); 33750 values->f->pushInt(values, 1); 33751 delElemIndexO(values, 0); 33752 trimO(values); 33753 r = self->f->zipJson(self, keys, values); 33754 ck_assert_ptr_eq(r, self); 33755 terminateO(keys); 33756 // non json array keys 33757 keys = allocSmallJson(); 33758 setTopIntO(keys, 1); 33759 r = self->f->zipJson(self, keys, values); 33760 ck_assert_ptr_eq(r, null); 33761 terminateO(keys); 33762 // non json array values 33763 keys = allocSmallJson(); 33764 keys->f->pushInt(keys, 1); 33765 freeO(values); 33766 setTopIntO(values, 1); 33767 r = self->f->zipJson(self, keys, values); 33768 ck_assert_ptr_eq(r, null); 33769 terminateO(keys); 33770 terminateO(values); 33771 // non smallJson object 33772 keys = (smallJsont*) allocSmallInt(1); 33773 values = allocSmallJson(); 33774 r = self->f->zipJson(self, keys, values); 33775 ck_assert_ptr_eq(r, null); 33776 terminateO(keys); 33777 keys = allocSmallJson(); 33778 terminateO(values); 33779 values = (smallJsont*) allocSmallInt(2); 33780 r = self->f->zipJson(self, keys, values); 33781 ck_assert_ptr_eq(r, null); 33782 // null 33783 r = self->f->zipJson(self, null, values); 33784 ck_assert_ptr_eq(r, null); 33785 r = self->f->zipJson(self, keys, null); 33786 ck_assert_ptr_eq(r, null); 33787 terminateO(keys); 33788 terminateO(values); 33789 terminateO(self); 33790 33791 } 33792 33793 33794 void zipJsonSmallArraySmallJsonT(void) { 33795 33796 smallJsont* r; 33797 smallJsont *self = allocSmallJson(); 33798 smallJsont *keys = allocSmallJson(); 33799 smallArrayt *values = allocSmallArray(); 33800 smallJsont *array1 = allocSmallJson(); 33801 smallArrayt *array2 = allocSmallArray(); 33802 33803 // non json array or dict 33804 setTypeBoolO(self); 33805 r = self->f->zipJsonSmallArray(self, array1, array2); 33806 ck_assert_ptr_eq(r, NULL); 33807 // json array 33808 // zip arrays 33809 // empty self 33810 freeO(self); 33811 array1->f->pushS(array1, "a"); 33812 array2->f->pushInt(array2, 1); 33813 r = self->f->zipJsonSmallArray(self, array1, array2); 33814 ck_assert_ptr_ne(r, NULL); 33815 char *s = toStringO(r); 33816 ck_assert_str_eq(s, "[[\"a\",1]]"); 33817 free(s); 33818 disposeO(array1); 33819 disposeO(array2); 33820 freeO(self); 33821 // add an element to self 33822 // array1 has 2 elements 33823 // array2 has 3 elements 33824 // only 2 elements are zipped 33825 self->f->pushS(self, "qwe"); 33826 array1->f->pushS(array1, "a"); 33827 array1->f->pushS(array1, "b"); 33828 array2->f->pushInt(array2, 1); 33829 array2->f->pushInt(array2, 2); 33830 array2->f->pushInt(array2, 3); 33831 r = self->f->zipJsonSmallArray(self, array1, array2); 33832 ck_assert_ptr_ne(r, NULL); 33833 s = toStringO(r); 33834 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 33835 free(s); 33836 // delete the element not in self 33837 delElemO(array2, 2); 33838 // empty arrays 33839 disposeO(array2); 33840 r = self->f->zipJsonSmallArray(self, array1, array2); 33841 ck_assert_ptr_ne(r, NULL); 33842 s = toStringO(r); 33843 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 33844 free(s); 33845 disposeO(array1); 33846 setTypeArrayO(array1); 33847 r = self->f->zipJsonSmallArray(self, array1, array2); 33848 ck_assert_ptr_ne(r, NULL); 33849 s = toStringO(r); 33850 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 33851 free(s); 33852 // array1 and array2 same element count 33853 array1->f->pushS(array1, "aa"); 33854 array1->f->pushS(array1, "bb"); 33855 array2->f->pushInt(array2, 11); 33856 array2->f->pushInt(array2, 22); 33857 delElemIndexO(array1, 1); 33858 r = self->f->zipJsonSmallArray(self, array1, array2); 33859 delElemO(array2, 1); 33860 ck_assert_ptr_ne(r, NULL); 33861 // some elements were zipped 33862 s = toStringO(self); 33863 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"aa\",11]]"); 33864 free(s); 33865 // but an element is NULL 33866 // non smallArray objects 33867 smashO(array1); 33868 array1 = (smallJsont*) allocSmallInt(2); 33869 r = self->f->zipJsonSmallArray(self, array1, array2); 33870 ck_assert_ptr_eq(r, NULL); 33871 terminateO(array1); 33872 array1 = allocSmallJson(); 33873 setTypeArrayO(array1); 33874 smashO(array2); 33875 array2 = (smallArrayt*) allocSmallInt(2); 33876 r = self->f->zipJsonSmallArray(self, array1, array2); 33877 ck_assert_ptr_eq(r, NULL); 33878 terminateO(array2); 33879 array2 = allocSmallArray(); 33880 // NULL arrays 33881 r = self->f->zipJsonSmallArray(self, NULL, array2); 33882 ck_assert_ptr_eq(r, NULL); 33883 r = self->f->zipJsonSmallArray(self, array1, NULL); 33884 ck_assert_ptr_eq(r, NULL); 33885 terminateO(self); 33886 smashO(array1); 33887 smashO(array2); 33888 // json dict 33889 self = allocSmallJson(); 33890 self->f->setInt(self, "", 1); 33891 // 3 elements in keys 33892 // 2 elements in values 33893 // only 2 key/values are zipped 33894 keys->f->pushS(keys, "a"); 33895 keys->f->pushS(keys, "b"); 33896 keys->f->pushS(keys, "c"); 33897 values->f->pushInt(values, 1); 33898 values->f->pushInt(values, 2); 33899 r = self->f->zipJsonSmallArray(self, keys, values); 33900 terminateO(keys); 33901 smashO(values); 33902 ck_assert_ptr_ne(r, NULL); 33903 s = toStringO(r); 33904 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 33905 free(s); 33906 // keys array with non string objects 33907 keys = allocSmallJson(); 33908 values = allocSmallArray(); 33909 keys->f->pushInt(keys, 1); 33910 values->f->pushInt(values, 1); 33911 r = self->f->zipJsonSmallArray(self, keys, values); 33912 ck_assert_ptr_eq(r, NULL); 33913 terminateO(keys); 33914 terminateO(values); 33915 // empty values 33916 keys = allocSmallJson(); 33917 values = allocSmallArray(); 33918 keys->f->pushInt(keys, 1); 33919 r = self->f->zipJsonSmallArray(self, keys, values); 33920 ck_assert_ptr_eq(r, self); 33921 terminateO(keys); 33922 // non json array keys 33923 keys = allocSmallJson(); 33924 setTopIntO(keys, 1); 33925 r = self->f->zipJsonSmallArray(self, keys, values); 33926 ck_assert_ptr_eq(r, null); 33927 terminateO(keys); 33928 // non smallArray object 33929 keys = (smallJsont*) allocSmallInt(1); 33930 r = self->f->zipJsonSmallArray(self, keys, values); 33931 ck_assert_ptr_eq(r, null); 33932 terminateO(keys); 33933 keys = allocSmallJson(); 33934 terminateO(values); 33935 values = (smallArrayt*) allocSmallInt(2); 33936 r = self->f->zipJsonSmallArray(self, keys, values); 33937 ck_assert_ptr_eq(r, null); 33938 // null 33939 r = self->f->zipJsonSmallArray(self, null, values); 33940 ck_assert_ptr_eq(r, null); 33941 r = self->f->zipJsonSmallArray(self, keys, null); 33942 ck_assert_ptr_eq(r, null); 33943 terminateO(keys); 33944 terminateO(values); 33945 terminateO(self); 33946 33947 } 33948 33949 33950 void zipJsonArraySmallJsonT(void) { 33951 33952 smallJsont* r; 33953 smallJsont *self = allocSmallJson(); 33954 smallJsont *keys = allocSmallJson(); 33955 char** values; 33956 smallJsont *array1 = allocSmallJson(); 33957 char** array2; 33958 33959 // non json array or dict 33960 setTypeBoolO(self); 33961 setTypeArrayO(array1); 33962 array2 = listCreateS("1"); 33963 r = self->f->zipJsonArray(self, array1, array2); 33964 ck_assert_ptr_eq(r, NULL); 33965 // json array 33966 // zip arrays 33967 // empty self 33968 freeO(self); 33969 array1->f->pushS(array1, "a"); 33970 r = self->f->zipJsonArray(self, array1, array2); 33971 ck_assert_ptr_ne(r, NULL); 33972 char *s = toStringO(r); 33973 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 33974 free(s); 33975 disposeO(array1); 33976 freen(array2); 33977 freeO(self); 33978 // add an element to self 33979 // array1 has 2 elements 33980 // array2 has 3 elements 33981 // only 2 elements are zipped 33982 self->f->pushS(self, "qwe"); 33983 array1->f->pushS(array1, "a"); 33984 array1->f->pushS(array1, "b"); 33985 array2 = listCreateS("1", "2", "3"); 33986 r = self->f->zipJsonArray(self, array1, array2); 33987 ck_assert_ptr_ne(r, NULL); 33988 s = toStringO(r); 33989 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33990 free(s); 33991 // delete the element not in self 33992 iListDelElemS(&array2, 2); 33993 // empty arrays 33994 iListRemoveS(&array2, 0, 2); 33995 r = self->f->zipJsonArray(self, array1, array2); 33996 ck_assert_ptr_ne(r, NULL); 33997 s = toStringO(r); 33998 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 33999 free(s); 34000 disposeO(array1); 34001 setTypeArrayO(array1); 34002 r = self->f->zipJsonArray(self, array1, array2); 34003 ck_assert_ptr_ne(r, NULL); 34004 s = toStringO(r); 34005 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 34006 free(s); 34007 free(array2); 34008 // array1 and array2 same element count 34009 array1->f->pushS(array1, "aa"); 34010 array1->f->pushS(array1, "bb"); 34011 array2 = listCreateS("11", "22"); 34012 delElemIndexO(array1, 1); 34013 r = self->f->zipJsonArray(self, array1, array2); 34014 iListDelElemS(&array2, 1); 34015 ck_assert_ptr_ne(r, NULL); 34016 // some elements were zipped 34017 s = toStringO(self); 34018 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 34019 free(s); 34020 // but an element is NULL 34021 // non smallJson objects 34022 smashO(array1); 34023 array1 = (smallJsont*) allocSmallInt(2); 34024 r = self->f->zipJsonArray(self, array1, array2); 34025 ck_assert_ptr_eq(r, NULL); 34026 terminateO(array1); 34027 array1 = allocSmallJson(); 34028 setTypeArrayO(array1); 34029 // NULL arrays 34030 r = self->f->zipJsonArray(self, NULL, array2); 34031 ck_assert_ptr_eq(r, NULL); 34032 r = self->f->zipJsonArray(self, array1, NULL); 34033 ck_assert_ptr_eq(r, NULL); 34034 terminateO(self); 34035 smashO(array1); 34036 free(array2); 34037 // json dict 34038 self = allocSmallJson(); 34039 self->f->setInt(self, "", 1); 34040 // 3 elements in keys 34041 // 2 elements in values 34042 // only 2 key/values are zipped 34043 keys->f->pushS(keys, "a"); 34044 keys->f->pushS(keys, "b"); 34045 keys->f->pushS(keys, "c"); 34046 values = listCreateS("1", "2"); 34047 r = self->f->zipJsonArray(self, keys, values); 34048 terminateO(keys); 34049 listFreeS(values); 34050 ck_assert_ptr_ne(r, NULL); 34051 s = toStringO(r); 34052 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 34053 free(s); 34054 // keys array with non string objects 34055 keys = allocSmallJson(); 34056 keys->f->pushInt(keys, 1); 34057 values = listCreateS("1"); 34058 r = self->f->zipJsonArray(self, keys, values); 34059 ck_assert_ptr_eq(r, NULL); 34060 terminateO(keys); 34061 listFreeS(values); 34062 // empty values 34063 keys = allocSmallJson(); 34064 keys->f->pushInt(keys, 1); 34065 listEmptyS(values); 34066 r = self->f->zipJsonArray(self, keys, values); 34067 ck_assert_ptr_eq(r, self); 34068 terminateO(keys); 34069 // non json array keys 34070 keys = allocSmallJson(); 34071 setTopIntO(keys, 1); 34072 r = self->f->zipJsonArray(self, keys, values); 34073 ck_assert_ptr_eq(r, null); 34074 terminateO(keys); 34075 // non smallArray object 34076 keys = (smallJsont*) allocSmallInt(1); 34077 r = self->f->zipJsonArray(self, keys, values); 34078 ck_assert_ptr_eq(r, null); 34079 terminateO(keys); 34080 keys = allocSmallJson(); 34081 // null 34082 r = self->f->zipJsonArray(self, null, values); 34083 ck_assert_ptr_eq(r, null); 34084 r = self->f->zipJsonArray(self, keys, null); 34085 ck_assert_ptr_eq(r, null); 34086 terminateO(keys); 34087 listFreeS(values); 34088 terminateO(self); 34089 34090 } 34091 34092 34093 void zipJsonCArraySmallJsonT(void) { 34094 34095 smallJsont* r; 34096 smallJsont *self = allocSmallJson(); 34097 smallJsont *keys = allocSmallJson(); 34098 const char* values[] = {"1", "2", null}; 34099 smallJsont *array1 = allocSmallJson(); 34100 const char* array2[] = {"1", "2", "3", null}; 34101 34102 // non json array or dict 34103 setTypeBoolO(self); 34104 setTypeArrayO(array1); 34105 r = self->f->zipJsonCArray(self, array1, array2); 34106 ck_assert_ptr_eq(r, NULL); 34107 // json array 34108 // zip arrays 34109 // empty self 34110 freeO(self); 34111 array1->f->pushS(array1, "a"); 34112 r = self->f->zipJsonCArray(self, array1, array2); 34113 ck_assert_ptr_ne(r, NULL); 34114 char *s = toStringO(r); 34115 ck_assert_str_eq(s, "[[\"a\",\"1\"]]"); 34116 free(s); 34117 disposeO(array1); 34118 freeO(self); 34119 // add an element to self 34120 // array1 has 2 elements 34121 // array2 has 3 elements 34122 // only 2 elements are zipped 34123 self->f->pushS(self, "qwe"); 34124 array1->f->pushS(array1, "a"); 34125 array1->f->pushS(array1, "b"); 34126 r = self->f->zipJsonCArray(self, array1, array2); 34127 ck_assert_ptr_ne(r, NULL); 34128 s = toStringO(r); 34129 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 34130 free(s); 34131 // empty arrays 34132 array2[0] = null; 34133 r = self->f->zipJsonCArray(self, array1, array2); 34134 ck_assert_ptr_ne(r, NULL); 34135 s = toStringO(r); 34136 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 34137 free(s); 34138 disposeO(array1); 34139 setTypeArrayO(array1); 34140 array2[0] = "11"; 34141 r = self->f->zipJsonCArray(self, array1, array2); 34142 ck_assert_ptr_ne(r, NULL); 34143 s = toStringO(r); 34144 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 34145 free(s); 34146 // array1 and array2 same element count 34147 array1->f->pushS(array1, "aa"); 34148 array1->f->pushS(array1, "bb"); 34149 array2[1] = "22"; 34150 delElemIndexO(array1, 1); 34151 r = self->f->zipJsonCArray(self, array1, array2); 34152 ck_assert_ptr_ne(r, NULL); 34153 // some elements were zipped 34154 s = toStringO(self); 34155 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"],[\"aa\",\"11\"]]"); 34156 free(s); 34157 // but an element is NULL 34158 // non smallJson objects 34159 smashO(array1); 34160 array1 = (smallJsont*) allocSmallInt(2); 34161 r = self->f->zipJsonCArray(self, array1, array2); 34162 ck_assert_ptr_eq(r, NULL); 34163 terminateO(array1); 34164 array1 = allocSmallJson(); 34165 setTypeArrayO(array1); 34166 // NULL arrays 34167 r = self->f->zipJsonCArray(self, NULL, array2); 34168 ck_assert_ptr_eq(r, NULL); 34169 r = self->f->zipJsonCArray(self, array1, NULL); 34170 ck_assert_ptr_eq(r, NULL); 34171 terminateO(self); 34172 smashO(array1); 34173 // json dict 34174 self = allocSmallJson(); 34175 self->f->setInt(self, "", 1); 34176 // 3 elements in keys 34177 // 2 elements in values 34178 // only 2 key/values are zipped 34179 keys->f->pushS(keys, "a"); 34180 keys->f->pushS(keys, "b"); 34181 keys->f->pushS(keys, "c"); 34182 r = self->f->zipJsonCArray(self, keys, values); 34183 terminateO(keys); 34184 ck_assert_ptr_ne(r, NULL); 34185 s = toStringO(r); 34186 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 34187 free(s); 34188 // keys array with non string objects 34189 keys = allocSmallJson(); 34190 keys->f->pushInt(keys, 1); 34191 r = self->f->zipJsonCArray(self, keys, values); 34192 ck_assert_ptr_eq(r, NULL); 34193 terminateO(keys); 34194 // empty values 34195 keys = allocSmallJson(); 34196 keys->f->pushInt(keys, 1); 34197 values[0] = null; 34198 r = self->f->zipJsonCArray(self, keys, values); 34199 ck_assert_ptr_eq(r, self); 34200 values[0] = "1"; 34201 terminateO(keys); 34202 // non json array keys 34203 keys = allocSmallJson(); 34204 setTopIntO(keys, 1); 34205 r = self->f->zipJsonCArray(self, keys, values); 34206 ck_assert_ptr_eq(r, null); 34207 terminateO(keys); 34208 // non smallArray object 34209 keys = (smallJsont*) allocSmallInt(1); 34210 r = self->f->zipJsonCArray(self, keys, values); 34211 ck_assert_ptr_eq(r, null); 34212 terminateO(keys); 34213 keys = allocSmallJson(); 34214 // null 34215 r = self->f->zipJsonCArray(self, null, values); 34216 ck_assert_ptr_eq(r, null); 34217 r = self->f->zipJsonCArray(self, keys, null); 34218 ck_assert_ptr_eq(r, null); 34219 terminateO(keys); 34220 terminateO(self); 34221 34222 } 34223 34224 34225 void zipSmallArrayJsonSmallJsonT(void) { 34226 34227 smallJsont* r; 34228 smallJsont *self = allocSmallJson(); 34229 smallArrayt *keys = allocSmallArray(); 34230 smallJsont *values = allocSmallJson(); 34231 34232 // non json array or dict 34233 setTypeBoolO(self); 34234 r = self->f->zipSmallArrayJson(self, keys, values); 34235 ck_assert_ptr_eq(r, NULL); 34236 freeO(self); 34237 // json array 34238 smallArrayt *array1 = allocSmallArray(); 34239 smallJsont *array2 = allocSmallJson(); 34240 // zip arrays 34241 // empty self 34242 array1->f->pushS(array1, "a"); 34243 array2->f->pushInt(array2, 1); 34244 r = self->f->zipSmallArrayJson(self, array1, array2); 34245 ck_assert_ptr_ne(r, NULL); 34246 char *s = toStringO(r); 34247 ck_assert_str_eq(s, "[[\"a\",1]]"); 34248 free(s); 34249 disposeO(array1); 34250 disposeO(array2); 34251 freeO(self); 34252 // add an element to self 34253 // array1 has 2 elements 34254 // array2 has 3 elements 34255 // only 2 elements are zipped 34256 self->f->pushS(self, "qwe"); 34257 array1->f->pushS(array1, "a"); 34258 array1->f->pushS(array1, "b"); 34259 array2->f->pushInt(array2, 1); 34260 array2->f->pushInt(array2, 2); 34261 array2->f->pushInt(array2, 3); 34262 r = self->f->zipSmallArrayJson(self, array1, array2); 34263 ck_assert_ptr_ne(r, NULL); 34264 s = toStringO(r); 34265 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34266 free(s); 34267 // delete the element not in self 34268 delElemIndexO(array2, 2); 34269 // empty arrays 34270 disposeO(array1); 34271 r = self->f->zipSmallArrayJson(self, array1, array2); 34272 ck_assert_ptr_ne(r, NULL); 34273 s = toStringO(r); 34274 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34275 free(s); 34276 disposeO(array2); 34277 array1->f->pushS(array1, "a"); 34278 r = self->f->zipSmallArrayJson(self, array1, array2); 34279 ck_assert_ptr_eq(r, NULL); 34280 array2->f->pushInt(array2, 1); 34281 delElemIndexO(array2, 0); 34282 r = self->f->zipSmallArrayJson(self, array1, array2); 34283 ck_assert_ptr_ne(r, NULL); 34284 s = toStringO(r); 34285 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"a\"]]"); 34286 free(s); 34287 disposeO(array1); 34288 trimO(array2); 34289 // array1 and array2 same element count 34290 array1->f->pushS(array1, "aa"); 34291 array1->f->pushS(array1, "bb"); 34292 array2->f->pushInt(array2, 11); 34293 array2->f->pushInt(array2, 22); 34294 delElemO(array1, 1); 34295 r = self->f->zipSmallArrayJson(self, array1, array2); 34296 delElemIndexO(array2, 1); 34297 ck_assert_ptr_ne(r, NULL); 34298 // some elements were zipped 34299 s = toStringO(self); 34300 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"a\"],[\"aa\",11]]"); 34301 free(s); 34302 // but an element is NULL 34303 // non smallJson objects 34304 smashO(array1); 34305 array1 = (smallArrayt*) allocSmallInt(2); 34306 r = self->f->zipSmallArrayJson(self, array1, array2); 34307 ck_assert_ptr_eq(r, NULL); 34308 terminateO(array1); 34309 array1 = allocSmallArray(); 34310 smashO(array2); 34311 array2 = (smallJsont*) allocSmallInt(2); 34312 r = self->f->zipSmallArrayJson(self, array1, array2); 34313 ck_assert_ptr_eq(r, NULL); 34314 terminateO(array2); 34315 array2 = allocSmallJson(); 34316 // NULL arrays 34317 r = self->f->zipSmallArrayJson(self, NULL, array2); 34318 ck_assert_ptr_eq(r, NULL); 34319 r = self->f->zipSmallArrayJson(self, array1, NULL); 34320 ck_assert_ptr_eq(r, NULL); 34321 terminateO(self); 34322 smashO(array1); 34323 smashO(array2); 34324 // json dict 34325 self = allocSmallJson(); 34326 // zip arrays 34327 self->f->setInt(self, "", 1); 34328 // 3 elements in keys 34329 // 2 elements in values 34330 // only 2 key/values are zipped 34331 keys->f->pushS(keys, "a"); 34332 keys->f->pushS(keys, "b"); 34333 keys->f->pushS(keys, "c"); 34334 values->f->pushInt(values, 1); 34335 values->f->pushInt(values, 2); 34336 r = self->f->zipSmallArrayJson(self, keys, values); 34337 terminateO(keys); 34338 smashO(values); 34339 ck_assert_ptr_ne(r, NULL); 34340 s = toStringO(r); 34341 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 34342 free(s); 34343 // keys array with non string objects 34344 keys = allocSmallArray(); 34345 values = allocSmallJson(); 34346 keys->f->pushInt(keys, 1); 34347 values->f->pushInt(values, 1); 34348 r = self->f->zipSmallArrayJson(self, keys, values); 34349 ck_assert_ptr_eq(r, NULL); 34350 terminateO(keys); 34351 terminateO(values); 34352 // empty values 34353 keys = allocSmallArray(); 34354 values = allocSmallJson(); 34355 keys->f->pushInt(keys, 1); 34356 values->f->pushInt(values, 1); 34357 delElemIndexO(values, 0); 34358 trimO(values); 34359 r = self->f->zipSmallArrayJson(self, keys, values); 34360 ck_assert_ptr_eq(r, self); 34361 terminateO(keys); 34362 // non smallArray object 34363 keys = (smallArrayt*) allocSmallInt(1); 34364 r = self->f->zipSmallArrayJson(self, keys, values); 34365 ck_assert_ptr_eq(r, null); 34366 terminateO(keys); 34367 keys = allocSmallArray(); 34368 terminateO(values); 34369 // non json array 34370 values = allocSmallJson(); 34371 setTopIntO(values, 1); 34372 r = self->f->zipSmallArrayJson(self, keys, values); 34373 ck_assert_ptr_eq(r, null); 34374 terminateO(values); 34375 // non smallJson values 34376 values = (smallJsont*) allocSmallInt(2); 34377 r = self->f->zipSmallArrayJson(self, keys, values); 34378 ck_assert_ptr_eq(r, null); 34379 // null 34380 r = self->f->zipSmallArrayJson(self, null, values); 34381 ck_assert_ptr_eq(r, null); 34382 r = self->f->zipSmallArrayJson(self, keys, null); 34383 ck_assert_ptr_eq(r, null); 34384 terminateO(keys); 34385 terminateO(values); 34386 terminateO(self); 34387 34388 } 34389 34390 34391 void zipArrayJsonSmallJsonT(void) { 34392 34393 smallJsont* r; 34394 smallJsont *self = allocSmallJson(); 34395 char** keys; 34396 smallJsont *values = allocSmallJson(); 34397 char** array1; 34398 smallJsont *array2 = allocSmallJson(); 34399 34400 // non json array or dict 34401 setTypeBoolO(self); 34402 array1 = listCreateS("a"); 34403 r = self->f->zipArrayJson(self, array1, array2); 34404 ck_assert_ptr_eq(r, NULL); 34405 // json array 34406 // zip arrays 34407 // empty self 34408 freeO(self); 34409 array2->f->pushInt(array2, 1); 34410 r = self->f->zipArrayJson(self, array1, array2); 34411 ck_assert_ptr_ne(r, NULL); 34412 char *s = toStringO(r); 34413 ck_assert_str_eq(s, "[[\"a\",1]]"); 34414 free(s); 34415 freen(array1); 34416 disposeO(array2); 34417 freeO(self); 34418 // add an element to self 34419 // array1 has 2 elements 34420 // array2 has 3 elements 34421 // only 2 elements are zipped 34422 self->f->pushS(self, "qwe"); 34423 array1 = listCreateS("a", "b"); 34424 array2->f->pushInt(array2, 1); 34425 array2->f->pushInt(array2, 2); 34426 array2->f->pushInt(array2, 3); 34427 r = self->f->zipArrayJson(self, array1, array2); 34428 ck_assert_ptr_ne(r, NULL); 34429 s = toStringO(r); 34430 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34431 free(s); 34432 // delete the element not in self 34433 delElemIndexO(array2, 2); 34434 // empty arrays 34435 disposeO(array2); 34436 setTypeArrayO(array2); 34437 r = self->f->zipArrayJson(self, array1, array2); 34438 ck_assert_ptr_ne(r, NULL); 34439 s = toStringO(r); 34440 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34441 free(s); 34442 iListRemoveS(&array1, 0, 2); 34443 r = self->f->zipArrayJson(self, array1, array2); 34444 free(array1); 34445 ck_assert_ptr_ne(r, NULL); 34446 s = toStringO(r); 34447 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34448 free(s); 34449 // array1 and array2 same element count 34450 array1 = listCreateS("aa", "bb"); 34451 array2->f->pushInt(array2, 11); 34452 array2->f->pushInt(array2, 22); 34453 iListDelElemS(&array1, 1); 34454 r = self->f->zipArrayJson(self, array1, array2); 34455 delElemIndexO(array2, 1); 34456 ck_assert_ptr_ne(r, NULL); 34457 // some elements were zipped 34458 s = toStringO(self); 34459 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"aa\",11]]"); 34460 free(s); 34461 // but an element is NULL 34462 // non smallArray objects 34463 smashO(array2); 34464 array2 = (smallJsont*) allocSmallInt(2); 34465 r = self->f->zipArrayJson(self, array1, array2); 34466 ck_assert_ptr_eq(r, NULL); 34467 terminateO(array2); 34468 array2 = allocSmallJson(); 34469 // NULL arrays 34470 r = self->f->zipArrayJson(self, NULL, array2); 34471 ck_assert_ptr_eq(r, NULL); 34472 r = self->f->zipArrayJson(self, array1, NULL); 34473 ck_assert_ptr_eq(r, NULL); 34474 terminateO(self); 34475 free(array1); 34476 smashO(array2); 34477 // json dict 34478 self = allocSmallJson(); 34479 self->f->setInt(self, "", 1); 34480 // 3 elements in keys 34481 // 2 elements in values 34482 // only 2 key/values are zipped 34483 keys = listCreateS("a", "b", "c"); 34484 values->f->pushInt(values, 1); 34485 values->f->pushInt(values, 2); 34486 r = self->f->zipArrayJson(self, keys, values); 34487 listFreeS(keys); 34488 smashO(values); 34489 ck_assert_ptr_ne(r, NULL); 34490 s = toStringO(r); 34491 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 34492 free(s); 34493 // empty values 34494 keys = listCreateS("a"); 34495 values = allocSmallJson(); 34496 values->f->pushInt(values, 1); 34497 delElemIndexO(values, 0); 34498 trimO(values); 34499 r = self->f->zipArrayJson(self, keys, values); 34500 ck_assert_ptr_eq(r, self); 34501 terminateO(values); 34502 // non json array 34503 values = allocSmallJson(); 34504 setTopIntO(values, 1); 34505 r = self->f->zipArrayJson(self, keys, values); 34506 ck_assert_ptr_eq(r, null); 34507 terminateO(values); 34508 // non smallJson values 34509 values = (smallJsont*) allocSmallInt(2); 34510 r = self->f->zipArrayJson(self, keys, values); 34511 ck_assert_ptr_eq(r, null); 34512 // null 34513 r = self->f->zipArrayJson(self, null, values); 34514 ck_assert_ptr_eq(r, null); 34515 r = self->f->zipArrayJson(self, keys, null); 34516 ck_assert_ptr_eq(r, null); 34517 listFreeS(keys); 34518 terminateO(values); 34519 terminateO(self); 34520 34521 } 34522 34523 34524 void zipCArrayJsonSmallJsonT(void) { 34525 34526 smallJsont* r; 34527 smallJsont *self = allocSmallJson(); 34528 const char* keys[] = {"a", "b", "c", null}; 34529 smallJsont *values = allocSmallJson(); 34530 const char* array1[] = {"a", "b", null}; 34531 smallJsont *array2 = allocSmallJson(); 34532 34533 // non json array or dict 34534 setTypeBoolO(self); 34535 r = self->f->zipCArrayJson(self, array1, array2); 34536 ck_assert_ptr_eq(r, NULL); 34537 // json array 34538 // zip arrays 34539 // empty self 34540 freeO(self); 34541 array2->f->pushInt(array2, 1); 34542 r = self->f->zipCArrayJson(self, array1, array2); 34543 ck_assert_ptr_ne(r, NULL); 34544 char *s = toStringO(r); 34545 ck_assert_str_eq(s, "[[\"a\",1]]"); 34546 free(s); 34547 disposeO(array2); 34548 freeO(self); 34549 // add an element to self 34550 // array1 has 2 elements 34551 // array2 has 3 elements 34552 // only 2 elements are zipped 34553 self->f->pushS(self, "qwe"); 34554 array2->f->pushInt(array2, 1); 34555 array2->f->pushInt(array2, 2); 34556 array2->f->pushInt(array2, 3); 34557 r = self->f->zipCArrayJson(self, array1, array2); 34558 ck_assert_ptr_ne(r, NULL); 34559 s = toStringO(r); 34560 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34561 free(s); 34562 // delete the element not in self 34563 delElemIndexO(array2, 2); 34564 // empty arrays 34565 disposeO(array2); 34566 setTypeArrayO(array2); 34567 r = self->f->zipCArrayJson(self, array1, array2); 34568 ck_assert_ptr_ne(r, NULL); 34569 s = toStringO(r); 34570 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34571 free(s); 34572 array1[0] = null; 34573 r = self->f->zipCArrayJson(self, array1, array2); 34574 ck_assert_ptr_ne(r, NULL); 34575 s = toStringO(r); 34576 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 34577 free(s); 34578 // array1 and array2 same element count 34579 array1[0] = "aa"; 34580 array1[1] = null; 34581 array2->f->pushInt(array2, 11); 34582 array2->f->pushInt(array2, 22); 34583 r = self->f->zipCArrayJson(self, array1, array2); 34584 delElemIndexO(array2, 1); 34585 ck_assert_ptr_ne(r, NULL); 34586 // some elements were zipped 34587 s = toStringO(self); 34588 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2],[\"aa\",11]]"); 34589 free(s); 34590 // but an element is NULL 34591 // non smallArray objects 34592 smashO(array2); 34593 array2 = (smallJsont*) allocSmallInt(2); 34594 r = self->f->zipCArrayJson(self, array1, array2); 34595 ck_assert_ptr_eq(r, NULL); 34596 terminateO(array2); 34597 array2 = allocSmallJson(); 34598 // NULL arrays 34599 r = self->f->zipCArrayJson(self, NULL, array2); 34600 ck_assert_ptr_eq(r, NULL); 34601 r = self->f->zipCArrayJson(self, array1, NULL); 34602 ck_assert_ptr_eq(r, NULL); 34603 terminateO(self); 34604 smashO(array2); 34605 // json dict 34606 self = allocSmallJson(); 34607 self->f->setInt(self, "", 1); 34608 // 3 elements in keys 34609 // 2 elements in values 34610 // only 2 key/values are zipped 34611 values->f->pushInt(values, 1); 34612 values->f->pushInt(values, 2); 34613 r = self->f->zipCArrayJson(self, keys, values); 34614 smashO(values); 34615 ck_assert_ptr_ne(r, NULL); 34616 s = toStringO(r); 34617 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 34618 free(s); 34619 // empty values 34620 values = allocSmallJson(); 34621 values->f->pushInt(values, 1); 34622 delElemIndexO(values, 0); 34623 trimO(values); 34624 r = self->f->zipCArrayJson(self, keys, values); 34625 ck_assert_ptr_eq(r, self); 34626 terminateO(values); 34627 // non json array 34628 values = allocSmallJson(); 34629 setTopIntO(values, 1); 34630 r = self->f->zipCArrayJson(self, keys, values); 34631 ck_assert_ptr_eq(r, null); 34632 terminateO(values); 34633 // non smallJson values 34634 values = (smallJsont*) allocSmallInt(2); 34635 r = self->f->zipCArrayJson(self, keys, values); 34636 ck_assert_ptr_eq(r, null); 34637 // null 34638 r = self->f->zipCArrayJson(self, null, values); 34639 ck_assert_ptr_eq(r, null); 34640 r = self->f->zipCArrayJson(self, keys, null); 34641 ck_assert_ptr_eq(r, null); 34642 terminateO(values); 34643 terminateO(self); 34644 34645 } 34646 34647 34648 void iterStartSmallJsonT(void) { 34649 34650 baset* r; 34651 smallJsont *self = allocSmallJson(); 34652 34653 // non json array or dict 34654 setTypeBoolO(self); 34655 r = iterStartO(self); 34656 ck_assert_ptr_eq(r, NULL); 34657 freeO(self); 34658 // json array 34659 // array with sObjects 34660 self->f->pushUndefined(self); 34661 self->f->pushBool(self, true); 34662 r = iterStartO(self); 34663 ck_assert_ptr_ne(r, NULL); 34664 ck_assert(isOUndefined(r)); 34665 // start again 34666 r = iterStartO(self); 34667 ck_assert_ptr_ne(r, NULL); 34668 ck_assert(isOUndefined(r)); 34669 // array with objects from other classes 34670 emptyO(self); 34671 createAllocateSmallInt(ip); 34672 ip->type = "anothertype"; 34673 setValG(ip, 11); 34674 smallJsont *r2 = self->f->push(self, (baset*)ip); 34675 ck_assert_ptr_ne(r2, NULL); 34676 r = iterStartO(self); 34677 ck_assert_ptr_ne(r, NULL); 34678 // array with all deleted elements 34679 emptyO(self); 34680 self->f->pushUndefined(self); 34681 delElemIndexO(self, 0); 34682 r = iterStartO(self); 34683 ck_assert_ptr_eq(r, NULL); 34684 // empty array 34685 emptyO(self); 34686 r = iterStartO(self); 34687 ck_assert_ptr_eq(r, NULL); 34688 terminateO(self); 34689 // json dict 34690 self = allocSmallJson(); 34691 // dict with keys and values 34692 self->f->setInt(self, "a", 1); 34693 self->f->setInt(self, "b", 2); 34694 r = iterStartO(self); 34695 ck_assert_ptr_ne(r, NULL); 34696 ck_assert(isOSmallInt(r)); 34697 // dict with objects from other classes 34698 emptyO(self); 34699 ip = allocSmallInt(2); 34700 ip->type = "anothertype"; 34701 self->f->set(self, "d", (baset*)ip); 34702 r = iterStartO(self); 34703 ck_assert_ptr_ne(r, NULL); 34704 // dict with deleted elements 34705 self->f->setInt(self, "a", 1); 34706 self->f->delElem(self, "d"); 34707 r = iterStartO(self); 34708 ck_assert_ptr_ne(r, NULL); 34709 // call iterStart again to trigger if (self->iterElementDataType != SH_DT_BASET) finishO(self->iterElement); 34710 r = iterStartO(self); 34711 ck_assert_ptr_ne(r, NULL); 34712 // empty self 34713 emptyO(self); 34714 r = iterStartO(self); 34715 ck_assert_ptr_eq(r, NULL); 34716 emptyO(self); 34717 r = iterStartO(self); 34718 ck_assert_ptr_eq(r, NULL); 34719 terminateO(self); 34720 34721 } 34722 34723 34724 void iterStartKeySmallJsonT(void) { 34725 34726 const char* r; 34727 smallJsont *self = allocSmallJson(); 34728 34729 // non json dict 34730 r = iterStartKeyO(self); 34731 ck_assert_ptr_eq(r, NULL); 34732 // json dict 34733 // dict with keys and values 34734 self->f->setInt(self, "a", 1); 34735 self->f->setInt(self, "b", 2); 34736 r = iterStartKeyO(self); 34737 ck_assert_ptr_ne(r, NULL); 34738 ck_assert_str_eq(r, "a"); 34739 // dict with objects from other classes 34740 emptyO(self); 34741 smallIntt *ip = allocSmallInt(2); 34742 ip->type = "anothertype"; 34743 self->f->set(self, "d", (baset*)ip); 34744 r = iterStartKeyO(self); 34745 ck_assert_ptr_ne(r, NULL); 34746 ck_assert_str_eq(r, "d"); 34747 // dict with deleted elements 34748 self->f->setInt(self, "a", 1); 34749 self->f->delElem(self, "d"); 34750 r = iterStartKeyO(self); 34751 ck_assert_ptr_ne(r, NULL); 34752 ck_assert_str_eq(r, "a"); 34753 // call iterStart again to trigger if (self->iterElementDataType != SH_DT_BASET) finishO(self->iterElement); 34754 r = iterStartKeyO(self); 34755 ck_assert_ptr_ne(r, NULL); 34756 ck_assert_str_eq(r, "a"); 34757 // empty self 34758 emptyO(self); 34759 r = iterStartKeyO(self); 34760 ck_assert_ptr_eq(r, NULL); 34761 terminateO(self); 34762 34763 } 34764 34765 34766 void iterStartLastSmallJsonT(void) { 34767 34768 baset* r; 34769 smallJsont *self = allocSmallJson(); 34770 34771 // non json array 34772 r = iterStartLastO(self); 34773 ck_assert_ptr_eq(r, NULL); 34774 // array with sObjects 34775 self->f->pushUndefined(self); 34776 self->f->pushBool(self, true); 34777 r = iterStartLastO(self); 34778 ck_assert_ptr_ne(r, NULL); 34779 ck_assert(isOSmallBool(r)); 34780 // start again 34781 r = iterStartLastO(self); 34782 ck_assert_ptr_ne(r, NULL); 34783 ck_assert(isOSmallBool(r)); 34784 // array with objects from other classes 34785 emptyO(self); 34786 createAllocateSmallInt(ip); 34787 ip->type = "anothertype"; 34788 setValG(ip, 11); 34789 smallJsont *r2 = self->f->push(self, (baset*)ip); 34790 ck_assert_ptr_ne(r2, NULL); 34791 r = iterStartLastO(self); 34792 ck_assert_ptr_ne(r, NULL); 34793 ck_assert(isOType(r, "anothertype")); 34794 // array with all deleted elements 34795 emptyO(self); 34796 self->f->pushUndefined(self); 34797 delElemIndexO(self, 0); 34798 r = iterStartLastO(self); 34799 ck_assert_ptr_eq(r, NULL); 34800 // empty array 34801 emptyO(self); 34802 r = iterStartLastO(self); 34803 ck_assert_ptr_eq(r, NULL); 34804 terminateO(self); 34805 34806 } 34807 34808 34809 void iterStartFromSmallJsonT(void) { 34810 34811 baset* r; 34812 smallJsont *self = allocSmallJson(); 34813 34814 // non json array 34815 r = iterStartFromO(self, 0); 34816 ck_assert_ptr_eq(r, NULL); 34817 // array with sObjects 34818 self->f->pushUndefined(self); 34819 self->f->pushBool(self, true); 34820 r = iterStartFromO(self, 1); 34821 ck_assert_ptr_ne(r, NULL); 34822 ck_assert(isOSmallBool(r)); 34823 // start again 34824 r = iterStartFromO(self, 1); 34825 ck_assert_ptr_ne(r, NULL); 34826 ck_assert(isOSmallBool(r)); 34827 // array with objects from other classes 34828 emptyO(self); 34829 self->f->pushUndefined(self); 34830 createAllocateSmallInt(ip); 34831 ip->type = "anothertype"; 34832 setValG(ip, 11); 34833 smallJsont *r2 = self->f->push(self, (baset*)ip); 34834 ck_assert_ptr_ne(r2, NULL); 34835 r = iterStartFromO(self, -1); 34836 ck_assert_ptr_ne(r, NULL); 34837 ck_assert(isOType(r, "anothertype")); 34838 // index outside array 34839 r = iterStartFromO(self, 2); 34840 ck_assert_ptr_eq(r, NULL); 34841 r = iterStartFromO(self, -3); 34842 ck_assert_ptr_eq(r, NULL); 34843 // array with all deleted elements 34844 // except the ones before the start index 34845 emptyO(self); 34846 self->f->pushUndefined(self); 34847 self->f->pushUndefined(self); 34848 self->f->pushUndefined(self); 34849 delElemIndexO(self, 1); 34850 delElemIndexO(self, 2); 34851 r = iterStartFromO(self, 1); 34852 ck_assert_ptr_eq(r, NULL); 34853 // array with all deleted elements 34854 emptyO(self); 34855 self->f->pushUndefined(self); 34856 self->f->pushUndefined(self); 34857 self->f->pushUndefined(self); 34858 delElemIndexO(self, 0); 34859 delElemIndexO(self, 1); 34860 delElemIndexO(self, 2); 34861 r = iterStartFromO(self, 1); 34862 ck_assert_ptr_eq(r, NULL); 34863 // empty array 34864 emptyO(self); 34865 r = iterStartFromO(self, 1); 34866 ck_assert_ptr_eq(r, NULL); 34867 terminateO(self); 34868 34869 } 34870 34871 34872 void iterStartFromStepSmallJsonT(void) { 34873 34874 baset* r; 34875 smallJsont *self = allocSmallJson(); 34876 34877 // non json array 34878 r = iterStartFromStepO(self, 0, 1); 34879 ck_assert_ptr_eq(r, NULL); 34880 // array with sObjects 34881 self->f->pushUndefined(self); 34882 self->f->pushBool(self, true); 34883 r = iterStartFromStepO(self, 1, 2); 34884 ck_assert_ptr_ne(r, NULL); 34885 ck_assert(isOSmallBool(r)); 34886 // start again 34887 r = iterStartFromStepO(self, 1, 2); 34888 ck_assert_ptr_ne(r, NULL); 34889 ck_assert(isOSmallBool(r)); 34890 // array with objects from other classes 34891 emptyO(self); 34892 self->f->pushUndefined(self); 34893 createAllocateSmallInt(ip); 34894 ip->type = "anothertype"; 34895 setValG(ip, 11); 34896 smallJsont *r2 = self->f->push(self, (baset*)ip); 34897 ck_assert_ptr_ne(r2, NULL); 34898 r = iterStartFromStepO(self, -1, 2); 34899 ck_assert_ptr_ne(r, NULL); 34900 ck_assert(isOType(r, "anothertype")); 34901 // index outside array 34902 r = iterStartFromStepO(self, 2, 1); 34903 ck_assert_ptr_eq(r, NULL); 34904 r = iterStartFromStepO(self, -3, 1); 34905 ck_assert_ptr_eq(r, NULL); 34906 // array with all deleted elements 34907 // except the ones before the start index 34908 emptyO(self); 34909 self->f->pushUndefined(self); 34910 self->f->pushUndefined(self); 34911 self->f->pushUndefined(self); 34912 delElemIndexO(self, 1); 34913 delElemIndexO(self, 2); 34914 r = iterStartFromStepO(self, 1, 1); 34915 ck_assert_ptr_eq(r, NULL); 34916 // negative step 34917 r = iterStartFromStepO(self, 1, -1); 34918 ck_assert_ptr_ne(r, NULL); 34919 ck_assert(isOUndefined(r)); 34920 // array with all deleted elements 34921 emptyO(self); 34922 self->f->pushUndefined(self); 34923 self->f->pushUndefined(self); 34924 self->f->pushUndefined(self); 34925 delElemIndexO(self, 0); 34926 delElemIndexO(self, 1); 34927 delElemIndexO(self, 2); 34928 r = iterStartFromStepO(self, 1, 2); 34929 ck_assert_ptr_eq(r, NULL); 34930 // empty array 34931 emptyO(self); 34932 r = iterStartFromStepO(self, 1, 1); 34933 ck_assert_ptr_eq(r, NULL); 34934 // step 0 34935 self->f->pushUndefined(self); 34936 r = iterStartFromStepO(self, 0, 0); 34937 ck_assert_ptr_eq(r, NULL); 34938 terminateO(self); 34939 34940 } 34941 34942 34943 void iterNextSmallJsonT(void) { 34944 34945 baset* r; 34946 smallJsont *self = allocSmallJson(); 34947 34948 // json array 34949 // array with sObjects 34950 self->f->pushUndefined(self); 34951 self->f->pushBool(self, true); 34952 r = iterStartO(self); 34953 ck_assert_ptr_ne(r, NULL); 34954 ck_assert(isOUndefined(r)); 34955 r = iterNextO(self); 34956 ck_assert(isOSmallBool(r)); 34957 // array with objects from other classes 34958 emptyO(self); 34959 createAllocateSmallInt(ip); 34960 ip->type = "anothertype"; 34961 setValG(ip, 11); 34962 smallJsont *r2 = self->f->push(self, (baset*)ip); 34963 ck_assert_ptr_ne(r2, NULL); 34964 createAllocateSmallInt(ip2); 34965 ip2->type = "anothertype2"; 34966 setValG(ip2, 11); 34967 r2 = self->f->push(self, (baset*)ip2); 34968 ck_assert_ptr_ne(r2, NULL); 34969 r = iterStartO(self); 34970 ck_assert_ptr_ne(r, NULL); 34971 ck_assert(isOType(r, "anothertype")); 34972 r = iterNextO(self); 34973 ck_assert_ptr_ne(r, NULL); 34974 ck_assert_str_eq(r->type, "anothertype2"); 34975 // iteration ended 34976 r = iterNextO(self); 34977 ck_assert_ptr_eq(r, NULL); 34978 // array with all deleted elements 34979 emptyO(self); 34980 self->f->pushUndefined(self); 34981 delElemIndexO(self, 0); 34982 r = iterStartO(self); 34983 ck_assert_ptr_eq(r, NULL); 34984 // empty array 34985 emptyO(self); 34986 r = iterStartO(self); 34987 ck_assert_ptr_eq(r, NULL); 34988 // empty array, uninitialized iterator 34989 emptyO(self); 34990 r = iterNextO(self); 34991 ck_assert_ptr_eq(r, NULL); 34992 terminateO(self); 34993 // json dict 34994 self = allocSmallJson(); 34995 // dict with keys and values 34996 self->f->setInt(self, "a", 1); 34997 self->f->setInt(self, "b", 2); 34998 r = iterStartO(self); 34999 ck_assert_ptr_ne(r, NULL); 35000 ck_assert(isOSmallInt(r)); 35001 smallIntt *i = (smallIntt*)r; 35002 ck_assert_int_eq(getValO(i), 1); 35003 r = iterNextO(self); 35004 ck_assert_ptr_ne(r, NULL); 35005 ck_assert(isOSmallInt(r)); 35006 i = (smallIntt*)r; 35007 ck_assert_int_eq(getValO(i), 2); 35008 // dict with objects from other classes 35009 emptyO(self); 35010 ip = allocSmallInt(2); 35011 ip->type = "anothertype"; 35012 self->f->set(self, "d", (baset*)ip); 35013 self->f->setInt(self, "a", 1); 35014 ip = allocSmallInt(3); 35015 ip->type = "anothertype2"; 35016 self->f->set(self, "e", (baset*)ip); 35017 self->f->setInt(self, "b", 2); 35018 self->f->delElem(self, "a"); 35019 self->f->delElem(self, "b"); 35020 r = iterStartO(self); 35021 ck_assert_ptr_ne(r, NULL); 35022 ck_assert(isOType(r, "anothertype")); 35023 r = iterNextO(self); 35024 ck_assert_ptr_ne(r, NULL); 35025 ck_assert(isOType(r, "anothertype2")); 35026 // iteration ended 35027 r = iterNextO(self); 35028 ck_assert_ptr_eq(r, NULL); 35029 // empty self, uninitialized iterator 35030 emptyO(self); 35031 r = iterNextO(self); 35032 ck_assert_ptr_eq(r, NULL); 35033 terminateO(self); 35034 35035 } 35036 35037 35038 void iterNextKeySmallJsonT(void) { 35039 35040 const char* r; 35041 smallJsont *self = allocSmallJson(); 35042 35043 // non json dict 35044 r = iterNextKeyO(self); 35045 ck_assert_ptr_eq(r, NULL); 35046 // json dict 35047 // dict with keys and values 35048 self->f->setInt(self, "a", 1); 35049 self->f->setInt(self, "b", 2); 35050 r = iterStartKeyO(self); 35051 ck_assert_ptr_ne(r, NULL); 35052 ck_assert_str_eq(r, "a"); 35053 r = iterNextKeyO(self); 35054 ck_assert_ptr_ne(r, NULL); 35055 ck_assert_str_eq(r, "b"); 35056 // dict with objects from other classes 35057 emptyO(self); 35058 smallIntt *ip = allocSmallInt(2); 35059 ip->type = "anothertype"; 35060 self->f->set(self, "d", (baset*)ip); 35061 self->f->setInt(self, "a", 1); 35062 ip = allocSmallInt(3); 35063 ip->type = "anothertype2"; 35064 self->f->set(self, "e", (baset*)ip); 35065 self->f->setInt(self, "b", 2); 35066 self->f->delElem(self, "a"); 35067 self->f->delElem(self, "b"); 35068 r = iterStartKeyO(self); 35069 ck_assert_ptr_ne(r, NULL); 35070 ck_assert_str_eq(r, "d"); 35071 r = iterNextKeyO(self); 35072 ck_assert_ptr_ne(r, NULL); 35073 ck_assert_str_eq(r, "e"); 35074 // iteration ended 35075 r = iterNextKeyO(self); 35076 ck_assert_ptr_eq(r, NULL); 35077 // empty self 35078 emptyO(self); 35079 r = iterNextKeyO(self); 35080 ck_assert_ptr_eq(r, NULL); 35081 terminateO(self); 35082 35083 } 35084 35085 35086 void iterElementSmallJsonT(void) { 35087 35088 baset* r; 35089 smallJsont *self = allocSmallJson(); 35090 35091 // start iteration 35092 self->f->pushUndefined(self); 35093 r = iterStartO(self); 35094 ck_assert_ptr_ne(r, NULL); 35095 baset *r2 = iterElementO(self); 35096 ck_assert_ptr_eq(r, r2); 35097 ck_assert_str_eq(r->type, "undefined"); 35098 // end iteration 35099 r = iterNextO(self); 35100 ck_assert_ptr_eq(r, NULL); 35101 r = iterElementO(self); 35102 ck_assert_ptr_eq(r, NULL); 35103 terminateO(self); 35104 35105 } 35106 35107 35108 void iterKeySmallJsonT(void) { 35109 35110 const char* r; 35111 smallJsont *self = allocSmallJson(); 35112 35113 self->f->setInt(self, "a", 1); 35114 baset *r2 = iterStartO(self); 35115 ck_assert_ptr_ne(r2, NULL); 35116 r = iterKeyO(self); 35117 ck_assert_ptr_ne(r, NULL); 35118 ck_assert_str_eq(r, "a"); 35119 // empty self 35120 freeO(self); 35121 r = iterKeyO(self); 35122 ck_assert_ptr_eq(r, NULL); 35123 terminateO(self); 35124 35125 } 35126 35127 35128 void iterIndexSmallJsonT(void) { 35129 35130 ssize_t r; 35131 baset* r2; 35132 smallJsont *self = allocSmallJson(); 35133 35134 // start iteration 35135 self->f->pushUndefined(self); 35136 r2 = iterStartO(self); 35137 ck_assert_ptr_ne(r2, NULL); 35138 ck_assert_str_eq(r2->type, "undefined"); 35139 r = iterIndexO(self); 35140 ck_assert_int_eq(r, 0); 35141 // end iteration 35142 r2 = iterNextO(self); 35143 ck_assert_ptr_eq(r2, NULL); 35144 r = iterIndexO(self); 35145 ck_assert_int_eq(r, -1); 35146 // empty self 35147 freeO(self); 35148 r = iterIndexO(self); 35149 ck_assert_int_eq(r, -1); 35150 terminateO(self); 35151 35152 } 35153 35154 35155 void iterStepSmallJsonT(void) { 35156 35157 int64_t r; 35158 baset* r2; 35159 smallJsont *self = allocSmallJson(); 35160 35161 // start iteration 35162 self->f->pushUndefined(self); 35163 r2 = iterStartO(self); 35164 ck_assert_ptr_ne(r2, NULL); 35165 ck_assert_str_eq(r2->type, "undefined"); 35166 r = iterStepO(self); 35167 ck_assert_int_eq(r, 1); 35168 // start iterator twice and 35169 // set step 35170 r2 =iterStartFromStepO(self, 0, 10); 35171 ck_assert_ptr_ne(r2, NULL); 35172 ck_assert_str_eq(r2->type, "undefined"); 35173 r = iterStepO(self); 35174 ck_assert_int_eq(r, 10); 35175 // empty self 35176 freeO(self); 35177 r = iterStepO(self); 35178 ck_assert_int_eq(r, -1); 35179 terminateO(self); 35180 35181 } 35182 35183 35184 void getUndefinedSmallJsonT(void) { 35185 35186 undefinedt* r; 35187 smallJsont *self = allocSmallJson(); 35188 35189 smallJsont *r2 = self->f->setUndefined(self, "1"); 35190 ck_assert_ptr_ne(r2, null); 35191 r = self->f->getUndefined(self, "1"); 35192 ck_assert_ptr_ne(r, null); 35193 finishO(r); 35194 // path 35195 createSmallArray(a); 35196 createSmallDict(d); 35197 a.f->pushDict(&a, &d); 35198 self->f->setArray(self, "array", &a); 35199 r2 = self->f->setUndefined(self, "\"array\"[0].\"key\""); 35200 ck_assert_ptr_ne(r2, null); 35201 r = self->f->getUndefined(self, "\"array\"[0].\"key\""); 35202 ck_assert_ptr_ne(r, null); 35203 finishO(r); 35204 // json bool 35205 freeO(self); 35206 setTypeBoolO(self); 35207 r = self->f->getUndefined(self, "1"); 35208 ck_assert_ptr_eq(r, null); 35209 // json array 35210 freeO(self); 35211 setTypeArrayO(self); 35212 r = self->f->getUndefined(self, "1"); 35213 ck_assert_ptr_eq(r, null); 35214 // non existing dict path 35215 freeO(self); 35216 r = self->f->getUndefined(self, "\"1\"[1]"); 35217 ck_assert_ptr_eq(r, null); 35218 // dict path but the object is an array 35219 resetO(&a); 35220 self->f->setArray(self, "1", &a); 35221 r = self->f->getUndefined(self, "\"1\".\"1\""); 35222 ck_assert_ptr_eq(r, null); 35223 // dict object in path but the key doesn't exists 35224 resetO(&d); 35225 self->f->setDict(self, "2", &d); 35226 r = self->f->getUndefined(self, "\"2\".\"1\".[12]"); 35227 ck_assert_ptr_eq(r, null); 35228 // non undefined object 35229 r2 = self->f->setInt(self, "1", 2); 35230 ck_assert_ptr_ne(r2, null); 35231 r = self->f->getUndefined(self, "1"); 35232 ck_assert_ptr_eq(r, null); 35233 // null key 35234 r = self->f->getUndefined(self, null); 35235 ck_assert_ptr_eq(r, null); 35236 // empty self 35237 freeO(self); 35238 r = self->f->getUndefined(self, "1"); 35239 ck_assert_ptr_eq(r, null); 35240 terminateO(self); 35241 35242 } 35243 35244 35245 void getBoolSmallJsonT(void) { 35246 35247 bool r; 35248 smallJsont *self = allocSmallJson(); 35249 35250 smallJsont *r2 = self->f->setBool(self, "1", true); 35251 ck_assert_ptr_ne(r2, null); 35252 r = self->f->getBool(self, "1"); 35253 ck_assert(r); 35254 // non bool object 35255 r2 = self->f->setInt(self, "1", 2); 35256 ck_assert_ptr_ne(r2, null); 35257 r = self->f->getBool(self, "1"); 35258 ck_assert(!r); 35259 // null key 35260 r = self->f->getBool(self, null); 35261 ck_assert(!r); 35262 // empty self 35263 freeO(self); 35264 r = self->f->getBool(self, "1"); 35265 ck_assert(!r); 35266 terminateO(self); 35267 35268 } 35269 35270 35271 void getBoolPSmallJsonT(void) { 35272 35273 bool* r; 35274 smallJsont *self = allocSmallJson(); 35275 35276 smallJsont *r2 = self->f->setBool(self, "1", true); 35277 ck_assert_ptr_ne(r2, null); 35278 r = self->f->getBoolP(self, "1"); 35279 ck_assert_ptr_ne(r, null); 35280 ck_assert(*r); 35281 // non bool object 35282 r2 = self->f->setInt(self, "1", 2); 35283 ck_assert_ptr_ne(r2, null); 35284 r = self->f->getBoolP(self, "1"); 35285 ck_assert_ptr_eq(r, null); 35286 // null key 35287 r = self->f->getBoolP(self, null); 35288 ck_assert_ptr_eq(r, null); 35289 // empty self 35290 freeO(self); 35291 r = self->f->getBoolP(self, "1"); 35292 ck_assert_ptr_eq(r, null); 35293 terminateO(self); 35294 35295 } 35296 35297 35298 void getDoubleSmallJsonT(void) { 35299 35300 double r; 35301 smallJsont *self = allocSmallJson(); 35302 35303 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 35304 ck_assert_ptr_ne(r2, null); 35305 r = self->f->getDouble(self, "1"); 35306 ck_assert(r == 2.2); 35307 // non double object 35308 r2 = self->f->setInt(self, "1", 2); 35309 ck_assert_ptr_ne(r2, null); 35310 r = self->f->getDouble(self, "1"); 35311 ck_assert(r == 0); 35312 // null key 35313 r = self->f->getDouble(self, null); 35314 ck_assert(!r); 35315 // empty self 35316 freeO(self); 35317 r = self->f->getDouble(self, "1"); 35318 ck_assert(!r); 35319 terminateO(self); 35320 35321 } 35322 35323 35324 void getDoublePSmallJsonT(void) { 35325 35326 double* r; 35327 smallJsont *self = allocSmallJson(); 35328 35329 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 35330 ck_assert_ptr_ne(r2, null); 35331 r = self->f->getDoubleP(self, "1"); 35332 ck_assert_ptr_ne(r, null); 35333 ck_assert(*r == 2.2); 35334 // non double object 35335 r2 = self->f->setInt(self, "1", 2); 35336 ck_assert_ptr_ne(r2, null); 35337 r = self->f->getDoubleP(self, "1"); 35338 ck_assert_ptr_eq(r, null); 35339 // null key 35340 r = self->f->getDoubleP(self, null); 35341 ck_assert_ptr_eq(r, null); 35342 // empty self 35343 freeO(self); 35344 r = self->f->getDoubleP(self, "1"); 35345 ck_assert_ptr_eq(r, null); 35346 terminateO(self); 35347 35348 } 35349 35350 35351 void getIntSmallJsonT(void) { 35352 35353 int64_t r; 35354 smallJsont *self = allocSmallJson(); 35355 35356 smallJsont *r2 = self->f->setInt(self, "1", 2); 35357 ck_assert_ptr_ne(r2, null); 35358 r = self->f->getInt(self, "1"); 35359 ck_assert_int_eq(r, 2); 35360 // non int object 35361 r2 = self->f->setBool(self, "1", true); 35362 ck_assert_ptr_ne(r2, null); 35363 r = self->f->getInt(self, "1"); 35364 ck_assert(!r); 35365 // null key 35366 r = self->f->getInt(self, null); 35367 ck_assert(!r); 35368 // empty self 35369 freeO(self); 35370 r = self->f->getInt(self, "1"); 35371 ck_assert(!r); 35372 terminateO(self); 35373 35374 } 35375 35376 35377 void getIntPSmallJsonT(void) { 35378 35379 int64_t* r; 35380 smallJsont *self = allocSmallJson(); 35381 35382 smallJsont *r2 = self->f->setInt(self, "1", 2); 35383 ck_assert_ptr_ne(r2, null); 35384 r = self->f->getIntP(self, "1"); 35385 ck_assert_ptr_ne(r, null); 35386 ck_assert_int_eq(*r, 2); 35387 // non int object 35388 r2 = self->f->setBool(self, "1", true); 35389 ck_assert_ptr_ne(r2, null); 35390 r = self->f->getIntP(self, "1"); 35391 ck_assert_ptr_eq(r, null); 35392 // null key 35393 r = self->f->getIntP(self, null); 35394 ck_assert_ptr_eq(r, null); 35395 // empty self 35396 freeO(self); 35397 r = self->f->getIntP(self, "1"); 35398 ck_assert_ptr_eq(r, null); 35399 terminateO(self); 35400 35401 } 35402 35403 35404 void getInt32SmallJsonT(void) { 35405 35406 int32_t r; 35407 smallJsont *self = allocSmallJson(); 35408 35409 smallJsont *r2 = self->f->setInt(self, "1", 2); 35410 ck_assert_ptr_ne(r2, null); 35411 r = self->f->getInt32(self, "1"); 35412 ck_assert_int_eq(r, 2); 35413 // non int object 35414 r2 = self->f->setBool(self, "1", true); 35415 ck_assert_ptr_ne(r2, null); 35416 r = self->f->getInt32(self, "1"); 35417 ck_assert(!r); 35418 // null key 35419 r = self->f->getInt32(self, null); 35420 ck_assert(!r); 35421 // empty self 35422 freeO(self); 35423 r = self->f->getInt32(self, "1"); 35424 ck_assert(!r); 35425 terminateO(self); 35426 35427 } 35428 35429 35430 void getInt32PSmallJsonT(void) { 35431 35432 int32_t* r; 35433 smallJsont *self = allocSmallJson(); 35434 35435 smallJsont *r2 = self->f->setInt(self, "1", 2); 35436 ck_assert_ptr_ne(r2, null); 35437 r = self->f->getInt32P(self, "1"); 35438 ck_assert_ptr_ne(r, null); 35439 ck_assert_int_eq(*r, 2); 35440 // non int object 35441 r2 = self->f->setBool(self, "1", true); 35442 ck_assert_ptr_ne(r2, null); 35443 r = self->f->getInt32P(self, "1"); 35444 ck_assert_ptr_eq(r, null); 35445 // null key 35446 r = self->f->getInt32P(self, null); 35447 ck_assert_ptr_eq(r, null); 35448 // empty self 35449 freeO(self); 35450 r = self->f->getInt32P(self, "1"); 35451 ck_assert_ptr_eq(r, null); 35452 terminateO(self); 35453 35454 } 35455 35456 35457 void getUintSmallJsonT(void) { 35458 35459 uint64_t r; 35460 smallJsont *self = allocSmallJson(); 35461 35462 smallJsont *r2 = self->f->setInt(self, "1", 2); 35463 ck_assert_ptr_ne(r2, null); 35464 r = self->f->getUint(self, "1"); 35465 ck_assert_int_eq(r, 2); 35466 // non int object 35467 r2 = self->f->setBool(self, "1", true); 35468 ck_assert_ptr_ne(r2, null); 35469 r = self->f->getUint(self, "1"); 35470 ck_assert(!r); 35471 // null key 35472 r = self->f->getUint(self, null); 35473 ck_assert(!r); 35474 // empty self 35475 freeO(self); 35476 r = self->f->getUint(self, "1"); 35477 ck_assert(!r); 35478 terminateO(self); 35479 35480 } 35481 35482 35483 void getUintPSmallJsonT(void) { 35484 35485 uint64_t* r; 35486 smallJsont *self = allocSmallJson(); 35487 35488 smallJsont *r2 = self->f->setInt(self, "1", 2); 35489 ck_assert_ptr_ne(r2, null); 35490 r = self->f->getUintP(self, "1"); 35491 ck_assert_ptr_ne(r, null); 35492 ck_assert_int_eq(*r, 2); 35493 // non int object 35494 r2 = self->f->setBool(self, "1", true); 35495 ck_assert_ptr_ne(r2, null); 35496 r = self->f->getUintP(self, "1"); 35497 ck_assert_ptr_eq(r, null); 35498 // null key 35499 r = self->f->getUintP(self, null); 35500 ck_assert_ptr_eq(r, null); 35501 // empty self 35502 freeO(self); 35503 r = self->f->getUintP(self, "1"); 35504 ck_assert_ptr_eq(r, null); 35505 terminateO(self); 35506 35507 } 35508 35509 35510 void getUint32SmallJsonT(void) { 35511 35512 uint32_t r; 35513 smallJsont *self = allocSmallJson(); 35514 35515 smallJsont *r2 = self->f->setInt(self, "1", 2); 35516 ck_assert_ptr_ne(r2, null); 35517 r = self->f->getUint32(self, "1"); 35518 ck_assert_int_eq(r, 2); 35519 // non int object 35520 r2 = self->f->setBool(self, "1", true); 35521 ck_assert_ptr_ne(r2, null); 35522 r = self->f->getUint32(self, "1"); 35523 ck_assert(!r); 35524 // null key 35525 r = self->f->getUint32(self, null); 35526 ck_assert(!r); 35527 // empty self 35528 freeO(self); 35529 r = self->f->getUint32(self, "1"); 35530 ck_assert(!r); 35531 terminateO(self); 35532 35533 } 35534 35535 35536 void getUint32PSmallJsonT(void) { 35537 35538 uint32_t* r; 35539 smallJsont *self = allocSmallJson(); 35540 35541 smallJsont *r2 = self->f->setInt(self, "1", 2); 35542 ck_assert_ptr_ne(r2, null); 35543 r = self->f->getUint32P(self, "1"); 35544 ck_assert_ptr_ne(r, null); 35545 ck_assert_int_eq(*r, 2); 35546 // non int object 35547 r2 = self->f->setBool(self, "1", true); 35548 ck_assert_ptr_ne(r2, null); 35549 r = self->f->getUint32P(self, "1"); 35550 ck_assert_ptr_eq(r, null); 35551 // null key 35552 r = self->f->getUint32P(self, null); 35553 ck_assert_ptr_eq(r, null); 35554 // empty self 35555 freeO(self); 35556 r = self->f->getUint32P(self, "1"); 35557 ck_assert_ptr_eq(r, null); 35558 terminateO(self); 35559 35560 } 35561 35562 35563 void getSSmallJsonT(void) { 35564 35565 char* r; 35566 smallJsont *self = allocSmallJson(); 35567 35568 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 35569 ck_assert_ptr_ne(r2, null); 35570 r = self->f->getS(self, "1"); 35571 ck_assert_ptr_ne(r, null); 35572 ck_assert_str_eq(r, "qwe"); 35573 // non string object 35574 r2 = self->f->setBool(self, "1", true); 35575 ck_assert_ptr_ne(r2, null); 35576 r = self->f->getS(self, "1"); 35577 ck_assert_ptr_eq(r, null); 35578 // null key 35579 r = self->f->getS(self, null); 35580 ck_assert_ptr_eq(r, null); 35581 // empty self 35582 freeO(self); 35583 r = self->f->getS(self, "1"); 35584 ck_assert_ptr_eq(r, null); 35585 terminateO(self); 35586 35587 } 35588 35589 35590 void getDictSmallJsonT(void) { 35591 35592 smallDictt* r; 35593 smallJsont *self = allocSmallJson(); 35594 35595 createAllocateSmallDict(D); 35596 smallJsont *r2 = self->f->setNFreeDict(self, "1", D); 35597 ck_assert_ptr_ne(r2, null); 35598 r = self->f->getDict(self, "1"); 35599 ck_assert_ptr_ne(r, null); 35600 char *s = toStringO(r); 35601 finishO(r); 35602 ck_assert_str_eq(s, "{}"); 35603 free(s); 35604 // non dict object 35605 r2 = self->f->setBool(self, "1", true); 35606 ck_assert_ptr_ne(r2, null); 35607 r = self->f->getDict(self, "1"); 35608 ck_assert_ptr_eq(r, null); 35609 // path 35610 smallDictt *dict = allocSmallDict(); 35611 createSmallArray(a); 35612 createSmallDict(d); 35613 a.f->pushDict(&a, &d); 35614 self->f->setArray(self, "array", &a); 35615 r2 = self->f->setDict(self, "\"array\"[0].\"key\"", dict); 35616 ck_assert_ptr_ne(r2, null); 35617 finishO(dict); 35618 r = self->f->getDict(self, "\"array\"[0].\"key\""); 35619 ck_assert_ptr_ne(r, null); 35620 finishO(r); 35621 // json bool 35622 freeO(self); 35623 setTypeBoolO(self); 35624 r = self->f->getDict(self, "1"); 35625 ck_assert_ptr_eq(r, null); 35626 // json array 35627 freeO(self); 35628 setTypeArrayO(self); 35629 r = self->f->getDict(self, "1"); 35630 ck_assert_ptr_eq(r, null); 35631 // non existing dict path 35632 freeO(self); 35633 r = self->f->getDict(self, "\"1\"[1]"); 35634 ck_assert_ptr_eq(r, null); 35635 // dict path but the object is an array 35636 resetO(&a); 35637 self->f->setArray(self, "1", &a); 35638 r = self->f->getDict(self, "\"1\".\"1\""); 35639 ck_assert_ptr_eq(r, null); 35640 // dict object in path but the key doesn't exists 35641 resetO(&d); 35642 self->f->setDict(self, "2", &d); 35643 r = self->f->getDict(self, "\"2\".\"1\".[12]"); 35644 ck_assert_ptr_eq(r, null); 35645 // null key 35646 r = self->f->getDict(self, null); 35647 ck_assert_ptr_eq(r, null); 35648 // empty self 35649 freeO(self); 35650 r = self->f->getDict(self, "1"); 35651 ck_assert_ptr_eq(r, null); 35652 terminateO(self); 35653 35654 } 35655 35656 35657 void getArraySmallJsonT(void) { 35658 35659 smallArrayt* r; 35660 smallJsont *self = allocSmallJson(); 35661 35662 createAllocateSmallArray(D); 35663 smallJsont *r2 = self->f->setNFreeArray(self, "1", D); 35664 ck_assert_ptr_ne(r2, null); 35665 r = self->f->getArray(self, "1"); 35666 ck_assert_ptr_ne(r, null); 35667 char *s = toStringO(r); 35668 finishO(r); 35669 ck_assert_str_eq(s, "[]"); 35670 free(s); 35671 // non Array object 35672 r2 = self->f->setBool(self, "1", true); 35673 ck_assert_ptr_ne(r2, null); 35674 r = self->f->getArray(self, "1"); 35675 ck_assert_ptr_eq(r, null); 35676 // path 35677 smallArrayt *array = allocSmallArray(); 35678 createSmallArray(a); 35679 createSmallDict(d); 35680 a.f->pushDict(&a, &d); 35681 self->f->setArray(self, "array", &a); 35682 r2 = self->f->setArray(self, "\"array\"[0].\"key\"", array); 35683 ck_assert_ptr_ne(r2, null); 35684 finishO(array); 35685 r = self->f->getArray(self, "\"array\"[0].\"key\""); 35686 ck_assert_ptr_ne(r, null); 35687 finishO(r); 35688 // json bool 35689 freeO(self); 35690 setTypeBoolO(self); 35691 r = self->f->getArray(self, "1"); 35692 ck_assert_ptr_eq(r, null); 35693 // json array 35694 freeO(self); 35695 setTypeArrayO(self); 35696 r = self->f->getArray(self, "1"); 35697 ck_assert_ptr_eq(r, null); 35698 // non existing dict path 35699 freeO(self); 35700 r = self->f->getArray(self, "\"1\"[1]"); 35701 ck_assert_ptr_eq(r, null); 35702 // dict path but the object is an array 35703 resetO(&a); 35704 self->f->setArray(self, "1", &a); 35705 r = self->f->getArray(self, "\"1\".\"1\""); 35706 ck_assert_ptr_eq(r, null); 35707 // dict object in path but the key doesn't exists 35708 resetO(&d); 35709 self->f->setDict(self, "2", &d); 35710 r = self->f->getArray(self, "\"2\".\"1\".[12]"); 35711 ck_assert_ptr_eq(r, null); 35712 // null key 35713 r = self->f->getArray(self, null); 35714 ck_assert_ptr_eq(r, null); 35715 // empty self 35716 freeO(self); 35717 r = self->f->getArray(self, "1"); 35718 ck_assert_ptr_eq(r, null); 35719 terminateO(self); 35720 35721 } 35722 35723 35724 void getSmallBoolSmallJsonT(void) { 35725 35726 smallBoolt* r; 35727 smallJsont *self = allocSmallJson(); 35728 35729 createAllocateSmallBool(D); 35730 smallJsont *r2 = self->f->setNFreeSmallBool(self, "1", D); 35731 ck_assert_ptr_ne(r2, null); 35732 r = self->f->getSmallBool(self, "1"); 35733 ck_assert_ptr_ne(r, null); 35734 char *s = toStringO(r); 35735 finishO(r); 35736 ck_assert_str_eq(s, "false"); 35737 free(s); 35738 // non SmallBool object 35739 r2 = self->f->setInt(self, "1", 0); 35740 ck_assert_ptr_ne(r2, null); 35741 r = self->f->getSmallBool(self, "1"); 35742 ck_assert_ptr_eq(r, null); 35743 // path 35744 smallBoolt *value = allocSmallBool(true); 35745 createSmallArray(a); 35746 createSmallDict(d); 35747 a.f->pushDict(&a, &d); 35748 self->f->setArray(self, "array", &a); 35749 r2 = self->f->setSmallBool(self, "\"array\"[0].\"key\"", value); 35750 ck_assert_ptr_ne(r2, null); 35751 finishO(value); 35752 r = self->f->getSmallBool(self, "\"array\"[0].\"key\""); 35753 ck_assert_ptr_ne(r, null); 35754 finishO(r); 35755 // json bool 35756 freeO(self); 35757 setTypeBoolO(self); 35758 r = self->f->getSmallBool(self, "1"); 35759 ck_assert_ptr_eq(r, null); 35760 // json array 35761 freeO(self); 35762 setTypeArrayO(self); 35763 r = self->f->getSmallBool(self, "1"); 35764 ck_assert_ptr_eq(r, null); 35765 // non existing dict path 35766 freeO(self); 35767 r = self->f->getSmallBool(self, "\"1\"[1]"); 35768 ck_assert_ptr_eq(r, null); 35769 // dict path but the object is an array 35770 resetO(&a); 35771 self->f->setArray(self, "1", &a); 35772 r = self->f->getSmallBool(self, "\"1\".\"1\""); 35773 ck_assert_ptr_eq(r, null); 35774 // dict object in path but the key doesn't exists 35775 resetO(&d); 35776 self->f->setDict(self, "2", &d); 35777 r = self->f->getSmallBool(self, "\"2\".\"1\".[12]"); 35778 ck_assert_ptr_eq(r, null); 35779 // null key 35780 r = self->f->getSmallBool(self, null); 35781 ck_assert_ptr_eq(r, null); 35782 // empty self 35783 freeO(self); 35784 r = self->f->getSmallBool(self, "1"); 35785 ck_assert_ptr_eq(r, null); 35786 terminateO(self); 35787 35788 } 35789 35790 35791 void getSmallBytesSmallJsonT(void) { 35792 35793 smallBytest* r; 35794 smallJsont *self = allocSmallJson(); 35795 35796 createAllocateSmallBytes(D); 35797 smallJsont *r2 = self->f->setNFreeSmallBytes(self, "1", D); 35798 ck_assert_ptr_ne(r2, null); 35799 r = self->f->getSmallBytes(self, "1"); 35800 ck_assert_ptr_ne(r, null); 35801 char *s = toStringO(r); 35802 finishO(r); 35803 ck_assert_str_eq(s, "[]"); 35804 free(s); 35805 // non SmallBytes object 35806 r2 = self->f->setBool(self, "1", true); 35807 ck_assert_ptr_ne(r2, null); 35808 r = self->f->getSmallBytes(self, "1"); 35809 ck_assert_ptr_eq(r, null); 35810 // path 35811 smallBytest *value = allocSmallBytes("qwf", sizeof("qwf")); 35812 createSmallArray(a); 35813 createSmallDict(d); 35814 a.f->pushDict(&a, &d); 35815 self->f->setArray(self, "array", &a); 35816 r2 = self->f->setSmallBytes(self, "\"array\"[0].\"key\"", value); 35817 ck_assert_ptr_ne(r2, null); 35818 finishO(value); 35819 r = self->f->getSmallBytes(self, "\"array\"[0].\"key\""); 35820 ck_assert_ptr_ne(r, null); 35821 finishO(r); 35822 // json bool 35823 freeO(self); 35824 setTypeBoolO(self); 35825 r = self->f->getSmallBytes(self, "1"); 35826 ck_assert_ptr_eq(r, null); 35827 // json array 35828 freeO(self); 35829 setTypeArrayO(self); 35830 r = self->f->getSmallBytes(self, "1"); 35831 ck_assert_ptr_eq(r, null); 35832 // non existing dict path 35833 freeO(self); 35834 r = self->f->getSmallBytes(self, "\"1\"[1]"); 35835 ck_assert_ptr_eq(r, null); 35836 // dict path but the object is an array 35837 resetO(&a); 35838 self->f->setArray(self, "1", &a); 35839 r = self->f->getSmallBytes(self, "\"1\".\"1\""); 35840 ck_assert_ptr_eq(r, null); 35841 // dict object in path but the key doesn't exists 35842 resetO(&d); 35843 self->f->setDict(self, "2", &d); 35844 r = self->f->getSmallBytes(self, "\"2\".\"1\".[12]"); 35845 ck_assert_ptr_eq(r, null); 35846 // null key 35847 r = self->f->getSmallBytes(self, null); 35848 ck_assert_ptr_eq(r, null); 35849 // empty self 35850 freeO(self); 35851 r = self->f->getSmallBytes(self, "1"); 35852 ck_assert_ptr_eq(r, null); 35853 terminateO(self); 35854 35855 } 35856 35857 35858 void getSmallDoubleSmallJsonT(void) { 35859 35860 smallDoublet* r; 35861 smallJsont *self = allocSmallJson(); 35862 35863 createAllocateSmallDouble(D); 35864 smallJsont *r2 = self->f->setNFreeSmallDouble(self, "1", D); 35865 ck_assert_ptr_ne(r2, null); 35866 r = self->f->getSmallDouble(self, "1"); 35867 ck_assert_ptr_ne(r, null); 35868 char *s = toStringO(r); 35869 finishO(r); 35870 ck_assert_str_eq(s, "0.000000e+00"); 35871 free(s); 35872 // non SmallDouble object 35873 r2 = self->f->setBool(self, "1", true); 35874 ck_assert_ptr_ne(r2, null); 35875 r = self->f->getSmallDouble(self, "1"); 35876 ck_assert_ptr_eq(r, null); 35877 // path 35878 smallDoublet *value = allocSmallDouble(1.2); 35879 createSmallArray(a); 35880 createSmallDict(d); 35881 a.f->pushDict(&a, &d); 35882 self->f->setArray(self, "array", &a); 35883 r2 = self->f->setSmallDouble(self, "\"array\"[0].\"key\"", value); 35884 ck_assert_ptr_ne(r2, null); 35885 finishO(value); 35886 r = self->f->getSmallDouble(self, "\"array\"[0].\"key\""); 35887 ck_assert_ptr_ne(r, null); 35888 finishO(r); 35889 // json bool 35890 freeO(self); 35891 setTypeBoolO(self); 35892 r = self->f->getSmallDouble(self, "1"); 35893 ck_assert_ptr_eq(r, null); 35894 // json array 35895 freeO(self); 35896 setTypeArrayO(self); 35897 r = self->f->getSmallDouble(self, "1"); 35898 ck_assert_ptr_eq(r, null); 35899 // non existing dict path 35900 freeO(self); 35901 r = self->f->getSmallDouble(self, "\"1\"[1]"); 35902 ck_assert_ptr_eq(r, null); 35903 // dict path but the object is an array 35904 resetO(&a); 35905 self->f->setArray(self, "1", &a); 35906 r = self->f->getSmallDouble(self, "\"1\".\"1\""); 35907 ck_assert_ptr_eq(r, null); 35908 // dict object in path but the key doesn't exists 35909 resetO(&d); 35910 self->f->setDict(self, "2", &d); 35911 r = self->f->getSmallDouble(self, "\"2\".\"1\".[12]"); 35912 ck_assert_ptr_eq(r, null); 35913 // null key 35914 r = self->f->getSmallDouble(self, null); 35915 ck_assert_ptr_eq(r, null); 35916 // empty self 35917 freeO(self); 35918 r = self->f->getSmallDouble(self, "1"); 35919 ck_assert_ptr_eq(r, null); 35920 terminateO(self); 35921 35922 } 35923 35924 35925 void getSmallIntSmallJsonT(void) { 35926 35927 smallIntt* r; 35928 smallJsont *self = allocSmallJson(); 35929 35930 createAllocateSmallInt(D); 35931 smallJsont *r2 = self->f->setNFreeSmallInt(self, "1", D); 35932 ck_assert_ptr_ne(r2, null); 35933 r = self->f->getSmallInt(self, "1"); 35934 ck_assert_ptr_ne(r, null); 35935 char *s = toStringO(r); 35936 finishO(r); 35937 ck_assert_str_eq(s, "0"); 35938 free(s); 35939 // non SmallInt object 35940 r2 = self->f->setBool(self, "1", true); 35941 ck_assert_ptr_ne(r2, null); 35942 r = self->f->getSmallInt(self, "1"); 35943 ck_assert_ptr_eq(r, null); 35944 // path 35945 smallIntt *value = allocSmallInt(1); 35946 createSmallArray(a); 35947 createSmallDict(d); 35948 a.f->pushDict(&a, &d); 35949 self->f->setArray(self, "array", &a); 35950 r2 = self->f->setSmallInt(self, "\"array\"[0].\"key\"", value); 35951 ck_assert_ptr_ne(r2, null); 35952 finishO(value); 35953 r = self->f->getSmallInt(self, "\"array\"[0].\"key\""); 35954 ck_assert_ptr_ne(r, null); 35955 finishO(r); 35956 // json bool 35957 freeO(self); 35958 setTypeBoolO(self); 35959 r = self->f->getSmallInt(self, "1"); 35960 ck_assert_ptr_eq(r, null); 35961 // json array 35962 freeO(self); 35963 setTypeArrayO(self); 35964 r = self->f->getSmallInt(self, "1"); 35965 ck_assert_ptr_eq(r, null); 35966 // non existing dict path 35967 freeO(self); 35968 r = self->f->getSmallInt(self, "\"1\"[1]"); 35969 ck_assert_ptr_eq(r, null); 35970 // dict path but the object is an array 35971 resetO(&a); 35972 self->f->setArray(self, "1", &a); 35973 r = self->f->getSmallInt(self, "\"1\".\"1\""); 35974 ck_assert_ptr_eq(r, null); 35975 // dict object in path but the key doesn't exists 35976 resetO(&d); 35977 self->f->setDict(self, "2", &d); 35978 r = self->f->getSmallInt(self, "\"2\".\"1\".[12]"); 35979 ck_assert_ptr_eq(r, null); 35980 // null key 35981 r = self->f->getSmallInt(self, null); 35982 ck_assert_ptr_eq(r, null); 35983 // empty self 35984 freeO(self); 35985 r = self->f->getSmallInt(self, "1"); 35986 ck_assert_ptr_eq(r, null); 35987 terminateO(self); 35988 35989 } 35990 35991 35992 void getSmallJsonSmallJsonT(void) { 35993 35994 smallJsont* r; 35995 smallJsont *self = allocSmallJson(); 35996 35997 createAllocateSmallJson(D); 35998 smallJsont *r2 = self->f->setNFreeSmallJson(self, "1", D); 35999 ck_assert_ptr_ne(r2, null); 36000 r = self->f->getSmallJson(self, "1"); 36001 ck_assert_ptr_ne(r, null); 36002 char *s = toStringO(r); 36003 finishO(r); 36004 ck_assert_str_eq(s, "{}"); 36005 free(s); 36006 r2 = self->f->setBool(self, "1", true); 36007 ck_assert_ptr_ne(r2, null); 36008 r = self->f->getSmallJson(self, "1"); 36009 ck_assert_ptr_ne(r, null); 36010 s = toStringO(r); 36011 finishO(r); 36012 ck_assert_str_eq(s, "true"); 36013 free(s); 36014 // non SmallJson object 36015 smallContainert *c = allocSmallContainer(NULL); 36016 r2 = self->f->setNFreeSmallContainer(self, "1", c); 36017 ck_assert_ptr_ne(r2, null); 36018 r = self->f->getSmallJson(self, "1"); 36019 ck_assert_ptr_eq(r, null); 36020 // path 36021 smallJsont *value = allocSmallJson(); 36022 createSmallArray(a); 36023 createSmallDict(d); 36024 a.f->pushDict(&a, &d); 36025 self->f->setArray(self, "array", &a); 36026 r = self->f->setSmallJson(self, "\"array\"[0].\"key\"", value); 36027 ck_assert_ptr_ne(r, null); 36028 finishO(value); 36029 r = self->f->getSmallJson(self, "\"array\"[0].\"key\""); 36030 ck_assert_ptr_ne(r, null); 36031 finishO(r); 36032 // json bool 36033 freeO(self); 36034 setTypeBoolO(self); 36035 r = self->f->getSmallJson(self, "1"); 36036 ck_assert_ptr_eq(r, null); 36037 // json array 36038 freeO(self); 36039 setTypeArrayO(self); 36040 r = self->f->getSmallJson(self, "1"); 36041 ck_assert_ptr_eq(r, null); 36042 // non existing dict path 36043 freeO(self); 36044 r = self->f->getSmallJson(self, "\"1\"[1]"); 36045 ck_assert_ptr_eq(r, null); 36046 // dict path but the object is an array 36047 resetO(&a); 36048 self->f->setArray(self, "1", &a); 36049 r = self->f->getSmallJson(self, "\"1\".\"1\""); 36050 ck_assert_ptr_eq(r, null); 36051 // dict object in path but the key doesn't exists 36052 resetO(&d); 36053 self->f->setDict(self, "2", &d); 36054 r = self->f->getSmallJson(self, "\"2\".\"1\".[12]"); 36055 ck_assert_ptr_eq(r, null); 36056 // null key 36057 r = self->f->getSmallJson(self, null); 36058 ck_assert_ptr_eq(r, null); 36059 // empty self 36060 freeO(self); 36061 r = self->f->getSmallJson(self, "1"); 36062 ck_assert_ptr_eq(r, null); 36063 terminateO(self); 36064 36065 } 36066 36067 36068 void getSmallStringSmallJsonT(void) { 36069 36070 smallStringt* r; 36071 smallJsont *self = allocSmallJson(); 36072 36073 createAllocateSmallString(D); 36074 smallJsont *r2 = self->f->setNFreeSmallString(self, "1", D); 36075 ck_assert_ptr_ne(r2, null); 36076 r = self->f->getSmallString(self, "1"); 36077 ck_assert_ptr_ne(r, null); 36078 char *s = toStringO(r); 36079 finishO(r); 36080 ck_assert_str_eq(s, ""); 36081 free(s); 36082 // non SmallString object 36083 r2 = self->f->setBool(self, "1", true); 36084 ck_assert_ptr_ne(r2, null); 36085 r = self->f->getSmallString(self, "1"); 36086 ck_assert_ptr_eq(r, null); 36087 // path 36088 smallStringt *value = allocSmallString("asd"); 36089 createSmallArray(a); 36090 createSmallDict(d); 36091 a.f->pushDict(&a, &d); 36092 self->f->setArray(self, "array", &a); 36093 r2 = self->f->setSmallString(self, "\"array\"[0].\"key\"", value); 36094 ck_assert_ptr_ne(r2, null); 36095 finishO(value); 36096 r = self->f->getSmallString(self, "\"array\"[0].\"key\""); 36097 ck_assert_ptr_ne(r, null); 36098 finishO(r); 36099 // json bool 36100 freeO(self); 36101 setTypeBoolO(self); 36102 r = self->f->getSmallString(self, "1"); 36103 ck_assert_ptr_eq(r, null); 36104 // json array 36105 freeO(self); 36106 setTypeArrayO(self); 36107 r = self->f->getSmallString(self, "1"); 36108 ck_assert_ptr_eq(r, null); 36109 // non existing dict path 36110 freeO(self); 36111 r = self->f->getSmallString(self, "\"1\"[1]"); 36112 ck_assert_ptr_eq(r, null); 36113 // dict path but the object is an array 36114 resetO(&a); 36115 self->f->setArray(self, "1", &a); 36116 r = self->f->getSmallString(self, "\"1\".\"1\""); 36117 ck_assert_ptr_eq(r, null); 36118 // dict object in path but the key doesn't exists 36119 resetO(&d); 36120 self->f->setDict(self, "2", &d); 36121 r = self->f->getSmallString(self, "\"2\".\"1\".[12]"); 36122 ck_assert_ptr_eq(r, null); 36123 // null key 36124 r = self->f->getSmallString(self, null); 36125 ck_assert_ptr_eq(r, null); 36126 // empty self 36127 freeO(self); 36128 r = self->f->getSmallString(self, "1"); 36129 ck_assert_ptr_eq(r, null); 36130 terminateO(self); 36131 36132 } 36133 36134 36135 void getVoidSmallJsonT(void) { 36136 36137 void* r; 36138 smallJsont *self = allocSmallJson(); 36139 36140 smallContainert* D = allocSmallContainer(&r); 36141 smallJsont *r2 = self->f->setNFreeSmallContainer(self, "1", D); 36142 ck_assert_ptr_ne(r2, null); 36143 r = self->f->getVoid(self, "1"); 36144 ck_assert_ptr_eq(r, &r); 36145 // non container object 36146 r2 = self->f->setBool(self, "1", true); 36147 ck_assert_ptr_ne(r2, null); 36148 r = self->f->getVoid(self, "1"); 36149 ck_assert_ptr_eq(r, null); 36150 // path 36151 smallContainert *value = allocSmallContainer(&r); 36152 createSmallArray(a); 36153 createSmallDict(d); 36154 a.f->pushDict(&a, &d); 36155 self->f->setArray(self, "array", &a); 36156 r2 = self->f->setSmallContainer(self, "\"array\"[0].\"key\"", value); 36157 ck_assert_ptr_ne(r2, null); 36158 finishO(value); 36159 r = self->f->getVoid(self, "\"array\"[0].\"key\""); 36160 ck_assert_ptr_ne(r, null); 36161 // json bool 36162 freeO(self); 36163 setTypeBoolO(self); 36164 r = self->f->getVoid(self, "1"); 36165 ck_assert_ptr_eq(r, null); 36166 // json array 36167 freeO(self); 36168 setTypeArrayO(self); 36169 r = self->f->getVoid(self, "1"); 36170 ck_assert_ptr_eq(r, null); 36171 // non existing dict path 36172 freeO(self); 36173 r = self->f->getVoid(self, "\"1\"[1]"); 36174 ck_assert_ptr_eq(r, null); 36175 // dict path but the object is an array 36176 resetO(&a); 36177 self->f->setArray(self, "1", &a); 36178 r = self->f->getVoid(self, "\"1\".\"1\""); 36179 ck_assert_ptr_eq(r, null); 36180 // dict object in path but the key doesn't exists 36181 resetO(&d); 36182 self->f->setDict(self, "2", &d); 36183 r = self->f->getVoid(self, "\"2\".\"1\".[12]"); 36184 ck_assert_ptr_eq(r, null); 36185 // null key 36186 r = self->f->getVoid(self, null); 36187 ck_assert_ptr_eq(r, null); 36188 // empty self 36189 freeO(self); 36190 r = self->f->getVoid(self, "1"); 36191 ck_assert_ptr_eq(r, null); 36192 terminateO(self); 36193 36194 } 36195 36196 36197 void getSmallContainerSmallJsonT(void) { 36198 36199 smallContainert* r; 36200 smallJsont *self = allocSmallJson(); 36201 36202 createAllocateSmallContainer(D); 36203 smallJsont *r2 = self->f->setNFreeSmallContainer(self, "1", D); 36204 ck_assert_ptr_ne(r2, null); 36205 r = self->f->getSmallContainer(self, "1"); 36206 ck_assert_ptr_ne(r, null); 36207 char *s = toStringO(r); 36208 finishO(r); 36209 ck_assert_str_eq(s, "<data smallContainer>"); 36210 free(s); 36211 // other base class 36212 smallIntt *t = allocSmallInt(2); 36213 t->type = "randomClass"; 36214 r2 = self->f->setNFree(self, "1", (baset*)t); 36215 ck_assert_ptr_ne(r2, null); 36216 r = self->f->getSmallContainer(self, "1"); 36217 ck_assert_ptr_eq(r, null); 36218 // non SmallContainer object 36219 r2 = self->f->setBool(self, "1", true); 36220 ck_assert_ptr_ne(r2, null); 36221 r = self->f->getSmallContainer(self, "1"); 36222 ck_assert_ptr_eq(r, null); 36223 // path 36224 smallContainert *value = allocSmallContainer(null); 36225 createSmallArray(a); 36226 createSmallDict(d); 36227 a.f->pushDict(&a, &d); 36228 self->f->setArray(self, "array", &a); 36229 r2 = self->f->setSmallContainer(self, "\"array\"[0].\"key\"", value); 36230 ck_assert_ptr_ne(r2, null); 36231 finishO(value); 36232 r = self->f->getSmallContainer(self, "\"array\"[0].\"key\""); 36233 ck_assert_ptr_ne(r, null); 36234 finishO(r); 36235 // json bool 36236 freeO(self); 36237 setTypeBoolO(self); 36238 r = self->f->getSmallContainer(self, "1"); 36239 ck_assert_ptr_eq(r, null); 36240 // json array 36241 freeO(self); 36242 setTypeArrayO(self); 36243 r = self->f->getSmallContainer(self, "1"); 36244 ck_assert_ptr_eq(r, null); 36245 // non existing dict path 36246 freeO(self); 36247 r = self->f->getSmallContainer(self, "\"1\"[1]"); 36248 ck_assert_ptr_eq(r, null); 36249 // dict path but the object is an array 36250 resetO(&a); 36251 self->f->setArray(self, "1", &a); 36252 r = self->f->getSmallContainer(self, "\"1\".\"1\""); 36253 ck_assert_ptr_eq(r, null); 36254 // dict object in path but the key doesn't exists 36255 resetO(&d); 36256 self->f->setDict(self, "2", &d); 36257 r = self->f->getSmallContainer(self, "\"2\".\"1\".[12]"); 36258 ck_assert_ptr_eq(r, null); 36259 // null key 36260 r = self->f->getSmallContainer(self, null); 36261 ck_assert_ptr_eq(r, null); 36262 // empty self 36263 freeO(self); 36264 r = self->f->getSmallContainer(self, "1"); 36265 ck_assert_ptr_eq(r, null); 36266 terminateO(self); 36267 36268 } 36269 36270 36271 void getNDupSmallJsonT(void) { 36272 36273 baset* r; 36274 smallJsont *self = allocSmallJson(); 36275 36276 smallIntt *c = allocSmallInt(2); 36277 smallJsont *r2 = self->f->setNFree(self, "1", (baset*) c); 36278 ck_assert_ptr_ne(r2, null); 36279 r = self->f->getNDup(self, "1"); 36280 ck_assert_ptr_ne(r, null); 36281 char *s = toStringO(r); 36282 terminateO(r); 36283 ck_assert_str_eq(s, "2"); 36284 free(s); 36285 // other base class 36286 smallIntt *t = allocSmallInt(3); 36287 t->type = "randomClass"; 36288 r2 = self->f->setNFree(self, "1", (baset*)t); 36289 ck_assert_ptr_ne(r2, null); 36290 r = self->f->getNDup(self, "1"); 36291 ck_assert_ptr_ne(r, null); 36292 s = toStringO(r); 36293 terminateO(r); 36294 ck_assert_str_eq(s, "3"); 36295 free(s); 36296 // path 36297 smallIntt *value = allocSmallInt(1); 36298 createSmallArray(a); 36299 createSmallDict(d); 36300 a.f->pushDict(&a, &d); 36301 self->f->setArray(self, "array", &a); 36302 r2 = self->f->setSmallInt(self, "\"array\"[0].\"key\"", value); 36303 ck_assert_ptr_ne(r2, null); 36304 finishO(value); 36305 r = self->f->getNDup(self, "\"array\"[0].\"key\""); 36306 ck_assert_ptr_ne(r, null); 36307 terminateO(r); 36308 // json bool 36309 freeO(self); 36310 setTypeBoolO(self); 36311 r = self->f->getNDup(self, "1"); 36312 ck_assert_ptr_eq(r, null); 36313 // json array 36314 freeO(self); 36315 setTypeArrayO(self); 36316 r = self->f->getNDup(self, "1"); 36317 ck_assert_ptr_eq(r, null); 36318 // non existing dict path 36319 freeO(self); 36320 r = self->f->getNDup(self, "\"1\"[1]"); 36321 ck_assert_ptr_eq(r, null); 36322 // dict path but the object is an array 36323 resetO(&a); 36324 self->f->setArray(self, "1", &a); 36325 r = self->f->getNDup(self, "\"1\".\"1\""); 36326 ck_assert_ptr_eq(r, null); 36327 // dict object in path but the key doesn't exists 36328 resetO(&d); 36329 self->f->setDict(self, "2", &d); 36330 r = self->f->getNDup(self, "\"2\".\"1\".[12]"); 36331 ck_assert_ptr_eq(r, null); 36332 // null key 36333 r = self->f->getNDup(self, null); 36334 ck_assert_ptr_eq(r, null); 36335 // empty self 36336 freeO(self); 36337 r = self->f->getNDup(self, "1"); 36338 ck_assert_ptr_eq(r, null); 36339 terminateO(self); 36340 36341 } 36342 36343 36344 void getNDupUndefinedSmallJsonT(void) { 36345 36346 undefinedt* r; 36347 smallJsont *self = allocSmallJson(); 36348 36349 smallJsont *r2 = self->f->setUndefined(self, "1"); 36350 ck_assert_ptr_ne(r2, null); 36351 r = self->f->getNDupUndefined(self, "1"); 36352 ck_assert_ptr_ne(r, null); 36353 terminateO(r); 36354 // non undefined object 36355 r2 = self->f->setInt(self, "1", 2); 36356 ck_assert_ptr_ne(r2, null); 36357 r = self->f->getNDupUndefined(self, "1"); 36358 ck_assert_ptr_eq(r, null); 36359 // path 36360 createSmallArray(a); 36361 createSmallDict(d); 36362 a.f->pushDict(&a, &d); 36363 self->f->setArray(self, "array", &a); 36364 r2 = self->f->setUndefined(self, "\"array\"[0].\"key\""); 36365 ck_assert_ptr_ne(r2, null); 36366 r = self->f->getNDupUndefined(self, "\"array\"[0].\"key\""); 36367 ck_assert_ptr_ne(r, null); 36368 terminateO(r); 36369 // json bool 36370 freeO(self); 36371 setTypeBoolO(self); 36372 r = self->f->getNDupUndefined(self, "1"); 36373 ck_assert_ptr_eq(r, null); 36374 // json array 36375 freeO(self); 36376 setTypeArrayO(self); 36377 r = self->f->getNDupUndefined(self, "1"); 36378 ck_assert_ptr_eq(r, null); 36379 // non existing dict path 36380 freeO(self); 36381 r = self->f->getNDupUndefined(self, "\"1\"[1]"); 36382 ck_assert_ptr_eq(r, null); 36383 // dict path but the object is an array 36384 resetO(&a); 36385 self->f->setArray(self, "1", &a); 36386 r = self->f->getNDupUndefined(self, "\"1\".\"1\""); 36387 ck_assert_ptr_eq(r, null); 36388 // dict object in path but the key doesn't exists 36389 resetO(&d); 36390 self->f->setDict(self, "2", &d); 36391 r = self->f->getNDupUndefined(self, "\"2\".\"1\".[12]"); 36392 ck_assert_ptr_eq(r, null); 36393 // null key 36394 r = self->f->getNDupUndefined(self, null); 36395 ck_assert_ptr_eq(r, null); 36396 // empty self 36397 freeO(self); 36398 r = self->f->getNDupUndefined(self, "1"); 36399 ck_assert_ptr_eq(r, null); 36400 terminateO(self); 36401 36402 } 36403 36404 36405 void getNDupBoolSmallJsonT(void) { 36406 36407 bool r; 36408 smallJsont *self = allocSmallJson(); 36409 36410 smallJsont *r2 = self->f->setBool(self, "1", true); 36411 ck_assert_ptr_ne(r2, null); 36412 r = self->f->getNDupBool(self, "1"); 36413 ck_assert(r); 36414 // non bool object 36415 r2 = self->f->setInt(self, "1", 2); 36416 ck_assert_ptr_ne(r2, null); 36417 r = self->f->getNDupBool(self, "1"); 36418 ck_assert(!r); 36419 // null key 36420 r = self->f->getNDupBool(self, null); 36421 ck_assert(!r); 36422 // empty self 36423 freeO(self); 36424 r = self->f->getNDupBool(self, "1"); 36425 ck_assert(!r); 36426 terminateO(self); 36427 36428 } 36429 36430 36431 void getNDupDoubleSmallJsonT(void) { 36432 36433 double r; 36434 smallJsont *self = allocSmallJson(); 36435 36436 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 36437 ck_assert_ptr_ne(r2, null); 36438 r = self->f->getNDupDouble(self, "1"); 36439 ck_assert(r == 2.2); 36440 // non double object 36441 r2 = self->f->setInt(self, "1", 2); 36442 ck_assert_ptr_ne(r2, null); 36443 r = self->f->getNDupDouble(self, "1"); 36444 ck_assert(r == 0); 36445 // null key 36446 r = self->f->getNDupDouble(self, null); 36447 ck_assert(r == 0); 36448 // empty self 36449 freeO(self); 36450 r = self->f->getNDupDouble(self, "1"); 36451 ck_assert(!r); 36452 terminateO(self); 36453 36454 } 36455 36456 36457 void getNDupIntSmallJsonT(void) { 36458 36459 int64_t r; 36460 smallJsont *self = allocSmallJson(); 36461 36462 smallJsont *r2 = self->f->setInt(self, "1", 2); 36463 ck_assert_ptr_ne(r2, null); 36464 r = self->f->getNDupInt(self, "1"); 36465 ck_assert_int_eq(r, 2); 36466 // non int object 36467 r2 = self->f->setBool(self, "1", true); 36468 ck_assert_ptr_ne(r2, null); 36469 r = self->f->getNDupInt(self, "1"); 36470 ck_assert(!r); 36471 // null key 36472 r = self->f->getNDupInt(self, null); 36473 ck_assert_int_eq(r, 0); 36474 // empty self 36475 freeO(self); 36476 r = self->f->getNDupInt(self, "1"); 36477 ck_assert(!r); 36478 terminateO(self); 36479 36480 } 36481 36482 36483 void getNDupInt32SmallJsonT(void) { 36484 36485 int32_t r; 36486 smallJsont *self = allocSmallJson(); 36487 36488 smallJsont *r2 = self->f->setInt(self, "1", 2); 36489 ck_assert_ptr_ne(r2, null); 36490 r = self->f->getNDupInt32(self, "1"); 36491 ck_assert_int_eq(r, 2); 36492 // non int object 36493 r2 = self->f->setBool(self, "1", true); 36494 ck_assert_ptr_ne(r2, null); 36495 r = self->f->getNDupInt32(self, "1"); 36496 ck_assert(!r); 36497 // null key 36498 r = self->f->getNDupInt32(self, null); 36499 ck_assert_int_eq(r, 0); 36500 // empty self 36501 freeO(self); 36502 r = self->f->getNDupInt32(self, "1"); 36503 ck_assert(!r); 36504 terminateO(self); 36505 36506 } 36507 36508 36509 void getNDupUintSmallJsonT(void) { 36510 36511 uint64_t r; 36512 smallJsont *self = allocSmallJson(); 36513 36514 smallJsont *r2 = self->f->setInt(self, "1", 2); 36515 ck_assert_ptr_ne(r2, null); 36516 r = self->f->getNDupUint(self, "1"); 36517 ck_assert_int_eq(r, 2); 36518 // non int object 36519 r2 = self->f->setBool(self, "1", true); 36520 ck_assert_ptr_ne(r2, null); 36521 r = self->f->getNDupUint(self, "1"); 36522 ck_assert(!r); 36523 // null key 36524 r = self->f->getNDupUint(self, null); 36525 ck_assert_int_eq(r, 0); 36526 // empty self 36527 freeO(self); 36528 r = self->f->getNDupUint(self, "1"); 36529 ck_assert(!r); 36530 terminateO(self); 36531 36532 } 36533 36534 36535 void getNDupUint32SmallJsonT(void) { 36536 36537 uint32_t r; 36538 smallJsont *self = allocSmallJson(); 36539 36540 smallJsont *r2 = self->f->setInt(self, "1", 2); 36541 ck_assert_ptr_ne(r2, null); 36542 r = self->f->getNDupUint32(self, "1"); 36543 ck_assert_int_eq(r, 2); 36544 // non int object 36545 r2 = self->f->setBool(self, "1", true); 36546 ck_assert_ptr_ne(r2, null); 36547 r = self->f->getNDupUint32(self, "1"); 36548 ck_assert(!r); 36549 // null key 36550 r = self->f->getNDupUint32(self, null); 36551 ck_assert_int_eq(r, 0); 36552 // empty self 36553 freeO(self); 36554 r = self->f->getNDupUint32(self, "1"); 36555 ck_assert(!r); 36556 terminateO(self); 36557 36558 } 36559 36560 36561 void getNDupSSmallJsonT(void) { 36562 36563 char* r; 36564 smallJsont *self = allocSmallJson(); 36565 36566 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 36567 ck_assert_ptr_ne(r2, null); 36568 r = self->f->getNDupS(self, "1"); 36569 ck_assert_ptr_ne(r, null); 36570 ck_assert_str_eq(r, "qwe"); 36571 free(r); 36572 // non string object 36573 r2 = self->f->setBool(self, "1", true); 36574 ck_assert_ptr_ne(r2, null); 36575 r = self->f->getNDupS(self, "1"); 36576 ck_assert_ptr_eq(r, null); 36577 // null key 36578 r = self->f->getNDupS(self, null); 36579 ck_assert_ptr_eq(r, null); 36580 // empty self 36581 freeO(self); 36582 r = self->f->getNDupS(self, "1"); 36583 ck_assert_ptr_eq(r, null); 36584 terminateO(self); 36585 36586 } 36587 36588 36589 void getNDupDictSmallJsonT(void) { 36590 36591 smallDictt* r; 36592 smallJsont *self = allocSmallJson(); 36593 36594 createAllocateSmallDict(D); 36595 smallJsont *r2 = self->f->setNFreeDict(self, "1", D); 36596 ck_assert_ptr_ne(r2, null); 36597 r = self->f->getNDupDict(self, "1"); 36598 ck_assert_ptr_ne(r, null); 36599 char *s = toStringO(r); 36600 terminateO(r); 36601 ck_assert_str_eq(s, "{}"); 36602 free(s); 36603 // non dict object 36604 r2 = self->f->setBool(self, "1", true); 36605 ck_assert_ptr_ne(r2, null); 36606 r = self->f->getNDupDict(self, "1"); 36607 ck_assert_ptr_eq(r, null); 36608 // path 36609 smallDictt *dict = allocSmallDict(); 36610 createSmallArray(a); 36611 createSmallDict(d); 36612 a.f->pushDict(&a, &d); 36613 self->f->setArray(self, "array", &a); 36614 r2 = self->f->setDict(self, "\"array\"[0].\"key\"", dict); 36615 ck_assert_ptr_ne(r2, null); 36616 finishO(dict); 36617 r = self->f->getNDupDict(self, "\"array\"[0].\"key\""); 36618 ck_assert_ptr_ne(r, null); 36619 terminateO(r); 36620 // json bool 36621 freeO(self); 36622 setTypeBoolO(self); 36623 r = self->f->getNDupDict(self, "1"); 36624 ck_assert_ptr_eq(r, null); 36625 // json array 36626 freeO(self); 36627 setTypeArrayO(self); 36628 r = self->f->getNDupDict(self, "1"); 36629 ck_assert_ptr_eq(r, null); 36630 // non existing dict path 36631 freeO(self); 36632 r = self->f->getNDupDict(self, "\"1\"[1]"); 36633 ck_assert_ptr_eq(r, null); 36634 // dict path but the object is an array 36635 resetO(&a); 36636 self->f->setArray(self, "1", &a); 36637 r = self->f->getNDupDict(self, "\"1\".\"1\""); 36638 ck_assert_ptr_eq(r, null); 36639 // dict object in path but the key doesn't exists 36640 resetO(&d); 36641 self->f->setDict(self, "2", &d); 36642 r = self->f->getNDupDict(self, "\"2\".\"1\".[12]"); 36643 ck_assert_ptr_eq(r, null); 36644 // null key 36645 r = self->f->getNDupDict(self, null); 36646 ck_assert_ptr_eq(r, null); 36647 // empty self 36648 freeO(self); 36649 r = self->f->getNDupDict(self, "1"); 36650 ck_assert_ptr_eq(r, null); 36651 terminateO(self); 36652 36653 } 36654 36655 36656 void getNDupArraySmallJsonT(void) { 36657 36658 smallArrayt* r; 36659 smallJsont *self = allocSmallJson(); 36660 36661 createAllocateSmallArray(D); 36662 smallJsont *r2 = self->f->setNFreeArray(self, "1", D); 36663 ck_assert_ptr_ne(r2, null); 36664 r = self->f->getNDupArray(self, "1"); 36665 ck_assert_ptr_ne(r, null); 36666 char *s = toStringO(r); 36667 terminateO(r); 36668 ck_assert_str_eq(s, "[]"); 36669 free(s); 36670 // non Array object 36671 r2 = self->f->setBool(self, "1", true); 36672 ck_assert_ptr_ne(r2, null); 36673 r = self->f->getNDupArray(self, "1"); 36674 ck_assert_ptr_eq(r, null); 36675 // path 36676 smallArrayt *array = allocSmallArray(); 36677 createSmallArray(a); 36678 createSmallDict(d); 36679 a.f->pushDict(&a, &d); 36680 self->f->setArray(self, "array", &a); 36681 r2 = self->f->setArray(self, "\"array\"[0].\"key\"", array); 36682 ck_assert_ptr_ne(r2, null); 36683 finishO(array); 36684 r = self->f->getNDupArray(self, "\"array\"[0].\"key\""); 36685 ck_assert_ptr_ne(r, null); 36686 terminateO(r); 36687 // json bool 36688 freeO(self); 36689 setTypeBoolO(self); 36690 r = self->f->getNDupArray(self, "1"); 36691 ck_assert_ptr_eq(r, null); 36692 // json array 36693 freeO(self); 36694 setTypeArrayO(self); 36695 r = self->f->getNDupArray(self, "1"); 36696 ck_assert_ptr_eq(r, null); 36697 // non existing dict path 36698 freeO(self); 36699 r = self->f->getNDupArray(self, "\"1\"[1]"); 36700 ck_assert_ptr_eq(r, null); 36701 // dict path but the object is an array 36702 resetO(&a); 36703 self->f->setArray(self, "1", &a); 36704 r = self->f->getNDupArray(self, "\"1\".\"1\""); 36705 ck_assert_ptr_eq(r, null); 36706 // dict object in path but the key doesn't exists 36707 resetO(&d); 36708 self->f->setDict(self, "2", &d); 36709 r = self->f->getNDupArray(self, "\"2\".\"1\".[12]"); 36710 ck_assert_ptr_eq(r, null); 36711 // null key 36712 r = self->f->getNDupArray(self, null); 36713 ck_assert_ptr_eq(r, null); 36714 // empty self 36715 freeO(self); 36716 r = self->f->getNDupArray(self, "1"); 36717 ck_assert_ptr_eq(r, null); 36718 terminateO(self); 36719 36720 } 36721 36722 36723 void getNDupSmallBoolSmallJsonT(void) { 36724 36725 smallBoolt* r; 36726 smallJsont *self = allocSmallJson(); 36727 36728 createAllocateSmallBool(D); 36729 smallJsont *r2 = self->f->setNFreeSmallBool(self, "1", D); 36730 ck_assert_ptr_ne(r2, null); 36731 r = self->f->getNDupSmallBool(self, "1"); 36732 ck_assert_ptr_ne(r, null); 36733 char *s = toStringO(r); 36734 terminateO(r); 36735 ck_assert_str_eq(s, "false"); 36736 free(s); 36737 // non SmallBool object 36738 r2 = self->f->setInt(self, "1", 0); 36739 ck_assert_ptr_ne(r2, null); 36740 r = self->f->getNDupSmallBool(self, "1"); 36741 ck_assert_ptr_eq(r, null); 36742 // path 36743 smallBoolt *value = allocSmallBool(true); 36744 createSmallArray(a); 36745 createSmallDict(d); 36746 a.f->pushDict(&a, &d); 36747 self->f->setArray(self, "array", &a); 36748 r2 = self->f->setSmallBool(self, "\"array\"[0].\"key\"", value); 36749 ck_assert_ptr_ne(r2, null); 36750 finishO(value); 36751 r = self->f->getNDupSmallBool(self, "\"array\"[0].\"key\""); 36752 ck_assert_ptr_ne(r, null); 36753 terminateO(r); 36754 // json bool 36755 freeO(self); 36756 setTypeBoolO(self); 36757 r = self->f->getNDupSmallBool(self, "1"); 36758 ck_assert_ptr_eq(r, null); 36759 // json array 36760 freeO(self); 36761 setTypeArrayO(self); 36762 r = self->f->getNDupSmallBool(self, "1"); 36763 ck_assert_ptr_eq(r, null); 36764 // non existing dict path 36765 freeO(self); 36766 r = self->f->getNDupSmallBool(self, "\"1\"[1]"); 36767 ck_assert_ptr_eq(r, null); 36768 // dict path but the object is an array 36769 resetO(&a); 36770 self->f->setArray(self, "1", &a); 36771 r = self->f->getNDupSmallBool(self, "\"1\".\"1\""); 36772 ck_assert_ptr_eq(r, null); 36773 // dict object in path but the key doesn't exists 36774 resetO(&d); 36775 self->f->setDict(self, "2", &d); 36776 r = self->f->getNDupSmallBool(self, "\"2\".\"1\".[12]"); 36777 ck_assert_ptr_eq(r, null); 36778 // null key 36779 r = self->f->getNDupSmallBool(self, null); 36780 ck_assert_ptr_eq(r, null); 36781 // empty self 36782 freeO(self); 36783 r = self->f->getNDupSmallBool(self, "1"); 36784 ck_assert_ptr_eq(r, null); 36785 terminateO(self); 36786 36787 } 36788 36789 36790 void getNDupSmallBytesSmallJsonT(void) { 36791 36792 smallBytest* r; 36793 smallJsont *self = allocSmallJson(); 36794 36795 createAllocateSmallBytes(D); 36796 smallJsont *r2 = self->f->setNFreeSmallBytes(self, "1", D); 36797 ck_assert_ptr_ne(r2, null); 36798 r = self->f->getNDupSmallBytes(self, "1"); 36799 ck_assert_ptr_ne(r, null); 36800 char *s = toStringO(r); 36801 terminateO(r); 36802 ck_assert_str_eq(s, "[]"); 36803 free(s); 36804 // non SmallBytes object 36805 r2 = self->f->setBool(self, "1", true); 36806 ck_assert_ptr_ne(r2, null); 36807 r = self->f->getNDupSmallBytes(self, "1"); 36808 ck_assert_ptr_eq(r, null); 36809 // path 36810 smallBytest *value = allocSmallBytes("qwf", sizeof("qwf")); 36811 createSmallArray(a); 36812 createSmallDict(d); 36813 a.f->pushDict(&a, &d); 36814 self->f->setArray(self, "array", &a); 36815 r2 = self->f->setSmallBytes(self, "\"array\"[0].\"key\"", value); 36816 ck_assert_ptr_ne(r2, null); 36817 finishO(value); 36818 r = self->f->getNDupSmallBytes(self, "\"array\"[0].\"key\""); 36819 ck_assert_ptr_ne(r, null); 36820 terminateO(r); 36821 // json bool 36822 freeO(self); 36823 setTypeBoolO(self); 36824 r = self->f->getNDupSmallBytes(self, "1"); 36825 ck_assert_ptr_eq(r, null); 36826 // json array 36827 freeO(self); 36828 setTypeArrayO(self); 36829 r = self->f->getNDupSmallBytes(self, "1"); 36830 ck_assert_ptr_eq(r, null); 36831 // non existing dict path 36832 freeO(self); 36833 r = self->f->getNDupSmallBytes(self, "\"1\"[1]"); 36834 ck_assert_ptr_eq(r, null); 36835 // dict path but the object is an array 36836 resetO(&a); 36837 self->f->setArray(self, "1", &a); 36838 r = self->f->getNDupSmallBytes(self, "\"1\".\"1\""); 36839 ck_assert_ptr_eq(r, null); 36840 // dict object in path but the key doesn't exists 36841 resetO(&d); 36842 self->f->setDict(self, "2", &d); 36843 r = self->f->getNDupSmallBytes(self, "\"2\".\"1\".[12]"); 36844 ck_assert_ptr_eq(r, null); 36845 // null key 36846 r = self->f->getNDupSmallBytes(self, null); 36847 ck_assert_ptr_eq(r, null); 36848 // empty self 36849 freeO(self); 36850 r = self->f->getNDupSmallBytes(self, "1"); 36851 ck_assert_ptr_eq(r, null); 36852 terminateO(self); 36853 36854 } 36855 36856 36857 void getNDupSmallDoubleSmallJsonT(void) { 36858 36859 smallDoublet* r; 36860 smallJsont *self = allocSmallJson(); 36861 36862 createAllocateSmallDouble(D); 36863 smallJsont *r2 = self->f->setNFreeSmallDouble(self, "1", D); 36864 ck_assert_ptr_ne(r2, null); 36865 r = self->f->getNDupSmallDouble(self, "1"); 36866 ck_assert_ptr_ne(r, null); 36867 char *s = toStringO(r); 36868 terminateO(r); 36869 ck_assert_str_eq(s, "0.000000e+00"); 36870 free(s); 36871 // non SmallDouble object 36872 r2 = self->f->setBool(self, "1", true); 36873 ck_assert_ptr_ne(r2, null); 36874 r = self->f->getNDupSmallDouble(self, "1"); 36875 ck_assert_ptr_eq(r, null); 36876 // path 36877 smallDoublet *value = allocSmallDouble(1.2); 36878 createSmallArray(a); 36879 createSmallDict(d); 36880 a.f->pushDict(&a, &d); 36881 self->f->setArray(self, "array", &a); 36882 r2 = self->f->setSmallDouble(self, "\"array\"[0].\"key\"", value); 36883 ck_assert_ptr_ne(r2, null); 36884 finishO(value); 36885 r = self->f->getNDupSmallDouble(self, "\"array\"[0].\"key\""); 36886 ck_assert_ptr_ne(r, null); 36887 terminateO(r); 36888 // json bool 36889 freeO(self); 36890 setTypeBoolO(self); 36891 r = self->f->getNDupSmallDouble(self, "1"); 36892 ck_assert_ptr_eq(r, null); 36893 // json array 36894 freeO(self); 36895 setTypeArrayO(self); 36896 r = self->f->getNDupSmallDouble(self, "1"); 36897 ck_assert_ptr_eq(r, null); 36898 // non existing dict path 36899 freeO(self); 36900 r = self->f->getNDupSmallDouble(self, "\"1\"[1]"); 36901 ck_assert_ptr_eq(r, null); 36902 // dict path but the object is an array 36903 resetO(&a); 36904 self->f->setArray(self, "1", &a); 36905 r = self->f->getNDupSmallDouble(self, "\"1\".\"1\""); 36906 ck_assert_ptr_eq(r, null); 36907 // dict object in path but the key doesn't exists 36908 resetO(&d); 36909 self->f->setDict(self, "2", &d); 36910 r = self->f->getNDupSmallDouble(self, "\"2\".\"1\".[12]"); 36911 ck_assert_ptr_eq(r, null); 36912 // null key 36913 r = self->f->getNDupSmallDouble(self, null); 36914 ck_assert_ptr_eq(r, null); 36915 // empty self 36916 freeO(self); 36917 r = self->f->getNDupSmallDouble(self, "1"); 36918 ck_assert_ptr_eq(r, null); 36919 terminateO(self); 36920 36921 } 36922 36923 36924 void getNDupSmallIntSmallJsonT(void) { 36925 36926 smallIntt* r; 36927 smallJsont *self = allocSmallJson(); 36928 36929 createAllocateSmallInt(D); 36930 smallJsont *r2 = self->f->setNFreeSmallInt(self, "1", D); 36931 ck_assert_ptr_ne(r2, null); 36932 r = self->f->getNDupSmallInt(self, "1"); 36933 ck_assert_ptr_ne(r, null); 36934 char *s = toStringO(r); 36935 terminateO(r); 36936 ck_assert_str_eq(s, "0"); 36937 free(s); 36938 // non SmallInt object 36939 r2 = self->f->setBool(self, "1", true); 36940 ck_assert_ptr_ne(r2, null); 36941 r = self->f->getNDupSmallInt(self, "1"); 36942 ck_assert_ptr_eq(r, null); 36943 // path 36944 smallIntt *value = allocSmallInt(1); 36945 createSmallArray(a); 36946 createSmallDict(d); 36947 a.f->pushDict(&a, &d); 36948 self->f->setArray(self, "array", &a); 36949 r2 = self->f->setSmallInt(self, "\"array\"[0].\"key\"", value); 36950 ck_assert_ptr_ne(r2, null); 36951 finishO(value); 36952 r = self->f->getNDupSmallInt(self, "\"array\"[0].\"key\""); 36953 ck_assert_ptr_ne(r, null); 36954 terminateO(r); 36955 // json bool 36956 freeO(self); 36957 setTypeBoolO(self); 36958 r = self->f->getNDupSmallInt(self, "1"); 36959 ck_assert_ptr_eq(r, null); 36960 // json array 36961 freeO(self); 36962 setTypeArrayO(self); 36963 r = self->f->getNDupSmallInt(self, "1"); 36964 ck_assert_ptr_eq(r, null); 36965 // non existing dict path 36966 freeO(self); 36967 r = self->f->getNDupSmallInt(self, "\"1\"[1]"); 36968 ck_assert_ptr_eq(r, null); 36969 // dict path but the object is an array 36970 resetO(&a); 36971 self->f->setArray(self, "1", &a); 36972 r = self->f->getNDupSmallInt(self, "\"1\".\"1\""); 36973 ck_assert_ptr_eq(r, null); 36974 // dict object in path but the key doesn't exists 36975 resetO(&d); 36976 self->f->setDict(self, "2", &d); 36977 r = self->f->getNDupSmallInt(self, "\"2\".\"1\".[12]"); 36978 ck_assert_ptr_eq(r, null); 36979 // null key 36980 r = self->f->getNDupSmallInt(self, null); 36981 ck_assert_ptr_eq(r, null); 36982 // empty self 36983 freeO(self); 36984 r = self->f->getNDupSmallInt(self, "1"); 36985 ck_assert_ptr_eq(r, null); 36986 terminateO(self); 36987 36988 } 36989 36990 36991 void getNDupSmallJsonSmallJsonT(void) { 36992 36993 smallJsont* r; 36994 smallJsont *self = allocSmallJson(); 36995 36996 createAllocateSmallJson(D); 36997 smallJsont *r2 = self->f->setNFreeSmallJson(self, "1", D); 36998 ck_assert_ptr_ne(r2, null); 36999 r = self->f->getNDupSmallJson(self, "1"); 37000 ck_assert_ptr_ne(r, null); 37001 char *s = toStringO(r); 37002 terminateO(r); 37003 ck_assert_str_eq(s, "{}"); 37004 free(s); 37005 r2 = self->f->setBool(self, "1", true); 37006 ck_assert_ptr_ne(r2, null); 37007 r = self->f->getNDupSmallJson(self, "1"); 37008 ck_assert_ptr_ne(r, null); 37009 s = toStringO(r); 37010 terminateO(r); 37011 ck_assert_str_eq(s, "true"); 37012 free(s); 37013 // non SmallJson object 37014 smallContainert *c = allocSmallContainer(NULL); 37015 r2 = self->f->setNFreeSmallContainer(self, "1", c); 37016 ck_assert_ptr_ne(r2, null); 37017 r = self->f->getNDupSmallJson(self, "1"); 37018 ck_assert_ptr_eq(r, null); 37019 // path 37020 smallJsont *value = allocSmallJson(); 37021 createSmallArray(a); 37022 createSmallDict(d); 37023 a.f->pushDict(&a, &d); 37024 self->f->setArray(self, "array", &a); 37025 r = self->f->setSmallJson(self, "\"array\"[0].\"key\"", value); 37026 ck_assert_ptr_ne(r, null); 37027 finishO(value); 37028 r = self->f->getNDupSmallJson(self, "\"array\"[0].\"key\""); 37029 ck_assert_ptr_ne(r, null); 37030 terminateO(r); 37031 // json bool 37032 freeO(self); 37033 setTypeBoolO(self); 37034 r = self->f->getNDupSmallJson(self, "1"); 37035 ck_assert_ptr_eq(r, null); 37036 // json array 37037 freeO(self); 37038 setTypeArrayO(self); 37039 r = self->f->getNDupSmallJson(self, "1"); 37040 ck_assert_ptr_eq(r, null); 37041 // non existing dict path 37042 freeO(self); 37043 r = self->f->getNDupSmallJson(self, "\"1\"[1]"); 37044 ck_assert_ptr_eq(r, null); 37045 // dict path but the object is an array 37046 resetO(&a); 37047 self->f->setArray(self, "1", &a); 37048 r = self->f->getNDupSmallJson(self, "\"1\".\"1\""); 37049 ck_assert_ptr_eq(r, null); 37050 // dict object in path but the key doesn't exists 37051 resetO(&d); 37052 self->f->setDict(self, "2", &d); 37053 r = self->f->getNDupSmallJson(self, "\"2\".\"1\".[12]"); 37054 ck_assert_ptr_eq(r, null); 37055 // null key 37056 r = self->f->getNDupSmallJson(self, null); 37057 ck_assert_ptr_eq(r, null); 37058 // empty self 37059 freeO(self); 37060 r = self->f->getNDupSmallJson(self, "1"); 37061 ck_assert_ptr_eq(r, null); 37062 terminateO(self); 37063 37064 } 37065 37066 37067 void getNDupSmallStringSmallJsonT(void) { 37068 37069 smallStringt* r; 37070 smallJsont *self = allocSmallJson(); 37071 37072 createAllocateSmallString(D); 37073 smallJsont *r2 = self->f->setNFreeSmallString(self, "1", D); 37074 ck_assert_ptr_ne(r2, null); 37075 r = self->f->getNDupSmallString(self, "1"); 37076 ck_assert_ptr_ne(r, null); 37077 char *s = toStringO(r); 37078 terminateO(r); 37079 ck_assert_str_eq(s, ""); 37080 free(s); 37081 // non SmallString object 37082 r2 = self->f->setBool(self, "1", true); 37083 ck_assert_ptr_ne(r2, null); 37084 r = self->f->getNDupSmallString(self, "1"); 37085 ck_assert_ptr_eq(r, null); 37086 // path 37087 smallStringt *value = allocSmallString("asd"); 37088 createSmallArray(a); 37089 createSmallDict(d); 37090 a.f->pushDict(&a, &d); 37091 self->f->setArray(self, "array", &a); 37092 r2 = self->f->setSmallString(self, "\"array\"[0].\"key\"", value); 37093 ck_assert_ptr_ne(r2, null); 37094 finishO(value); 37095 r = self->f->getNDupSmallString(self, "\"array\"[0].\"key\""); 37096 ck_assert_ptr_ne(r, null); 37097 terminateO(r); 37098 // json bool 37099 freeO(self); 37100 setTypeBoolO(self); 37101 r = self->f->getNDupSmallString(self, "1"); 37102 ck_assert_ptr_eq(r, null); 37103 // json array 37104 freeO(self); 37105 setTypeArrayO(self); 37106 r = self->f->getNDupSmallString(self, "1"); 37107 ck_assert_ptr_eq(r, null); 37108 // non existing dict path 37109 freeO(self); 37110 r = self->f->getNDupSmallString(self, "\"1\"[1]"); 37111 ck_assert_ptr_eq(r, null); 37112 // dict path but the object is an array 37113 resetO(&a); 37114 self->f->setArray(self, "1", &a); 37115 r = self->f->getNDupSmallString(self, "\"1\".\"1\""); 37116 ck_assert_ptr_eq(r, null); 37117 // dict object in path but the key doesn't exists 37118 resetO(&d); 37119 self->f->setDict(self, "2", &d); 37120 r = self->f->getNDupSmallString(self, "\"2\".\"1\".[12]"); 37121 ck_assert_ptr_eq(r, null); 37122 // null key 37123 r = self->f->getNDupSmallString(self, null); 37124 ck_assert_ptr_eq(r, null); 37125 // empty self 37126 freeO(self); 37127 r = self->f->getNDupSmallString(self, "1"); 37128 ck_assert_ptr_eq(r, null); 37129 terminateO(self); 37130 37131 } 37132 37133 37134 void getNDupVoidSmallJsonT(void) { 37135 37136 void* r; 37137 smallJsont *self = allocSmallJson(); 37138 37139 smallContainert* D = allocSmallContainer(&r); 37140 smallJsont *r2 = self->f->setNFreeSmallContainer(self, "1", D); 37141 ck_assert_ptr_ne(r2, null); 37142 r = self->f->getNDupVoid(self, "1"); 37143 // result is null because the duplicate function in the container 37144 // is not set. 37145 ck_assert_ptr_eq(r, null); 37146 // non container object 37147 r2 = self->f->setBool(self, "1", true); 37148 ck_assert_ptr_ne(r2, null); 37149 r = self->f->getNDupVoid(self, "1"); 37150 ck_assert_ptr_eq(r, null); 37151 // path 37152 smallContainert *value = allocSmallContainer(&r); 37153 createSmallArray(a); 37154 createSmallDict(d); 37155 a.f->pushDict(&a, &d); 37156 self->f->setArray(self, "array", &a); 37157 r2 = self->f->setSmallContainer(self, "\"array\"[0].\"key\"", value); 37158 ck_assert_ptr_ne(r2, null); 37159 finishO(value); 37160 r = self->f->getNDupVoid(self, "\"array\"[0].\"key\""); 37161 // result is null because the duplicate function in the container 37162 // is not set. 37163 ck_assert_ptr_eq(r, null); 37164 // json bool 37165 freeO(self); 37166 setTypeBoolO(self); 37167 r = self->f->getNDupVoid(self, "1"); 37168 ck_assert_ptr_eq(r, null); 37169 // json array 37170 freeO(self); 37171 setTypeArrayO(self); 37172 r = self->f->getNDupVoid(self, "1"); 37173 ck_assert_ptr_eq(r, null); 37174 // non existing dict path 37175 freeO(self); 37176 r = self->f->getNDupVoid(self, "\"1\"[1]"); 37177 ck_assert_ptr_eq(r, null); 37178 // dict path but the object is an array 37179 resetO(&a); 37180 self->f->setArray(self, "1", &a); 37181 r = self->f->getNDupVoid(self, "\"1\".\"1\""); 37182 ck_assert_ptr_eq(r, null); 37183 // dict object in path but the key doesn't exists 37184 resetO(&d); 37185 self->f->setDict(self, "2", &d); 37186 r = self->f->getNDupVoid(self, "\"2\".\"1\".[12]"); 37187 ck_assert_ptr_eq(r, null); 37188 // null key 37189 r = self->f->getNDupVoid(self, null); 37190 ck_assert_ptr_eq(r, null); 37191 // empty self 37192 freeO(self); 37193 r = self->f->getNDupVoid(self, "1"); 37194 ck_assert_ptr_eq(r, null); 37195 terminateO(self); 37196 37197 } 37198 37199 37200 void getNDupSmallContainerSmallJsonT(void) { 37201 37202 smallContainert* r; 37203 smallJsont *self = allocSmallJson(); 37204 37205 createAllocateSmallContainer(D); 37206 smallJsont *r2 = self->f->setNFreeSmallContainer(self, "1", D); 37207 ck_assert_ptr_ne(r2, null); 37208 r = self->f->getNDupSmallContainer(self, "1"); 37209 ck_assert_ptr_ne(r, null); 37210 char *s = toStringO(r); 37211 terminateO(r); 37212 ck_assert_str_eq(s, "<data smallContainer>"); 37213 free(s); 37214 // other base class 37215 smallIntt *t = allocSmallInt(2); 37216 t->type = "randomClass"; 37217 r2 = self->f->setNFree(self, "1", (baset*)t); 37218 ck_assert_ptr_ne(r2, null); 37219 r = self->f->getNDupSmallContainer(self, "1"); 37220 ck_assert_ptr_eq(r, null); 37221 // non SmallContainer object 37222 r2 = self->f->setBool(self, "1", true); 37223 ck_assert_ptr_ne(r2, null); 37224 r = self->f->getNDupSmallContainer(self, "1"); 37225 ck_assert_ptr_eq(r, null); 37226 // path 37227 smallContainert *value = allocSmallContainer(null); 37228 createSmallArray(a); 37229 createSmallDict(d); 37230 a.f->pushDict(&a, &d); 37231 self->f->setArray(self, "array", &a); 37232 r2 = self->f->setSmallContainer(self, "\"array\"[0].\"key\"", value); 37233 ck_assert_ptr_ne(r2, null); 37234 finishO(value); 37235 r = self->f->getNDupSmallContainer(self, "\"array\"[0].\"key\""); 37236 ck_assert_ptr_ne(r, null); 37237 terminateO(r); 37238 // json bool 37239 freeO(self); 37240 setTypeBoolO(self); 37241 r = self->f->getNDupSmallContainer(self, "1"); 37242 ck_assert_ptr_eq(r, null); 37243 // json array 37244 freeO(self); 37245 setTypeArrayO(self); 37246 r = self->f->getNDupSmallContainer(self, "1"); 37247 ck_assert_ptr_eq(r, null); 37248 // non existing dict path 37249 freeO(self); 37250 r = self->f->getNDupSmallContainer(self, "\"1\"[1]"); 37251 ck_assert_ptr_eq(r, null); 37252 // dict path but the object is an array 37253 resetO(&a); 37254 self->f->setArray(self, "1", &a); 37255 r = self->f->getNDupSmallContainer(self, "\"1\".\"1\""); 37256 ck_assert_ptr_eq(r, null); 37257 // dict object in path but the key doesn't exists 37258 resetO(&d); 37259 self->f->setDict(self, "2", &d); 37260 r = self->f->getNDupSmallContainer(self, "\"2\".\"1\".[12]"); 37261 ck_assert_ptr_eq(r, null); 37262 // null key 37263 r = self->f->getNDupSmallContainer(self, null); 37264 ck_assert_ptr_eq(r, null); 37265 // empty self 37266 freeO(self); 37267 r = self->f->getNDupSmallContainer(self, "1"); 37268 ck_assert_ptr_eq(r, null); 37269 terminateO(self); 37270 37271 } 37272 37273 37274 void getAtSmallJsonT(void) { 37275 37276 baset* r; 37277 smallJsont *self = allocG(rtSmallJsont); 37278 smallJsont *r2; 37279 37280 // non json array 37281 ck_assert_ptr_eq(getAtO(self, 0), null); 37282 // add elements to self 37283 r2 = self->f->pushInt(self, 1); 37284 ck_assert_ptr_ne(r2, null); 37285 createSmallDict(e2); 37286 r2 = self->f->pushDict(self, &e2); 37287 ck_assert_ptr_ne(r2, null); 37288 r2 = self->f->pushInt(self, 3); 37289 ck_assert_ptr_ne(r2, null); 37290 createSmallDict(e4); 37291 r2 = self->f->pushDict(self, &e4); 37292 ck_assert_ptr_ne(r2, null); 37293 // positive index 37294 r = getAtO(self,1); 37295 ck_assert_ptr_ne(r, null); 37296 char *s = toStringO(r); 37297 finishO(r); 37298 ck_assert_str_eq(s, "{}"); 37299 free(s); 37300 s = toStringO(self); 37301 ck_assert_str_eq(s, "[1,{},3,{}]"); 37302 free(s); 37303 // negative index 37304 r = getAtO(self,-1); 37305 ck_assert_ptr_ne(r, null); 37306 s = toStringO(r); 37307 finishO(r); 37308 ck_assert_str_eq(s, "{}"); 37309 free(s); 37310 s = toStringO(self); 37311 ck_assert_str_eq(s, "[1,{},3,{}]"); 37312 free(s); 37313 // index outside 37314 ck_assert_ptr_eq(getAtO(self, 20), NULL); 37315 ck_assert_ptr_eq(getAtO(self, -7), NULL); 37316 // empty list 37317 emptyO(self); 37318 ck_assert_ptr_eq(getAtO(self, 0), NULL); 37319 ck_assert_ptr_eq(getAtO(self, -1), NULL); 37320 terminateO(self); 37321 37322 } 37323 37324 37325 void getAtUndefinedSmallJsonT(void) { 37326 37327 undefinedt* r; 37328 smallJsont *self = allocSmallJson(); 37329 smallJsont *r2; 37330 37331 // non json array 37332 ck_assert_ptr_eq(self->f->getAtUndefined(self, 0), null); 37333 // add elements to self 37334 r2 = self->f->pushInt(self, 1); 37335 ck_assert_ptr_ne(r2, null); 37336 r2 = self->f->pushUndefined(self); 37337 ck_assert_ptr_ne(r2, null); 37338 r2 = self->f->pushInt(self, 3); 37339 ck_assert_ptr_ne(r2, null); 37340 r2 = self->f->pushUndefined(self); 37341 ck_assert_ptr_ne(r2, null); 37342 37343 // positive index 37344 r = self->f->getAtUndefined(self,1); 37345 ck_assert_ptr_ne(r, null); 37346 char *s = toStringO(r); 37347 finishO(r); 37348 ck_assert_str_eq(s, "null"); 37349 free(s); 37350 s = toStringO(self); 37351 ck_assert_str_eq(s, "[1,null,3,null]"); 37352 free(s); 37353 // negative index 37354 r = self->f->getAtUndefined(self,-1); 37355 ck_assert_ptr_ne(r, null); 37356 s = toStringO(r); 37357 finishO(r); 37358 ck_assert_str_eq(s, "null"); 37359 free(s); 37360 s = toStringO(self); 37361 ck_assert_str_eq(s, "[1,null,3,null]"); 37362 free(s); 37363 // wrong object type 37364 createSmallInt(I); 37365 setValG(&I, 11); 37366 r2 = self->f->pushSmallInt(self, &I); 37367 ck_assert_ptr_ne(r2, null); 37368 r = self->f->getAtUndefined(self,-1); 37369 ck_assert_ptr_eq(r, null); 37370 s = toStringO(self); 37371 ck_assert_str_eq(s, "[1,null,3,null,11]"); 37372 free(s); 37373 // index outside 37374 ck_assert_ptr_eq(self->f->getAtUndefined(self, 20), NULL); 37375 ck_assert_ptr_eq(self->f->getAtUndefined(self, -6), NULL); 37376 // empty list 37377 emptyO(self); 37378 ck_assert_ptr_eq(self->f->getAtUndefined(self, 0), NULL); 37379 ck_assert_ptr_eq(self->f->getAtUndefined(self, -1), NULL); 37380 terminateO(self); 37381 37382 } 37383 37384 37385 void getAtBoolSmallJsonT(void) { 37386 37387 bool r; 37388 smallJsont *self = allocSmallJson(); 37389 smallJsont *r2; 37390 37391 // add elements to self 37392 r2 = self->f->pushInt(self, 1); 37393 ck_assert_ptr_ne(r2, null); 37394 r2 = self->f->pushBool(self, TRUE); 37395 ck_assert_ptr_ne(r2, null); 37396 r2 = self->f->pushInt(self, 3); 37397 ck_assert_ptr_ne(r2, null); 37398 r2 = self->f->pushBool(self, TRUE); 37399 ck_assert_ptr_ne(r2, null); 37400 37401 // positive index 37402 r = self->f->getAtBool(self,1); 37403 ck_assert(r); 37404 char *s = toStringO(self); 37405 ck_assert_str_eq(s, "[1,true,3,true]"); 37406 free(s); 37407 // negative index 37408 r = self->f->getAtBool(self,-1); 37409 ck_assert(r); 37410 s = toStringO(self); 37411 ck_assert_str_eq(s, "[1,true,3,true]"); 37412 free(s); 37413 // wrong object type 37414 createSmallInt(I); 37415 setValG(&I, 11); 37416 r2 = self->f->pushSmallInt(self, &I); 37417 r = self->f->getAtBool(self,-1); 37418 ck_assert(!r); 37419 s = toStringO(self); 37420 ck_assert_str_eq(s, "[1,true,3,true,11]"); 37421 free(s); 37422 // wrong object type of another user class 37423 // User classes are stored in containers transparently 37424 createAllocateSmallInt(ip); 37425 ip->type = "anothertype"; 37426 setValG(ip, 11); 37427 r2 = self->f->push(self, (baset*)ip); 37428 ck_assert_ptr_ne(r2, null); 37429 r = self->f->getAtBool(self,-1); 37430 ck_assert(!r); 37431 s = toStringO(self); 37432 ck_assert_str_eq(s, "[1,true,3,true,11,\"<data container>\"]"); 37433 free(s); 37434 // index outside 37435 ck_assert(!self->f->getAtBool(self, 20)); 37436 ck_assert(!self->f->getAtBool(self, -7)); 37437 // empty list 37438 emptyO(self); 37439 ck_assert(!self->f->getAtBool(self, 0)); 37440 ck_assert(!self->f->getAtBool(self, -1)); 37441 terminateO(self); 37442 37443 } 37444 37445 37446 void getAtBoolPSmallJsonT(void) { 37447 37448 bool* r; 37449 smallJsont *self = allocSmallJson(); 37450 smallJsont *r2; 37451 37452 // add elements to self 37453 r2 = self->f->pushInt(self, 1); 37454 ck_assert_ptr_ne(r2, null); 37455 r2 = self->f->pushBool(self, TRUE); 37456 ck_assert_ptr_ne(r2, null); 37457 r2 = self->f->pushInt(self, 3); 37458 ck_assert_ptr_ne(r2, null); 37459 r2 = self->f->pushBool(self, TRUE); 37460 ck_assert_ptr_ne(r2, null); 37461 37462 // positive index 37463 r = self->f->getAtBoolP(self,1); 37464 ck_assert_ptr_ne(r, null); 37465 ck_assert(*r); 37466 char *s = toStringO(self); 37467 ck_assert_str_eq(s, "[1,true,3,true]"); 37468 free(s); 37469 // negative index 37470 r = self->f->getAtBoolP(self,-1); 37471 ck_assert_ptr_ne(r, null); 37472 ck_assert(*r); 37473 s = toStringO(self); 37474 ck_assert_str_eq(s, "[1,true,3,true]"); 37475 free(s); 37476 // wrong object type 37477 createSmallInt(I); 37478 setValG(&I, 11); 37479 r2 = self->f->pushSmallInt(self, &I); 37480 r = self->f->getAtBoolP(self,-1); 37481 ck_assert_ptr_eq(r, null); 37482 s = toStringO(self); 37483 ck_assert_str_eq(s, "[1,true,3,true,11]"); 37484 free(s); 37485 // wrong object type of another user class 37486 // User classes are stored in containers transparently 37487 createAllocateSmallInt(ip); 37488 ip->type = "anothertype"; 37489 setValG(ip, 11); 37490 r2 = self->f->push(self, (baset*)ip); 37491 ck_assert_ptr_ne(r2, null); 37492 r = self->f->getAtBoolP(self,-1); 37493 ck_assert_ptr_eq(r, null); 37494 s = toStringO(self); 37495 ck_assert_str_eq(s, "[1,true,3,true,11,\"<data container>\"]"); 37496 free(s); 37497 // index outside 37498 ck_assert(!self->f->getAtBoolP(self, 20)); 37499 ck_assert(!self->f->getAtBoolP(self, -7)); 37500 // empty list 37501 emptyO(self); 37502 ck_assert(!self->f->getAtBoolP(self, 0)); 37503 ck_assert(!self->f->getAtBoolP(self, -1)); 37504 terminateO(self); 37505 37506 } 37507 37508 37509 void getAtDoubleSmallJsonT(void) { 37510 37511 double r; 37512 smallJsont *self = allocSmallJson(); 37513 smallJsont *r2; 37514 37515 // add elements to self 37516 r2 = self->f->pushInt(self, 1); 37517 ck_assert_ptr_ne(r2, null); 37518 r2 = self->f->pushDouble(self, 2); 37519 ck_assert_ptr_ne(r2, null); 37520 r2 = self->f->pushInt(self, 3); 37521 ck_assert_ptr_ne(r2, null); 37522 r2 = self->f->pushDouble(self, 4); 37523 ck_assert_ptr_ne(r2, null); 37524 37525 // positive index 37526 r = self->f->getAtDouble(self,1); 37527 ck_assert(r==2); 37528 char *s = toStringO(self); 37529 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00]"); 37530 free(s); 37531 // negative index 37532 r = self->f->getAtDouble(self,-1); 37533 ck_assert(r==4); 37534 s = toStringO(self); 37535 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00]"); 37536 free(s); 37537 // wrong object type 37538 createSmallInt(I); 37539 setValG(&I, 11); 37540 r2 = self->f->pushSmallInt(self, &I); 37541 r = self->f->getAtDouble(self,-1); 37542 ck_assert(!r); 37543 s = toStringO(self); 37544 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00,11]"); 37545 free(s); 37546 // wrong object type of another user class 37547 // User classes are stored in containers transparently 37548 createAllocateSmallInt(ip); 37549 ip->type = "anothertype"; 37550 setValG(ip, 11); 37551 r2 = self->f->push(self, (baset*)ip); 37552 ck_assert_ptr_ne(r2, null); 37553 r = self->f->getAtDouble(self,-1); 37554 ck_assert(!r); 37555 s = toStringO(self); 37556 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00,11,\"<data container>\"]"); 37557 free(s); 37558 // index outside 37559 ck_assert(!self->f->getAtDouble(self, 20)); 37560 ck_assert(!self->f->getAtDouble(self, -7)); 37561 // empty list 37562 emptyO(self); 37563 ck_assert(!self->f->getAtDouble(self, 0)); 37564 ck_assert(!self->f->getAtDouble(self, -1)); 37565 terminateO(self); 37566 37567 } 37568 37569 37570 void getAtDoublePSmallJsonT(void) { 37571 37572 double* r; 37573 smallJsont *self = allocSmallJson(); 37574 smallJsont *r2; 37575 37576 // add elements to self 37577 r2 = self->f->pushInt(self, 1); 37578 ck_assert_ptr_ne(r2, null); 37579 r2 = self->f->pushDouble(self, 2); 37580 ck_assert_ptr_ne(r2, null); 37581 r2 = self->f->pushInt(self, 3); 37582 ck_assert_ptr_ne(r2, null); 37583 r2 = self->f->pushDouble(self, 4); 37584 ck_assert_ptr_ne(r2, null); 37585 37586 // positive index 37587 r = self->f->getAtDoubleP(self,1); 37588 ck_assert_ptr_ne(r, null); 37589 ck_assert(*r==2); 37590 char *s = toStringO(self); 37591 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00]"); 37592 free(s); 37593 // negative index 37594 r = self->f->getAtDoubleP(self,-1); 37595 ck_assert_ptr_ne(r, null); 37596 ck_assert(*r==4); 37597 s = toStringO(self); 37598 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00]"); 37599 free(s); 37600 // wrong object type 37601 createSmallInt(I); 37602 setValG(&I, 11); 37603 r2 = self->f->pushSmallInt(self, &I); 37604 r = self->f->getAtDoubleP(self,-1); 37605 ck_assert_ptr_eq(r, null); 37606 s = toStringO(self); 37607 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00,11]"); 37608 free(s); 37609 // wrong object type of another user class 37610 // User classes are stored in containers transparently 37611 createAllocateSmallInt(ip); 37612 ip->type = "anothertype"; 37613 setValG(ip, 11); 37614 r2 = self->f->push(self, (baset*)ip); 37615 ck_assert_ptr_ne(r2, null); 37616 r = self->f->getAtDoubleP(self,-1); 37617 ck_assert_ptr_eq(r, null); 37618 s = toStringO(self); 37619 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00,11,\"<data container>\"]"); 37620 free(s); 37621 // index outside 37622 ck_assert(!self->f->getAtDoubleP(self, 20)); 37623 ck_assert(!self->f->getAtDoubleP(self, -7)); 37624 // empty list 37625 emptyO(self); 37626 ck_assert(!self->f->getAtDoubleP(self, 0)); 37627 ck_assert(!self->f->getAtDoubleP(self, -1)); 37628 terminateO(self); 37629 37630 } 37631 37632 37633 void getAtIntSmallJsonT(void) { 37634 37635 int64_t r; 37636 smallJsont *self = allocSmallJson(); 37637 smallJsont *r2; 37638 37639 // add elements to self 37640 r2 = self->f->pushInt(self, 1); 37641 ck_assert_ptr_ne(r2, null); 37642 r2 = self->f->pushInt(self, 2); 37643 ck_assert_ptr_ne(r2, null); 37644 r2 = self->f->pushInt(self, 3); 37645 ck_assert_ptr_ne(r2, null); 37646 r2 = self->f->pushInt(self, 4); 37647 ck_assert_ptr_ne(r2, null); 37648 37649 // positive index 37650 r = self->f->getAtInt(self,1); 37651 ck_assert(r==2); 37652 char *s = toStringO(self); 37653 ck_assert_str_eq(s, "[1,2,3,4]"); 37654 free(s); 37655 // negative index 37656 r = self->f->getAtInt(self,-1); 37657 ck_assert(r==4); 37658 s = toStringO(self); 37659 ck_assert_str_eq(s, "[1,2,3,4]"); 37660 free(s); 37661 // wrong object type 37662 createSmallDouble(I); 37663 setValG(&I, 11); 37664 r2 = self->f->pushSmallDouble(self, &I); 37665 r = self->f->getAtInt(self,-1); 37666 ck_assert(!r); 37667 s = toStringO(self); 37668 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 37669 free(s); 37670 // wrong object type of another user class 37671 // User classes are stored in containers transparently 37672 createAllocateSmallInt(ip); 37673 ip->type = "anothertype"; 37674 setValG(ip, 11); 37675 r2 = self->f->push(self, (baset*)ip); 37676 ck_assert_ptr_ne(r2, null); 37677 r = self->f->getAtInt(self,-1); 37678 ck_assert(!r); 37679 s = toStringO(self); 37680 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 37681 free(s); 37682 // index outside 37683 ck_assert(!self->f->getAtInt(self, 20)); 37684 ck_assert(!self->f->getAtInt(self, -7)); 37685 // empty list 37686 emptyO(self); 37687 ck_assert(!self->f->getAtInt(self, 0)); 37688 ck_assert(!self->f->getAtInt(self, -1)); 37689 terminateO(self); 37690 37691 } 37692 37693 37694 void getAtIntPSmallJsonT(void) { 37695 37696 int64_t* r; 37697 smallJsont *self = allocSmallJson(); 37698 smallJsont *r2; 37699 37700 // add elements to self 37701 r2 = self->f->pushInt(self, 1); 37702 ck_assert_ptr_ne(r2, null); 37703 r2 = self->f->pushInt(self, 2); 37704 ck_assert_ptr_ne(r2, null); 37705 r2 = self->f->pushInt(self, 3); 37706 ck_assert_ptr_ne(r2, null); 37707 r2 = self->f->pushInt(self, 4); 37708 ck_assert_ptr_ne(r2, null); 37709 37710 // positive index 37711 r = self->f->getAtIntP(self,1); 37712 ck_assert_ptr_ne(r, null); 37713 ck_assert(*r==2); 37714 char *s = toStringO(self); 37715 ck_assert_str_eq(s, "[1,2,3,4]"); 37716 free(s); 37717 // negative index 37718 r = self->f->getAtIntP(self,-1); 37719 ck_assert_ptr_ne(r, null); 37720 ck_assert(*r==4); 37721 s = toStringO(self); 37722 ck_assert_str_eq(s, "[1,2,3,4]"); 37723 free(s); 37724 // wrong object type 37725 createSmallDouble(I); 37726 setValG(&I, 11); 37727 r2 = self->f->pushSmallDouble(self, &I); 37728 r = self->f->getAtIntP(self,-1); 37729 ck_assert_ptr_eq(r, null); 37730 s = toStringO(self); 37731 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 37732 free(s); 37733 // wrong object type of another user class 37734 // User classes are stored in containers transparently 37735 createAllocateSmallInt(ip); 37736 ip->type = "anothertype"; 37737 setValG(ip, 11); 37738 r2 = self->f->push(self, (baset*)ip); 37739 ck_assert_ptr_ne(r2, null); 37740 r = self->f->getAtIntP(self,-1); 37741 ck_assert_ptr_eq(r, null); 37742 s = toStringO(self); 37743 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 37744 free(s); 37745 // index outside 37746 ck_assert(!self->f->getAtIntP(self, 20)); 37747 ck_assert(!self->f->getAtIntP(self, -7)); 37748 // empty list 37749 emptyO(self); 37750 ck_assert(!self->f->getAtIntP(self, 0)); 37751 ck_assert(!self->f->getAtIntP(self, -1)); 37752 terminateO(self); 37753 37754 } 37755 37756 37757 void getAtInt32SmallJsonT(void) { 37758 37759 int32_t r; 37760 smallJsont *self = allocSmallJson(); 37761 smallJsont *r2; 37762 37763 // add elements to self 37764 r2 = self->f->pushInt(self, 1); 37765 ck_assert_ptr_ne(r2, null); 37766 r2 = self->f->pushInt(self, 2); 37767 ck_assert_ptr_ne(r2, null); 37768 r2 = self->f->pushInt(self, 3); 37769 ck_assert_ptr_ne(r2, null); 37770 r2 = self->f->pushInt(self, 4); 37771 ck_assert_ptr_ne(r2, null); 37772 37773 // positive index 37774 r = self->f->getAtInt32(self,1); 37775 ck_assert(r==2); 37776 char *s = toStringO(self); 37777 ck_assert_str_eq(s, "[1,2,3,4]"); 37778 free(s); 37779 // negative index 37780 r = self->f->getAtInt32(self,-1); 37781 ck_assert(r==4); 37782 s = toStringO(self); 37783 ck_assert_str_eq(s, "[1,2,3,4]"); 37784 free(s); 37785 // wrong object type 37786 createSmallDouble(I); 37787 setValG(&I, 11); 37788 r2 = self->f->pushSmallDouble(self, &I); 37789 r = self->f->getAtInt32(self,-1); 37790 ck_assert(!r); 37791 s = toStringO(self); 37792 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 37793 free(s); 37794 // wrong object type of another user class 37795 // User classes are stored in containers transparently 37796 createAllocateSmallInt(ip); 37797 ip->type = "anothertype"; 37798 setValG(ip, 11); 37799 r2 = self->f->push(self, (baset*)ip); 37800 ck_assert_ptr_ne(r2, null); 37801 r = self->f->getAtInt32(self,-1); 37802 ck_assert(!r); 37803 s = toStringO(self); 37804 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 37805 free(s); 37806 // index outside 37807 ck_assert(!self->f->getAtInt32(self, 20)); 37808 ck_assert(!self->f->getAtInt32(self, -7)); 37809 // empty list 37810 emptyO(self); 37811 ck_assert(!self->f->getAtInt32(self, 0)); 37812 ck_assert(!self->f->getAtInt32(self, -1)); 37813 terminateO(self); 37814 37815 } 37816 37817 37818 void getAtInt32PSmallJsonT(void) { 37819 37820 int32_t* r; 37821 smallJsont *self = allocSmallJson(); 37822 smallJsont *r2; 37823 37824 // add elements to self 37825 r2 = self->f->pushInt(self, 1); 37826 ck_assert_ptr_ne(r2, null); 37827 r2 = self->f->pushInt(self, 2); 37828 ck_assert_ptr_ne(r2, null); 37829 r2 = self->f->pushInt(self, 3); 37830 ck_assert_ptr_ne(r2, null); 37831 r2 = self->f->pushInt(self, 4); 37832 ck_assert_ptr_ne(r2, null); 37833 37834 // positive index 37835 r = self->f->getAtInt32P(self,1); 37836 ck_assert_ptr_ne(r, null); 37837 ck_assert(*r==2); 37838 char *s = toStringO(self); 37839 ck_assert_str_eq(s, "[1,2,3,4]"); 37840 free(s); 37841 // negative index 37842 r = self->f->getAtInt32P(self,-1); 37843 ck_assert_ptr_ne(r, null); 37844 ck_assert(*r==4); 37845 s = toStringO(self); 37846 ck_assert_str_eq(s, "[1,2,3,4]"); 37847 free(s); 37848 // wrong object type 37849 createSmallDouble(I); 37850 setValG(&I, 11); 37851 r2 = self->f->pushSmallDouble(self, &I); 37852 r = self->f->getAtInt32P(self,-1); 37853 ck_assert_ptr_eq(r, null); 37854 s = toStringO(self); 37855 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 37856 free(s); 37857 // wrong object type of another user class 37858 // User classes are stored in containers transparently 37859 createAllocateSmallInt(ip); 37860 ip->type = "anothertype"; 37861 setValG(ip, 11); 37862 r2 = self->f->push(self, (baset*)ip); 37863 ck_assert_ptr_ne(r2, null); 37864 r = self->f->getAtInt32P(self,-1); 37865 ck_assert_ptr_eq(r, null); 37866 s = toStringO(self); 37867 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 37868 free(s); 37869 // index outside 37870 ck_assert(!self->f->getAtInt32P(self, 20)); 37871 ck_assert(!self->f->getAtInt32P(self, -7)); 37872 // empty list 37873 emptyO(self); 37874 ck_assert(!self->f->getAtInt32P(self, 0)); 37875 ck_assert(!self->f->getAtInt32P(self, -1)); 37876 terminateO(self); 37877 37878 } 37879 37880 37881 void getAtUintSmallJsonT(void) { 37882 37883 uint64_t r; 37884 smallJsont *self = allocSmallJson(); 37885 smallJsont *r2; 37886 37887 // add elements to self 37888 r2 = self->f->pushInt(self, 1); 37889 ck_assert_ptr_ne(r2, null); 37890 r2 = self->f->pushInt(self, 2); 37891 ck_assert_ptr_ne(r2, null); 37892 r2 = self->f->pushInt(self, 3); 37893 ck_assert_ptr_ne(r2, null); 37894 r2 = self->f->pushInt(self, 4); 37895 ck_assert_ptr_ne(r2, null); 37896 37897 // positive index 37898 r = self->f->getAtUint(self,1); 37899 ck_assert(r==2); 37900 char *s = toStringO(self); 37901 ck_assert_str_eq(s, "[1,2,3,4]"); 37902 free(s); 37903 // negative index 37904 r = self->f->getAtUint(self,-1); 37905 ck_assert(r==4); 37906 s = toStringO(self); 37907 ck_assert_str_eq(s, "[1,2,3,4]"); 37908 free(s); 37909 // wrong object type 37910 createSmallDouble(I); 37911 setValG(&I, 11); 37912 r2 = self->f->pushSmallDouble(self, &I); 37913 r = self->f->getAtUint(self,-1); 37914 ck_assert(!r); 37915 s = toStringO(self); 37916 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 37917 free(s); 37918 // wrong object type of another user class 37919 // User classes are stored in containers transparently 37920 createAllocateSmallInt(ip); 37921 ip->type = "anothertype"; 37922 setValG(ip, 11); 37923 r2 = self->f->push(self, (baset*)ip); 37924 ck_assert_ptr_ne(r2, null); 37925 r = self->f->getAtUint(self,-1); 37926 ck_assert(!r); 37927 s = toStringO(self); 37928 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 37929 free(s); 37930 // index outside 37931 ck_assert(!self->f->getAtUint(self, 20)); 37932 ck_assert(!self->f->getAtUint(self, -7)); 37933 // empty list 37934 emptyO(self); 37935 ck_assert(!self->f->getAtUint(self, 0)); 37936 ck_assert(!self->f->getAtUint(self, -1)); 37937 terminateO(self); 37938 37939 } 37940 37941 37942 void getAtUintPSmallJsonT(void) { 37943 37944 uint64_t* r; 37945 smallJsont *self = allocSmallJson(); 37946 smallJsont *r2; 37947 37948 // add elements to self 37949 r2 = self->f->pushInt(self, 1); 37950 ck_assert_ptr_ne(r2, null); 37951 r2 = self->f->pushInt(self, 2); 37952 ck_assert_ptr_ne(r2, null); 37953 r2 = self->f->pushInt(self, 3); 37954 ck_assert_ptr_ne(r2, null); 37955 r2 = self->f->pushInt(self, 4); 37956 ck_assert_ptr_ne(r2, null); 37957 37958 // positive index 37959 r = self->f->getAtUintP(self,1); 37960 ck_assert_ptr_ne(r, null); 37961 ck_assert(*r==2); 37962 char *s = toStringO(self); 37963 ck_assert_str_eq(s, "[1,2,3,4]"); 37964 free(s); 37965 // negative index 37966 r = self->f->getAtUintP(self,-1); 37967 ck_assert_ptr_ne(r, null); 37968 ck_assert(*r==4); 37969 s = toStringO(self); 37970 ck_assert_str_eq(s, "[1,2,3,4]"); 37971 free(s); 37972 // wrong object type 37973 createSmallDouble(I); 37974 setValG(&I, 11); 37975 r2 = self->f->pushSmallDouble(self, &I); 37976 r = self->f->getAtUintP(self,-1); 37977 ck_assert_ptr_eq(r, null); 37978 s = toStringO(self); 37979 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 37980 free(s); 37981 // wrong object type of another user class 37982 // User classes are stored in containers transparently 37983 createAllocateSmallInt(ip); 37984 ip->type = "anothertype"; 37985 setValG(ip, 11); 37986 r2 = self->f->push(self, (baset*)ip); 37987 ck_assert_ptr_ne(r2, null); 37988 r = self->f->getAtUintP(self,-1); 37989 ck_assert_ptr_eq(r, null); 37990 s = toStringO(self); 37991 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 37992 free(s); 37993 // index outside 37994 ck_assert(!self->f->getAtUintP(self, 20)); 37995 ck_assert(!self->f->getAtUintP(self, -7)); 37996 // empty list 37997 emptyO(self); 37998 ck_assert(!self->f->getAtUintP(self, 0)); 37999 ck_assert(!self->f->getAtUintP(self, -1)); 38000 terminateO(self); 38001 38002 } 38003 38004 38005 void getAtUint32SmallJsonT(void) { 38006 38007 uint32_t r; 38008 smallJsont *self = allocSmallJson(); 38009 smallJsont *r2; 38010 38011 // add elements to self 38012 r2 = self->f->pushInt(self, 1); 38013 ck_assert_ptr_ne(r2, null); 38014 r2 = self->f->pushInt(self, 2); 38015 ck_assert_ptr_ne(r2, null); 38016 r2 = self->f->pushInt(self, 3); 38017 ck_assert_ptr_ne(r2, null); 38018 r2 = self->f->pushInt(self, 4); 38019 ck_assert_ptr_ne(r2, null); 38020 38021 // positive index 38022 r = self->f->getAtUint32(self,1); 38023 ck_assert(r==2); 38024 char *s = toStringO(self); 38025 ck_assert_str_eq(s, "[1,2,3,4]"); 38026 free(s); 38027 // negative index 38028 r = self->f->getAtUint32(self,-1); 38029 ck_assert(r==4); 38030 s = toStringO(self); 38031 ck_assert_str_eq(s, "[1,2,3,4]"); 38032 free(s); 38033 // wrong object type 38034 createSmallDouble(I); 38035 setValG(&I, 11); 38036 r2 = self->f->pushSmallDouble(self, &I); 38037 r = self->f->getAtUint32(self,-1); 38038 ck_assert(!r); 38039 s = toStringO(self); 38040 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 38041 free(s); 38042 // wrong object type of another user class 38043 // User classes are stored in containers transparently 38044 createAllocateSmallInt(ip); 38045 ip->type = "anothertype"; 38046 setValG(ip, 11); 38047 r2 = self->f->push(self, (baset*)ip); 38048 ck_assert_ptr_ne(r2, null); 38049 r = self->f->getAtUint32(self,-1); 38050 ck_assert(!r); 38051 s = toStringO(self); 38052 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 38053 free(s); 38054 // index outside 38055 ck_assert(!self->f->getAtUint32(self, 20)); 38056 ck_assert(!self->f->getAtUint32(self, -7)); 38057 // empty list 38058 emptyO(self); 38059 ck_assert(!self->f->getAtUint32(self, 0)); 38060 ck_assert(!self->f->getAtUint32(self, -1)); 38061 terminateO(self); 38062 38063 } 38064 38065 38066 void getAtUint32PSmallJsonT(void) { 38067 38068 uint32_t* r; 38069 smallJsont *self = allocSmallJson(); 38070 smallJsont *r2; 38071 38072 // add elements to self 38073 r2 = self->f->pushInt(self, 1); 38074 ck_assert_ptr_ne(r2, null); 38075 r2 = self->f->pushInt(self, 2); 38076 ck_assert_ptr_ne(r2, null); 38077 r2 = self->f->pushInt(self, 3); 38078 ck_assert_ptr_ne(r2, null); 38079 r2 = self->f->pushInt(self, 4); 38080 ck_assert_ptr_ne(r2, null); 38081 38082 // positive index 38083 r = self->f->getAtUint32P(self,1); 38084 ck_assert_ptr_ne(r, null); 38085 ck_assert(*r==2); 38086 char *s = toStringO(self); 38087 ck_assert_str_eq(s, "[1,2,3,4]"); 38088 free(s); 38089 // negative index 38090 r = self->f->getAtUint32P(self,-1); 38091 ck_assert_ptr_ne(r, null); 38092 ck_assert(*r==4); 38093 s = toStringO(self); 38094 ck_assert_str_eq(s, "[1,2,3,4]"); 38095 free(s); 38096 // wrong object type 38097 createSmallDouble(I); 38098 setValG(&I, 11); 38099 r2 = self->f->pushSmallDouble(self, &I); 38100 r = self->f->getAtUint32P(self,-1); 38101 ck_assert_ptr_eq(r, null); 38102 s = toStringO(self); 38103 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 38104 free(s); 38105 // wrong object type of another user class 38106 // User classes are stored in containers transparently 38107 createAllocateSmallInt(ip); 38108 ip->type = "anothertype"; 38109 setValG(ip, 11); 38110 r2 = self->f->push(self, (baset*)ip); 38111 ck_assert_ptr_ne(r2, null); 38112 r = self->f->getAtUint32P(self,-1); 38113 ck_assert_ptr_eq(r, null); 38114 s = toStringO(self); 38115 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 38116 free(s); 38117 // index outside 38118 ck_assert(!self->f->getAtUint32P(self, 20)); 38119 ck_assert(!self->f->getAtUint32P(self, -7)); 38120 // empty list 38121 emptyO(self); 38122 ck_assert(!self->f->getAtUint32P(self, 0)); 38123 ck_assert(!self->f->getAtUint32P(self, -1)); 38124 terminateO(self); 38125 38126 } 38127 38128 38129 void getAtSSmallJsonT(void) { 38130 38131 char* r; 38132 smallJsont *self = allocSmallJson(); 38133 smallJsont *r2; 38134 38135 // add elements to self 38136 r2 = self->f->pushInt(self, 1); 38137 ck_assert_ptr_ne(r2, null); 38138 r2 = self->f->pushS(self, "2"); 38139 ck_assert_ptr_ne(r2, null); 38140 r2 = self->f->pushInt(self, 3); 38141 ck_assert_ptr_ne(r2, null); 38142 r2 = self->f->pushS(self, "4"); 38143 ck_assert_ptr_ne(r2, null); 38144 38145 // positive index 38146 r = self->f->getAtS(self,1); 38147 ck_assert_ptr_ne(r, null); 38148 ck_assert_str_eq(r, "2"); 38149 char *s = toStringO(self); 38150 ck_assert_str_eq(s, "[1,\"2\",3,\"4\"]"); 38151 free(s); 38152 // negative index 38153 r = self->f->getAtS(self,-1); 38154 ck_assert_ptr_ne(r, null); 38155 ck_assert_str_eq(r, "4"); 38156 s = toStringO(self); 38157 ck_assert_str_eq(s, "[1,\"2\",3,\"4\"]"); 38158 free(s); 38159 // wrong object type 38160 createSmallInt(I); 38161 setValG(&I, 11); 38162 r2 = self->f->pushSmallInt(self, &I); 38163 r = self->f->getAtS(self,-1); 38164 ck_assert_ptr_eq(r, NULL); 38165 s = toStringO(self); 38166 ck_assert_str_eq(s, "[1,\"2\",3,\"4\",11]"); 38167 free(s); 38168 // wrong object type of another user class 38169 // User classes are stored in containers transparently 38170 createAllocateSmallInt(ip); 38171 ip->type = "anothertype"; 38172 setValG(ip, 11); 38173 r2 = self->f->push(self, (baset*)ip); 38174 ck_assert_ptr_ne(r2, null); 38175 r = self->f->getAtS(self,-1); 38176 ck_assert_ptr_eq(r, NULL); 38177 s = toStringO(self); 38178 ck_assert_str_eq(s, "[1,\"2\",3,\"4\",11,\"<data container>\"]"); 38179 free(s); 38180 // index outside 38181 ck_assert_ptr_eq(self->f->getAtS(self, 20), NULL); 38182 ck_assert_ptr_eq(self->f->getAtS(self, -7), NULL); 38183 // empty list 38184 emptyO(self); 38185 ck_assert_ptr_eq(self->f->getAtS(self, 0), NULL); 38186 ck_assert_ptr_eq(self->f->getAtS(self, -1), NULL); 38187 terminateO(self); 38188 38189 } 38190 38191 38192 void getAtDictSmallJsonT(void) { 38193 38194 smallDictt* r; 38195 smallJsont *self = allocSmallJson(); 38196 smallJsont *r2; 38197 38198 // non json array 38199 ck_assert_ptr_eq(self->f->getAtDict(self, 0), null); 38200 // add elements to self 38201 r2 = self->f->pushInt(self, 1); 38202 ck_assert_ptr_ne(r2, null); 38203 createSmallDict(e2); 38204 r2 = self->f->pushDict(self, &e2); 38205 ck_assert_ptr_ne(r2, null); 38206 r2 = self->f->pushInt(self, 3); 38207 ck_assert_ptr_ne(r2, null); 38208 createSmallDict(e4); 38209 r2 = self->f->pushDict(self, &e4); 38210 ck_assert_ptr_ne(r2, null); 38211 38212 // positive index 38213 r = self->f->getAtDict(self,1); 38214 ck_assert_ptr_ne(r, null); 38215 char *s = toStringO(r); 38216 finishO(r); 38217 ck_assert_str_eq(s, "{}"); 38218 free(s); 38219 s = toStringO(self); 38220 ck_assert_str_eq(s, "[1,{},3,{}]"); 38221 free(s); 38222 // negative index 38223 r = self->f->getAtDict(self,-1); 38224 ck_assert_ptr_ne(r, null); 38225 s = toStringO(r); 38226 finishO(r); 38227 ck_assert_str_eq(s, "{}"); 38228 free(s); 38229 s = toStringO(self); 38230 ck_assert_str_eq(s, "[1,{},3,{}]"); 38231 free(s); 38232 // wrong object type 38233 createSmallInt(I); 38234 setValG(&I, 11); 38235 r2 = self->f->pushSmallInt(self, &I); 38236 r = self->f->getAtDict(self,-1); 38237 ck_assert_ptr_eq(r, NULL); 38238 s = toStringO(self); 38239 ck_assert_str_eq(s, "[1,{},3,{},11]"); 38240 free(s); 38241 // wrong object type of another user class 38242 // User classes are stored in containers transparently 38243 createAllocateSmallInt(ip); 38244 ip->type = "anothertype"; 38245 setValG(ip, 11); 38246 r2 = self->f->push(self, (baset*)ip); 38247 ck_assert_ptr_ne(r2, null); 38248 r = self->f->getAtDict(self,-1); 38249 ck_assert_ptr_eq(r, NULL); 38250 s = toStringO(self); 38251 ck_assert_str_eq(s, "[1,{},3,{},11,\"<data container>\"]"); 38252 free(s); 38253 // index outside 38254 ck_assert_ptr_eq(self->f->getAtDict(self, 20), NULL); 38255 ck_assert_ptr_eq(self->f->getAtDict(self, -7), NULL); 38256 // empty list 38257 emptyO(self); 38258 ck_assert_ptr_eq(self->f->getAtDict(self, 0), NULL); 38259 ck_assert_ptr_eq(self->f->getAtDict(self, -1), NULL); 38260 terminateO(self); 38261 38262 } 38263 38264 38265 void getAtArraySmallJsonT(void) { 38266 38267 smallArrayt* r; 38268 smallJsont *self = allocSmallJson(); 38269 smallJsont *r2; 38270 38271 // non json array 38272 ck_assert_ptr_eq(self->f->getAtArray(self, 0), null); 38273 // add elements to self 38274 r2 = self->f->pushInt(self, 1); 38275 ck_assert_ptr_ne(r2, null); 38276 createSmallArray(e2); 38277 r2 = self->f->pushArray(self, &e2); 38278 ck_assert_ptr_ne(r2, null); 38279 r2 = self->f->pushInt(self, 3); 38280 ck_assert_ptr_ne(r2, null); 38281 createSmallArray(e4); 38282 r2 = self->f->pushArray(self, &e4); 38283 ck_assert_ptr_ne(r2, null); 38284 38285 // positive index 38286 r = self->f->getAtArray(self,1); 38287 ck_assert_ptr_ne(r, null); 38288 char *s = toStringO(r); 38289 finishO(r); 38290 ck_assert_str_eq(s, "[]"); 38291 free(s); 38292 s = toStringO(self); 38293 ck_assert_str_eq(s, "[1,[],3,[]]"); 38294 free(s); 38295 // negative index 38296 r = self->f->getAtArray(self,-1); 38297 ck_assert_ptr_ne(r, null); 38298 s = toStringO(r); 38299 finishO(r); 38300 ck_assert_str_eq(s, "[]"); 38301 free(s); 38302 s = toStringO(self); 38303 ck_assert_str_eq(s, "[1,[],3,[]]"); 38304 free(s); 38305 // wrong object type 38306 createSmallInt(I); 38307 setValG(&I, 11); 38308 r2 = self->f->pushSmallInt(self, &I); 38309 r = self->f->getAtArray(self,-1); 38310 ck_assert_ptr_eq(r, NULL); 38311 s = toStringO(self); 38312 ck_assert_str_eq(s, "[1,[],3,[],11]"); 38313 free(s); 38314 // wrong object type of another user class 38315 // User classes are stored in containers transparently 38316 createAllocateSmallInt(ip); 38317 ip->type = "anothertype"; 38318 setValG(ip, 11); 38319 r2 = self->f->push(self, (baset*)ip); 38320 ck_assert_ptr_ne(r2, null); 38321 r = self->f->getAtArray(self,-1); 38322 ck_assert_ptr_eq(r, NULL); 38323 s = toStringO(self); 38324 ck_assert_str_eq(s, "[1,[],3,[],11,\"<data container>\"]"); 38325 free(s); 38326 // index outside 38327 ck_assert_ptr_eq(self->f->getAtArray(self, 20), NULL); 38328 ck_assert_ptr_eq(self->f->getAtArray(self, -7), NULL); 38329 // empty list 38330 emptyO(self); 38331 ck_assert_ptr_eq(self->f->getAtArray(self, 0), NULL); 38332 ck_assert_ptr_eq(self->f->getAtArray(self, -1), NULL); 38333 terminateO(self); 38334 38335 } 38336 38337 38338 void getAtSmallBoolSmallJsonT(void) { 38339 38340 smallBoolt* r; 38341 smallJsont *self = allocSmallJson(); 38342 smallJsont *r2; 38343 38344 // non json array 38345 ck_assert_ptr_eq(self->f->getAtSmallBool(self, 0), null); 38346 // add elements to self 38347 r2 = self->f->pushInt(self, 1); 38348 ck_assert_ptr_ne(r2, null); 38349 createSmallBool(e2); 38350 r2 = self->f->pushBool(self, true); 38351 ck_assert_ptr_ne(r2, null); 38352 r2 = self->f->pushInt(self, 3); 38353 ck_assert_ptr_ne(r2, null); 38354 createSmallBool(e4); 38355 r2 = self->f->pushBool(self, true); 38356 ck_assert_ptr_ne(r2, null); 38357 38358 // positive index 38359 r = self->f->getAtSmallBool(self,1); 38360 ck_assert_ptr_ne(r, null); 38361 char *s = toStringO(r); 38362 finishO(r); 38363 ck_assert_str_eq(s, "true"); 38364 free(s); 38365 s = toStringO(self); 38366 ck_assert_str_eq(s, "[1,true,3,true]"); 38367 free(s); 38368 // negative index 38369 r = self->f->getAtSmallBool(self,-1); 38370 ck_assert_ptr_ne(r, null); 38371 s = toStringO(r); 38372 finishO(r); 38373 ck_assert_str_eq(s, "true"); 38374 free(s); 38375 s = toStringO(self); 38376 ck_assert_str_eq(s, "[1,true,3,true]"); 38377 free(s); 38378 // wrong object type 38379 createSmallInt(I); 38380 setValG(&I, 11); 38381 r2 = self->f->pushSmallInt(self, &I); 38382 r = self->f->getAtSmallBool(self,2); 38383 ck_assert_ptr_eq(r, NULL); 38384 s = toStringO(self); 38385 ck_assert_str_eq(s, "[1,true,3,true,11]"); 38386 free(s); 38387 // wrong object type of another user class 38388 // User classes are stored in containers transparently 38389 createAllocateSmallInt(ip); 38390 ip->type = "anothertype"; 38391 setValG(ip, 11); 38392 r2 = self->f->push(self, (baset*)ip); 38393 ck_assert_ptr_ne(r2, null); 38394 r = self->f->getAtSmallBool(self,-1); 38395 ck_assert_ptr_eq(r, NULL); 38396 s = toStringO(self); 38397 ck_assert_str_eq(s, "[1,true,3,true,11,\"<data container>\"]"); 38398 free(s); 38399 // index outside 38400 ck_assert_ptr_eq(self->f->getAtSmallBool(self, 20), NULL); 38401 ck_assert_ptr_eq(self->f->getAtSmallBool(self, -7), NULL); 38402 // empty list 38403 emptyO(self); 38404 ck_assert_ptr_eq(self->f->getAtSmallBool(self, 0), NULL); 38405 ck_assert_ptr_eq(self->f->getAtSmallBool(self, -1), NULL); 38406 terminateO(self); 38407 38408 } 38409 38410 38411 void getAtSmallBytesSmallJsonT(void) { 38412 38413 smallBytest* r; 38414 smallJsont *self = allocSmallJson(); 38415 smallJsont *r2; 38416 38417 // non json array 38418 ck_assert_ptr_eq(self->f->getAtSmallBytes(self, 0), null); 38419 // add elements to self 38420 r2 = self->f->pushInt(self, 1); 38421 ck_assert_ptr_ne(r2, null); 38422 createSmallBytes(e2); 38423 r2 = self->f->pushSmallBytes(self, &e2); 38424 ck_assert_ptr_ne(r2, null); 38425 r2 = self->f->pushInt(self, 3); 38426 ck_assert_ptr_ne(r2, null); 38427 createSmallBytes(e4); 38428 r2 = self->f->pushSmallBytes(self, &e4); 38429 ck_assert_ptr_ne(r2, null); 38430 38431 // positive index 38432 r = self->f->getAtSmallBytes(self,1); 38433 ck_assert_ptr_ne(r, null); 38434 char *s = toStringO(r); 38435 finishO(r); 38436 ck_assert_str_eq(s, "[]"); 38437 free(s); 38438 s = toStringO(self); 38439 ck_assert_str_eq(s, "[1,[],3,[]]"); 38440 free(s); 38441 // negative index 38442 r = self->f->getAtSmallBytes(self,-1); 38443 ck_assert_ptr_ne(r, null); 38444 s = toStringO(r); 38445 finishO(r); 38446 ck_assert_str_eq(s, "[]"); 38447 free(s); 38448 s = toStringO(self); 38449 ck_assert_str_eq(s, "[1,[],3,[]]"); 38450 free(s); 38451 // wrong object type 38452 createSmallInt(I); 38453 setValG(&I, 11); 38454 r2 = self->f->pushSmallInt(self, &I); 38455 r = self->f->getAtSmallBytes(self,-1); 38456 ck_assert_ptr_eq(r, NULL); 38457 s = toStringO(self); 38458 ck_assert_str_eq(s, "[1,[],3,[],11]"); 38459 free(s); 38460 // wrong object type of another user class 38461 // User classes are stored in containers transparently 38462 createAllocateSmallInt(ip); 38463 ip->type = "anothertype"; 38464 setValG(ip, 11); 38465 r2 = self->f->push(self, (baset*)ip); 38466 ck_assert_ptr_ne(r2, null); 38467 r = self->f->getAtSmallBytes(self,-1); 38468 ck_assert_ptr_eq(r, NULL); 38469 s = toStringO(self); 38470 ck_assert_str_eq(s, "[1,[],3,[],11,\"<data container>\"]"); 38471 free(s); 38472 // index outside 38473 ck_assert_ptr_eq(self->f->getAtSmallBytes(self, 20), NULL); 38474 ck_assert_ptr_eq(self->f->getAtSmallBytes(self, -7), NULL); 38475 // empty list 38476 emptyO(self); 38477 ck_assert_ptr_eq(self->f->getAtSmallBytes(self, 0), NULL); 38478 ck_assert_ptr_eq(self->f->getAtSmallBytes(self, -1), NULL); 38479 terminateO(self); 38480 38481 } 38482 38483 38484 void getAtSmallDoubleSmallJsonT(void) { 38485 38486 smallDoublet* r; 38487 smallJsont *self = allocSmallJson(); 38488 smallJsont *r2; 38489 38490 // non json array 38491 ck_assert_ptr_eq(self->f->getAtSmallDouble(self, 0), null); 38492 // add elements to self 38493 r2 = self->f->pushInt(self, 1); 38494 ck_assert_ptr_ne(r2, null); 38495 createSmallDouble(e2); 38496 r2 = self->f->pushSmallDouble(self, &e2); 38497 ck_assert_ptr_ne(r2, null); 38498 r2 = self->f->pushInt(self, 3); 38499 ck_assert_ptr_ne(r2, null); 38500 createSmallDouble(e4); 38501 r2 = self->f->pushSmallDouble(self, &e4); 38502 ck_assert_ptr_ne(r2, null); 38503 38504 // positive index 38505 r = self->f->getAtSmallDouble(self,1); 38506 ck_assert_ptr_ne(r, null); 38507 char *s = toStringO(r); 38508 finishO(r); 38509 ck_assert_str_eq(s, "0.000000e+00"); 38510 free(s); 38511 s = toStringO(self); 38512 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00]"); 38513 free(s); 38514 // negative index 38515 r = self->f->getAtSmallDouble(self,-1); 38516 ck_assert_ptr_ne(r, null); 38517 s = toStringO(r); 38518 finishO(r); 38519 ck_assert_str_eq(s, "0.000000e+00"); 38520 free(s); 38521 s = toStringO(self); 38522 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00]"); 38523 free(s); 38524 // wrong object type 38525 createSmallInt(I); 38526 setValG(&I, 11); 38527 r2 = self->f->pushSmallInt(self, &I); 38528 r = self->f->getAtSmallDouble(self,-1); 38529 ck_assert_ptr_eq(r, NULL); 38530 s = toStringO(self); 38531 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00,11]"); 38532 free(s); 38533 // wrong object type of another user class 38534 // User classes are stored in containers transparently 38535 createAllocateSmallInt(ip); 38536 ip->type = "anothertype"; 38537 setValG(ip, 11); 38538 r2 = self->f->push(self, (baset*)ip); 38539 ck_assert_ptr_ne(r2, null); 38540 r = self->f->getAtSmallDouble(self,-1); 38541 ck_assert_ptr_eq(r, NULL); 38542 s = toStringO(self); 38543 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00,11,\"<data container>\"]"); 38544 free(s); 38545 // index outside 38546 ck_assert_ptr_eq(self->f->getAtSmallDouble(self, 20), NULL); 38547 ck_assert_ptr_eq(self->f->getAtSmallDouble(self, -7), NULL); 38548 // empty list 38549 emptyO(self); 38550 ck_assert_ptr_eq(self->f->getAtSmallDouble(self, 0), NULL); 38551 ck_assert_ptr_eq(self->f->getAtSmallDouble(self, -1), NULL); 38552 terminateO(self); 38553 38554 } 38555 38556 38557 void getAtSmallIntSmallJsonT(void) { 38558 38559 smallIntt* r; 38560 smallJsont *self = allocSmallJson(); 38561 smallJsont *r2; 38562 38563 // non json array 38564 ck_assert_ptr_eq(self->f->getAtSmallInt(self, 0), null); 38565 // add elements to self 38566 r2 = self->f->pushBool(self, true); 38567 ck_assert_ptr_ne(r2, null); 38568 createSmallInt(e2); 38569 r2 = self->f->pushSmallInt(self, &e2); 38570 ck_assert_ptr_ne(r2, null); 38571 r2 = self->f->pushBool(self, true); 38572 ck_assert_ptr_ne(r2, null); 38573 createSmallInt(e4); 38574 r2 = self->f->pushSmallInt(self, &e4); 38575 ck_assert_ptr_ne(r2, null); 38576 38577 // positive index 38578 r = self->f->getAtSmallInt(self,1); 38579 ck_assert_ptr_ne(r, null); 38580 char *s = toStringO(r); 38581 finishO(r); 38582 ck_assert_str_eq(s, "0"); 38583 free(s); 38584 s = toStringO(self); 38585 ck_assert_str_eq(s, "[true,0,true,0]"); 38586 free(s); 38587 // negative index 38588 r = self->f->getAtSmallInt(self,-1); 38589 ck_assert_ptr_ne(r, null); 38590 s = toStringO(r); 38591 finishO(r); 38592 ck_assert_str_eq(s, "0"); 38593 free(s); 38594 s = toStringO(self); 38595 ck_assert_str_eq(s, "[true,0,true,0]"); 38596 free(s); 38597 // wrong object type 38598 createSmallDouble(I); 38599 setValG(&I, 11); 38600 r2 = self->f->pushSmallDouble(self, &I); 38601 r = self->f->getAtSmallInt(self,-1); 38602 ck_assert_ptr_eq(r, NULL); 38603 s = toStringO(self); 38604 ck_assert_str_eq(s, "[true,0,true,0,1.100000e+01]"); 38605 free(s); 38606 // wrong object type of another user class 38607 // User classes are stored in containers transparently 38608 createAllocateSmallInt(ip); 38609 ip->type = "anothertype"; 38610 setValG(ip, 11); 38611 r2 = self->f->push(self, (baset*)ip); 38612 ck_assert_ptr_ne(r2, null); 38613 r = self->f->getAtSmallInt(self,-1); 38614 ck_assert_ptr_eq(r, NULL); 38615 s = toStringO(self); 38616 ck_assert_str_eq(s, "[true,0,true,0,1.100000e+01,\"<data container>\"]"); 38617 free(s); 38618 // index outside 38619 ck_assert_ptr_eq(self->f->getAtSmallInt(self, 20), NULL); 38620 ck_assert_ptr_eq(self->f->getAtSmallInt(self, -7), NULL); 38621 // empty list 38622 emptyO(self); 38623 ck_assert_ptr_eq(self->f->getAtSmallInt(self, 0), NULL); 38624 ck_assert_ptr_eq(self->f->getAtSmallInt(self, -1), NULL); 38625 terminateO(self); 38626 38627 } 38628 38629 38630 void getAtSmallJsonSmallJsonT(void) { 38631 38632 smallJsont* r; 38633 smallJsont *self = allocSmallJson(); 38634 smallJsont *r2; 38635 38636 // non json array 38637 ck_assert_ptr_eq(self->f->getAtSmallJson(self, 0), null); 38638 // add elements to self 38639 r2 = self->f->pushInt(self, 1); 38640 ck_assert_ptr_ne(r2, null); 38641 createSmallJson(e2); 38642 r2 = self->f->pushSmallJson(self, &e2); 38643 ck_assert_ptr_ne(r2, null); 38644 r2 = self->f->pushInt(self, 3); 38645 ck_assert_ptr_ne(r2, null); 38646 createSmallJson(e4); 38647 r2 = self->f->pushSmallJson(self, &e4); 38648 ck_assert_ptr_ne(r2, null); 38649 38650 // positive index 38651 r = self->f->getAtSmallJson(self,1); 38652 ck_assert_ptr_ne(r, null); 38653 char *s = toStringO(r); 38654 finishO(r); 38655 ck_assert_str_eq(s, "{}"); 38656 free(s); 38657 s = toStringO(self); 38658 ck_assert_str_eq(s, "[1,{},3,{}]"); 38659 free(s); 38660 // negative index 38661 r = self->f->getAtSmallJson(self,-1); 38662 ck_assert_ptr_ne(r, null); 38663 s = toStringO(r); 38664 finishO(r); 38665 ck_assert_str_eq(s, "{}"); 38666 free(s); 38667 s = toStringO(self); 38668 ck_assert_str_eq(s, "[1,{},3,{}]"); 38669 free(s); 38670 // wrong object type 38671 createSmallBytes(I); 38672 r2 = self->f->pushSmallBytes(self, &I); 38673 r = self->f->getAtSmallJson(self,-1); 38674 ck_assert_ptr_eq(r, NULL); 38675 s = toStringO(self); 38676 ck_assert_str_eq(s, "[1,{},3,{},[]]"); 38677 free(s); 38678 // wrong object type of another user class 38679 // User classes are stored in containers transparently 38680 createAllocateSmallInt(ip); 38681 ip->type = "anothertype"; 38682 setValG(ip, 11); 38683 r2 = self->f->push(self, (baset*)ip); 38684 ck_assert_ptr_ne(r2, null); 38685 r = self->f->getAtSmallJson(self,-1); 38686 ck_assert_ptr_eq(r, NULL); 38687 s = toStringO(self); 38688 ck_assert_str_eq(s, "[1,{},3,{},[],\"<data container>\"]"); 38689 free(s); 38690 // index outside 38691 ck_assert_ptr_eq(self->f->getAtSmallJson(self, 20), NULL); 38692 ck_assert_ptr_eq(self->f->getAtSmallJson(self, -7), NULL); 38693 // empty list 38694 emptyO(self); 38695 ck_assert_ptr_eq(self->f->getAtSmallJson(self, 0), NULL); 38696 ck_assert_ptr_eq(self->f->getAtSmallJson(self, -1), NULL); 38697 terminateO(self); 38698 38699 } 38700 38701 38702 void getAtSmallStringSmallJsonT(void) { 38703 38704 smallStringt* r; 38705 smallJsont *self = allocSmallJson(); 38706 smallJsont *r2; 38707 38708 // non json array 38709 ck_assert_ptr_eq(self->f->getAtSmallString(self, 0), null); 38710 // add elements to self 38711 r2 = self->f->pushInt(self, 1); 38712 ck_assert_ptr_ne(r2, null); 38713 createSmallString(e2); 38714 r2 = self->f->pushSmallString(self, &e2); 38715 ck_assert_ptr_ne(r2, null); 38716 r2 = self->f->pushInt(self, 3); 38717 ck_assert_ptr_ne(r2, null); 38718 createSmallString(e4); 38719 r2 = self->f->pushSmallString(self, &e4); 38720 ck_assert_ptr_ne(r2, null); 38721 38722 // positive index 38723 r = self->f->getAtSmallString(self,1); 38724 ck_assert_ptr_ne(r, null); 38725 char *s = toStringO(r); 38726 finishO(r); 38727 ck_assert_str_eq(s, ""); 38728 free(s); 38729 s = toStringO(self); 38730 ck_assert_str_eq(s, "[1,\"\",3,\"\"]"); 38731 free(s); 38732 // negative index 38733 r = self->f->getAtSmallString(self,-1); 38734 ck_assert_ptr_ne(r, null); 38735 s = toStringO(r); 38736 finishO(r); 38737 ck_assert_str_eq(s, ""); 38738 free(s); 38739 s = toStringO(self); 38740 ck_assert_str_eq(s, "[1,\"\",3,\"\"]"); 38741 free(s); 38742 // wrong object type 38743 createSmallInt(I); 38744 setValG(&I, 11); 38745 r2 = self->f->pushSmallInt(self, &I); 38746 r = self->f->getAtSmallString(self,-1); 38747 ck_assert_ptr_eq(r, NULL); 38748 s = toStringO(self); 38749 ck_assert_str_eq(s, "[1,\"\",3,\"\",11]"); 38750 free(s); 38751 // wrong object type of another user class 38752 // User classes are stored in containers transparently 38753 createAllocateSmallInt(ip); 38754 ip->type = "anothertype"; 38755 setValG(ip, 11); 38756 r2 = self->f->push(self, (baset*)ip); 38757 ck_assert_ptr_ne(r2, null); 38758 r = self->f->getAtSmallString(self,-1); 38759 ck_assert_ptr_eq(r, NULL); 38760 s = toStringO(self); 38761 ck_assert_str_eq(s, "[1,\"\",3,\"\",11,\"<data container>\"]"); 38762 free(s); 38763 // index outside 38764 ck_assert_ptr_eq(self->f->getAtSmallString(self, 20), NULL); 38765 ck_assert_ptr_eq(self->f->getAtSmallString(self, -7), NULL); 38766 // empty list 38767 emptyO(self); 38768 ck_assert_ptr_eq(self->f->getAtSmallString(self, 0), NULL); 38769 ck_assert_ptr_eq(self->f->getAtSmallString(self, -1), NULL); 38770 terminateO(self); 38771 38772 } 38773 38774 38775 void getAtVoidSmallJsonT(void) { 38776 38777 void* r; 38778 smallJsont *self = allocSmallJson(); 38779 smallJsont *r2; 38780 38781 // non json array 38782 ck_assert_ptr_eq(self->f->getAtVoid(self, 0), null); 38783 // add elements to self 38784 r2 = self->f->pushInt(self, 1); 38785 ck_assert_ptr_ne(r2, null); 38786 r2 = pushVoidSmallJsonG(self, &r); 38787 ck_assert_ptr_ne(r2, null); 38788 r2 = self->f->pushInt(self, 3); 38789 ck_assert_ptr_ne(r2, null); 38790 r2 = pushVoidSmallJsonG(self, &self); 38791 ck_assert_ptr_ne(r2, null); 38792 38793 // positive index 38794 r = self->f->getAtVoid(self,1); 38795 ck_assert_ptr_eq(r, &r); 38796 char *s = toStringO(self); 38797 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 38798 free(s); 38799 // negative index 38800 r = self->f->getAtVoid(self,-1); 38801 ck_assert_ptr_eq(r, &self); 38802 s = toStringO(self); 38803 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 38804 free(s); 38805 // wrong object type 38806 createSmallInt(I); 38807 setValG(&I, 11); 38808 r2 = self->f->pushSmallInt(self, &I); 38809 r = self->f->getAtVoid(self,-1); 38810 ck_assert_ptr_eq(r, NULL); 38811 s = toStringO(self); 38812 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11]"); 38813 free(s); 38814 // wrong object type of another user class 38815 // User classes are stored in containers transparently 38816 createAllocateSmallInt(ip); 38817 ip->type = "anothertype"; 38818 setValG(ip, 11); 38819 r2 = self->f->push(self, (baset*)ip); 38820 ck_assert_ptr_ne(r2, null); 38821 r = self->f->getAtVoid(self,-1); 38822 ck_assert_ptr_eq(r, NULL); 38823 s = toStringO(self); 38824 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11,\"<data container>\"]"); 38825 free(s); 38826 // index outside 38827 ck_assert_ptr_eq(self->f->getAtVoid(self, 20), NULL); 38828 ck_assert_ptr_eq(self->f->getAtVoid(self, -7), NULL); 38829 // empty list 38830 emptyO(self); 38831 ck_assert_ptr_eq(self->f->getAtVoid(self, 0), NULL); 38832 ck_assert_ptr_eq(self->f->getAtVoid(self, -1), NULL); 38833 terminateO(self); 38834 38835 } 38836 38837 38838 void getAtSmallContainerSmallJsonT(void) { 38839 38840 smallContainert* r; 38841 smallJsont *self = allocSmallJson(); 38842 smallJsont *r2; 38843 38844 // non json array 38845 ck_assert_ptr_eq(self->f->getAtSmallContainer(self, 0), null); 38846 // add elements to self 38847 r2 = self->f->pushInt(self, 1); 38848 ck_assert_ptr_ne(r2, null); 38849 createSmallContainer(e2); 38850 r2 = self->f->pushSmallContainer(self, &e2); 38851 ck_assert_ptr_ne(r2, null); 38852 r2 = self->f->pushInt(self, 3); 38853 ck_assert_ptr_ne(r2, null); 38854 createSmallContainer(e4); 38855 r2 = self->f->pushSmallContainer(self, &e4); 38856 ck_assert_ptr_ne(r2, null); 38857 38858 // positive index 38859 r = self->f->getAtSmallContainer(self,1); 38860 ck_assert_ptr_ne(r, null); 38861 char *s = toStringO(r); 38862 finishO(r); 38863 ck_assert_str_eq(s, "<data smallContainer>"); 38864 free(s); 38865 s = toStringO(self); 38866 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 38867 free(s); 38868 // negative index 38869 r = self->f->getAtSmallContainer(self,-1); 38870 ck_assert_ptr_ne(r, null); 38871 s = toStringO(r); 38872 finishO(r); 38873 ck_assert_str_eq(s, "<data smallContainer>"); 38874 free(s); 38875 s = toStringO(self); 38876 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 38877 free(s); 38878 // wrong object type 38879 createSmallInt(I); 38880 setValG(&I, 11); 38881 r2 = self->f->pushSmallInt(self, &I); 38882 r = self->f->getAtSmallContainer(self,-1); 38883 ck_assert_ptr_eq(r, NULL); 38884 s = toStringO(self); 38885 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11]"); 38886 free(s); 38887 // wrong object type of another user class 38888 // User classes are stored in containers transparently 38889 createAllocateSmallInt(ip); 38890 ip->type = "anothertype"; 38891 setValG(ip, 11); 38892 r2 = self->f->push(self, (baset*)ip); 38893 ck_assert_ptr_ne(r2, null); 38894 r = self->f->getAtSmallContainer(self,-1); 38895 ck_assert_ptr_eq(r, NULL); 38896 s = toStringO(self); 38897 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11,\"<data container>\"]"); 38898 free(s); 38899 // index outside 38900 ck_assert_ptr_eq(self->f->getAtSmallContainer(self, 20), NULL); 38901 ck_assert_ptr_eq(self->f->getAtSmallContainer(self, -7), NULL); 38902 // empty list 38903 emptyO(self); 38904 ck_assert_ptr_eq(self->f->getAtSmallContainer(self, 0), NULL); 38905 ck_assert_ptr_eq(self->f->getAtSmallContainer(self, -1), NULL); 38906 terminateO(self); 38907 38908 } 38909 38910 38911 void getAtNDupSmallJsonT(void) { 38912 38913 baset* r; 38914 smallJsont *self = allocSmallJson(); 38915 smallJsont *r2; 38916 38917 // non json array 38918 ck_assert_ptr_eq(self->f->getAtNDup(self, 0), null); 38919 // add elements to self 38920 r2 = self->f->pushInt(self, 1); 38921 ck_assert_ptr_ne(r2, null); 38922 r2 = self->f->pushInt(self, 2); 38923 ck_assert_ptr_ne(r2, null); 38924 r2 = self->f->pushInt(self, 3); 38925 ck_assert_ptr_ne(r2, null); 38926 r2 = self->f->pushInt(self, 4); 38927 ck_assert_ptr_ne(r2, null); 38928 38929 // positive index 38930 r = self->f->getAtNDup(self,1); 38931 ck_assert_ptr_ne(r, null); 38932 char *s = toStringO(r); 38933 terminateO(r); 38934 ck_assert_str_eq(s, "2"); 38935 free(s); 38936 s = toStringO(self); 38937 ck_assert_str_eq(s, "[1,2,3,4]"); 38938 free(s); 38939 // negative index 38940 r = self->f->getAtNDup(self,-1); 38941 ck_assert_ptr_ne(r, null); 38942 s = toStringO(r); 38943 terminateO(r); 38944 ck_assert_str_eq(s, "4"); 38945 free(s); 38946 s = toStringO(self); 38947 ck_assert_str_eq(s, "[1,2,3,4]"); 38948 free(s); 38949 // undefined object 38950 r2 = self->f->pushUndefined(self); 38951 ck_assert_ptr_ne(r2, null); 38952 r = self->f->getAtNDup(self,-1); 38953 ck_assert_ptr_ne(r, null); 38954 s = toStringO(r); 38955 terminateO(r); 38956 ck_assert_str_eq(s, "null"); 38957 free(s); 38958 s = toStringO(self); 38959 ck_assert_str_eq(s, "[1,2,3,4,null]"); 38960 free(s); 38961 // container 38962 createSmallContainer(c); 38963 r2 = self->f->pushSmallContainer(self, &c); 38964 r = self->f->getAtNDup(self,-1); 38965 ck_assert_ptr_ne(r, null); 38966 s = toStringO(r); 38967 terminateO(r); 38968 ck_assert_str_eq(s, "<data smallContainer>"); 38969 free(s); 38970 s = toStringO(self); 38971 ck_assert_str_eq(s, "[1,2,3,4,null,\"<data container>\"]"); 38972 free(s); 38973 // base object in container 38974 createAllocateSmallInt(I); 38975 setValG(I, 11); 38976 I->type = "anothertype"; 38977 r2 = self->f->push(self, (baset*)I); 38978 r = self->f->getAtNDup(self,-1); 38979 ck_assert_ptr_ne(r, null); 38980 // r->type is not anothertype, because the duplicate function is from the smallInt class 38981 ck_assert_str_eq(r->type, "smallInt"); 38982 s = toStringO(r); 38983 terminateO(r); 38984 ck_assert_str_eq(s, "11"); 38985 free(s); 38986 s = toStringO(self); 38987 ck_assert_str_eq(s, "[1,2,3,4,null,\"<data container>\",\"<data container>\"]"); 38988 free(s); 38989 // index outside 38990 ck_assert_ptr_eq(self->f->getAtNDup(self, 20), NULL); 38991 ck_assert_ptr_eq(self->f->getAtNDup(self, -8), NULL); 38992 // empty list 38993 emptyO(self); 38994 ck_assert_ptr_eq(self->f->getAtNDup(self, 0), NULL); 38995 ck_assert_ptr_eq(self->f->getAtNDup(self, -1), NULL); 38996 terminateO(self); 38997 38998 } 38999 39000 39001 void getAtNDupUndefinedSmallJsonT(void) { 39002 39003 undefinedt* r; 39004 smallJsont *self = allocSmallJson(); 39005 smallJsont *r2; 39006 39007 // non json array 39008 ck_assert_ptr_eq(self->f->getAtNDupUndefined(self, 0), null); 39009 // add elements to self 39010 r2 = self->f->pushInt(self, 1); 39011 ck_assert_ptr_ne(r2, null); 39012 r2 = self->f->pushUndefined(self); 39013 ck_assert_ptr_ne(r2, null); 39014 r2 = self->f->pushInt(self, 3); 39015 ck_assert_ptr_ne(r2, null); 39016 r2 = self->f->pushUndefined(self); 39017 ck_assert_ptr_ne(r2, null); 39018 39019 // positive index 39020 r = self->f->getAtNDupUndefined(self,1); 39021 ck_assert_ptr_ne(r, null); 39022 char *s = toStringO(r); 39023 terminateO(r); 39024 ck_assert_str_eq(s, "null"); 39025 free(s); 39026 s = toStringO(self); 39027 ck_assert_str_eq(s, "[1,null,3,null]"); 39028 free(s); 39029 // negative index 39030 r = self->f->getAtNDupUndefined(self,-1); 39031 ck_assert_ptr_ne(r, null); 39032 s = toStringO(r); 39033 terminateO(r); 39034 ck_assert_str_eq(s, "null"); 39035 free(s); 39036 s = toStringO(self); 39037 ck_assert_str_eq(s, "[1,null,3,null]"); 39038 free(s); 39039 // wrong object type 39040 createSmallInt(I); 39041 setValG(&I, 11); 39042 r2 = self->f->pushSmallInt(self, &I); 39043 ck_assert_ptr_ne(r2, null); 39044 r = self->f->getAtNDupUndefined(self,-1); 39045 ck_assert_ptr_eq(r, null); 39046 s = toStringO(self); 39047 ck_assert_str_eq(s, "[1,null,3,null,11]"); 39048 free(s); 39049 // index outside 39050 ck_assert_ptr_eq(self->f->getAtNDupUndefined(self, 20), NULL); 39051 ck_assert_ptr_eq(self->f->getAtNDupUndefined(self, -6), NULL); 39052 // empty list 39053 emptyO(self); 39054 ck_assert_ptr_eq(self->f->getAtNDupUndefined(self, 0), NULL); 39055 ck_assert_ptr_eq(self->f->getAtNDupUndefined(self, -1), NULL); 39056 terminateO(self); 39057 39058 } 39059 39060 39061 void getAtNDupBoolSmallJsonT(void) { 39062 39063 bool r; 39064 smallJsont *self = allocSmallJson(); 39065 smallJsont *r2; 39066 39067 // add elements to self 39068 r2 = self->f->pushInt(self, 1); 39069 ck_assert_ptr_ne(r2, null); 39070 r2 = self->f->pushBool(self, TRUE); 39071 ck_assert_ptr_ne(r2, null); 39072 r2 = self->f->pushInt(self, 3); 39073 ck_assert_ptr_ne(r2, null); 39074 r2 = self->f->pushBool(self, TRUE); 39075 ck_assert_ptr_ne(r2, null); 39076 39077 // positive index 39078 r = self->f->getAtNDupBool(self,1); 39079 ck_assert(r); 39080 char *s = toStringO(self); 39081 ck_assert_str_eq(s, "[1,true,3,true]"); 39082 free(s); 39083 // negative index 39084 r = self->f->getAtNDupBool(self,-1); 39085 ck_assert(r); 39086 s = toStringO(self); 39087 ck_assert_str_eq(s, "[1,true,3,true]"); 39088 free(s); 39089 // wrong object type 39090 createSmallInt(I); 39091 setValG(&I, 11); 39092 r2 = self->f->pushSmallInt(self, &I); 39093 r = self->f->getAtNDupBool(self,-1); 39094 ck_assert(!r); 39095 s = toStringO(self); 39096 ck_assert_str_eq(s, "[1,true,3,true,11]"); 39097 free(s); 39098 // wrong object type of another user class 39099 // User classes are stored in containers transparently 39100 createAllocateSmallInt(ip); 39101 ip->type = "anothertype"; 39102 setValG(ip, 11); 39103 r2 = self->f->push(self, (baset*)ip); 39104 ck_assert_ptr_ne(r2, null); 39105 r = self->f->getAtNDupBool(self,-1); 39106 ck_assert(!r); 39107 s = toStringO(self); 39108 ck_assert_str_eq(s, "[1,true,3,true,11,\"<data container>\"]"); 39109 free(s); 39110 // index outside 39111 ck_assert(!self->f->getAtNDupBool(self, 20)); 39112 ck_assert(!self->f->getAtNDupBool(self, -7)); 39113 // empty list 39114 emptyO(self); 39115 ck_assert(!self->f->getAtNDupBool(self, 0)); 39116 ck_assert(!self->f->getAtNDupBool(self, -1)); 39117 terminateO(self); 39118 39119 } 39120 39121 39122 void getAtNDupDoubleSmallJsonT(void) { 39123 39124 double r; 39125 smallJsont *self = allocSmallJson(); 39126 smallJsont *r2; 39127 39128 // add elements to self 39129 r2 = self->f->pushInt(self, 1); 39130 ck_assert_ptr_ne(r2, null); 39131 r2 = self->f->pushDouble(self, 2); 39132 ck_assert_ptr_ne(r2, null); 39133 r2 = self->f->pushInt(self, 3); 39134 ck_assert_ptr_ne(r2, null); 39135 r2 = self->f->pushDouble(self, 4); 39136 ck_assert_ptr_ne(r2, null); 39137 39138 // positive index 39139 r = self->f->getAtNDupDouble(self,1); 39140 ck_assert(r==2); 39141 char *s = toStringO(self); 39142 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00]"); 39143 free(s); 39144 // negative index 39145 r = self->f->getAtNDupDouble(self,-1); 39146 ck_assert(r==4); 39147 s = toStringO(self); 39148 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00]"); 39149 free(s); 39150 // wrong object type 39151 createSmallInt(I); 39152 setValG(&I, 11); 39153 r2 = self->f->pushSmallInt(self, &I); 39154 r = self->f->getAtNDupDouble(self,-1); 39155 ck_assert(!r); 39156 s = toStringO(self); 39157 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00,11]"); 39158 free(s); 39159 // wrong object type of another user class 39160 // User classes are stored in containers transparently 39161 createAllocateSmallInt(ip); 39162 ip->type = "anothertype"; 39163 setValG(ip, 11); 39164 r2 = self->f->push(self, (baset*)ip); 39165 ck_assert_ptr_ne(r2, null); 39166 r = self->f->getAtNDupDouble(self,-1); 39167 ck_assert(!r); 39168 s = toStringO(self); 39169 ck_assert_str_eq(s, "[1,2.000000e+00,3,4.000000e+00,11,\"<data container>\"]"); 39170 free(s); 39171 // index outside 39172 ck_assert(!self->f->getAtNDupDouble(self, 20)); 39173 ck_assert(!self->f->getAtNDupDouble(self, -7)); 39174 // empty list 39175 emptyO(self); 39176 ck_assert(!self->f->getAtNDupDouble(self, 0)); 39177 ck_assert(!self->f->getAtNDupDouble(self, -1)); 39178 terminateO(self); 39179 39180 } 39181 39182 39183 void getAtNDupIntSmallJsonT(void) { 39184 39185 int64_t r; 39186 smallJsont *self = allocSmallJson(); 39187 smallJsont *r2; 39188 39189 // add elements to self 39190 r2 = self->f->pushInt(self, 1); 39191 ck_assert_ptr_ne(r2, null); 39192 r2 = self->f->pushInt(self, 2); 39193 ck_assert_ptr_ne(r2, null); 39194 r2 = self->f->pushInt(self, 3); 39195 ck_assert_ptr_ne(r2, null); 39196 r2 = self->f->pushInt(self, 4); 39197 ck_assert_ptr_ne(r2, null); 39198 39199 // positive index 39200 r = self->f->getAtNDupInt(self,1); 39201 ck_assert(r==2); 39202 char *s = toStringO(self); 39203 ck_assert_str_eq(s, "[1,2,3,4]"); 39204 free(s); 39205 // negative index 39206 r = self->f->getAtNDupInt(self,-1); 39207 ck_assert(r==4); 39208 s = toStringO(self); 39209 ck_assert_str_eq(s, "[1,2,3,4]"); 39210 free(s); 39211 // wrong object type 39212 createSmallDouble(I); 39213 setValG(&I, 11); 39214 r2 = self->f->pushSmallDouble(self, &I); 39215 r = self->f->getAtNDupInt(self,-1); 39216 ck_assert(!r); 39217 s = toStringO(self); 39218 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 39219 free(s); 39220 // wrong object type of another user class 39221 // User classes are stored in containers transparently 39222 createAllocateSmallInt(ip); 39223 ip->type = "anothertype"; 39224 setValG(ip, 11); 39225 r2 = self->f->push(self, (baset*)ip); 39226 ck_assert_ptr_ne(r2, null); 39227 r = self->f->getAtNDupInt(self,-1); 39228 ck_assert(!r); 39229 s = toStringO(self); 39230 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 39231 free(s); 39232 // index outside 39233 ck_assert(!self->f->getAtNDupInt(self, 20)); 39234 ck_assert(!self->f->getAtNDupInt(self, -7)); 39235 // empty list 39236 emptyO(self); 39237 ck_assert(!self->f->getAtNDupInt(self, 0)); 39238 ck_assert(!self->f->getAtNDupInt(self, -1)); 39239 terminateO(self); 39240 39241 } 39242 39243 39244 void getAtNDupInt32SmallJsonT(void) { 39245 39246 int32_t r; 39247 smallJsont *self = allocSmallJson(); 39248 smallJsont *r2; 39249 39250 // add elements to self 39251 r2 = self->f->pushInt(self, 1); 39252 ck_assert_ptr_ne(r2, null); 39253 r2 = self->f->pushInt(self, 2); 39254 ck_assert_ptr_ne(r2, null); 39255 r2 = self->f->pushInt(self, 3); 39256 ck_assert_ptr_ne(r2, null); 39257 r2 = self->f->pushInt(self, 4); 39258 ck_assert_ptr_ne(r2, null); 39259 39260 // positive index 39261 r = self->f->getAtNDupInt32(self,1); 39262 ck_assert(r==2); 39263 char *s = toStringO(self); 39264 ck_assert_str_eq(s, "[1,2,3,4]"); 39265 free(s); 39266 // negative index 39267 r = self->f->getAtNDupInt32(self,-1); 39268 ck_assert(r==4); 39269 s = toStringO(self); 39270 ck_assert_str_eq(s, "[1,2,3,4]"); 39271 free(s); 39272 // wrong object type 39273 createSmallDouble(I); 39274 setValG(&I, 11); 39275 r2 = self->f->pushSmallDouble(self, &I); 39276 r = self->f->getAtNDupInt32(self,-1); 39277 ck_assert(!r); 39278 s = toStringO(self); 39279 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 39280 free(s); 39281 // wrong object type of another user class 39282 // User classes are stored in containers transparently 39283 createAllocateSmallInt(ip); 39284 ip->type = "anothertype"; 39285 setValG(ip, 11); 39286 r2 = self->f->push(self, (baset*)ip); 39287 ck_assert_ptr_ne(r2, null); 39288 r = self->f->getAtNDupInt32(self,-1); 39289 ck_assert(!r); 39290 s = toStringO(self); 39291 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 39292 free(s); 39293 // index outside 39294 ck_assert(!self->f->getAtNDupInt32(self, 20)); 39295 ck_assert(!self->f->getAtNDupInt32(self, -7)); 39296 // empty list 39297 emptyO(self); 39298 ck_assert(!self->f->getAtNDupInt32(self, 0)); 39299 ck_assert(!self->f->getAtNDupInt32(self, -1)); 39300 terminateO(self); 39301 39302 } 39303 39304 39305 void getAtNDupUintSmallJsonT(void) { 39306 39307 uint64_t r; 39308 smallJsont *self = allocSmallJson(); 39309 smallJsont *r2; 39310 39311 // add elements to self 39312 r2 = self->f->pushInt(self, 1); 39313 ck_assert_ptr_ne(r2, null); 39314 r2 = self->f->pushInt(self, 2); 39315 ck_assert_ptr_ne(r2, null); 39316 r2 = self->f->pushInt(self, 3); 39317 ck_assert_ptr_ne(r2, null); 39318 r2 = self->f->pushInt(self, 4); 39319 ck_assert_ptr_ne(r2, null); 39320 39321 // positive index 39322 r = self->f->getAtNDupUint(self,1); 39323 ck_assert(r==2); 39324 char *s = toStringO(self); 39325 ck_assert_str_eq(s, "[1,2,3,4]"); 39326 free(s); 39327 // negative index 39328 r = self->f->getAtNDupUint(self,-1); 39329 ck_assert(r==4); 39330 s = toStringO(self); 39331 ck_assert_str_eq(s, "[1,2,3,4]"); 39332 free(s); 39333 // wrong object type 39334 createSmallDouble(I); 39335 setValG(&I, 11); 39336 r2 = self->f->pushSmallDouble(self, &I); 39337 r = self->f->getAtNDupUint(self,-1); 39338 ck_assert(!r); 39339 s = toStringO(self); 39340 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 39341 free(s); 39342 // wrong object type of another user class 39343 // User classes are stored in containers transparently 39344 createAllocateSmallInt(ip); 39345 ip->type = "anothertype"; 39346 setValG(ip, 11); 39347 r2 = self->f->push(self, (baset*)ip); 39348 ck_assert_ptr_ne(r2, null); 39349 r = self->f->getAtNDupUint(self,-1); 39350 ck_assert(!r); 39351 s = toStringO(self); 39352 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 39353 free(s); 39354 // index outside 39355 ck_assert(!self->f->getAtNDupUint(self, 20)); 39356 ck_assert(!self->f->getAtNDupUint(self, -7)); 39357 // empty list 39358 emptyO(self); 39359 ck_assert(!self->f->getAtNDupUint(self, 0)); 39360 ck_assert(!self->f->getAtNDupUint(self, -1)); 39361 terminateO(self); 39362 39363 } 39364 39365 39366 void getAtNDupUint32SmallJsonT(void) { 39367 39368 uint32_t r; 39369 smallJsont *self = allocSmallJson(); 39370 smallJsont *r2; 39371 39372 // add elements to self 39373 r2 = self->f->pushInt(self, 1); 39374 ck_assert_ptr_ne(r2, null); 39375 r2 = self->f->pushInt(self, 2); 39376 ck_assert_ptr_ne(r2, null); 39377 r2 = self->f->pushInt(self, 3); 39378 ck_assert_ptr_ne(r2, null); 39379 r2 = self->f->pushInt(self, 4); 39380 ck_assert_ptr_ne(r2, null); 39381 39382 // positive index 39383 r = self->f->getAtNDupUint32(self,1); 39384 ck_assert(r==2); 39385 char *s = toStringO(self); 39386 ck_assert_str_eq(s, "[1,2,3,4]"); 39387 free(s); 39388 // negative index 39389 r = self->f->getAtNDupUint32(self,-1); 39390 ck_assert(r==4); 39391 s = toStringO(self); 39392 ck_assert_str_eq(s, "[1,2,3,4]"); 39393 free(s); 39394 // wrong object type 39395 createSmallDouble(I); 39396 setValG(&I, 11); 39397 r2 = self->f->pushSmallDouble(self, &I); 39398 r = self->f->getAtNDupUint32(self,-1); 39399 ck_assert(!r); 39400 s = toStringO(self); 39401 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01]"); 39402 free(s); 39403 // wrong object type of another user class 39404 // User classes are stored in containers transparently 39405 createAllocateSmallInt(ip); 39406 ip->type = "anothertype"; 39407 setValG(ip, 11); 39408 r2 = self->f->push(self, (baset*)ip); 39409 ck_assert_ptr_ne(r2, null); 39410 r = self->f->getAtNDupUint32(self,-1); 39411 ck_assert(!r); 39412 s = toStringO(self); 39413 ck_assert_str_eq(s, "[1,2,3,4,1.100000e+01,\"<data container>\"]"); 39414 free(s); 39415 // index outside 39416 ck_assert(!self->f->getAtNDupUint32(self, 20)); 39417 ck_assert(!self->f->getAtNDupUint32(self, -7)); 39418 // empty list 39419 emptyO(self); 39420 ck_assert(!self->f->getAtNDupUint32(self, 0)); 39421 ck_assert(!self->f->getAtNDupUint32(self, -1)); 39422 terminateO(self); 39423 39424 } 39425 39426 39427 void getAtNDupSSmallJsonT(void) { 39428 39429 char* r; 39430 smallJsont *self = allocSmallJson(); 39431 smallJsont *r2; 39432 39433 // add elements to self 39434 r2 = self->f->pushInt(self, 1); 39435 ck_assert_ptr_ne(r2, null); 39436 r2 = self->f->pushS(self, "2"); 39437 ck_assert_ptr_ne(r2, null); 39438 r2 = self->f->pushInt(self, 3); 39439 ck_assert_ptr_ne(r2, null); 39440 r2 = self->f->pushS(self, "4"); 39441 ck_assert_ptr_ne(r2, null); 39442 39443 // positive index 39444 r = self->f->getAtNDupS(self,1); 39445 ck_assert_ptr_ne(r, null); 39446 ck_assert_str_eq(r, "2"); 39447 free(r); 39448 char *s = toStringO(self); 39449 ck_assert_str_eq(s, "[1,\"2\",3,\"4\"]"); 39450 free(s); 39451 // negative index 39452 r = self->f->getAtNDupS(self,-1); 39453 ck_assert_ptr_ne(r, null); 39454 ck_assert_str_eq(r, "4"); 39455 free(r); 39456 s = toStringO(self); 39457 ck_assert_str_eq(s, "[1,\"2\",3,\"4\"]"); 39458 free(s); 39459 // wrong object type 39460 createSmallInt(I); 39461 setValG(&I, 11); 39462 r2 = self->f->pushSmallInt(self, &I); 39463 r = self->f->getAtNDupS(self,-1); 39464 ck_assert_ptr_eq(r, NULL); 39465 s = toStringO(self); 39466 ck_assert_str_eq(s, "[1,\"2\",3,\"4\",11]"); 39467 free(s); 39468 // wrong object type of another user class 39469 // User classes are stored in containers transparently 39470 createAllocateSmallInt(ip); 39471 ip->type = "anothertype"; 39472 setValG(ip, 11); 39473 r2 = self->f->push(self, (baset*)ip); 39474 ck_assert_ptr_ne(r2, null); 39475 r = self->f->getAtNDupS(self,-1); 39476 ck_assert_ptr_eq(r, NULL); 39477 s = toStringO(self); 39478 ck_assert_str_eq(s, "[1,\"2\",3,\"4\",11,\"<data container>\"]"); 39479 free(s); 39480 // index outside 39481 ck_assert_ptr_eq(self->f->getAtNDupS(self, 20), NULL); 39482 ck_assert_ptr_eq(self->f->getAtNDupS(self, -7), NULL); 39483 // empty list 39484 emptyO(self); 39485 ck_assert_ptr_eq(self->f->getAtNDupS(self, 0), NULL); 39486 ck_assert_ptr_eq(self->f->getAtNDupS(self, -1), NULL); 39487 terminateO(self); 39488 39489 } 39490 39491 39492 void getAtNDupDictSmallJsonT(void) { 39493 39494 smallDictt* r; 39495 smallJsont *self = allocSmallJson(); 39496 smallJsont *r2; 39497 39498 // non json array 39499 ck_assert_ptr_eq(self->f->getAtNDupDict(self, 0), null); 39500 // add elements to self 39501 r2 = self->f->pushInt(self, 1); 39502 ck_assert_ptr_ne(r2, null); 39503 createSmallDict(e2); 39504 r2 = self->f->pushDict(self, &e2); 39505 ck_assert_ptr_ne(r2, null); 39506 r2 = self->f->pushInt(self, 3); 39507 ck_assert_ptr_ne(r2, null); 39508 createSmallDict(e4); 39509 r2 = self->f->pushDict(self, &e4); 39510 ck_assert_ptr_ne(r2, null); 39511 39512 // positive index 39513 r = self->f->getAtNDupDict(self,1); 39514 ck_assert_ptr_ne(r, null); 39515 char *s = toStringO(r); 39516 terminateO(r); 39517 ck_assert_str_eq(s, "{}"); 39518 free(s); 39519 s = toStringO(self); 39520 ck_assert_str_eq(s, "[1,{},3,{}]"); 39521 free(s); 39522 // negative index 39523 r = self->f->getAtNDupDict(self,-1); 39524 ck_assert_ptr_ne(r, null); 39525 s = toStringO(r); 39526 terminateO(r); 39527 ck_assert_str_eq(s, "{}"); 39528 free(s); 39529 s = toStringO(self); 39530 ck_assert_str_eq(s, "[1,{},3,{}]"); 39531 free(s); 39532 // wrong object type 39533 createSmallInt(I); 39534 setValG(&I, 11); 39535 r2 = self->f->pushSmallInt(self, &I); 39536 r = self->f->getAtNDupDict(self,-1); 39537 ck_assert_ptr_eq(r, NULL); 39538 s = toStringO(self); 39539 ck_assert_str_eq(s, "[1,{},3,{},11]"); 39540 free(s); 39541 // wrong object type of another user class 39542 // User classes are stored in containers transparently 39543 createAllocateSmallInt(ip); 39544 ip->type = "anothertype"; 39545 setValG(ip, 11); 39546 r2 = self->f->push(self, (baset*)ip); 39547 ck_assert_ptr_ne(r2, null); 39548 r = self->f->getAtNDupDict(self,-1); 39549 ck_assert_ptr_eq(r, NULL); 39550 s = toStringO(self); 39551 ck_assert_str_eq(s, "[1,{},3,{},11,\"<data container>\"]"); 39552 free(s); 39553 // index outside 39554 ck_assert_ptr_eq(self->f->getAtNDupDict(self, 20), NULL); 39555 ck_assert_ptr_eq(self->f->getAtNDupDict(self, -7), NULL); 39556 // empty list 39557 emptyO(self); 39558 ck_assert_ptr_eq(self->f->getAtNDupDict(self, 0), NULL); 39559 ck_assert_ptr_eq(self->f->getAtNDupDict(self, -1), NULL); 39560 terminateO(self); 39561 39562 } 39563 39564 39565 void getAtNDupArraySmallJsonT(void) { 39566 39567 smallArrayt* r; 39568 smallJsont *self = allocSmallJson(); 39569 smallJsont *r2; 39570 39571 // non json array 39572 ck_assert_ptr_eq(self->f->getAtNDupArray(self, 0), null); 39573 // add elements to self 39574 r2 = self->f->pushInt(self, 1); 39575 ck_assert_ptr_ne(r2, null); 39576 createSmallArray(e2); 39577 r2 = self->f->pushArray(self, &e2); 39578 ck_assert_ptr_ne(r2, null); 39579 r2 = self->f->pushInt(self, 3); 39580 ck_assert_ptr_ne(r2, null); 39581 createSmallArray(e4); 39582 r2 = self->f->pushArray(self, &e4); 39583 ck_assert_ptr_ne(r2, null); 39584 39585 // positive index 39586 r = self->f->getAtNDupArray(self,1); 39587 ck_assert_ptr_ne(r, null); 39588 char *s = toStringO(r); 39589 terminateO(r); 39590 ck_assert_str_eq(s, "[]"); 39591 free(s); 39592 s = toStringO(self); 39593 ck_assert_str_eq(s, "[1,[],3,[]]"); 39594 free(s); 39595 // negative index 39596 r = self->f->getAtNDupArray(self,-1); 39597 ck_assert_ptr_ne(r, null); 39598 s = toStringO(r); 39599 terminateO(r); 39600 ck_assert_str_eq(s, "[]"); 39601 free(s); 39602 s = toStringO(self); 39603 ck_assert_str_eq(s, "[1,[],3,[]]"); 39604 free(s); 39605 // wrong object type 39606 createSmallInt(I); 39607 setValG(&I, 11); 39608 r2 = self->f->pushSmallInt(self, &I); 39609 r = self->f->getAtNDupArray(self,-1); 39610 ck_assert_ptr_eq(r, NULL); 39611 s = toStringO(self); 39612 ck_assert_str_eq(s, "[1,[],3,[],11]"); 39613 free(s); 39614 // wrong object type of another user class 39615 // User classes are stored in containers transparently 39616 createAllocateSmallInt(ip); 39617 ip->type = "anothertype"; 39618 setValG(ip, 11); 39619 r2 = self->f->push(self, (baset*)ip); 39620 ck_assert_ptr_ne(r2, null); 39621 r = self->f->getAtNDupArray(self,-1); 39622 ck_assert_ptr_eq(r, NULL); 39623 s = toStringO(self); 39624 ck_assert_str_eq(s, "[1,[],3,[],11,\"<data container>\"]"); 39625 free(s); 39626 // index outside 39627 ck_assert_ptr_eq(self->f->getAtNDupArray(self, 20), NULL); 39628 ck_assert_ptr_eq(self->f->getAtNDupArray(self, -7), NULL); 39629 // empty list 39630 emptyO(self); 39631 ck_assert_ptr_eq(self->f->getAtNDupArray(self, 0), NULL); 39632 ck_assert_ptr_eq(self->f->getAtNDupArray(self, -1), NULL); 39633 terminateO(self); 39634 39635 } 39636 39637 39638 void getAtNDupSmallBoolSmallJsonT(void) { 39639 39640 smallBoolt* r; 39641 smallJsont *self = allocSmallJson(); 39642 smallJsont *r2; 39643 39644 // non json array 39645 ck_assert_ptr_eq(self->f->getAtNDupSmallBool(self, 0), null); 39646 // add elements to self 39647 r2 = self->f->pushInt(self, 1); 39648 ck_assert_ptr_ne(r2, null); 39649 createSmallBool(e2); 39650 r2 = self->f->pushBool(self, true); 39651 ck_assert_ptr_ne(r2, null); 39652 r2 = self->f->pushInt(self, 3); 39653 ck_assert_ptr_ne(r2, null); 39654 createSmallBool(e4); 39655 r2 = self->f->pushBool(self, true); 39656 ck_assert_ptr_ne(r2, null); 39657 39658 // positive index 39659 r = self->f->getAtNDupSmallBool(self,1); 39660 ck_assert_ptr_ne(r, null); 39661 char *s = toStringO(r); 39662 terminateO(r); 39663 ck_assert_str_eq(s, "true"); 39664 free(s); 39665 s = toStringO(self); 39666 ck_assert_str_eq(s, "[1,true,3,true]"); 39667 free(s); 39668 // negative index 39669 r = self->f->getAtNDupSmallBool(self,-1); 39670 ck_assert_ptr_ne(r, null); 39671 s = toStringO(r); 39672 terminateO(r); 39673 ck_assert_str_eq(s, "true"); 39674 free(s); 39675 s = toStringO(self); 39676 ck_assert_str_eq(s, "[1,true,3,true]"); 39677 free(s); 39678 // wrong object type 39679 createSmallInt(I); 39680 setValG(&I, 11); 39681 r2 = self->f->pushSmallInt(self, &I); 39682 r = self->f->getAtNDupSmallBool(self,2); 39683 ck_assert_ptr_eq(r, NULL); 39684 s = toStringO(self); 39685 ck_assert_str_eq(s, "[1,true,3,true,11]"); 39686 free(s); 39687 // wrong object type of another user class 39688 // User classes are stored in containers transparently 39689 createAllocateSmallInt(ip); 39690 ip->type = "anothertype"; 39691 setValG(ip, 11); 39692 r2 = self->f->push(self, (baset*)ip); 39693 ck_assert_ptr_ne(r2, null); 39694 r = self->f->getAtNDupSmallBool(self,-1); 39695 ck_assert_ptr_eq(r, NULL); 39696 s = toStringO(self); 39697 ck_assert_str_eq(s, "[1,true,3,true,11,\"<data container>\"]"); 39698 free(s); 39699 // index outside 39700 ck_assert_ptr_eq(self->f->getAtNDupSmallBool(self, 20), NULL); 39701 ck_assert_ptr_eq(self->f->getAtNDupSmallBool(self, -7), NULL); 39702 // empty list 39703 emptyO(self); 39704 ck_assert_ptr_eq(self->f->getAtNDupSmallBool(self, 0), NULL); 39705 ck_assert_ptr_eq(self->f->getAtNDupSmallBool(self, -1), NULL); 39706 terminateO(self); 39707 39708 } 39709 39710 39711 void getAtNDupSmallBytesSmallJsonT(void) { 39712 39713 smallBytest* r; 39714 smallJsont *self = allocSmallJson(); 39715 smallJsont *r2; 39716 39717 // non json array 39718 ck_assert_ptr_eq(self->f->getAtNDupSmallBytes(self, 0), null); 39719 // add elements to self 39720 r2 = self->f->pushInt(self, 1); 39721 ck_assert_ptr_ne(r2, null); 39722 createSmallBytes(e2); 39723 r2 = self->f->pushSmallBytes(self, &e2); 39724 ck_assert_ptr_ne(r2, null); 39725 r2 = self->f->pushInt(self, 3); 39726 ck_assert_ptr_ne(r2, null); 39727 createSmallBytes(e4); 39728 r2 = self->f->pushSmallBytes(self, &e4); 39729 ck_assert_ptr_ne(r2, null); 39730 39731 // positive index 39732 r = self->f->getAtNDupSmallBytes(self,1); 39733 ck_assert_ptr_ne(r, null); 39734 char *s = toStringO(r); 39735 terminateO(r); 39736 ck_assert_str_eq(s, "[]"); 39737 free(s); 39738 s = toStringO(self); 39739 ck_assert_str_eq(s, "[1,[],3,[]]"); 39740 free(s); 39741 // negative index 39742 r = self->f->getAtNDupSmallBytes(self,-1); 39743 ck_assert_ptr_ne(r, null); 39744 s = toStringO(r); 39745 terminateO(r); 39746 ck_assert_str_eq(s, "[]"); 39747 free(s); 39748 s = toStringO(self); 39749 ck_assert_str_eq(s, "[1,[],3,[]]"); 39750 free(s); 39751 // wrong object type 39752 createSmallInt(I); 39753 setValG(&I, 11); 39754 r2 = self->f->pushSmallInt(self, &I); 39755 r = self->f->getAtNDupSmallBytes(self,-1); 39756 ck_assert_ptr_eq(r, NULL); 39757 s = toStringO(self); 39758 ck_assert_str_eq(s, "[1,[],3,[],11]"); 39759 free(s); 39760 // wrong object type of another user class 39761 // User classes are stored in containers transparently 39762 createAllocateSmallInt(ip); 39763 ip->type = "anothertype"; 39764 setValG(ip, 11); 39765 r2 = self->f->push(self, (baset*)ip); 39766 ck_assert_ptr_ne(r2, null); 39767 r = self->f->getAtNDupSmallBytes(self,-1); 39768 ck_assert_ptr_eq(r, NULL); 39769 s = toStringO(self); 39770 ck_assert_str_eq(s, "[1,[],3,[],11,\"<data container>\"]"); 39771 free(s); 39772 // index outside 39773 ck_assert_ptr_eq(self->f->getAtNDupSmallBytes(self, 20), NULL); 39774 ck_assert_ptr_eq(self->f->getAtNDupSmallBytes(self, -7), NULL); 39775 // empty list 39776 emptyO(self); 39777 ck_assert_ptr_eq(self->f->getAtNDupSmallBytes(self, 0), NULL); 39778 ck_assert_ptr_eq(self->f->getAtNDupSmallBytes(self, -1), NULL); 39779 terminateO(self); 39780 39781 } 39782 39783 39784 void getAtNDupSmallDoubleSmallJsonT(void) { 39785 39786 smallDoublet* r; 39787 smallJsont *self = allocSmallJson(); 39788 smallJsont *r2; 39789 39790 // non json array 39791 ck_assert_ptr_eq(self->f->getAtNDupSmallDouble(self, 0), null); 39792 // add elements to self 39793 r2 = self->f->pushInt(self, 1); 39794 ck_assert_ptr_ne(r2, null); 39795 createSmallDouble(e2); 39796 r2 = self->f->pushSmallDouble(self, &e2); 39797 ck_assert_ptr_ne(r2, null); 39798 r2 = self->f->pushInt(self, 3); 39799 ck_assert_ptr_ne(r2, null); 39800 createSmallDouble(e4); 39801 r2 = self->f->pushSmallDouble(self, &e4); 39802 ck_assert_ptr_ne(r2, null); 39803 39804 // positive index 39805 r = self->f->getAtNDupSmallDouble(self,1); 39806 ck_assert_ptr_ne(r, null); 39807 char *s = toStringO(r); 39808 terminateO(r); 39809 ck_assert_str_eq(s, "0.000000e+00"); 39810 free(s); 39811 s = toStringO(self); 39812 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00]"); 39813 free(s); 39814 // negative index 39815 r = self->f->getAtNDupSmallDouble(self,-1); 39816 ck_assert_ptr_ne(r, null); 39817 s = toStringO(r); 39818 terminateO(r); 39819 ck_assert_str_eq(s, "0.000000e+00"); 39820 free(s); 39821 s = toStringO(self); 39822 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00]"); 39823 free(s); 39824 // wrong object type 39825 createSmallInt(I); 39826 setValG(&I, 11); 39827 r2 = self->f->pushSmallInt(self, &I); 39828 r = self->f->getAtNDupSmallDouble(self,-1); 39829 ck_assert_ptr_eq(r, NULL); 39830 s = toStringO(self); 39831 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00,11]"); 39832 free(s); 39833 // wrong object type of another user class 39834 // User classes are stored in containers transparently 39835 createAllocateSmallInt(ip); 39836 ip->type = "anothertype"; 39837 setValG(ip, 11); 39838 r2 = self->f->push(self, (baset*)ip); 39839 ck_assert_ptr_ne(r2, null); 39840 r = self->f->getAtNDupSmallDouble(self,-1); 39841 ck_assert_ptr_eq(r, NULL); 39842 s = toStringO(self); 39843 ck_assert_str_eq(s, "[1,0.000000e+00,3,0.000000e+00,11,\"<data container>\"]"); 39844 free(s); 39845 // index outside 39846 ck_assert_ptr_eq(self->f->getAtNDupSmallDouble(self, 20), NULL); 39847 ck_assert_ptr_eq(self->f->getAtNDupSmallDouble(self, -7), NULL); 39848 // empty list 39849 emptyO(self); 39850 ck_assert_ptr_eq(self->f->getAtNDupSmallDouble(self, 0), NULL); 39851 ck_assert_ptr_eq(self->f->getAtNDupSmallDouble(self, -1), NULL); 39852 terminateO(self); 39853 39854 } 39855 39856 39857 void getAtNDupSmallIntSmallJsonT(void) { 39858 39859 smallIntt* r; 39860 smallJsont *self = allocSmallJson(); 39861 smallJsont *r2; 39862 39863 // non json array 39864 ck_assert_ptr_eq(self->f->getAtNDupSmallInt(self, 0), null); 39865 // add elements to self 39866 r2 = self->f->pushBool(self, true); 39867 ck_assert_ptr_ne(r2, null); 39868 createSmallInt(e2); 39869 r2 = self->f->pushSmallInt(self, &e2); 39870 ck_assert_ptr_ne(r2, null); 39871 r2 = self->f->pushBool(self, true); 39872 ck_assert_ptr_ne(r2, null); 39873 createSmallInt(e4); 39874 r2 = self->f->pushSmallInt(self, &e4); 39875 ck_assert_ptr_ne(r2, null); 39876 39877 // positive index 39878 r = self->f->getAtNDupSmallInt(self,1); 39879 ck_assert_ptr_ne(r, null); 39880 char *s = toStringO(r); 39881 terminateO(r); 39882 ck_assert_str_eq(s, "0"); 39883 free(s); 39884 s = toStringO(self); 39885 ck_assert_str_eq(s, "[true,0,true,0]"); 39886 free(s); 39887 // negative index 39888 r = self->f->getAtNDupSmallInt(self,-1); 39889 ck_assert_ptr_ne(r, null); 39890 s = toStringO(r); 39891 terminateO(r); 39892 ck_assert_str_eq(s, "0"); 39893 free(s); 39894 s = toStringO(self); 39895 ck_assert_str_eq(s, "[true,0,true,0]"); 39896 free(s); 39897 // wrong object type 39898 createSmallDouble(I); 39899 setValG(&I, 11); 39900 r2 = self->f->pushSmallDouble(self, &I); 39901 r = self->f->getAtNDupSmallInt(self,-1); 39902 ck_assert_ptr_eq(r, NULL); 39903 s = toStringO(self); 39904 ck_assert_str_eq(s, "[true,0,true,0,1.100000e+01]"); 39905 free(s); 39906 // wrong object type of another user class 39907 // User classes are stored in containers transparently 39908 createAllocateSmallInt(ip); 39909 ip->type = "anothertype"; 39910 setValG(ip, 11); 39911 r2 = self->f->push(self, (baset*)ip); 39912 ck_assert_ptr_ne(r2, null); 39913 r = self->f->getAtNDupSmallInt(self,-1); 39914 ck_assert_ptr_eq(r, NULL); 39915 s = toStringO(self); 39916 ck_assert_str_eq(s, "[true,0,true,0,1.100000e+01,\"<data container>\"]"); 39917 free(s); 39918 // index outside 39919 ck_assert_ptr_eq(self->f->getAtNDupSmallInt(self, 20), NULL); 39920 ck_assert_ptr_eq(self->f->getAtNDupSmallInt(self, -7), NULL); 39921 // empty list 39922 emptyO(self); 39923 ck_assert_ptr_eq(self->f->getAtNDupSmallInt(self, 0), NULL); 39924 ck_assert_ptr_eq(self->f->getAtNDupSmallInt(self, -1), NULL); 39925 terminateO(self); 39926 39927 } 39928 39929 39930 void getAtNDupSmallJsonSmallJsonT(void) { 39931 39932 smallJsont* r; 39933 smallJsont *self = allocSmallJson(); 39934 smallJsont *r2; 39935 39936 // non json array 39937 ck_assert_ptr_eq(self->f->getAtNDupSmallJson(self, 0), null); 39938 // add elements to self 39939 r2 = self->f->pushInt(self, 1); 39940 ck_assert_ptr_ne(r2, null); 39941 createSmallJson(e2); 39942 r2 = self->f->pushSmallJson(self, &e2); 39943 ck_assert_ptr_ne(r2, null); 39944 r2 = self->f->pushInt(self, 3); 39945 ck_assert_ptr_ne(r2, null); 39946 createSmallJson(e4); 39947 r2 = self->f->pushSmallJson(self, &e4); 39948 ck_assert_ptr_ne(r2, null); 39949 39950 // positive index 39951 r = self->f->getAtNDupSmallJson(self,1); 39952 ck_assert_ptr_ne(r, null); 39953 char *s = toStringO(r); 39954 terminateO(r); 39955 ck_assert_str_eq(s, "{}"); 39956 free(s); 39957 s = toStringO(self); 39958 ck_assert_str_eq(s, "[1,{},3,{}]"); 39959 free(s); 39960 // negative index 39961 r = self->f->getAtNDupSmallJson(self,-1); 39962 ck_assert_ptr_ne(r, null); 39963 s = toStringO(r); 39964 terminateO(r); 39965 ck_assert_str_eq(s, "{}"); 39966 free(s); 39967 s = toStringO(self); 39968 ck_assert_str_eq(s, "[1,{},3,{}]"); 39969 free(s); 39970 // wrong object type 39971 createSmallBytes(I); 39972 r2 = self->f->pushSmallBytes(self, &I); 39973 r = self->f->getAtNDupSmallJson(self,-1); 39974 ck_assert_ptr_eq(r, NULL); 39975 s = toStringO(self); 39976 ck_assert_str_eq(s, "[1,{},3,{},[]]"); 39977 free(s); 39978 // wrong object type of another user class 39979 // User classes are stored in containers transparently 39980 createAllocateSmallInt(ip); 39981 ip->type = "anothertype"; 39982 setValG(ip, 11); 39983 r2 = self->f->push(self, (baset*)ip); 39984 ck_assert_ptr_ne(r2, null); 39985 r = self->f->getAtNDupSmallJson(self,-1); 39986 ck_assert_ptr_eq(r, NULL); 39987 s = toStringO(self); 39988 ck_assert_str_eq(s, "[1,{},3,{},[],\"<data container>\"]"); 39989 free(s); 39990 // index outside 39991 ck_assert_ptr_eq(self->f->getAtNDupSmallJson(self, 20), NULL); 39992 ck_assert_ptr_eq(self->f->getAtNDupSmallJson(self, -7), NULL); 39993 // empty list 39994 emptyO(self); 39995 ck_assert_ptr_eq(self->f->getAtNDupSmallJson(self, 0), NULL); 39996 ck_assert_ptr_eq(self->f->getAtNDupSmallJson(self, -1), NULL); 39997 terminateO(self); 39998 39999 } 40000 40001 40002 void getAtNDupSmallStringSmallJsonT(void) { 40003 40004 smallStringt* r; 40005 smallJsont *self = allocSmallJson(); 40006 smallJsont *r2; 40007 40008 // non json array 40009 ck_assert_ptr_eq(self->f->getAtNDupSmallString(self, 0), null); 40010 // add elements to self 40011 r2 = self->f->pushInt(self, 1); 40012 ck_assert_ptr_ne(r2, null); 40013 createSmallString(e2); 40014 r2 = self->f->pushSmallString(self, &e2); 40015 ck_assert_ptr_ne(r2, null); 40016 r2 = self->f->pushInt(self, 3); 40017 ck_assert_ptr_ne(r2, null); 40018 createSmallString(e4); 40019 r2 = self->f->pushSmallString(self, &e4); 40020 ck_assert_ptr_ne(r2, null); 40021 40022 // positive index 40023 r = self->f->getAtNDupSmallString(self,1); 40024 ck_assert_ptr_ne(r, null); 40025 char *s = toStringO(r); 40026 terminateO(r); 40027 ck_assert_str_eq(s, ""); 40028 free(s); 40029 s = toStringO(self); 40030 ck_assert_str_eq(s, "[1,\"\",3,\"\"]"); 40031 free(s); 40032 // negative index 40033 r = self->f->getAtNDupSmallString(self,-1); 40034 ck_assert_ptr_ne(r, null); 40035 s = toStringO(r); 40036 terminateO(r); 40037 ck_assert_str_eq(s, ""); 40038 free(s); 40039 s = toStringO(self); 40040 ck_assert_str_eq(s, "[1,\"\",3,\"\"]"); 40041 free(s); 40042 // wrong object type 40043 createSmallInt(I); 40044 setValG(&I, 11); 40045 r2 = self->f->pushSmallInt(self, &I); 40046 r = self->f->getAtNDupSmallString(self,-1); 40047 ck_assert_ptr_eq(r, NULL); 40048 s = toStringO(self); 40049 ck_assert_str_eq(s, "[1,\"\",3,\"\",11]"); 40050 free(s); 40051 // wrong object type of another user class 40052 // User classes are stored in containers transparently 40053 createAllocateSmallInt(ip); 40054 ip->type = "anothertype"; 40055 setValG(ip, 11); 40056 r2 = self->f->push(self, (baset*)ip); 40057 ck_assert_ptr_ne(r2, null); 40058 r = self->f->getAtNDupSmallString(self,-1); 40059 ck_assert_ptr_eq(r, NULL); 40060 s = toStringO(self); 40061 ck_assert_str_eq(s, "[1,\"\",3,\"\",11,\"<data container>\"]"); 40062 free(s); 40063 // index outside 40064 ck_assert_ptr_eq(self->f->getAtNDupSmallString(self, 20), NULL); 40065 ck_assert_ptr_eq(self->f->getAtNDupSmallString(self, -7), NULL); 40066 // empty list 40067 emptyO(self); 40068 ck_assert_ptr_eq(self->f->getAtNDupSmallString(self, 0), NULL); 40069 ck_assert_ptr_eq(self->f->getAtNDupSmallString(self, -1), NULL); 40070 terminateO(self); 40071 40072 } 40073 40074 40075 void getAtNDupVoidSmallJsonT(void) { 40076 40077 void* r; 40078 smallJsont *self = allocSmallJson(); 40079 smallJsont *r2; 40080 40081 // non json array 40082 ck_assert_ptr_eq(self->f->getAtNDupVoid(self, 0), null); 40083 // add elements to self 40084 r2 = self->f->pushInt(self, 1); 40085 ck_assert_ptr_ne(r2, null); 40086 r2 = pushVoidSmallJsonG(self, &r); 40087 ck_assert_ptr_ne(r2, null); 40088 r2 = self->f->pushInt(self, 3); 40089 ck_assert_ptr_ne(r2, null); 40090 r2 = pushVoidSmallJsonG(self, &self); 40091 ck_assert_ptr_ne(r2, null); 40092 40093 // positive index 40094 r = self->f->getAtNDupVoid(self,1); 40095 // duplicate function is not set so the data is not duplicated 40096 ck_assert_ptr_eq(r, NULL); 40097 char *s = toStringO(self); 40098 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 40099 free(s); 40100 // negative index 40101 r = self->f->getAtNDupVoid(self,-1); 40102 // duplicate function is not set so the data is not duplicated 40103 ck_assert_ptr_eq(r, NULL); 40104 s = toStringO(self); 40105 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 40106 free(s); 40107 // wrong object type 40108 createSmallInt(I); 40109 setValG(&I, 11); 40110 r2 = self->f->pushSmallInt(self, &I); 40111 r = self->f->getAtNDupVoid(self,-1); 40112 ck_assert_ptr_eq(r, NULL); 40113 s = toStringO(self); 40114 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11]"); 40115 free(s); 40116 // wrong object type of another user class 40117 // User classes are stored in containers transparently 40118 createAllocateSmallInt(ip); 40119 ip->type = "anothertype"; 40120 setValG(ip, 11); 40121 r2 = self->f->push(self, (baset*)ip); 40122 ck_assert_ptr_ne(r2, null); 40123 r = self->f->getAtNDupVoid(self,-1); 40124 ck_assert_ptr_eq(r, NULL); 40125 s = toStringO(self); 40126 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11,\"<data container>\"]"); 40127 free(s); 40128 // index outside 40129 ck_assert_ptr_eq(self->f->getAtNDupVoid(self, 20), NULL); 40130 ck_assert_ptr_eq(self->f->getAtNDupVoid(self, -7), NULL); 40131 // empty list 40132 emptyO(self); 40133 ck_assert_ptr_eq(self->f->getAtNDupVoid(self, 0), NULL); 40134 ck_assert_ptr_eq(self->f->getAtNDupVoid(self, -1), NULL); 40135 terminateO(self); 40136 40137 } 40138 40139 40140 void getAtNDupSmallContainerSmallJsonT(void) { 40141 40142 smallContainert* r; 40143 smallJsont *self = allocSmallJson(); 40144 smallJsont *r2; 40145 40146 // non json array 40147 ck_assert_ptr_eq(self->f->getAtNDupSmallContainer(self, 0), null); 40148 // add elements to self 40149 r2 = self->f->pushInt(self, 1); 40150 ck_assert_ptr_ne(r2, null); 40151 createSmallContainer(e2); 40152 r2 = self->f->pushSmallContainer(self, &e2); 40153 ck_assert_ptr_ne(r2, null); 40154 r2 = self->f->pushInt(self, 3); 40155 ck_assert_ptr_ne(r2, null); 40156 createSmallContainer(e4); 40157 r2 = self->f->pushSmallContainer(self, &e4); 40158 ck_assert_ptr_ne(r2, null); 40159 40160 // positive index 40161 r = self->f->getAtNDupSmallContainer(self,1); 40162 ck_assert_ptr_ne(r, null); 40163 char *s = toStringO(r); 40164 terminateO(r); 40165 ck_assert_str_eq(s, "<data smallContainer>"); 40166 free(s); 40167 s = toStringO(self); 40168 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 40169 free(s); 40170 // negative index 40171 r = self->f->getAtNDupSmallContainer(self,-1); 40172 ck_assert_ptr_ne(r, null); 40173 s = toStringO(r); 40174 terminateO(r); 40175 ck_assert_str_eq(s, "<data smallContainer>"); 40176 free(s); 40177 s = toStringO(self); 40178 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\"]"); 40179 free(s); 40180 // wrong object type 40181 createSmallInt(I); 40182 setValG(&I, 11); 40183 r2 = self->f->pushSmallInt(self, &I); 40184 r = self->f->getAtNDupSmallContainer(self,-1); 40185 ck_assert_ptr_eq(r, NULL); 40186 s = toStringO(self); 40187 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11]"); 40188 free(s); 40189 // wrong object type of another user class 40190 // User classes are stored in containers transparently 40191 createAllocateSmallInt(ip); 40192 ip->type = "anothertype"; 40193 setValG(ip, 11); 40194 r2 = self->f->push(self, (baset*)ip); 40195 ck_assert_ptr_ne(r2, null); 40196 r = self->f->getAtNDupSmallContainer(self,-1); 40197 ck_assert_ptr_eq(r, NULL); 40198 s = toStringO(self); 40199 ck_assert_str_eq(s, "[1,\"<data container>\",3,\"<data container>\",11,\"<data container>\"]"); 40200 free(s); 40201 // index outside 40202 ck_assert_ptr_eq(self->f->getAtNDupSmallContainer(self, 20), NULL); 40203 ck_assert_ptr_eq(self->f->getAtNDupSmallContainer(self, -7), NULL); 40204 // empty list 40205 emptyO(self); 40206 ck_assert_ptr_eq(self->f->getAtNDupSmallContainer(self, 0), NULL); 40207 ck_assert_ptr_eq(self->f->getAtNDupSmallContainer(self, -1), NULL); 40208 terminateO(self); 40209 40210 } 40211 40212 40213 void getNumSmallJsonT(void) { 40214 40215 double r; 40216 smallJsont *self = allocSmallJson(); 40217 smallJsont *r2; 40218 40219 // non json array 40220 ck_assert(getNumO(self, 0) == 0); 40221 r2 = self->f->setInt(self, "1", 1); 40222 ck_assert_ptr_ne(r2, null); 40223 r2 = self->f->setDouble(self, "2", 2.2); 40224 ck_assert_ptr_ne(r2, null); 40225 r2 = self->f->setS(self, "3", "2"); 40226 ck_assert_ptr_ne(r2, null); 40227 r = getNumO(self, "1"); 40228 ck_assert(r == 1); 40229 r = getNumO(self, "2"); 40230 ck_assert(r == 2.2); 40231 // not a number 40232 r = getNumO(self, "3"); 40233 ck_assert(r == 0); 40234 // path 40235 createSmallArray(a); 40236 createSmallDict(d); 40237 a.f->pushDict(&a, &d); 40238 self->f->setArray(self, "array", &a); 40239 r2 = self->f->setInt(self, "\"array\"[0].\"key\"", 123); 40240 ck_assert_ptr_ne(r2, null); 40241 r = getNumO(self, "\"array\"[0].\"key\""); 40242 ck_assert_int_eq(r, 123); 40243 // json bool 40244 freeO(self); 40245 setTypeBoolO(self); 40246 r = getNumO(self, "1"); 40247 ck_assert(r == 0); 40248 // json array 40249 freeO(self); 40250 setTypeArrayO(self); 40251 r = getNumO(self, "1"); 40252 ck_assert(r == 0); 40253 // non existing dict path 40254 freeO(self); 40255 r = getNumO(self, "\"1\"[1]"); 40256 ck_assert(r == 0); 40257 // dict path but the object is an array 40258 resetO(&a); 40259 self->f->setArray(self, "1", &a); 40260 r = getNumO(self, "\"1\".\"1\""); 40261 ck_assert(r == 0); 40262 // dict object in path but the key doesn't exists 40263 resetO(&d); 40264 self->f->setDict(self, "2", &d); 40265 r = getNumO(self, "\"2\".\"1\".[12]"); 40266 ck_assert(r == 0); 40267 // null key 40268 r = getNumO(self, null); 40269 ck_assert(r == 0); 40270 // empty self 40271 freeO(self); 40272 r = getNumO(self, "1"); 40273 ck_assert(r == 0); 40274 terminateO(self); 40275 40276 } 40277 40278 40279 void getNumAtSmallJsonT(void) { 40280 40281 double r; 40282 smallJsont *self = allocSmallJson(); 40283 smallJsont *r2; 40284 40285 // non json array 40286 ck_assert(!getNumAtO(self, 0)); 40287 // add elements to self 40288 r2 = self->f->pushInt(self, 1); 40289 ck_assert_ptr_ne(r2, null); 40290 r2 = self->f->pushDouble(self, 2); 40291 ck_assert_ptr_ne(r2, null); 40292 r2 = self->f->pushInt(self, 3); 40293 ck_assert_ptr_ne(r2, null); 40294 r2 = self->f->pushInt(self, 4); 40295 ck_assert_ptr_ne(r2, null); 40296 40297 // positive index 40298 r = getNumAtO(self,1); 40299 ck_assert(r==2); 40300 char *s = toStringO(self); 40301 ck_assert_str_eq(s, "[1,2.000000e+00,3,4]"); 40302 free(s); 40303 // negative index 40304 r = getNumAtO(self,-1); 40305 ck_assert(r==4); 40306 s = toStringO(self); 40307 ck_assert_str_eq(s, "[1,2.000000e+00,3,4]"); 40308 free(s); 40309 // wrong object type of another user class 40310 // User classes are stored in containers transparently 40311 createAllocateSmallInt(ip); 40312 ip->type = "anothertype"; 40313 setValG(ip, 11); 40314 r2 = self->f->push(self, (baset*)ip); 40315 ck_assert_ptr_ne(r2, null); 40316 r = getNumAtO(self,-1); 40317 ck_assert(!r); 40318 s = toStringO(self); 40319 ck_assert_str_eq(s, "[1,2.000000e+00,3,4,\"<data container>\"]"); 40320 free(s); 40321 // index outside 40322 ck_assert(!getNumAtO(self, 20)); 40323 ck_assert(!getNumAtO(self, -7)); 40324 // empty list 40325 emptyO(self); 40326 ck_assert(!getNumAtO(self, 0)); 40327 ck_assert(!getNumAtO(self, -1)); 40328 terminateO(self); 40329 40330 } 40331 40332 40333 void delElemSmallJsonT(void) { 40334 40335 smallJsont* r; 40336 smallJsont *self = allocG(rtSmallJsont); 40337 40338 self->f->setBool(self, "lib", true); 40339 // delete element 40340 r = delElemO(self, "lib"); 40341 ck_assert_ptr_ne(r, null); 40342 smallBoolt *oBool3 = (smallBoolt *)self->f->get(self, "lib"); 40343 ck_assert_ptr_eq(oBool3, NULL); 40344 // path 40345 baset *value = (baset*) allocSmallInt(2); 40346 createSmallArray(a); 40347 createSmallDict(d); 40348 a.f->pushDict(&a, &d); 40349 self->f->setArray(self, "array", &a); 40350 r = self->f->set(self, "\"array\"[0].\"key\"", value); 40351 ck_assert_ptr_ne(r, null); 40352 finishO(value); 40353 r = delElemO(self, "\"array\"[0].\"key\""); 40354 ck_assert_ptr_ne(r, null); 40355 // json bool 40356 freeO(self); 40357 setTypeBoolO(self); 40358 r = delElemO(self, "1"); 40359 ck_assert_ptr_eq(r, null); 40360 // json array 40361 freeO(self); 40362 setTypeArrayO(self); 40363 r = delElemO(self, "1"); 40364 ck_assert_ptr_eq(r, null); 40365 // non existing dict path 40366 freeO(self); 40367 r = delElemO(self, "\"1\"[1]"); 40368 ck_assert_ptr_eq(r, null); 40369 // dict path but the object is an array 40370 resetO(&a); 40371 self->f->setArray(self, "1", &a); 40372 r = delElemO(self, "\"1\".\"1\""); 40373 ck_assert_ptr_eq(r, null); 40374 // dict object in path but the key doesn't exists 40375 resetO(&d); 40376 self->f->setDict(self, "2", &d); 40377 r = delElemO(self, "\"2\".\"1\".[12]"); 40378 ck_assert_ptr_eq(r, null); 40379 // delete non existing element 40380 r = delElemO(self, NULL); 40381 ck_assert_ptr_eq(r, null); 40382 r = delElemO(self, "non existing"); 40383 ck_assert_ptr_ne(r, null); 40384 terminateO(self); 40385 40386 } 40387 40388 40389 void delSmallJsonT(void) { 40390 40391 smallJsont* r; 40392 smallJsont *self = allocG(rtSmallJsont); 40393 40394 // json string 40395 // empty string 40396 setTopSO(self, ""); 40397 r = delO(self, 0,1); 40398 ck_assert_ptr_eq(r, null); 40399 // del 40400 freeO(self); 40401 setTopSO(self, "sheepy"); 40402 r = delO(self, 0,2); 40403 ck_assert_ptr_ne(r, null); 40404 char *s = toStringO(r); 40405 ck_assert_str_eq(s, "eepy"); 40406 free(s); 40407 // negative index 40408 freeO(self); 40409 setTopSO(self, "sheepy"); 40410 r = delO(self, -2,0); 40411 ck_assert_ptr_ne(r, null); 40412 s = toStringO(r); 40413 ck_assert_str_eq(s, "shee"); 40414 free(s); 40415 // positive and negative indexes 40416 freeO(self); 40417 setTopSO(self, "sheepy"); 40418 r = delO(self, 2,-2); 40419 ck_assert_ptr_ne(r, null); 40420 s = toStringO(r); 40421 ck_assert_str_eq(s, "shpy"); 40422 free(s); 40423 // start = end 40424 freeO(self); 40425 setTopSO(self, "sheepy"); 40426 r = delO(self, 2,-4); 40427 ck_assert_ptr_ne(r, null); 40428 s = toStringO(r); 40429 ck_assert_str_eq(s, "sheepy"); 40430 free(s); 40431 // delete entire string 40432 freeO(self); 40433 setTopSO(self, "sheepy"); 40434 r = delO(self, 0,0); 40435 ck_assert_ptr_ne(r, null); 40436 s = toStringO(r); 40437 ck_assert_str_eq(s, ""); 40438 free(s); 40439 // end of string 40440 freeO(self); 40441 setTopSO(self, "sheepy"); 40442 r = delO(self, 2,6); 40443 ck_assert_ptr_ne(r, null); 40444 s = toStringO(r); 40445 ck_assert_str_eq(s, "sh"); 40446 free(s); 40447 // NULL string 40448 freeO(self); 40449 r = delO(self, 2,-4); 40450 ck_assert_ptr_eq(r, NULL); 40451 // start outside string 40452 freeO(self); 40453 setTopSO(self, "sheepy"); 40454 r = delO(self, 20,-4); 40455 ck_assert_ptr_eq(r, null); 40456 s = toStringO(self); 40457 ck_assert_str_eq(s, "sheepy"); 40458 free(s); 40459 r = delO(self, -20,-4); 40460 ck_assert_ptr_ne(r, null); 40461 s = toStringO(r); 40462 ck_assert_str_eq(s, "eepy"); 40463 free(s); 40464 // end outside string 40465 freeO(self); 40466 setTopSO(self, "sheepy"); 40467 r = delO(self, 2,40); 40468 ck_assert_ptr_ne(r, null); 40469 s = toStringO(r); 40470 ck_assert_str_eq(s, "sh"); 40471 free(s); 40472 freeO(self); 40473 setTopSO(self, "sheepy"); 40474 r = delO(self, 2,-40); 40475 ck_assert_ptr_eq(r, null); 40476 s = toStringO(self); 40477 ck_assert_str_eq(s, "sheepy"); 40478 free(s); 40479 // end before start 40480 freeO(self); 40481 setTopSO(self, "sheepy"); 40482 r = delO(self, 4,2); 40483 ck_assert_ptr_eq(r, null); 40484 s = toStringO(self); 40485 ck_assert_str_eq(s, "sheepy"); 40486 free(s); 40487 terminateO(self); 40488 // json array 40489 self = allocSmallJson(); 40490 self->f->pushUndefined(self); 40491 self->f->pushInt(self, 123); 40492 self->f->pushS(self, "sheepy"); 40493 self->f->pushInt(self, 5345); 40494 // del 40495 r = delO(self,1,-1); 40496 ck_assert_ptr_ne(r, null); 40497 s = toStringO(self); 40498 ck_assert_str_eq(s, "[null,5345]"); 40499 free(s); 40500 terminateO(self); 40501 // start outside 40502 self = allocSmallJson(); 40503 self->f->pushUndefined(self); 40504 self->f->pushInt(self, 123); 40505 self->f->pushS(self, "sheepy"); 40506 self->f->pushInt(self, 5345); 40507 r = delO(self,20,-1); 40508 ck_assert_ptr_eq(r, null); 40509 s = toStringO(self); 40510 ck_assert_str_eq(s, "[null,123,\"sheepy\",5345]"); 40511 free(s); 40512 terminateO(self); 40513 // start negative and outside 40514 self = allocSmallJson(); 40515 self->f->pushUndefined(self); 40516 self->f->pushInt(self, 123); 40517 self->f->pushS(self, "sheepy"); 40518 self->f->pushInt(self, 5345); 40519 r = delO(self,-20,1); 40520 ck_assert_ptr_ne(r, null); 40521 s = toStringO(self); 40522 ck_assert_str_eq(s, "[123,\"sheepy\",5345]"); 40523 free(s); 40524 terminateO(self); 40525 // end outside 40526 self = allocSmallJson(); 40527 self->f->pushUndefined(self); 40528 self->f->pushInt(self, 123); 40529 self->f->pushS(self, "sheepy"); 40530 self->f->pushInt(self, 5345); 40531 r = delO(self,2,40); 40532 ck_assert_ptr_ne(r, null); 40533 s = toStringO(self); 40534 ck_assert_str_eq(s, "[null,123]"); 40535 free(s); 40536 terminateO(self); 40537 // end negative and outside 40538 self = allocSmallJson(); 40539 self->f->pushUndefined(self); 40540 self->f->pushInt(self, 123); 40541 self->f->pushS(self, "sheepy"); 40542 self->f->pushInt(self, 5345); 40543 r = delO(self,2,-40); 40544 ck_assert_ptr_eq(r, null); 40545 s = toStringO(self); 40546 ck_assert_str_eq(s, "[null,123,\"sheepy\",5345]"); 40547 free(s); 40548 terminateO(self); 40549 // end before start 40550 self = allocSmallJson(); 40551 self->f->pushUndefined(self); 40552 self->f->pushInt(self, 123); 40553 self->f->pushS(self, "sheepy"); 40554 self->f->pushInt(self, 5345); 40555 r = delO(self,3,2); 40556 ck_assert_ptr_eq(r, null); 40557 s = toStringO(self); 40558 ck_assert_str_eq(s, "[null,123,\"sheepy\",5345]"); 40559 free(s); 40560 terminateO(self); 40561 // negative start last element 40562 self = allocSmallJson(); 40563 self->f->pushUndefined(self); 40564 self->f->pushInt(self, 123); 40565 self->f->pushS(self, "sheepy"); 40566 self->f->pushInt(self, 5345); 40567 r = delO(self,-1,0); 40568 ck_assert_ptr_ne(r, null); 40569 s = toStringO(self); 40570 ck_assert_str_eq(s, "[null,123,\"sheepy\"]"); 40571 free(s); 40572 terminateO(self); 40573 // start = end 40574 self = allocSmallJson(); 40575 self->f->pushUndefined(self); 40576 self->f->pushInt(self, 123); 40577 self->f->pushS(self, "sheepy"); 40578 self->f->pushInt(self, 5345); 40579 r = delO(self,1,1); 40580 ck_assert_ptr_ne(r, null); 40581 s = toStringO(self); 40582 ck_assert_str_eq(s, "[null,123,\"sheepy\",5345]"); 40583 free(s); 40584 terminateO(self); 40585 // empty list 40586 self = allocSmallJson(); 40587 r = delO(self,0,0); 40588 ck_assert_ptr_eq(r, null); 40589 setTypeArrayO(self); 40590 r = delO(self,0,0); 40591 ck_assert_ptr_eq(r, null); 40592 terminateO(self); 40593 40594 } 40595 40596 40597 void delElemIndexSmallJsonT(void) { 40598 40599 smallJsont* r; 40600 smallJsont *self = allocG(rtSmallJsont); 40601 40602 // non json array 40603 r = delElemIndexO(self, 0); 40604 ck_assert_ptr_eq(r, null); 40605 // json string 40606 // del 40607 freeO(self); 40608 setTopSO(self, "sheepy"); 40609 r = delElemIndexO(self, 0); 40610 ck_assert_ptr_ne(r, null); 40611 char *s = toStringO(r); 40612 ck_assert_str_eq(s, "heepy"); 40613 free(s); 40614 freeO(self); 40615 setTopSO(self, "sheepy"); 40616 r = delElemIndexO(self, 5); 40617 ck_assert_ptr_ne(r, null); 40618 s = toStringO(r); 40619 ck_assert_str_eq(s, "sheep"); 40620 free(s); 40621 // negative index 40622 freeO(self); 40623 setTopSO(self, "sheepy"); 40624 r = delElemIndexO(self, -1); 40625 ck_assert_ptr_ne(r, null); 40626 s = toStringO(r); 40627 ck_assert_str_eq(s, "sheep"); 40628 free(s); 40629 freeO(self); 40630 setTopSO(self, "sheepy"); 40631 r = delElemIndexO(self, -6); 40632 ck_assert_ptr_ne(r, null); 40633 s = toStringO(r); 40634 ck_assert_str_eq(s, "heepy"); 40635 free(s); 40636 // index outside string 40637 freeO(self); 40638 setTopSO(self, "sheepy"); 40639 r = delElemIndexO(self, 6); 40640 ck_assert_ptr_eq(r, null); 40641 r = delElemIndexO(self, -7); 40642 ck_assert_ptr_eq(r, null); 40643 // empty string 40644 freeO(self); 40645 setTopSO(self, ""); 40646 ck_assert_ptr_eq(delElemIndexO(self, 0), null); 40647 // null string 40648 freeO(self); 40649 ck_assert_ptr_eq(delElemIndexO(self, 0), null); 40650 terminateO(self); 40651 // json array 40652 self = allocSmallJson(); 40653 setTypeArrayO(self); 40654 // empty array 40655 ck_assert_ptr_eq(delElemIndexO(self, 0), null); 40656 // outside positive and negative 40657 self->f->pushS(self, ""); 40658 ck_assert_ptr_eq(delElemIndexO(self, 1), null); 40659 ck_assert_ptr_eq(delElemIndexO(self, -2), null); 40660 // del 40661 ck_assert_ptr_ne(delElemIndexO(self, -1), null); 40662 s = toStringO(self); 40663 ck_assert_str_eq(s, "[]"); 40664 free(s); 40665 terminateO(self); 40666 40667 } 40668 40669 40670 void removeElemSmallJsonT(void) { 40671 40672 smallJsont* r; 40673 smallJsont *self = allocSmallJson(); 40674 40675 smallIntt *i = allocSmallInt(1); 40676 r = self->f->setSmallInt(self, "1", i); 40677 ck_assert_ptr_ne(r, null); 40678 r = self->f->removeElem(self, "1"); 40679 ck_assert_ptr_ne(r, null); 40680 terminateO(i); 40681 char *s = toStringO(r); 40682 ck_assert_str_eq(s, "{}"); 40683 free(s); 40684 // path 40685 baset *value = (baset*) allocSmallInt(2); 40686 createSmallArray(a); 40687 createSmallDict(d); 40688 a.f->pushDict(&a, &d); 40689 self->f->setArray(self, "array", &a); 40690 r = self->f->set(self, "\"array\"[0].\"key\"", value); 40691 ck_assert_ptr_ne(r, null); 40692 r = self->f->removeElem(self, "\"array\"[0].\"key\""); 40693 ck_assert_ptr_ne(r, null); 40694 terminateO(value); 40695 // json bool 40696 freeO(self); 40697 setTypeBoolO(self); 40698 r = self->f->removeElem(self, "1"); 40699 ck_assert_ptr_eq(r, null); 40700 // json array 40701 freeO(self); 40702 setTypeArrayO(self); 40703 r = self->f->removeElem(self, "1"); 40704 ck_assert_ptr_eq(r, null); 40705 // non existing dict path 40706 freeO(self); 40707 r = self->f->removeElem(self, "\"1\"[1]"); 40708 ck_assert_ptr_eq(r, null); 40709 // dict path but the object is an array 40710 resetO(&a); 40711 self->f->setArray(self, "1", &a); 40712 r = self->f->removeElem(self, "\"1\".\"1\""); 40713 ck_assert_ptr_eq(r, null); 40714 // dict object in path but the key doesn't exists 40715 resetO(&d); 40716 self->f->setDict(self, "2", &d); 40717 r = self->f->removeElem(self, "\"2\".\"1\".[12]"); 40718 ck_assert_ptr_eq(r, null); 40719 delElemO(self, "2"); 40720 // non existing key 40721 r = self->f->removeElem(self, "1"); 40722 ck_assert_ptr_ne(r, null); 40723 freeO(&a); // self->f->setArray(self, "1", &a) above allocates an sArray 40724 s = toStringO(r); 40725 ck_assert_str_eq(s, "{}"); 40726 free(s); 40727 // null key 40728 r = self->f->removeElem(self, null); 40729 ck_assert_ptr_eq(r, null); 40730 // empty self 40731 freeO(self); 40732 r = self->f->removeElem(self, "qwe"); 40733 ck_assert_ptr_eq(r, null); 40734 terminateO(self); 40735 40736 } 40737 40738 40739 void removeSmallJsonT(void) { 40740 40741 smallJsont* r; 40742 smallJsont *self = allocSmallJson(); 40743 40744 // non json array or string 40745 ck_assert_ptr_eq(removeO(self, 0, 1), null); 40746 // json string -> same code as delO json string 40747 // empty string 40748 setTopSO(self, ""); 40749 r = removeO(self, 0,1); 40750 ck_assert_ptr_eq(r, null); 40751 // del 40752 freeO(self); 40753 setTopSO(self, "sheepy"); 40754 r = removeO(self, 0,2); 40755 ck_assert_ptr_ne(r, null); 40756 char *s = toStringO(r); 40757 ck_assert_str_eq(s, "eepy"); 40758 free(s); 40759 // negative index 40760 freeO(self); 40761 setTopSO(self, "sheepy"); 40762 r = removeO(self, -2,0); 40763 ck_assert_ptr_ne(r, null); 40764 s = toStringO(r); 40765 ck_assert_str_eq(s, "shee"); 40766 free(s); 40767 // positive and negative indexes 40768 freeO(self); 40769 setTopSO(self, "sheepy"); 40770 r = removeO(self, 2,-2); 40771 ck_assert_ptr_ne(r, null); 40772 s = toStringO(r); 40773 ck_assert_str_eq(s, "shpy"); 40774 free(s); 40775 // start = end 40776 freeO(self); 40777 setTopSO(self, "sheepy"); 40778 r = removeO(self, 2,-4); 40779 ck_assert_ptr_ne(r, null); 40780 s = toStringO(r); 40781 ck_assert_str_eq(s, "sheepy"); 40782 free(s); 40783 // delete entire string 40784 freeO(self); 40785 setTopSO(self, "sheepy"); 40786 r = removeO(self, 0,0); 40787 ck_assert_ptr_ne(r, null); 40788 s = toStringO(r); 40789 ck_assert_str_eq(s, ""); 40790 free(s); 40791 // end of string 40792 freeO(self); 40793 setTopSO(self, "sheepy"); 40794 r = removeO(self, 2,6); 40795 ck_assert_ptr_ne(r, null); 40796 s = toStringO(r); 40797 ck_assert_str_eq(s, "sh"); 40798 free(s); 40799 // NULL string 40800 freeO(self); 40801 r = removeO(self, 2,-4); 40802 ck_assert_ptr_eq(r, NULL); 40803 // start outside string 40804 freeO(self); 40805 setTopSO(self, "sheepy"); 40806 r = removeO(self, 20,-4); 40807 ck_assert_ptr_eq(r, null); 40808 s = toStringO(self); 40809 ck_assert_str_eq(s, "sheepy"); 40810 free(s); 40811 r = removeO(self, -20,-4); 40812 ck_assert_ptr_ne(r, null); 40813 s = toStringO(r); 40814 ck_assert_str_eq(s, "eepy"); 40815 free(s); 40816 // end outside string 40817 freeO(self); 40818 setTopSO(self, "sheepy"); 40819 r = removeO(self, 2,40); 40820 ck_assert_ptr_ne(r, null); 40821 s = toStringO(r); 40822 ck_assert_str_eq(s, "sh"); 40823 free(s); 40824 freeO(self); 40825 setTopSO(self, "sheepy"); 40826 r = removeO(self, 2,-40); 40827 ck_assert_ptr_eq(r, null); 40828 s = toStringO(self); 40829 ck_assert_str_eq(s, "sheepy"); 40830 free(s); 40831 // end before start 40832 freeO(self); 40833 setTopSO(self, "sheepy"); 40834 r = removeO(self, 4,2); 40835 ck_assert_ptr_eq(r, null); 40836 s = toStringO(self); 40837 ck_assert_str_eq(s, "sheepy"); 40838 free(s); 40839 terminateO(self); 40840 // json array 40841 self = allocSmallJson(); 40842 // add elements to self 40843 r = self->f->pushInt(self, 1); 40844 ck_assert_ptr_ne(r, null); 40845 r = self->f->pushInt(self, 2); 40846 ck_assert_ptr_ne(r, null); 40847 r = self->f->pushInt(self, 3); 40848 ck_assert_ptr_ne(r, null); 40849 r = self->f->pushInt(self, 4); 40850 ck_assert_ptr_ne(r, null); 40851 40852 smallIntt *e[4]; 40853 arange(i,e) { 40854 e[i] = self->f->getAtSmallInt(self, i); 40855 } 40856 40857 // negative index 40858 r = removeO(self, 1, -1); 40859 ck_assert_ptr_ne(r, null); 40860 s = toStringO(self); 40861 ck_assert_str_eq(s, "[1,4]"); 40862 free(s); 40863 // start outside 40864 ck_assert_ptr_eq(removeO(self, 20, -4), NULL); 40865 // end outside 40866 r = removeO(self, 0, 40); 40867 ck_assert_ptr_ne(r, null); 40868 s = toStringO(self); 40869 ck_assert_str_eq(s, "[]"); 40870 free(s); 40871 arange(i,e) { 40872 terminateO(e[i]); 40873 } 40874 // end negative and outside 40875 // remove elements with NULL (set by removeO) 40876 trimO(self); 40877 // add elements to self 40878 r = self->f->pushInt(self, 1); 40879 ck_assert_ptr_ne(r, null); 40880 r = self->f->pushInt(self, 2); 40881 ck_assert_ptr_ne(r, null); 40882 r = self->f->pushInt(self, 3); 40883 ck_assert_ptr_ne(r, null); 40884 r = self->f->pushInt(self, 4); 40885 ck_assert_ptr_ne(r, null); 40886 arange(i,e) { 40887 e[i] = self->f->getAtSmallInt(self, i); 40888 } 40889 ck_assert_ptr_eq(removeO(self, 2, -40), NULL); 40890 s = toStringO(self); 40891 ck_assert_str_eq(s, "[1,2,3,4]"); 40892 free(s); 40893 // end before start 40894 ck_assert_ptr_eq(removeO(self, 3, 2), NULL); 40895 s = toStringO(self); 40896 ck_assert_str_eq(s, "[1,2,3,4]"); 40897 free(s); 40898 // negative start last element 40899 r = removeO(self, -1, 0); 40900 ck_assert_ptr_ne(r, null); 40901 s = toStringO(self); 40902 ck_assert_str_eq(s, "[1,2,3]"); 40903 free(s); 40904 // negative start and outside 40905 r = removeO(self, -10, 1); 40906 ck_assert_ptr_ne(r, null); 40907 s = toStringO(self); 40908 ck_assert_str_eq(s, "[2,3]"); 40909 free(s); 40910 // start = end 40911 r = removeO(self, 1, 1); 40912 ck_assert_ptr_ne(r, null); 40913 s = toStringO(self); 40914 ck_assert_str_eq(s, "[2,3]"); 40915 free(s); 40916 // remove all 40917 r = removeO(self, 0, 0); 40918 ck_assert_ptr_ne(r, null); 40919 s = toStringO(self); 40920 ck_assert_str_eq(s, "[]"); 40921 free(s); 40922 arange(i,e) { 40923 terminateO(e[i]); 40924 } 40925 // empty list 40926 emptyO(self); 40927 ck_assert_ptr_eq(removeO(self, 0, 0), NULL); 40928 ck_assert_ptr_eq(removeO(self, -1, 0), NULL); 40929 terminateO(self); 40930 40931 } 40932 40933 40934 void removeElemIndexSmallJsonT(void) { 40935 40936 smallJsont* r; 40937 smallJsont *self = allocSmallJson(); 40938 40939 // non json array 40940 r = removeElemIndexO(self, 0); 40941 ck_assert_ptr_eq(r, null); 40942 // json string 40943 // del 40944 freeO(self); 40945 setTopSO(self, "sheepy"); 40946 r = removeElemIndexO(self, 0); 40947 ck_assert_ptr_ne(r, null); 40948 char *s = toStringO(r); 40949 ck_assert_str_eq(s, "heepy"); 40950 free(s); 40951 freeO(self); 40952 setTopSO(self, "sheepy"); 40953 r = removeElemIndexO(self, 5); 40954 ck_assert_ptr_ne(r, null); 40955 s = toStringO(r); 40956 ck_assert_str_eq(s, "sheep"); 40957 free(s); 40958 // negative index 40959 freeO(self); 40960 setTopSO(self, "sheepy"); 40961 r = removeElemIndexO(self, -1); 40962 ck_assert_ptr_ne(r, null); 40963 s = toStringO(r); 40964 ck_assert_str_eq(s, "sheep"); 40965 free(s); 40966 freeO(self); 40967 setTopSO(self, "sheepy"); 40968 r = removeElemIndexO(self, -6); 40969 ck_assert_ptr_ne(r, null); 40970 s = toStringO(r); 40971 ck_assert_str_eq(s, "heepy"); 40972 free(s); 40973 // index outside string 40974 freeO(self); 40975 setTopSO(self, "sheepy"); 40976 r = removeElemIndexO(self, 6); 40977 ck_assert_ptr_eq(r, null); 40978 r = removeElemIndexO(self, -7); 40979 ck_assert_ptr_eq(r, null); 40980 // empty string 40981 freeO(self); 40982 setTopSO(self, ""); 40983 ck_assert_ptr_eq(removeElemIndexO(self, 0), null); 40984 // null string 40985 freeO(self); 40986 ck_assert_ptr_eq(removeElemIndexO(self, 0), null); 40987 terminateO(self); 40988 // json array 40989 self = allocSmallJson(); 40990 // add elements to self 40991 r = self->f->pushInt(self, 1); 40992 ck_assert_ptr_ne(r, null); 40993 r = self->f->pushInt(self, 2); 40994 ck_assert_ptr_ne(r, null); 40995 r = self->f->pushInt(self, 3); 40996 ck_assert_ptr_ne(r, null); 40997 r = self->f->pushInt(self, 4); 40998 ck_assert_ptr_ne(r, null); 40999 41000 smallIntt *e[2]; 41001 e[0] = self->f->getAtSmallInt(self, 1); 41002 e[1] = self->f->getAtSmallInt(self, 3); 41003 41004 // positive index 41005 r = removeElemIndexO(self,1); 41006 ck_assert_ptr_ne(r, null); 41007 s = toStringO(self); 41008 ck_assert_str_eq(s, "[1,3,4]"); 41009 free(s); 41010 // negative index 41011 r = removeElemIndexO(self,-1); 41012 ck_assert_ptr_ne(r, null); 41013 s = toStringO(self); 41014 ck_assert_str_eq(s, "[1,3]"); 41015 free(s); 41016 terminateO(e[0]); 41017 terminateO(e[1]); 41018 // index outside 41019 ck_assert_ptr_eq(removeElemIndexO(self, 20), NULL); 41020 ck_assert_ptr_eq(removeElemIndexO(self, -5), NULL); 41021 // empty list 41022 emptyO(self); 41023 ck_assert_ptr_eq(removeElemIndexO(self, 0), NULL); 41024 ck_assert_ptr_eq(removeElemIndexO(self, -1), NULL); 41025 terminateO(self); 41026 41027 } 41028 41029 41030 void stringifySmallStringSmallJsonT(void) { 41031 41032 smallStringt* r; 41033 smallJsont *self = allocG(rtSmallJsont); 41034 41035 // stringifySmallJson is tested in cSmallJsonT 41036 // this test checks the parts not tested in cSmallJsonT 41037 // json dict 41038 self->f->setS(self, "\\\\", "\\erw\\\""); 41039 r = stringifySmallStringO(self, 2); 41040 ck_assert_ptr_ne(r, null); 41041 char *s = toStringO(r); 41042 terminateO(r); 41043 ck_assert_str_eq(s, "{\n \"\\\\\": \"\\\\erw\\\\\\\"\"\n}\n"); 41044 free(s); 41045 // json array 41046 freeO(self); 41047 self->f->pushS(self, "\\\\ewq\\\""); 41048 r = stringifySmallStringO(self, 2); 41049 ck_assert_ptr_ne(r, null); 41050 s = toStringO(r); 41051 terminateO(r); 41052 ck_assert_str_eq(s, "[\n \"\\\\\\\\ewq\\\\\\\"\"\n]\n"); 41053 free(s); 41054 terminateO(self); 41055 41056 } 41057 41058 41059 void toYMLSmallStringSmallJsonT(void) { 41060 41061 smallStringt* r; 41062 smallJsont *self = allocG(rtSmallJsont); 41063 41064 self->f->pushS(self, "qwe"); 41065 r = toYMLSmallStringO(self, 2); 41066 ck_assert_ptr_ne(r, null); 41067 char *s = toStringO(r); 41068 ck_assert_str_eq(s, "---\n - qwe\n"); 41069 free(s); 41070 terminateO(r); 41071 // blank and empty keys should have quotes 41072 freeO(self); 41073 self->f->setS(self, "", "empty"); 41074 self->f->setS(self, " ", "blank"); 41075 r = toYMLSmallStringO(self, 2); 41076 ck_assert_ptr_ne(r, null); 41077 s = toStringO(r); 41078 ck_assert_str_eq(s, "---\n \"\": empty\n \" \": blank\n"); 41079 free(s); 41080 terminateO(r); 41081 terminateO(self); 41082 41083 } 41084 41085 41086 void parseSmallJsonSmallJsonT(void) { 41087 41088 bool r; 41089 smallJsont *self = allocG(rtSmallJsont); 41090 smallJsont *input = allocSmallJson(); 41091 41092 // non json string 41093 r = self->f->parseSmallJson(self, input); 41094 ck_assert(!r); 41095 // json string 41096 setTopSO(input, "true"); 41097 r = self->f->parseSmallJson(self, input); 41098 ck_assert(r); 41099 terminateO(input); 41100 char *s = toStringO(self); 41101 ck_assert_str_eq(s, "true"); 41102 free(s); 41103 // non json object 41104 input = (smallJsont*) allocSmallInt(123); 41105 r = self->f->parseSmallJson(self, input); 41106 ck_assert(!r); 41107 terminateO(input); 41108 // null 41109 r = self->f->parseSmallJson(self, null); 41110 ck_assert(!r); 41111 terminateO(self); 41112 41113 } 41114 41115 41116 void parseSmallStringSmallJsonT(void) { 41117 41118 bool r; 41119 smallJsont *self = allocG(rtSmallJsont); 41120 smallStringt *input = allocSmallString("true"); 41121 41122 // string 41123 r = self->f->parseSmallString(self, input); 41124 ck_assert(r); 41125 terminateO(input); 41126 char *s = toStringO(self); 41127 ck_assert_str_eq(s, "true"); 41128 free(s); 41129 // non smallString object 41130 input = (smallStringt*) allocSmallInt(123); 41131 r = self->f->parseSmallString(self, input); 41132 ck_assert(!r); 41133 terminateO(input); 41134 // null 41135 r = self->f->parseSmallString(self, null); 41136 ck_assert(!r); 41137 terminateO(self); 41138 41139 } 41140 41141 41142 void parseYMLSmallJsonSmallJsonT(void) { 41143 41144 bool r; 41145 smallJsont *self = allocG(rtSmallJsont); 41146 smallJsont *input = allocSmallJson(); 41147 41148 // non json string 41149 r = self->f->parseYMLSmallJson(self, input); 41150 ck_assert(!r); 41151 // json string 41152 setTopSO(input, "---\n - qwe"); 41153 r = self->f->parseYMLSmallJson(self, input); 41154 ck_assert(r); 41155 terminateO(input); 41156 char *s = toStringO(self); 41157 ck_assert_str_eq(s, "[\"qwe\"]"); 41158 free(s); 41159 // non json object 41160 input = (smallJsont*) allocSmallInt(123); 41161 r = self->f->parseYMLSmallJson(self, input); 41162 ck_assert(!r); 41163 terminateO(input); 41164 // null 41165 r = self->f->parseYMLSmallJson(self, null); 41166 ck_assert(!r); 41167 terminateO(self); 41168 41169 } 41170 41171 41172 void parseYMLSmallStringSmallJsonT(void) { 41173 41174 bool r; 41175 smallJsont *self = allocG(rtSmallJsont); 41176 smallStringt *input = allocSmallString("---\n - qwe"); 41177 41178 // string 41179 r = self->f->parseYMLSmallString(self, input); 41180 ck_assert(r); 41181 terminateO(input); 41182 char *s = toStringO(self); 41183 ck_assert_str_eq(s, "[\"qwe\"]"); 41184 free(s); 41185 // non smallString object 41186 input = (smallStringt*) allocSmallInt(123); 41187 r = self->f->parseYMLSmallString(self, input); 41188 ck_assert(!r); 41189 terminateO(input); 41190 // null 41191 r = self->f->parseYMLSmallString(self, null); 41192 ck_assert(!r); 41193 terminateO(self); 41194 41195 } 41196 41197 41198 void logSmallJsonT(void) { 41199 41200 smallJsont *self = allocSmallJson(); 41201 41202 // only prints to stdout 41203 logO(self); 41204 terminateO(self); 41205 41206 } 41207 41208 41209 void readFileSmallJsonT(void) { 41210 41211 smallJsont *self = allocG(rtSmallJsont); 41212 41213 self->f->setS(self, "key", "value"); 41214 writeFileO(self, "read.JSON"); 41215 writeFileO(self, "read.YML"); 41216 writeFileO(self, "read.BIN"); 41217 // read files 41218 freeO(self); 41219 ck_assert_ptr_ne(readFileO(self, "read.JSON"), null); 41220 char *s = toStringO(self); 41221 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 41222 free(s); 41223 freeO(self); 41224 ck_assert_ptr_ne(readFileO(self, "read.YML"), null); 41225 s = toStringO(self); 41226 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 41227 free(s); 41228 freeO(self); 41229 ck_assert_ptr_ne(readFileO(self, "read.BIN"), null); 41230 s = toStringO(self); 41231 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 41232 free(s); 41233 freeO(self); 41234 rmAll("read.JSON"); 41235 rmAll("read.YML"); 41236 rmAll("read.BIN"); 41237 // non existing files 41238 ck_assert_ptr_eq(readFileO(self, "nonexisting.json"), null); 41239 ck_assert_ptr_eq(readFileO(self, "nonexisting.Yml"), null); 41240 ck_assert_ptr_eq(readFileO(self, "nonexisting.Bin"), null); 41241 // invalid extension, not json, yml or bin 41242 ck_assert_ptr_eq(readFileO(self, "libsheepyCSmallArray.h"), null); 41243 // null filename 41244 ck_assert_ptr_eq(readFileO(self, null), null); 41245 terminateO(self); 41246 41247 } 41248 41249 41250 void readFileSmallStringSmallJsonT(void) { 41251 41252 smallJsont *self = allocG(rtSmallJsont); 41253 smallStringt *filePath = allocSmallString("read.json"); 41254 41255 self->f->setS(self, "key", "value"); 41256 writeFileO(self, "read.json"); 41257 freeO(self); 41258 ck_assert_ptr_ne(self->f->readFileSmallString(self, filePath), null); 41259 char *s = toStringO(self); 41260 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 41261 free(s); 41262 freeO(self); 41263 rmAll("read.json"); 41264 // non smallString object 41265 terminateO(filePath); 41266 filePath = (smallStringt*) allocSmallInt(123); 41267 ck_assert_ptr_eq(self->f->readFileSmallString(self, filePath), null); 41268 terminateO(filePath); 41269 // null path 41270 ck_assert_ptr_eq(self->f->readFileSmallString(self, null), null); 41271 terminateO(self); 41272 41273 } 41274 41275 41276 void readFileJsonSmallJsonT(void) { 41277 41278 smallJsont *self = allocG(rtSmallJsont); 41279 smallJsont *filePath = allocSmallJson(); 41280 41281 setTopSO(filePath, "read.json"); 41282 self->f->setS(self, "key", "value"); 41283 writeFileO(self, "read.json"); 41284 freeO(self); 41285 ck_assert_ptr_ne(readFileJsonO(self, filePath), null); 41286 char *s = toStringO(self); 41287 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 41288 free(s); 41289 freeO(self); 41290 rmAll("read.json"); 41291 // non json string 41292 freeO(filePath); 41293 setTypeBoolO(filePath); 41294 ck_assert_ptr_eq(readFileJsonO(self, filePath), null); 41295 // non smallJson object 41296 terminateO(filePath); 41297 filePath = (smallJsont*) allocSmallInt(123); 41298 ck_assert_ptr_eq(readFileJsonO(self, filePath), null); 41299 terminateO(filePath); 41300 // null path 41301 ck_assert_ptr_eq(readFileJsonO(self, null), null); 41302 terminateO(self); 41303 41304 } 41305 41306 41307 void readStreamSmallJsonT(void) { 41308 41309 smallJsont* r; 41310 smallJsont *self = allocSmallJson(); 41311 FILE *fp; 41312 41313 // stream 41314 fp = fopen("file.json", "r"); 41315 r = readStreamO(self, fp); 41316 fclose(fp); 41317 ck_assert_ptr_ne(r, NULL); 41318 char *s = toStringO(r); 41319 ck_assert_str_eq(s, "{\"dasd\":\"asd\",\"asd\":234,\"dict\":{\"array\":[1,1],\"asd\":true,\"float\":3.434000e+01},\"bool\":false,\"zzz\":null}"); 41320 free(s); 41321 // empty stream, error because it is not valid json 41322 emptyO(self); 41323 fp = fopen("../chmodTest.null", "r"); 41324 r = readStreamO(self, fp); 41325 fclose(fp); 41326 ck_assert_ptr_eq(r, NULL); 41327 ck_assert(isEmptyO(self)); 41328 // NULL stream 41329 ck_assert_ptr_eq(readStreamO(self, NULL), NULL); 41330 terminateO(self); 41331 41332 } 41333 41334 41335 void writeFileSmallJsonT(void) { 41336 41337 bool r; 41338 smallJsont *self = allocSmallJson(); 41339 41340 self->f->setInt(self, "", 1); 41341 self->f->setInt(self, "b", 2); 41342 r = writeFileO(self, "smallDictFile.json"); 41343 ck_assert(r); 41344 ck_assert(fileExists("smallDictFile.json")); 41345 char *s = readFileToS("smallDictFile.json"); 41346 ck_assert_str_eq(s, "{\n \"\": 1,\n \"b\": 2\n}\n"); 41347 free(s); 41348 rmAll("smallDictFile.json"); 41349 r = writeFileO(self, "smallDictFile.yml"); 41350 ck_assert(r); 41351 ck_assert(fileExists("smallDictFile.yml")); 41352 freeO(self); 41353 ck_assert_ptr_ne(readFileO(self, "smallDictFile.yml"), null); 41354 s = toStringO(self); 41355 ck_assert_str_eq(s, "{\"\":1,\"b\":2}"); 41356 free(s); 41357 rmAll("smallDictFile.yml"); 41358 r = writeFileO(self, "smallDictFile.bin"); 41359 ck_assert(r); 41360 ck_assert(fileExists("smallDictFile.bin")); 41361 freeO(self); 41362 readFileO(self, "smallDictFile.bin"); 41363 s = toStringO(self); 41364 ck_assert_str_eq(s, "{\"\":1,\"b\":2}"); 41365 free(s); 41366 rmAll("smallDictFile.bin"); 41367 // write readonly path 41368 ck_assert(!writeFileO(self, "/readOnlyFileTest.bin")); 41369 // blank file path 41370 r = writeFileO(self, " "); 41371 ck_assert(!r); 41372 // null file path 41373 r = writeFileO(self, null); 41374 ck_assert(!r); 41375 terminateO(self); 41376 41377 } 41378 41379 41380 void writeFileSmallStringSmallJsonT(void) { 41381 41382 bool r; 41383 smallJsont *self = allocSmallJson(); 41384 smallStringt *filePath = allocSmallString("smallDictFile.json"); 41385 41386 self->f->setInt(self, "", 1); 41387 self->f->setInt(self, "b", 2); 41388 r = self->f->writeFileSmallString(self, filePath); 41389 ck_assert(r); 41390 ck_assert(fileExists("smallDictFile.json")); 41391 char *s = readFileToS("smallDictFile.json"); 41392 ck_assert_str_eq(s, "{\n \"\": 1,\n \"b\": 2\n}\n"); 41393 free(s); 41394 rmAll("smallDictFile.json"); 41395 // blank path 41396 setValO(filePath, " "); 41397 r = self->f->writeFileSmallString(self, filePath); 41398 ck_assert(!r); 41399 // non smallString object 41400 terminateO(filePath); 41401 filePath = (smallStringt*) allocSmallInt(2); 41402 r = self->f->writeFileSmallString(self, filePath); 41403 ck_assert(!r); 41404 // null path 41405 r = self->f->writeFileSmallString(self, null); 41406 ck_assert(!r); 41407 terminateO(filePath); 41408 terminateO(self); 41409 41410 } 41411 41412 41413 void writeFileJsonSmallJsonT(void) { 41414 41415 bool r; 41416 smallJsont *self = allocSmallJson(); 41417 smallJsont *filePath = allocSmallJson(); 41418 41419 self->f->setInt(self, "", 1); 41420 self->f->setInt(self, "b", 2); 41421 setTopSO(filePath, "smallDictFile.json"); 41422 r = self->f->writeFileJson(self, filePath); 41423 ck_assert(r); 41424 ck_assert(fileExists("smallDictFile.json")); 41425 char *s = readFileToS("smallDictFile.json"); 41426 ck_assert_str_eq(s, "{\n \"\": 1,\n \"b\": 2\n}\n"); 41427 free(s); 41428 rmAll("smallDictFile.json"); 41429 // blank path 41430 freeO(filePath); 41431 setTopSO(filePath, " "); 41432 r = self->f->writeFileJson(self, filePath); 41433 ck_assert(!r); 41434 // non json string 41435 freeO(filePath); 41436 setTopIntO(filePath, 2); 41437 r = self->f->writeFileJson(self, filePath); 41438 ck_assert(!r); 41439 // non json object 41440 terminateO(filePath); 41441 filePath = (smallJsont*) allocSmallInt(2); 41442 r = self->f->writeFileJson(self, filePath); 41443 ck_assert(!r); 41444 // null path 41445 r = self->f->writeFileJson(self, null); 41446 ck_assert(!r); 41447 terminateO(filePath); 41448 terminateO(self); 41449 41450 } 41451 41452 41453 void writeStreamSmallJsonT(void) { 41454 41455 bool r; 41456 smallJsont *self = allocSmallJson(); 41457 FILE *fp; 41458 41459 // write textOutTest.null 41460 fp = fopen("file.json", "r"); 41461 smallJsont *r2 = readStreamO(self, fp); 41462 fclose(fp); 41463 ck_assert_ptr_ne(r2, NULL); 41464 fp = fopen("outTest.json", "w"); 41465 r = writeStreamO(self, fp); 41466 ck_assert(r); 41467 fclose(fp); 41468 // check textOutTest.null 41469 fp = fopen("outTest.json", "r"); 41470 r2 = readStreamO(self, fp); 41471 fclose(fp); 41472 ck_assert_ptr_ne(r2, NULL); 41473 char *s = toStringO(r2); 41474 ck_assert_str_eq(s, "{\"dasd\":\"asd\",\"asd\":234,\"dict\":{\"array\":[1,1],\"asd\":true,\"float\":3.434000e+01},\"bool\":false,\"zzz\":null}"); 41475 free(s); 41476 // wrong stream: read instead of write 41477 fp = fopen("outTest.json", "r"); 41478 ck_assert(!writeStreamO(self, fp)); 41479 fclose(fp); 41480 // null stream 41481 ck_assert(!writeStreamO(self, null)); 41482 rmAll("outTest.json"); 41483 terminateO(self); 41484 41485 } 41486 41487 41488 void appendFileSmallJsonT(void) { 41489 41490 bool r; 41491 smallJsont *self = allocSmallJson(); 41492 41493 self->f->setInt(self, "", 1); 41494 self->f->setInt(self, "b", 2); 41495 // append json 41496 writeFileS("smallDictFile.json", "-"); 41497 r = appendFileO(self, "smallDictFile.json"); 41498 ck_assert(r); 41499 ck_assert(fileExists("smallDictFile.json")); 41500 char *s = readFileToS("smallDictFile.json"); 41501 ck_assert_str_eq(s, "-{\n \"\": 1,\n \"b\": 2\n}\n"); 41502 free(s); 41503 rmAll("smallDictFile.json"); 41504 // append yml 41505 writeFileS("smallDictFile.yml", "-"); 41506 r = appendFileO(self, "smallDictFile.yml"); 41507 ck_assert(r); 41508 ck_assert(fileExists("smallDictFile.yml")); 41509 s = readFileToS("smallDictFile.yml"); 41510 ck_assert_str_eq(s, "----\n \"\": 1\n b: 2\n"); 41511 free(s); 41512 rmAll("smallDictFile.yml"); 41513 // append json string 41514 writeFileS("smallDictFile", "-"); 41515 freeO(self); 41516 setTopSO(self, "qwe"); 41517 r = appendFileO(self, "smallDictFile"); 41518 ck_assert(r); 41519 ck_assert(fileExists("smallDictFile")); 41520 s = readFileToS("smallDictFile"); 41521 ck_assert_str_eq(s, "-qwe"); 41522 free(s); 41523 rmAll("smallDictFile"); 41524 // append json array 41525 writeFileS("smallDictFile", "-"); 41526 freeO(self); 41527 self->f->pushS(self, "qwe"); 41528 self->f->pushS(self, "asd"); 41529 r = appendFileO(self, "smallDictFile"); 41530 ck_assert(r); 41531 ck_assert(fileExists("smallDictFile")); 41532 s = readFileToS("smallDictFile"); 41533 ck_assert_str_eq(s, "-qwe\nasd\n"); 41534 free(s); 41535 rmAll("smallDictFile"); 41536 // read only path 41537 r = appendFileO(self, "/readOnlyAppend"); 41538 ck_assert(!r); 41539 // append json int should not work 41540 // blank file path 41541 r = appendFileO(self, " "); 41542 ck_assert(!r); 41543 // null file path 41544 r = appendFileO(self, null); 41545 ck_assert(!r); 41546 terminateO(self); 41547 41548 } 41549 41550 41551 void appendFileSmallStringSmallJsonT(void) { 41552 41553 bool r; 41554 smallJsont *self = allocSmallJson(); 41555 smallStringt *filePath = allocSmallString("smallDictFile.json"); 41556 41557 self->f->setInt(self, "", 1); 41558 self->f->setInt(self, "b", 2); 41559 writeFileS("smallDictFile.json", "-"); 41560 r = self->f->appendFileSmallString(self, filePath); 41561 ck_assert(r); 41562 ck_assert(fileExists("smallDictFile.json")); 41563 char *s = readFileToS("smallDictFile.json"); 41564 ck_assert_str_eq(s, "-{\n \"\": 1,\n \"b\": 2\n}\n"); 41565 free(s); 41566 rmAll("smallDictFile.json"); 41567 // blank path 41568 setValO(filePath, " "); 41569 r = self->f->appendFileSmallString(self, filePath); 41570 ck_assert(!r); 41571 // non smallString object 41572 terminateO(filePath); 41573 filePath = (smallStringt*) allocSmallInt(2); 41574 r = self->f->appendFileSmallString(self, filePath); 41575 ck_assert(!r); 41576 // null path 41577 r = self->f->appendFileSmallString(self, null); 41578 ck_assert(!r); 41579 terminateO(filePath); 41580 terminateO(self); 41581 41582 } 41583 41584 41585 void appendFileJsonSmallJsonT(void) { 41586 41587 int r; 41588 smallJsont *self = allocG(rtSmallJsont); 41589 smallJsont *filePath = allocSmallJson(); 41590 41591 setTopSO(filePath, "smallDictFile.json"); 41592 self->f->setInt(self, "", 1); 41593 self->f->setInt(self, "b", 2); 41594 writeFileS("smallDictFile.json", "-"); 41595 r = appendFileJsonO(self, filePath); 41596 ck_assert(r); 41597 ck_assert(fileExists("smallDictFile.json")); 41598 char *s = readFileToS("smallDictFile.json"); 41599 ck_assert_str_eq(s, "-{\n \"\": 1,\n \"b\": 2\n}\n"); 41600 free(s); 41601 rmAll("smallDictFile.json"); 41602 // blank path 41603 freeO(filePath); 41604 setTopSO(filePath, " "); 41605 r = appendFileJsonO(self, filePath); 41606 ck_assert(!r); 41607 // non smallJson object 41608 terminateO(filePath); 41609 filePath = (smallJsont*) allocSmallInt(2); 41610 r = appendFileJsonO(self, filePath); 41611 ck_assert(!r); 41612 // null path 41613 r = appendFileJsonO(self, null); 41614 ck_assert(!r); 41615 terminateO(filePath); 41616 terminateO(self); 41617 41618 } 41619 41620 41621 void readTextSmallJsonT(void) { 41622 41623 smallJsont* r; 41624 smallJsont *self = allocSmallJson(); 41625 41626 // text 41627 r = readTextO(self, "../textTest.null"); 41628 ck_assert_ptr_ne(r, NULL); 41629 char *s = toStringO(r); 41630 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41631 free(s); 41632 // non empty and non json array 41633 freeO(self); 41634 setTypeIntO(self); 41635 r = readTextO(self, "../textTest.null"); 41636 ck_assert_ptr_eq(r, NULL); 41637 // empty text 41638 setTypeArrayO(self); 41639 emptyO(self); 41640 r = readTextO(self, "../chmodTest.null"); 41641 ck_assert_ptr_ne(r, NULL); 41642 ck_assert(isEmptyO(self)); 41643 // NULL path 41644 r = readTextO(self, NULL); 41645 ck_assert_ptr_eq(r, NULL); 41646 // non existing path 41647 if (fileExists("../nonExistingFile")) 41648 rmAll("../nonExistingFile"); 41649 r = readTextO(self, "../nonExistingFile"); 41650 ck_assert_ptr_eq(r, NULL); 41651 terminateO(self); 41652 41653 } 41654 41655 41656 void readTextSmallStringSmallJsonT(void) { 41657 41658 smallJsont* r; 41659 smallJsont *self = allocSmallJson(); 41660 smallStringt *filePath = allocSmallString(""); 41661 41662 // text 41663 setValO(filePath, "../textTest.null"); 41664 r = readTextSmallStringO(self, filePath); 41665 ck_assert_ptr_ne(r, NULL); 41666 char *s = toStringO(r); 41667 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41668 free(s); 41669 // empty text 41670 emptyO(self); 41671 setValO(filePath, "../chmodTest.null"); 41672 r = readTextSmallStringO(self, filePath); 41673 ck_assert_ptr_ne(r, NULL); 41674 ck_assert(isEmptyO(self)); 41675 // NULL path 41676 r = readTextSmallStringO(self, NULL); 41677 ck_assert_ptr_eq(r, NULL); 41678 // non existing path 41679 if (fileExists("../nonExistingFile")) 41680 rmAll("../nonExistingFile"); 41681 setValO(filePath, "../nonExistingFile"); 41682 r = readTextSmallStringO(self, filePath); 41683 ck_assert_ptr_eq(r, NULL); 41684 // blank file path 41685 setValO(filePath, " "); 41686 r = readTextSmallStringO(self, filePath); 41687 ck_assert_ptr_eq(r, NULL); 41688 // non smallString object 41689 terminateO(filePath); 41690 filePath = (smallStringt*) allocSmallInt(2); 41691 r = readTextSmallStringO(self, filePath); 41692 ck_assert_ptr_eq(r, NULL); 41693 terminateO(self); 41694 terminateO(filePath); 41695 41696 } 41697 41698 41699 void readTextJsonSmallJsonT(void) { 41700 41701 smallJsont* r; 41702 smallJsont *self = allocG(rtSmallJsont); 41703 smallJsont *filePath = allocSmallJson(); 41704 41705 // text 41706 freeO(filePath); 41707 setTopSO(filePath, "../textTest.null"); 41708 r = readTextJsonO(self, filePath); 41709 ck_assert_ptr_ne(r, NULL); 41710 char *s = toStringO(r); 41711 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41712 free(s); 41713 // empty text 41714 emptyO(self); 41715 freeO(filePath); 41716 setTopSO(filePath, "../chmodTest.null"); 41717 r = readTextJsonO(self, filePath); 41718 ck_assert_ptr_ne(r, NULL); 41719 ck_assert(isEmptyO(self)); 41720 // NULL path 41721 r = readTextJsonO(self, NULL); 41722 ck_assert_ptr_eq(r, NULL); 41723 // non existing path 41724 if (fileExists("../nonExistingFile")) 41725 rmAll("../nonExistingFile"); 41726 freeO(filePath); 41727 setTopSO(filePath, "../nonExistingFile"); 41728 r = readTextJsonO(self, filePath); 41729 ck_assert_ptr_eq(r, NULL); 41730 // blank file path 41731 freeO(filePath); 41732 setTopSO(filePath, " "); 41733 r = readTextJsonO(self, filePath); 41734 ck_assert_ptr_eq(r, NULL); 41735 // non smallString object 41736 terminateO(filePath); 41737 filePath = (smallJsont*) allocSmallInt(2); 41738 r = readTextJsonO(self, filePath); 41739 ck_assert_ptr_eq(r, NULL); 41740 terminateO(self); 41741 terminateO(filePath); 41742 41743 } 41744 41745 41746 void readTextStreamSmallJsonT(void) { 41747 41748 smallJsont* r; 41749 smallJsont *self = allocG(rtSmallJsont); 41750 FILE *fp; 41751 41752 // stream 41753 fp = fopen("../textTest.null", "r"); 41754 r = self->f->readTextStream(self, fp); 41755 fclose(fp); 41756 ck_assert_ptr_ne(r, NULL); 41757 char *s = toStringO(r); 41758 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41759 free(s); 41760 // non empty and non json array 41761 freeO(self); 41762 setTypeIntO(self); 41763 fp = fopen("../chmodTest.null", "r"); 41764 ck_assert_ptr_eq(self->f->readTextStream(self, fp), NULL); 41765 // empty stream 41766 setTypeArrayO(self); 41767 r = self->f->readTextStream(self, fp); 41768 fclose(fp); 41769 ck_assert_ptr_ne(r, NULL); 41770 ck_assert(isEmptyO(self)); 41771 // NULL stream 41772 ck_assert_ptr_eq(self->f->readTextStream(self, NULL), NULL); 41773 terminateO(self); 41774 41775 } 41776 41777 41778 void writeTextSmallJsonT(void) { 41779 41780 bool r; 41781 smallJsont *self = allocSmallJson(); 41782 41783 // write textOutTest.null 41784 smallJsont *r2 = readTextO(self, "../textTest.null"); 41785 ck_assert_ptr_ne(r2, NULL); 41786 r = writeTextO(self, "../textOutTest.null"); 41787 ck_assert(r); 41788 // check textOutTest.null 41789 emptyO(self); 41790 r2 = readTextO(self, "../textOutTest.null"); 41791 ck_assert_ptr_ne(r2, NULL); 41792 char *s = toStringO(r2); 41793 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41794 free(s); 41795 // read only path 41796 r = writeTextO(self, "/readOnlyPath"); 41797 ck_assert(!r); 41798 // non empty and non json array 41799 freeO(self); 41800 setTypeIntO(self); 41801 r = writeTextO(self, "../textOutTest.null"); 41802 ck_assert(!r); 41803 // empty text 41804 setTypeArrayO(self); 41805 emptyO(self); 41806 r = writeTextO(self, "../textOutTest.null"); 41807 ck_assert(!r); 41808 r2 = readTextO(self, "../textOutTest.null"); 41809 ck_assert_ptr_ne(r2, NULL); 41810 s = toStringO(r2); 41811 ck_assert_str_eq(s, "[]"); 41812 free(s); 41813 // non existing file 41814 // make sure the file doesnt exist 41815 if (fileExists("../nonExistingFile")) 41816 rmAll("../nonExistingFile"); 41817 self->f->pushS(self, "qwe"); 41818 ck_assert(writeTextO(self, "../nonExistingFile")); 41819 if (fileExists("../nonExistingFile")) 41820 rmAll("../nonExistingFile"); 41821 // NULL path 41822 ck_assert(!writeTextO(self, NULL)); 41823 terminateO(self); 41824 41825 } 41826 41827 41828 void writeTextSmallStringSmallJsonT(void) { 41829 41830 bool r; 41831 smallJsont *self = allocSmallJson(); 41832 smallStringt *filePath = allocSmallString(""); 41833 41834 // write textOutTest.null 41835 smallJsont *r2 = readTextO(self, "../textTest.null"); 41836 ck_assert_ptr_ne(r2, NULL); 41837 setValO(filePath, "../textOutTest.null"); 41838 r = writeTextSmallStringO(self, filePath); 41839 ck_assert(r); 41840 // check textOutTest.null 41841 emptyO(self); 41842 r2 = readTextO(self, "../textOutTest.null"); 41843 ck_assert_ptr_ne(r2, NULL); 41844 char *s = toStringO(r2); 41845 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41846 free(s); 41847 // empty array 41848 emptyO(self); 41849 setValO(filePath, "../textOutTest.null"); 41850 r = writeTextSmallStringO(self, filePath); 41851 ck_assert(!r); 41852 r2 = readTextO(self, "../textOutTest.null"); 41853 ck_assert_ptr_ne(r2, NULL); 41854 s = toStringO(r2); 41855 ck_assert_str_eq(s, "[]"); 41856 free(s); 41857 // non existing file 41858 // make sure the file doesnt exist 41859 if (fileExists("../nonExistingFile")) 41860 rmAll("../nonExistingFile"); 41861 self->f->pushS(self, "qwe"); 41862 setValO(filePath, "../nonExistingFile"); 41863 ck_assert(writeTextSmallStringO(self, filePath)); 41864 if (fileExists("../nonExistingFile")) 41865 rmAll("../nonExistingFile"); 41866 // non smallJson object 41867 terminateO(filePath); 41868 filePath = (smallStringt*) allocSmallInt(2); 41869 r = writeTextSmallStringO(self, filePath); 41870 ck_assert(!r); 41871 // NULL path 41872 ck_assert(!writeTextSmallStringO(self, NULL)); 41873 terminateO(self); 41874 terminateO(filePath); 41875 41876 } 41877 41878 41879 void writeTextJsonSmallJsonT(void) { 41880 41881 bool r; 41882 smallJsont *self = allocG(rtSmallJsont); 41883 smallJsont *filePath = allocSmallJson(); 41884 41885 // write textOutTest.null 41886 smallJsont *r2 = readTextO(self, "../textTest.null"); 41887 ck_assert_ptr_ne(r2, NULL); 41888 freeO(filePath); 41889 setTopSO(filePath, "../textOutTest.null"); 41890 r = writeTextJsonO(self, filePath); 41891 ck_assert(r); 41892 // check textOutTest.null 41893 emptyO(self); 41894 r2 = readTextO(self, "../textOutTest.null"); 41895 ck_assert_ptr_ne(r2, NULL); 41896 char *s = toStringO(r2); 41897 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41898 free(s); 41899 // empty array 41900 emptyO(self); 41901 freeO(filePath); 41902 setTopSO(filePath, "../textOutTest.null"); 41903 r = writeTextJsonO(self, filePath); 41904 ck_assert(!r); 41905 r2 = readTextO(self, "../textOutTest.null"); 41906 ck_assert_ptr_ne(r2, NULL); 41907 s = toStringO(r2); 41908 ck_assert_str_eq(s, "[]"); 41909 free(s); 41910 // non existing file 41911 // make sure the file doesnt exist 41912 if (fileExists("../nonExistingFile")) 41913 rmAll("../nonExistingFile"); 41914 self->f->pushS(self, "qwe"); 41915 freeO(filePath); 41916 setTopSO(filePath, "../nonExistingFile"); 41917 ck_assert(writeTextJsonO(self, filePath)); 41918 if (fileExists("../nonExistingFile")) 41919 rmAll("../nonExistingFile"); 41920 // non smallJson object 41921 terminateO(filePath); 41922 filePath = (smallJsont*) allocSmallInt(2); 41923 r = writeTextJsonO(self, filePath); 41924 ck_assert(!r); 41925 // NULL path 41926 ck_assert(!writeTextJsonO(self, NULL)); 41927 rmAll("../textOutTest.null"); 41928 terminateO(self); 41929 terminateO(filePath); 41930 41931 } 41932 41933 41934 void writeTextStreamSmallJsonT(void) { 41935 41936 bool r; 41937 smallJsont *self = allocG(rtSmallJsont); 41938 FILE *fp; 41939 41940 // non json array 41941 fp = fopen("../textTest.null", "r"); 41942 r = self->f->writeTextStream(self, fp); 41943 ck_assert(!r); 41944 // write textOutTest.null 41945 smallJsont *r2 = self->f->readTextStream(self, fp); 41946 fclose(fp); 41947 ck_assert_ptr_ne(r2, NULL); 41948 fp = fopen("../textOutTest.null", "w"); 41949 r = self->f->writeTextStream(self, fp); 41950 ck_assert(r); 41951 // empty array 41952 emptyO(self); 41953 ck_assert(!self->f->writeTextStream(self, fp)); 41954 fclose(fp); 41955 // check textOutTest.null 41956 fp = fopen("../textOutTest.null", "r"); 41957 r2 = self->f->readTextStream(self, fp); 41958 fclose(fp); 41959 ck_assert_ptr_ne(r2, NULL); 41960 char *s = toStringO(r2); 41961 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 41962 free(s); 41963 terminateO(self); 41964 41965 } 41966 41967 41968 void appendTextSmallJsonT(void) { 41969 41970 bool r; 41971 smallJsont *self = allocSmallJson(); 41972 41973 // append to textOutTest.null 41974 smallJsont *r2 = readTextO(self, "../textTest.null"); 41975 ck_assert_ptr_ne(r2, NULL); 41976 r = writeTextO(self, "../textOutTest.null"); 41977 ck_assert(r); 41978 emptyO(self); 41979 self->f->pushS(self, "A"); 41980 self->f->pushS(self, "B"); 41981 r = appendTextO(self, "../textOutTest.null"); 41982 // check textOutTest.null 41983 emptyO(self); 41984 r2 = readTextO(self, "../textOutTest.null"); 41985 ck_assert_ptr_ne(r2, NULL); 41986 char *s = toStringO(r2); 41987 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 41988 free(s); 41989 // non existing file 41990 // make sure the file doesnt exist 41991 if (fileExists("../nonExistingFile")) 41992 rmAll("../nonExistingFile"); 41993 ck_assert(appendTextO(self, "../nonExistingFile")); 41994 if (fileExists("../nonExistingFile")) 41995 rmAll("../nonExistingFile"); 41996 // empty array 41997 emptyO(self); 41998 r = appendTextO(self, "../textOutTest.null"); 41999 ck_assert(!r); 42000 // check textOutTest.null 42001 emptyO(self); 42002 r2 = readTextO(self, "../textOutTest.null"); 42003 ck_assert_ptr_ne(r2, NULL); 42004 s = toStringO(r2); 42005 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 42006 free(s); 42007 // blank path 42008 ck_assert(!appendTextO(self, " ")); 42009 // NULL path 42010 ck_assert(!appendTextO(self, NULL)); 42011 // non empty json and non json array 42012 freeO(self); 42013 setTypeBoolO(self); 42014 ck_assert(!appendTextO(self, "appendTest.txt")); 42015 terminateO(self); 42016 42017 } 42018 42019 42020 void appendTextSmallStringSmallJsonT(void) { 42021 42022 bool r; 42023 smallJsont *self = allocSmallJson(); 42024 smallStringt *filePath = allocSmallString(""); 42025 42026 // append to textOutTest.null 42027 smallJsont *r2 = readTextO(self, "../textTest.null"); 42028 ck_assert_ptr_ne(r2, NULL); 42029 r = writeTextO(self, "../textOutTest.null"); 42030 ck_assert(r); 42031 emptyO(self); 42032 self->f->pushS(self, "A"); 42033 self->f->pushS(self, "B"); 42034 setValO(filePath, "../textOutTest.null"); 42035 r = appendTextSmallStringO(self, filePath); 42036 // check textOutTest.null 42037 emptyO(self); 42038 r2 = readTextO(self, "../textOutTest.null"); 42039 ck_assert_ptr_ne(r2, NULL); 42040 char *s = toStringO(r2); 42041 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 42042 free(s); 42043 // non existing file 42044 // make sure the file doesnt exist 42045 if (fileExists("../nonExistingFile")) 42046 rmAll("../nonExistingFile"); 42047 setValO(filePath, "../nonExistingFile"); 42048 ck_assert(appendTextSmallStringO(self, filePath)); 42049 if (fileExists("../nonExistingFile")) 42050 rmAll("../nonExistingFile"); 42051 // empty array 42052 emptyO(self); 42053 r = appendTextSmallStringO(self, filePath); 42054 ck_assert(!r); 42055 // check textOutTest.null 42056 emptyO(self); 42057 r2 = readTextO(self, "../textOutTest.null"); 42058 ck_assert_ptr_ne(r2, NULL); 42059 s = toStringO(r2); 42060 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 42061 free(s); 42062 // blank path 42063 setValO(filePath, " "); 42064 ck_assert(!appendTextSmallStringO(self, filePath)); 42065 // non smallString object 42066 terminateO(filePath); 42067 filePath = (smallStringt*) allocSmallInt(2); 42068 r = appendTextSmallStringO(self, filePath); 42069 ck_assert(!r); 42070 // NULL path 42071 ck_assert(!appendTextSmallStringO(self, NULL)); 42072 terminateO(self); 42073 terminateO(filePath); 42074 42075 } 42076 42077 42078 void appendTextJsonSmallJsonT(void) { 42079 42080 bool r; 42081 smallJsont *self = allocG(rtSmallJsont); 42082 smallJsont *filePath = allocSmallJson(); 42083 42084 // append to textOutTest.null 42085 smallJsont *r2 = readTextO(self, "../textTest.null"); 42086 ck_assert_ptr_ne(r2, NULL); 42087 r = writeTextO(self, "../textOutTest.null"); 42088 ck_assert(r); 42089 emptyO(self); 42090 self->f->pushS(self, "A"); 42091 self->f->pushS(self, "B"); 42092 freeO(filePath); 42093 setTopSO(filePath, "../textOutTest.null"); 42094 r = appendTextJsonO(self, filePath); 42095 // check textOutTest.null 42096 emptyO(self); 42097 r2 = readTextO(self, "../textOutTest.null"); 42098 ck_assert_ptr_ne(r2, NULL); 42099 char *s = toStringO(r2); 42100 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 42101 free(s); 42102 // non existing file 42103 // make sure the file doesnt exist 42104 if (fileExists("../nonExistingFile")) 42105 rmAll("../nonExistingFile"); 42106 freeO(filePath); 42107 setTopSO(filePath, "../nonExistingFile"); 42108 ck_assert(appendTextJsonO(self, filePath)); 42109 if (fileExists("../nonExistingFile")) 42110 rmAll("../nonExistingFile"); 42111 // empty array 42112 emptyO(self); 42113 r = appendTextJsonO(self, filePath); 42114 ck_assert(!r); 42115 // check textOutTest.null 42116 emptyO(self); 42117 r2 = readTextO(self, "../textOutTest.null"); 42118 ck_assert_ptr_ne(r2, NULL); 42119 s = toStringO(r2); 42120 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 42121 free(s); 42122 // blank path 42123 freeO(filePath); 42124 setTopSO(filePath, " "); 42125 ck_assert(!appendTextJsonO(self, filePath)); 42126 // non smallString object 42127 terminateO(filePath); 42128 filePath = (smallJsont*) allocSmallInt(2); 42129 r = appendTextJsonO(self, filePath); 42130 ck_assert(!r); 42131 // NULL path 42132 ck_assert(!appendTextJsonO(self, NULL)); 42133 terminateO(self); 42134 terminateO(filePath); 42135 42136 } 42137 42138 42139 void typeStringSmallJsonT(void) { 42140 42141 const char* r; 42142 smallJsont *self = allocG(rtSmallJsont); 42143 42144 self->f->setBool(self, "lib", true); 42145 r = typeStringO(self, "lib"); 42146 ck_assert_ptr_ne(r, null); 42147 ck_assert_str_eq(r, "bool"); 42148 // path 42149 baset *value = (baset*) allocSmallInt(2); 42150 createSmallArray(a); 42151 createSmallDict(d); 42152 a.f->pushDict(&a, &d); 42153 self->f->setArray(self, "array", &a); 42154 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 42155 ck_assert_ptr_ne(r2, null); 42156 finishO(value); 42157 r = typeStringO(self, "\"array\"[0].\"key\""); 42158 ck_assert_ptr_ne(r, null); 42159 ck_assert_str_eq(r, "int"); 42160 // json bool 42161 freeO(self); 42162 setTypeBoolO(self); 42163 r = typeStringO(self, "1"); 42164 ck_assert_ptr_eq(r, null); 42165 // json array 42166 freeO(self); 42167 setTypeArrayO(self); 42168 r = typeStringO(self, "1"); 42169 ck_assert_ptr_eq(r, null); 42170 // non existing dict path 42171 freeO(self); 42172 r = typeStringO(self, "\"1\"[1]"); 42173 ck_assert_ptr_eq(r, null); 42174 // dict path but the object is an array 42175 resetO(&a); 42176 self->f->setArray(self, "1", &a); 42177 r = typeStringO(self, "\"1\".\"1\""); 42178 ck_assert_ptr_eq(r, null); 42179 // dict object in path but the key doesn't exists 42180 resetO(&d); 42181 self->f->setDict(self, "2", &d); 42182 r = typeStringO(self, "\"2\".\"1\".[12]"); 42183 ck_assert_ptr_eq(r, null); 42184 // non existing element 42185 r = typeStringO(self, "randomKey"); 42186 ck_assert_ptr_eq(r, null); 42187 // null key 42188 r = typeStringO(self, null); 42189 ck_assert_ptr_eq(r, null); 42190 terminateO(self); 42191 42192 } 42193 42194 42195 void typeSmallStringSmallJsonT(void) { 42196 42197 smallStringt* r; 42198 smallJsont *self = allocSmallJson(); 42199 42200 self->f->setInt(self, "", 1); 42201 self->f->setInt(self, "b", 2); 42202 r = typeSmallStringO(self, ""); 42203 ck_assert_str_eq(ssGet(r), "int"); 42204 terminateO(r); 42205 // non existing key 42206 r = typeSmallStringO(self, "asd"); 42207 ck_assert_ptr_eq(r, null); 42208 terminateO(self); 42209 42210 } 42211 42212 42213 void typeAtStringSmallJsonT(void) { 42214 42215 const char* r; 42216 smallJsont *self = allocG(rtSmallJsont); 42217 42218 // empty self 42219 r = typeAtStringO(self, 0); 42220 ck_assert_str_eq(r, "not a sheepy object"); 42221 terminateO(self); 42222 42223 } 42224 42225 42226 void typeAtSmallStringSmallJsonT(void) { 42227 42228 smallStringt* r; 42229 smallJsont *self = allocSmallJson(); 42230 42231 // empty array 42232 r = typeAtSmallStringO(self, 0); 42233 ck_assert_ptr_ne(r, NULL); 42234 char *s = toStringO(r); 42235 ck_assert_str_eq(s, "not a sheepy object"); 42236 free(s); 42237 terminateO(self); 42238 terminateO(r); 42239 42240 } 42241 42242 42243 void typeStringKCharSmallJsonT(void) { 42244 42245 const char* r; 42246 smallJsont *self = allocSmallJson(); 42247 42248 self->f->setInt(self, "", 1); 42249 self->f->setInt(self, "b", 2); 42250 r = typeStringKCharO(self, 'b'); 42251 ck_assert_str_eq(r, "int"); 42252 terminateO(self); 42253 42254 } 42255 42256 42257 void typeSmallStringKCharSmallJsonT(void) { 42258 42259 smallStringt* r; 42260 smallJsont *self = allocSmallJson(); 42261 42262 self->f->setInt(self, "", 1); 42263 self->f->setInt(self, "b", 2); 42264 r = typeSmallStringKCharO(self, 'b'); 42265 ck_assert_str_eq(ssGet(r), "int"); 42266 terminateO(r); 42267 // non existing key 42268 r = typeSmallStringKCharO(self, 'a'); 42269 ck_assert_ptr_eq(r, null); 42270 terminateO(self); 42271 42272 } 42273 42274 42275 void typeSmallJsonT(void) { 42276 42277 char r; 42278 smallJsont *self = allocG(rtSmallJsont); 42279 42280 self->f->setBool(self, "lib", true); 42281 r = typeO(self, "lib"); 42282 ck_assert_int_eq(r, 2); 42283 // path 42284 baset *value = (baset*) allocSmallInt(2); 42285 createSmallArray(a); 42286 createSmallDict(d); 42287 a.f->pushDict(&a, &d); 42288 self->f->setArray(self, "array", &a); 42289 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 42290 ck_assert_ptr_ne(r2, null); 42291 finishO(value); 42292 r = typeO(self, "\"array\"[0].\"key\""); 42293 ck_assert_int_eq(r, 7); 42294 // json bool 42295 freeO(self); 42296 setTypeBoolO(self); 42297 r = typeO(self, "1"); 42298 ck_assert(!r); 42299 // json array 42300 freeO(self); 42301 setTypeArrayO(self); 42302 r = typeO(self, "1"); 42303 ck_assert(!r); 42304 // non existing dict path 42305 freeO(self); 42306 r = typeO(self, "\"1\"[1]"); 42307 ck_assert(!r); 42308 // dict path but the object is an array 42309 resetO(&a); 42310 self->f->setArray(self, "1", &a); 42311 r = typeO(self, "\"1\".\"1\""); 42312 ck_assert(!r); 42313 // dict object in path but the key doesn't exists 42314 resetO(&d); 42315 self->f->setDict(self, "2", &d); 42316 r = typeO(self, "\"2\".\"1\".[12]"); 42317 ck_assert(!r); 42318 // non existing element 42319 r = typeO(self, "randomKey"); 42320 ck_assert(!r); 42321 // null key 42322 r = typeO(self, null); 42323 ck_assert(!r); 42324 terminateO(self); 42325 42326 } 42327 42328 42329 void typeKCharSmallJsonT(void) { 42330 42331 char r; 42332 smallJsont *self = allocSmallJson(); 42333 42334 self->f->setInt(self, "", 1); 42335 self->f->setInt(self, "b", 2); 42336 r = typeKCharO(self, 'b'); 42337 ck_assert_int_eq(r, 7); 42338 terminateO(self); 42339 42340 } 42341 42342 42343 void typeAtSmallJsonT(void) { 42344 42345 smallJsont *self = allocG(rtSmallJsont); 42346 42347 // non json array 42348 ck_assert_int_eq(typeAtO(self, 0), 0); 42349 // empty json array 42350 setTypeArrayO(self); 42351 ck_assert_int_eq(typeAtO(self, 0), 0); 42352 // type 42353 self->f->pushInt(self, 1); 42354 ck_assert_int_eq(typeAtO(self, 0), 7); 42355 // outside 42356 ck_assert_int_eq(typeAtO(self, 1), 0); 42357 ck_assert_int_eq(typeAtO(self, -2), 0); 42358 terminateO(self); 42359 42360 } 42361 42362 42363 void typeStringsSmallJsonT(void) { 42364 42365 smallJsont* r; 42366 smallJsont *self = allocG(rtSmallJsont); 42367 42368 // non json array or dict 42369 setTypeBoolO(self); 42370 r = typeStringsO(self); 42371 ck_assert_ptr_eq(r, null); 42372 // json dict 42373 freeO(self); 42374 self->f->setUndefined(self, "u"); 42375 self->f->setS(self, "s", "s"); 42376 self->f->setInt(self, "i", 123); 42377 r = typeStringsO(self); 42378 ck_assert_ptr_ne(r, null); 42379 char *s = toStringO(r); 42380 ck_assert_str_eq(s, "{\"u\":\"undefined\",\"s\":\"string\",\"i\":\"int\"}"); 42381 free(s); 42382 terminateO(r); 42383 // json array 42384 freeO(self); 42385 self->f->pushUndefined(self); 42386 self->f->pushS(self,"qwe"); 42387 self->f->pushInt(self,123); 42388 r = typeStringsO(self); 42389 ck_assert_ptr_ne(r, null); 42390 s = toStringO(r); 42391 ck_assert_str_eq(s, "[\"undefined\",\"string\",\"int\"]"); 42392 free(s); 42393 terminateO(r); 42394 terminateO(self); 42395 42396 } 42397 42398 42399 void typesSmallJsonT(void) { 42400 42401 smallBytest* r; 42402 smallJsont *self = allocG(rtSmallJsont); 42403 42404 // non json array 42405 r = typesO(self); 42406 ck_assert_ptr_eq(r, null); 42407 // empty json array 42408 setTypeArrayO(self); 42409 r = typesO(self); 42410 ck_assert_ptr_eq(r, null); 42411 // json array with elements 42412 self->f->pushUndefined(self); 42413 self->f->pushS(self,"qwe"); 42414 self->f->pushInt(self,123); 42415 r = typesO(self); 42416 ck_assert_ptr_ne(r, null); 42417 char *s = toStringO(r); 42418 ck_assert_str_eq(s, "[0x01,0x08,0x07]"); 42419 free(s); 42420 terminateO(r); 42421 terminateO(self); 42422 42423 } 42424 42425 42426 void isETypeAtSmallJsonT(void) { 42427 42428 bool r; 42429 smallJsont *self = allocSmallJson(); 42430 42431 // non json array 42432 r = isETypeAtO(self, 0, "undefined"); 42433 ck_assert(!r); 42434 // json array 42435 self->f->pushUndefined(self); 42436 r = isETypeAtO(self, 0, "undefined"); 42437 ck_assert(r); 42438 // NULL type 42439 emptyO(self); 42440 r = isETypeAtO(self, 0, NULL); 42441 ck_assert(!r); 42442 terminateO(self); 42443 42444 } 42445 42446 42447 void isEUndefinedAtSmallJsonT(void) { 42448 42449 bool r; 42450 smallJsont *self = allocSmallJson(); 42451 42452 // non json array 42453 r = isEUndefinedAtO(self, 0); 42454 ck_assert(!r); 42455 // array 42456 self->f->pushUndefined(self); 42457 self->f->pushS(self, ""); 42458 r = isEUndefinedAtO(self, 0); 42459 ck_assert(r); 42460 r = isEUndefinedAtO(self, -1); 42461 ck_assert(!r); 42462 terminateO(self); 42463 42464 } 42465 42466 42467 void isEBoolAtSmallJsonT(void) { 42468 42469 bool r; 42470 smallJsont *self = allocSmallJson(); 42471 42472 // non json array 42473 r = isEBoolAtO(self, 0); 42474 ck_assert(!r); 42475 // array 42476 self->f->pushBool(self, true); 42477 self->f->pushS(self, ""); 42478 r = isEBoolAtO(self, 0); 42479 ck_assert(r); 42480 r = isEBoolAtO(self, -1); 42481 ck_assert(!r); 42482 terminateO(self); 42483 42484 } 42485 42486 42487 void isEContainerAtSmallJsonT(void) { 42488 42489 bool r; 42490 smallJsont *self = allocSmallJson(); 42491 42492 // non json array 42493 r = isEContainerAtO(self, 0); 42494 ck_assert(!r); 42495 // array 42496 createSmallContainer(c); 42497 self->f->pushSmallContainer(self, &c); 42498 self->f->pushS(self, ""); 42499 r = isEContainerAtO(self, 0); 42500 ck_assert(r); 42501 r = isEContainerAtO(self, -1); 42502 ck_assert(!r); 42503 terminateO(self); 42504 42505 } 42506 42507 42508 void isEDictAtSmallJsonT(void) { 42509 42510 bool r; 42511 smallJsont *self = allocSmallJson(); 42512 42513 // non json array 42514 r = isEDictAtO(self, 0); 42515 ck_assert(!r); 42516 // array 42517 createSmallDict(d); 42518 self->f->pushDict(self, &d); 42519 self->f->pushS(self, ""); 42520 r = isEDictAtO(self, 0); 42521 ck_assert(r); 42522 r = isEDictAtO(self, -1); 42523 ck_assert(!r); 42524 terminateO(self); 42525 42526 } 42527 42528 42529 void isEDoubleAtSmallJsonT(void) { 42530 42531 bool r; 42532 smallJsont *self = allocSmallJson(); 42533 42534 // non json array 42535 r = isEDoubleAtO(self, 0); 42536 ck_assert(!r); 42537 // array 42538 self->f->pushDouble(self, 1); 42539 self->f->pushS(self, ""); 42540 r = isEDoubleAtO(self, 0); 42541 ck_assert(r); 42542 r = isEDoubleAtO(self, -1); 42543 ck_assert(!r); 42544 terminateO(self); 42545 42546 } 42547 42548 42549 void isEIntAtSmallJsonT(void) { 42550 42551 bool r; 42552 smallJsont *self = allocSmallJson(); 42553 42554 // non json array 42555 r = isEIntAtO(self, 0); 42556 ck_assert(!r); 42557 // array 42558 self->f->pushInt(self, 1); 42559 self->f->pushS(self, ""); 42560 r = isEIntAtO(self, 0); 42561 ck_assert(r); 42562 r = isEIntAtO(self, -1); 42563 ck_assert(!r); 42564 terminateO(self); 42565 42566 } 42567 42568 42569 void isEStringAtSmallJsonT(void) { 42570 42571 bool r; 42572 smallJsont *self = allocSmallJson(); 42573 42574 // non json array 42575 r = isEStringAtO(self, 0); 42576 ck_assert(!r); 42577 // array 42578 self->f->pushUndefined(self); 42579 self->f->pushS(self, ""); 42580 r = isEStringAtO(self, -1); 42581 ck_assert(r); 42582 r = isEStringAtO(self, 0); 42583 ck_assert(!r); 42584 terminateO(self); 42585 42586 } 42587 42588 42589 void isEFaststringAtSmallJsonT(void) { 42590 42591 bool r; 42592 smallJsont *self = allocG(rtSmallJsont); 42593 42594 // non json array 42595 r = isEFaststringAtO(self, 0); 42596 ck_assert(!r); 42597 // array 42598 self->f->pushUndefined(self); 42599 self->f->pushS(self, ""); 42600 r = isEFaststringAtO(self, -1); 42601 ck_assert(!r); 42602 r = isEFaststringAtO(self, 0); 42603 ck_assert(!r); 42604 terminateO(self); 42605 42606 } 42607 42608 42609 void isEArrayAtSmallJsonT(void) { 42610 42611 bool r; 42612 smallJsont *self = allocSmallJson(); 42613 42614 // non json array 42615 r = isEArrayAtO(self, 0); 42616 ck_assert(!r); 42617 // array 42618 createSmallArray(a); 42619 self->f->pushArray(self, &a); 42620 self->f->pushS(self, ""); 42621 r = isEArrayAtO(self, 0); 42622 ck_assert(r); 42623 r = isEArrayAtO(self, -1); 42624 ck_assert(!r); 42625 terminateO(self); 42626 42627 } 42628 42629 42630 void isEBytesAtSmallJsonT(void) { 42631 42632 bool r; 42633 smallJsont *self = allocSmallJson(); 42634 42635 // non json array 42636 r = isEBytesAtO(self, 0); 42637 ck_assert(!r); 42638 // array 42639 createSmallBytes(b); 42640 self->f->pushSmallBytes(self, &b); 42641 self->f->pushS(self, ""); 42642 r = isEBytesAtO(self, 0); 42643 ck_assert(r); 42644 r = isEBytesAtO(self, -1); 42645 ck_assert(!r); 42646 terminateO(self); 42647 42648 } 42649 42650 42651 void isETypeSmallJsonT(void) { 42652 42653 bool r; 42654 smallJsont *self = allocSmallJson(); 42655 42656 self->f->setInt(self, "", 1); 42657 r = isETypeO(self, "", "int"); 42658 ck_assert(r); 42659 // path 42660 baset *value = (baset*) allocSmallInt(2); 42661 createSmallArray(a); 42662 createSmallDict(d); 42663 a.f->pushDict(&a, &d); 42664 self->f->setArray(self, "array", &a); 42665 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 42666 ck_assert_ptr_ne(r2, null); 42667 finishO(value); 42668 r = isETypeO(self, "\"array\"[0].\"key\"", "int"); 42669 ck_assert(r); 42670 r = isETypeO(self, "\"array\"[0].\"key\"", "bool"); 42671 ck_assert(!r); 42672 // json bool 42673 freeO(self); 42674 setTypeBoolO(self); 42675 r = isETypeO(self, "1", "bool"); 42676 ck_assert(!r); 42677 // json array 42678 freeO(self); 42679 setTypeArrayO(self); 42680 r = isETypeO(self, "1", "array"); 42681 ck_assert(!r); 42682 // non existing dict path 42683 freeO(self); 42684 r = isETypeO(self, "\"1\"[1]", "int"); 42685 ck_assert(!r); 42686 // dict path but the object is an array 42687 resetO(&a); 42688 self->f->setArray(self, "1", &a); 42689 r = isETypeO(self, "\"1\".\"1\"", "int"); 42690 ck_assert(!r); 42691 // dict object in path but the key doesn't exists 42692 resetO(&d); 42693 self->f->setDict(self, "2", &d); 42694 r = isETypeO(self, "\"2\".\"1\".[12]", "int"); 42695 ck_assert(!r); 42696 // non existing element 42697 r = isETypeO(self, "randomKey", "int"); 42698 ck_assert(!r); 42699 // null type 42700 r = isETypeO(self, "", null); 42701 ck_assert(!r); 42702 // null key 42703 r = isETypeO(self, null, "int"); 42704 ck_assert(!r); 42705 // empty dict 42706 freeO(self); 42707 r = isETypeO(self, "", "int"); 42708 ck_assert(!r); 42709 terminateO(self); 42710 42711 } 42712 42713 42714 void isEUndefinedSmallJsonT(void) { 42715 42716 bool r; 42717 smallJsont *self = allocSmallJson(); 42718 42719 self->f->setInt(self, "", 1); 42720 self->f->setUndefined(self, "b"); 42721 r = isEUndefinedO(self, "b"); 42722 ck_assert(r); 42723 r = isEUndefinedO(self, ""); 42724 ck_assert(!r); 42725 // path 42726 createSmallArray(a); 42727 createSmallDict(d); 42728 a.f->pushDict(&a, &d); 42729 self->f->setArray(self, "array", &a); 42730 smallJsont *r2 = self->f->setUndefined(self, "\"array\"[0].\"key\""); 42731 r2 = self->f->setS(self, "\"array\"[0].\"s\"", "asd"); 42732 ck_assert_ptr_ne(r2, null); 42733 r = isEUndefinedO(self, "\"array\"[0].\"key\""); 42734 ck_assert(r); 42735 r = isEUndefinedO(self, "\"array\"[0].\"s\""); 42736 ck_assert(!r); 42737 // json bool 42738 freeO(self); 42739 setTypeBoolO(self); 42740 r = isEUndefinedO(self, "1"); 42741 ck_assert(!r); 42742 // json array 42743 freeO(self); 42744 setTypeArrayO(self); 42745 r = isEUndefinedO(self, "1"); 42746 ck_assert(!r); 42747 // non existing dict path 42748 freeO(self); 42749 r = isEUndefinedO(self, "\"1\"[1]"); 42750 ck_assert(!r); 42751 // dict path but the object is an array 42752 resetO(&a); 42753 self->f->setArray(self, "1", &a); 42754 r = isEUndefinedO(self, "\"1\".\"1\""); 42755 ck_assert(!r); 42756 // dict object in path but the key doesn't exists 42757 resetO(&d); 42758 self->f->setDict(self, "2", &d); 42759 r = isEUndefinedO(self, "\"2\".\"1\".[12]"); 42760 ck_assert(!r); 42761 // non existing key 42762 r = isEUndefinedO(self, "qwe"); 42763 ck_assert(!r); 42764 // empty dict 42765 freeO(self); 42766 r = isEUndefinedO(self, ""); 42767 ck_assert(!r); 42768 terminateO(self); 42769 42770 } 42771 42772 42773 void isEBoolSmallJsonT(void) { 42774 42775 bool r; 42776 smallJsont *self = allocSmallJson(); 42777 42778 self->f->setInt(self, "", 1); 42779 self->f->setBool(self, "b", true); 42780 r = isEBoolO(self, "b"); 42781 ck_assert(r); 42782 r = isEBoolO(self, ""); 42783 ck_assert(!r); 42784 // path 42785 baset *value = (baset*) allocSmallBool(true); 42786 createSmallArray(a); 42787 createSmallDict(d); 42788 a.f->pushDict(&a, &d); 42789 self->f->setArray(self, "array", &a); 42790 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 42791 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 42792 ck_assert_ptr_ne(r2, null); 42793 finishO(value); 42794 r = isEBoolO(self, "\"array\"[0].\"key\""); 42795 ck_assert(r); 42796 r = isEBoolO(self, "\"array\"[0].\"s\""); 42797 ck_assert(!r); 42798 // json bool 42799 freeO(self); 42800 setTypeBoolO(self); 42801 r = isEBoolO(self, "1"); 42802 ck_assert(!r); 42803 // json array 42804 freeO(self); 42805 setTypeArrayO(self); 42806 r = isEBoolO(self, "1"); 42807 ck_assert(!r); 42808 // non existing dict path 42809 freeO(self); 42810 r = isEBoolO(self, "\"1\"[1]"); 42811 ck_assert(!r); 42812 // dict path but the object is an array 42813 resetO(&a); 42814 self->f->setArray(self, "1", &a); 42815 r = isEBoolO(self, "\"1\".\"1\""); 42816 ck_assert(!r); 42817 // dict object in path but the key doesn't exists 42818 resetO(&d); 42819 self->f->setDict(self, "2", &d); 42820 r = isEBoolO(self, "\"2\".\"1\".[12]"); 42821 ck_assert(!r); 42822 // non existing key 42823 r = isEBoolO(self, "qwe"); 42824 ck_assert(!r); 42825 // empty dict 42826 freeO(self); 42827 r = isEBoolO(self, ""); 42828 ck_assert(!r); 42829 terminateO(self); 42830 42831 } 42832 42833 42834 void isEContainerSmallJsonT(void) { 42835 42836 bool r; 42837 smallJsont *self = allocSmallJson(); 42838 42839 createSmallContainer(c); 42840 self->f->setInt(self, "", 1); 42841 self->f->setBool(self, "b", true); 42842 self->f->setSmallContainer(self, "c", &c); 42843 r = isEContainerO(self, "c"); 42844 ck_assert(r); 42845 r = isEContainerO(self, "b"); 42846 ck_assert(!r); 42847 // path 42848 baset *value = (baset*) allocSmallContainer(null); 42849 createSmallArray(a); 42850 createSmallDict(d); 42851 a.f->pushDict(&a, &d); 42852 self->f->setArray(self, "array", &a); 42853 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 42854 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 42855 ck_assert_ptr_ne(r2, null); 42856 finishO(value); 42857 r = isEContainerO(self, "\"array\"[0].\"key\""); 42858 ck_assert(r); 42859 r = isEContainerO(self, "\"array\"[0].\"s\""); 42860 ck_assert(!r); 42861 // json bool 42862 freeO(self); 42863 setTypeBoolO(self); 42864 r = isEContainerO(self, "1"); 42865 ck_assert(!r); 42866 // json array 42867 freeO(self); 42868 setTypeArrayO(self); 42869 r = isEContainerO(self, "1"); 42870 ck_assert(!r); 42871 // non existing dict path 42872 freeO(self); 42873 r = isEContainerO(self, "\"1\"[1]"); 42874 ck_assert(!r); 42875 // dict path but the object is an array 42876 resetO(&a); 42877 self->f->setArray(self, "1", &a); 42878 r = isEContainerO(self, "\"1\".\"1\""); 42879 ck_assert(!r); 42880 // dict object in path but the key doesn't exists 42881 resetO(&d); 42882 self->f->setDict(self, "2", &d); 42883 r = isEContainerO(self, "\"2\".\"1\".[12]"); 42884 ck_assert(!r); 42885 // non existing key 42886 r = isEContainerO(self, "qwe"); 42887 ck_assert(!r); 42888 // empty dict 42889 freeO(self); 42890 r = isEContainerO(self, ""); 42891 ck_assert(!r); 42892 terminateO(self); 42893 42894 } 42895 42896 42897 void isEDictSmallJsonT(void) { 42898 42899 bool r; 42900 smallJsont *self = allocSmallJson(); 42901 42902 self->f->setInt(self, "", 1); 42903 createSmallDict(D); 42904 self->f->setDict(self, "b", &D); 42905 r = isEDictO(self, "b"); 42906 ck_assert(r); 42907 r = isEDictO(self, ""); 42908 ck_assert(!r); 42909 // path 42910 baset *value = (baset*) allocSmallDict(); 42911 createSmallArray(a); 42912 createSmallDict(d); 42913 a.f->pushDict(&a, &d); 42914 self->f->setArray(self, "array", &a); 42915 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 42916 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 42917 ck_assert_ptr_ne(r2, null); 42918 finishO(value); 42919 r = isEDictO(self, "\"array\"[0].\"key\""); 42920 ck_assert(r); 42921 r = isEDictO(self, "\"array\"[0].\"s\""); 42922 ck_assert(!r); 42923 // json bool 42924 freeO(self); 42925 setTypeBoolO(self); 42926 r = isEDictO(self, "1"); 42927 ck_assert(!r); 42928 // json array 42929 freeO(self); 42930 setTypeArrayO(self); 42931 r = isEDictO(self, "1"); 42932 ck_assert(!r); 42933 // non existing dict path 42934 freeO(self); 42935 r = isEDictO(self, "\"1\"[1]"); 42936 ck_assert(!r); 42937 // dict path but the object is an array 42938 resetO(&a); 42939 self->f->setArray(self, "1", &a); 42940 r = isEDictO(self, "\"1\".\"1\""); 42941 ck_assert(!r); 42942 // dict object in path but the key doesn't exists 42943 resetO(&d); 42944 self->f->setDict(self, "2", &d); 42945 r = isEDictO(self, "\"2\".\"1\".[12]"); 42946 ck_assert(!r); 42947 // non existing key 42948 r = isEDictO(self, "qwe"); 42949 ck_assert(!r); 42950 // empty dict 42951 freeO(self); 42952 r = isEDictO(self, ""); 42953 ck_assert(!r); 42954 terminateO(self); 42955 42956 } 42957 42958 42959 void isEDoubleSmallJsonT(void) { 42960 42961 bool r; 42962 smallJsont *self = allocSmallJson(); 42963 42964 self->f->setInt(self, "", 1); 42965 self->f->setDouble(self, "b", 2.2); 42966 r = isEDoubleO(self, "b"); 42967 ck_assert(r); 42968 r = isEDoubleO(self, ""); 42969 ck_assert(!r); 42970 // path 42971 baset *value = (baset*) allocSmallDouble(2.2); 42972 createSmallArray(a); 42973 createSmallDict(d); 42974 a.f->pushDict(&a, &d); 42975 self->f->setArray(self, "array", &a); 42976 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 42977 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 42978 ck_assert_ptr_ne(r2, null); 42979 finishO(value); 42980 r = isEDoubleO(self, "\"array\"[0].\"key\""); 42981 ck_assert(r); 42982 r = isEDoubleO(self, "\"array\"[0].\"s\""); 42983 ck_assert(!r); 42984 // json bool 42985 freeO(self); 42986 setTypeBoolO(self); 42987 r = isEDoubleO(self, "1"); 42988 ck_assert(!r); 42989 // json array 42990 freeO(self); 42991 setTypeArrayO(self); 42992 r = isEDoubleO(self, "1"); 42993 ck_assert(!r); 42994 // non existing dict path 42995 freeO(self); 42996 r = isEDoubleO(self, "\"1\"[1]"); 42997 ck_assert(!r); 42998 // dict path but the object is an array 42999 resetO(&a); 43000 self->f->setArray(self, "1", &a); 43001 r = isEDoubleO(self, "\"1\".\"1\""); 43002 ck_assert(!r); 43003 // dict object in path but the key doesn't exists 43004 resetO(&d); 43005 self->f->setDict(self, "2", &d); 43006 r = isEDoubleO(self, "\"2\".\"1\".[12]"); 43007 ck_assert(!r); 43008 // non existing key 43009 r = isEDoubleO(self, "qwe"); 43010 ck_assert(!r); 43011 // empty dict 43012 freeO(self); 43013 r = isEDoubleO(self, ""); 43014 ck_assert(!r); 43015 terminateO(self); 43016 43017 } 43018 43019 43020 void isEIntSmallJsonT(void) { 43021 43022 bool r; 43023 smallJsont *self = allocSmallJson(); 43024 43025 self->f->setBool(self, "", true); 43026 self->f->setInt(self, "b", 2); 43027 r = isEIntO(self, "b"); 43028 ck_assert(r); 43029 r = isEIntO(self, ""); 43030 ck_assert(!r); 43031 // path 43032 baset *value = (baset*) allocSmallInt(123); 43033 createSmallArray(a); 43034 createSmallDict(d); 43035 a.f->pushDict(&a, &d); 43036 self->f->setArray(self, "array", &a); 43037 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 43038 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 43039 ck_assert_ptr_ne(r2, null); 43040 finishO(value); 43041 r = isEIntO(self, "\"array\"[0].\"key\""); 43042 ck_assert(r); 43043 r = isEIntO(self, "\"array\"[0].\"s\""); 43044 ck_assert(!r); 43045 // json bool 43046 freeO(self); 43047 setTypeBoolO(self); 43048 r = isEIntO(self, "1"); 43049 ck_assert(!r); 43050 // json array 43051 freeO(self); 43052 setTypeArrayO(self); 43053 r = isEIntO(self, "1"); 43054 ck_assert(!r); 43055 // non existing dict path 43056 freeO(self); 43057 r = isEIntO(self, "\"1\"[1]"); 43058 ck_assert(!r); 43059 // dict path but the object is an array 43060 resetO(&a); 43061 self->f->setArray(self, "1", &a); 43062 r = isEIntO(self, "\"1\".\"1\""); 43063 ck_assert(!r); 43064 // dict object in path but the key doesn't exists 43065 resetO(&d); 43066 self->f->setDict(self, "2", &d); 43067 r = isEIntO(self, "\"2\".\"1\".[12]"); 43068 ck_assert(!r); 43069 // non existing key 43070 r = isEIntO(self, "qwe"); 43071 ck_assert(!r); 43072 // empty dict 43073 freeO(self); 43074 r = isEIntO(self, ""); 43075 ck_assert(!r); 43076 terminateO(self); 43077 43078 } 43079 43080 43081 void isEStringSmallJsonT(void) { 43082 43083 bool r; 43084 smallJsont *self = allocSmallJson(); 43085 43086 self->f->setInt(self, "", 1); 43087 self->f->setS(self, "b", "!@#"); 43088 r = isEStringO(self, "b"); 43089 ck_assert(r); 43090 r = isEStringO(self, ""); 43091 ck_assert(!r); 43092 // path 43093 baset *value = (baset*) allocSmallString("qwe"); 43094 createSmallArray(a); 43095 createSmallDict(d); 43096 a.f->pushDict(&a, &d); 43097 self->f->setArray(self, "array", &a); 43098 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 43099 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 43100 ck_assert_ptr_ne(r2, null); 43101 finishO(value); 43102 r = isEStringO(self, "\"array\"[0].\"key\""); 43103 ck_assert(r); 43104 r = isEStringO(self, "\"array\"[0].\"s\""); 43105 ck_assert(!r); 43106 // json bool 43107 freeO(self); 43108 setTypeBoolO(self); 43109 r = isEStringO(self, "1"); 43110 ck_assert(!r); 43111 // json array 43112 freeO(self); 43113 setTypeArrayO(self); 43114 r = isEStringO(self, "1"); 43115 ck_assert(!r); 43116 // non existing dict path 43117 freeO(self); 43118 r = isEStringO(self, "\"1\"[1]"); 43119 ck_assert(!r); 43120 // dict path but the object is an array 43121 resetO(&a); 43122 self->f->setArray(self, "1", &a); 43123 r = isEStringO(self, "\"1\".\"1\""); 43124 ck_assert(!r); 43125 // dict object in path but the key doesn't exists 43126 resetO(&d); 43127 self->f->setDict(self, "2", &d); 43128 r = isEStringO(self, "\"2\".\"1\".[12]"); 43129 ck_assert(!r); 43130 // non existing key 43131 r = isEStringO(self, "qwe"); 43132 ck_assert(!r); 43133 // empty dict 43134 freeO(self); 43135 r = isEStringO(self, ""); 43136 ck_assert(!r); 43137 terminateO(self); 43138 43139 } 43140 43141 43142 void isEFaststringSmallJsonT(void) { 43143 43144 bool r; 43145 smallJsont *self = allocSmallJson(); 43146 43147 self->f->setInt(self, "", 1); 43148 r = isEFaststringO(self, ""); 43149 ck_assert(!r); 43150 // path 43151 baset *value = (baset*) allocSmallBool(true); 43152 createSmallArray(a); 43153 createSmallDict(d); 43154 a.f->pushDict(&a, &d); 43155 self->f->setArray(self, "array", &a); 43156 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 43157 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 43158 ck_assert_ptr_ne(r2, null); 43159 finishO(value); 43160 r = isEFaststringO(self, "\"array\"[0].\"key\""); 43161 ck_assert(!r); 43162 r = isEFaststringO(self, "\"array\"[0].\"s\""); 43163 ck_assert(!r); 43164 // json bool 43165 freeO(self); 43166 setTypeBoolO(self); 43167 r = isEFaststringO(self, "1"); 43168 ck_assert(!r); 43169 // json array 43170 freeO(self); 43171 setTypeArrayO(self); 43172 r = isEFaststringO(self, "1"); 43173 ck_assert(!r); 43174 // non existing dict path 43175 freeO(self); 43176 r = isEFaststringO(self, "\"1\"[1]"); 43177 ck_assert(!r); 43178 // dict path but the object is an array 43179 resetO(&a); 43180 self->f->setArray(self, "1", &a); 43181 r = isEFaststringO(self, "\"1\".\"1\""); 43182 ck_assert(!r); 43183 // dict object in path but the key doesn't exists 43184 resetO(&d); 43185 self->f->setDict(self, "2", &d); 43186 r = isEFaststringO(self, "\"2\".\"1\".[12]"); 43187 ck_assert(!r); 43188 // non existing key 43189 r = isEFaststringO(self, "qwe"); 43190 ck_assert(!r); 43191 // empty dict 43192 freeO(self); 43193 r = isEFaststringO(self, ""); 43194 ck_assert(!r); 43195 terminateO(self); 43196 43197 } 43198 43199 43200 void isEArraySmallJsonT(void) { 43201 43202 bool r; 43203 smallJsont *self = allocSmallJson(); 43204 43205 createSmallArray(A); 43206 self->f->setInt(self, "", 1); 43207 self->f->setArray(self, "b", &A); 43208 r = isEArrayO(self, "b"); 43209 ck_assert(r); 43210 r = isEArrayO(self, ""); 43211 ck_assert(!r); 43212 // path 43213 baset *value = (baset*) allocSmallArray(); 43214 createSmallArray(a); 43215 createSmallDict(d); 43216 a.f->pushDict(&a, &d); 43217 self->f->setArray(self, "array", &a); 43218 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 43219 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 43220 ck_assert_ptr_ne(r2, null); 43221 finishO(value); 43222 r = isEArrayO(self, "\"array\"[0].\"key\""); 43223 ck_assert(r); 43224 r = isEArrayO(self, "\"array\"[0].\"s\""); 43225 ck_assert(!r); 43226 // json bool 43227 freeO(self); 43228 setTypeBoolO(self); 43229 r = isEArrayO(self, "1"); 43230 ck_assert(!r); 43231 // json array 43232 freeO(self); 43233 setTypeArrayO(self); 43234 r = isEArrayO(self, "1"); 43235 ck_assert(!r); 43236 // non existing dict path 43237 freeO(self); 43238 r = isEArrayO(self, "\"1\"[1]"); 43239 ck_assert(!r); 43240 // dict path but the object is an array 43241 resetO(&a); 43242 self->f->setArray(self, "1", &a); 43243 r = isEArrayO(self, "\"1\".\"1\""); 43244 ck_assert(!r); 43245 // dict object in path but the key doesn't exists 43246 resetO(&d); 43247 self->f->setDict(self, "2", &d); 43248 r = isEArrayO(self, "\"2\".\"1\".[12]"); 43249 ck_assert(!r); 43250 // non existing key 43251 r = isEArrayO(self, "qwe"); 43252 ck_assert(!r); 43253 // empty dict 43254 freeO(self); 43255 r = isEArrayO(self, ""); 43256 ck_assert(!r); 43257 terminateO(self); 43258 43259 } 43260 43261 43262 void isEBytesSmallJsonT(void) { 43263 43264 bool r; 43265 smallJsont *self = allocSmallJson(); 43266 43267 createSmallBytes(b); 43268 self->f->setInt(self, "", 1); 43269 self->f->setSmallBytes(self, "b", &b); 43270 r = isEBytesO(self, "b"); 43271 ck_assert(r); 43272 r = isEBytesO(self, ""); 43273 ck_assert(!r); 43274 // path 43275 baset *value = (baset*) allocSmallBytes("", sizeof("")); 43276 createSmallArray(a); 43277 createSmallDict(d); 43278 a.f->pushDict(&a, &d); 43279 self->f->setArray(self, "array", &a); 43280 smallJsont *r2 = self->f->set(self, "\"array\"[0].\"key\"", value); 43281 r2 = self->f->setUndefined(self, "\"array\"[0].\"s\""); 43282 ck_assert_ptr_ne(r2, null); 43283 finishO(value); 43284 r = isEBytesO(self, "\"array\"[0].\"key\""); 43285 ck_assert(r); 43286 r = isEBytesO(self, "\"array\"[0].\"s\""); 43287 ck_assert(!r); 43288 // json bool 43289 freeO(self); 43290 setTypeBoolO(self); 43291 r = isEBytesO(self, "1"); 43292 ck_assert(!r); 43293 // json array 43294 freeO(self); 43295 setTypeArrayO(self); 43296 r = isEBytesO(self, "1"); 43297 ck_assert(!r); 43298 // non existing dict path 43299 freeO(self); 43300 r = isEBytesO(self, "\"1\"[1]"); 43301 ck_assert(!r); 43302 // dict path but the object is an array 43303 resetO(&a); 43304 self->f->setArray(self, "1", &a); 43305 r = isEBytesO(self, "\"1\".\"1\""); 43306 ck_assert(!r); 43307 // dict object in path but the key doesn't exists 43308 resetO(&d); 43309 self->f->setDict(self, "2", &d); 43310 r = isEBytesO(self, "\"2\".\"1\".[12]"); 43311 ck_assert(!r); 43312 // non existing key 43313 r = isEBytesO(self, "qwe"); 43314 ck_assert(!r); 43315 // empty dict 43316 freeO(self); 43317 r = isEBytesO(self, ""); 43318 ck_assert(!r); 43319 terminateO(self); 43320 43321 } 43322 43323 43324 void areAllETypeSmallJsonT(void) { 43325 43326 bool r; 43327 smallJsont *self = allocSmallJson(); 43328 43329 self->f->setBool(self, "a", true); 43330 self->f->setBool(self, "b", true); 43331 r = areAllETypeO(self, "bool"); 43332 ck_assert(r); 43333 self->f->setInt(self, "c", 2); 43334 r = areAllETypeO(self, "bool"); 43335 ck_assert(!r); 43336 // null type 43337 r = areAllETypeO(self, null); 43338 ck_assert(!r); 43339 // empty self 43340 freeO(self); 43341 setTypeDictO(self); 43342 r = areAllETypeO(self, "bool"); 43343 ck_assert(!r); 43344 self->f->setS(self, "a", ""); 43345 self->f->delElem(self, "a"); 43346 r = areAllETypeO(self, "string"); 43347 ck_assert(!r); 43348 // json array 43349 freeO(self); 43350 // empty array 43351 r = areAllETypeO(self, "undefined"); 43352 ck_assert(!r); 43353 setTypeArrayO(self); 43354 r = areAllETypeO(self, "undefined"); 43355 ck_assert(!r); 43356 // array 43357 self->f->pushUndefined(self); 43358 self->f->pushUndefined(self); 43359 self->f->pushUndefined(self); 43360 delElemIndexO(self, 1); 43361 r = areAllETypeO(self, "undefined"); 43362 ck_assert(!r); 43363 trimO(self); 43364 r = areAllETypeO(self, "undefined"); 43365 ck_assert(r); 43366 // NULL type 43367 r = areAllETypeO(self, NULL); 43368 ck_assert(!r); 43369 terminateO(self); 43370 43371 } 43372 43373 43374 void areAllEUndefinedSmallJsonT(void) { 43375 43376 bool r; 43377 smallJsont *self = allocSmallJson(); 43378 43379 // array 43380 self->f->pushUndefined(self); 43381 self->f->pushUndefined(self); 43382 self->f->pushUndefined(self); 43383 r = areAllEUndefinedO(self); 43384 ck_assert(r); 43385 terminateO(self); 43386 43387 } 43388 43389 43390 void areAllEBoolSmallJsonT(void) { 43391 43392 bool r; 43393 smallJsont *self = allocSmallJson(); 43394 43395 // array 43396 self->f->pushBool(self, true); 43397 self->f->pushBool(self, true); 43398 self->f->pushBool(self, true); 43399 r = areAllEBoolO(self); 43400 ck_assert(r); 43401 terminateO(self); 43402 43403 } 43404 43405 43406 void areAllEContainerSmallJsonT(void) { 43407 43408 bool r; 43409 smallJsont *self = allocSmallJson(); 43410 43411 createSmallContainer(c); 43412 self->f->pushSmallContainer(self, &c); 43413 r = areAllEContainerO(self); 43414 ck_assert(r); 43415 terminateO(self); 43416 43417 } 43418 43419 43420 void areAllEDictSmallJsonT(void) { 43421 43422 bool r; 43423 smallJsont *self = allocSmallJson(); 43424 43425 createSmallDict(d); 43426 self->f->pushDict(self, &d); 43427 r = areAllEDictO(self); 43428 ck_assert(r); 43429 terminateO(self); 43430 43431 } 43432 43433 43434 void areAllEDoubleSmallJsonT(void) { 43435 43436 bool r; 43437 smallJsont *self = allocSmallJson(); 43438 43439 self->f->pushDouble(self, 1); 43440 r = areAllEDoubleO(self); 43441 ck_assert(r); 43442 terminateO(self); 43443 43444 } 43445 43446 43447 void areAllEIntSmallJsonT(void) { 43448 43449 bool r; 43450 smallJsont *self = allocSmallJson(); 43451 43452 self->f->pushInt(self, 1); 43453 r = areAllEIntO(self); 43454 ck_assert(r); 43455 terminateO(self); 43456 43457 } 43458 43459 43460 void areAllEStringSmallJsonT(void) { 43461 43462 bool r; 43463 smallJsont *self = allocSmallJson(); 43464 43465 self->f->pushS(self, ""); 43466 r = areAllEStringO(self); 43467 ck_assert(r); 43468 terminateO(self); 43469 43470 } 43471 43472 43473 void areAllEFaststringSmallJsonT(void) { 43474 43475 bool r; 43476 smallJsont *self = allocSmallJson(); 43477 43478 self->f->pushS(self, ""); 43479 r = areAllEFaststringO(self); 43480 ck_assert(!r); 43481 terminateO(self); 43482 43483 } 43484 43485 43486 void areAllEArraySmallJsonT(void) { 43487 43488 bool r; 43489 smallJsont *self = allocSmallJson(); 43490 43491 createSmallArray(a); 43492 self->f->pushArray(self, &a); 43493 r = areAllEArrayO(self); 43494 ck_assert(r); 43495 terminateO(self); 43496 43497 } 43498 43499 43500 void areAllEBytesSmallJsonT(void) { 43501 43502 bool r; 43503 smallJsont *self = allocSmallJson(); 43504 43505 createSmallBytes(b); 43506 self->f->pushSmallBytes(self, &b); 43507 r = areAllEBytesO(self); 43508 ck_assert(r); 43509 terminateO(self); 43510 43511 } 43512 43513 43514 void duplicateSmallJsonGT(void) { 43515 43516 smallJsont* r; 43517 smallJsont *self = allocSmallJson(); 43518 43519 self->f->pushInt(self, 1); 43520 iterStartO(self); 43521 r = duplicateSmallJsonG(self); 43522 char *s = toStringO(r); 43523 ck_assert_int_eq(r->iterIndex, 0); 43524 terminateO(r); 43525 ck_assert_str_eq(s, "[1]"); 43526 free(s); 43527 // with iterator 43528 freeO(self); 43529 self->f->setS(self, "qwe", "asd"); 43530 iterStartO(self); 43531 r = duplicateSmallJsonG(self); 43532 ck_assert_ptr_ne(r, null); 43533 s = toStringO(r); 43534 ck_assert_str_eq(s, "{\"qwe\":\"asd\"}"); 43535 free(s); 43536 ck_assert_str_eq(r->iterKey, "qwe"); 43537 terminateO(r); 43538 terminateO(self); 43539 43540 } 43541 43542 43543 void freeSmallJsonGT(void) { 43544 43545 smallJsont *self = allocSmallJson(); 43546 43547 self->f->pushInt(self, 1); 43548 freeSmallJsonG(self); 43549 char *s = toStringO(self); 43550 ck_assert_str_eq(s, "{}"); 43551 free(s); 43552 terminateO(self); 43553 43554 } 43555 43556 43557 void setTopSmallJsonGT(void) { 43558 43559 smallJsont* r; 43560 smallJsont *self = allocG(rtSmallJsont); 43561 43562 // value is a smallJson 43563 // undefined 43564 createAllocateSmallJson(js); 43565 createUndefined(u); 43566 setTopO(js, (baset*)&u); 43567 r = setTopSmallJsonG(self, (baset*) js); 43568 ck_assert_ptr_ne(r, null); 43569 char *s = toStringO(r); 43570 ck_assert_str_eq(s, "null"); 43571 free(s); 43572 resetO(js); 43573 freeO(self); 43574 // bool 43575 setTopBoolO(js, true); 43576 r = setTopSmallJsonG(self, (baset*) js); 43577 ck_assert_ptr_ne(r, null); 43578 s = toStringO(r); 43579 ck_assert_str_eq(s, "true"); 43580 free(s); 43581 resetO(js); 43582 freeO(self); 43583 // double 43584 setTopDoubleO(js, 2.2); 43585 r = setTopSmallJsonG(self, (baset*) js); 43586 ck_assert_ptr_ne(r, null); 43587 s = toStringO(r); 43588 ck_assert_str_eq(s, "2.200000e+00"); 43589 free(s); 43590 resetO(js); 43591 freeO(self); 43592 // int 43593 setTopIntO(js, 2); 43594 r = setTopSmallJsonG(self, (baset*) js); 43595 ck_assert_ptr_ne(r, null); 43596 s = toStringO(r); 43597 ck_assert_str_eq(s, "2"); 43598 free(s); 43599 resetO(js); 43600 freeO(self); 43601 // string 43602 setTopSO(js, "qwe"); 43603 r = setTopSmallJsonG(self, (baset*) js); 43604 ck_assert_ptr_ne(r, null); 43605 s = toStringO(r); 43606 ck_assert_str_eq(s, "qwe"); 43607 free(s); 43608 resetO(js); 43609 freeO(self); 43610 // dict 43611 js->f->setS(js, "1", "2"); 43612 r = setTopSmallJsonG(self, (baset*) js); 43613 ck_assert_ptr_ne(r, null); 43614 s = toStringO(r); 43615 ck_assert_str_eq(s, "{\"1\":\"2\"}"); 43616 free(s); 43617 resetO(js); 43618 freeO(self); 43619 // array 43620 js->f->pushS(js, "qwe"); 43621 r = setTopSmallJsonG(self, (baset*) js); 43622 ck_assert_ptr_ne(r, null); 43623 s = toStringO(r); 43624 ck_assert_str_eq(s, "[\"qwe\"]"); 43625 free(s); 43626 resetO(js); 43627 terminateO(js); 43628 terminateO(self); 43629 43630 } 43631 43632 43633 void setTopBoolSmallJsonGT(void) { 43634 43635 smallJsont* r; 43636 smallJsont *self = allocG(rtSmallJsont); 43637 43638 r = setTopBoolSmallJsonG(self, true); 43639 ck_assert_ptr_ne(r, null); 43640 char *s = toStringO(r); 43641 ck_assert_str_eq(s, "true"); 43642 free(s); 43643 terminateO(self); 43644 43645 } 43646 43647 43648 void setTopDoubleSmallJsonGT(void) { 43649 43650 smallJsont* r; 43651 smallJsont *self = allocG(rtSmallJsont); 43652 43653 r = setTopDoubleSmallJsonG(self, 2); 43654 ck_assert_ptr_ne(r, null); 43655 char *s = toStringO(r); 43656 ck_assert_str_eq(s, "2.000000e+00"); 43657 free(s); 43658 terminateO(self); 43659 43660 } 43661 43662 43663 void setTopIntSmallJsonGT(void) { 43664 43665 smallJsont* r; 43666 smallJsont *self = allocG(rtSmallJsont); 43667 43668 r = setTopIntSmallJsonG(self, 2); 43669 ck_assert_ptr_ne(r, null); 43670 char *s = toStringO(r); 43671 ck_assert_str_eq(s, "2"); 43672 free(s); 43673 terminateO(self); 43674 43675 } 43676 43677 43678 void setTopStringSmallJsonGT(void) { 43679 43680 smallJsont* r; 43681 smallJsont *self = allocG(rtSmallJsont); 43682 43683 r = setTopStringSmallJsonG(self, "qwe"); 43684 ck_assert_ptr_ne(r, null); 43685 char *s = toStringO(r); 43686 ck_assert_str_eq(s, "qwe"); 43687 free(s); 43688 terminateO(self); 43689 43690 } 43691 43692 43693 void setTopCharSmallJsonGT(void) { 43694 43695 smallJsont* r; 43696 smallJsont *self = allocG(rtSmallJsont); 43697 43698 r = setTopCharSmallJsonG(self, 'X'); 43699 ck_assert_ptr_ne(r, null); 43700 char *s = toStringO(r); 43701 ck_assert_str_eq(s, "X"); 43702 free(s); 43703 terminateO(self); 43704 43705 } 43706 43707 43708 void setTopDictSmallJsonGT(void) { 43709 43710 smallJsont* r; 43711 smallJsont *self = allocG(rtSmallJsont); 43712 smallDictt *value = allocSmallDict(); 43713 43714 r = setTopDictSmallJsonG(self, value); 43715 ck_assert_ptr_ne(r, null); 43716 finishG(value); 43717 char *s = toStringO(r); 43718 ck_assert_str_eq(s, "{}"); 43719 free(s); 43720 terminateO(self); 43721 43722 } 43723 43724 43725 void setTopArraySmallJsonGT(void) { 43726 43727 smallJsont* r; 43728 smallJsont *self = allocG(rtSmallJsont); 43729 smallArrayt *value = allocSmallArray(); 43730 43731 r = setTopArraySmallJsonG(self, value); 43732 ck_assert_ptr_ne(r, null); 43733 finishG(value); 43734 char *s = toStringO(r); 43735 ck_assert_str_eq(s, "[]"); 43736 free(s); 43737 terminateO(self); 43738 43739 } 43740 43741 43742 void setTopArraycSmallJsonGT(void) { 43743 43744 smallJsont* r; 43745 smallJsont *self = allocG(rtSmallJsont); 43746 char **value = listCreateS("a","bb"); 43747 43748 r = setTopArraycSmallJsonG(self, value); 43749 ck_assert_ptr_ne(r, null); 43750 listFreeS(value); 43751 char *s = toStringO(r); 43752 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 43753 free(s); 43754 terminateO(self); 43755 43756 } 43757 43758 43759 void setTopCArraycSmallJsonGT(void) { 43760 43761 smallJsont* r; 43762 smallJsont *self = allocG(rtSmallJsont); 43763 const char *value[] = {"a", "bb", null}; 43764 43765 r = setTopCArraycSmallJsonG(self, value); 43766 ck_assert_ptr_ne(r, null); 43767 char *s = toStringO(r); 43768 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 43769 free(s); 43770 terminateO(self); 43771 43772 } 43773 43774 43775 void setTopSmallBoolSmallJsonGT(void) { 43776 43777 smallJsont* r; 43778 smallJsont *self = allocG(rtSmallJsont); 43779 smallBoolt *value = allocSmallBool(true); 43780 43781 r = setTopSmallBoolSmallJsonG(self, value); 43782 ck_assert_ptr_ne(r, null); 43783 finishG(value); 43784 char *s = toStringO(r); 43785 ck_assert_str_eq(s, "true"); 43786 free(s); 43787 terminateO(self); 43788 43789 } 43790 43791 43792 void setTopSmallDoubleSmallJsonGT(void) { 43793 43794 smallJsont* r; 43795 smallJsont *self = allocG(rtSmallJsont); 43796 smallDoublet *value = allocSmallDouble(2); 43797 43798 r = setTopSmallDoubleSmallJsonG(self, value); 43799 ck_assert_ptr_ne(r, null); 43800 finishG(value); 43801 char *s = toStringO(r); 43802 ck_assert_str_eq(s, "2.000000e+00"); 43803 free(s); 43804 terminateO(self); 43805 43806 } 43807 43808 43809 void setTopSmallIntSmallJsonGT(void) { 43810 43811 smallJsont* r; 43812 smallJsont *self = allocG(rtSmallJsont); 43813 smallIntt *value = allocSmallInt(2); 43814 43815 r = setTopSmallIntSmallJsonG(self, value); 43816 ck_assert_ptr_ne(r, null); 43817 finishG(value); 43818 char *s = toStringO(r); 43819 ck_assert_str_eq(s, "2"); 43820 free(s); 43821 terminateO(self); 43822 43823 } 43824 43825 43826 void setTopSmallJsonSmallJsonGT(void) { 43827 43828 smallJsont* r; 43829 smallJsont *self = allocG(rtSmallJsont); 43830 smallJsont *value = allocSmallJson(); 43831 43832 r = setTopSmallJsonSmallJsonG(self, value); 43833 ck_assert_ptr_ne(r, null); 43834 finishG(value); 43835 char *s = toStringO(r); 43836 ck_assert_str_eq(s, "{}"); 43837 free(s); 43838 terminateO(self); 43839 43840 } 43841 43842 43843 void setTopSmallStringSmallJsonGT(void) { 43844 43845 smallJsont* r; 43846 smallJsont *self = allocG(rtSmallJsont); 43847 smallStringt *value = allocSmallString("qwe"); 43848 43849 r = setTopSmallStringSmallJsonG(self, value); 43850 ck_assert_ptr_ne(r, null); 43851 finishG(value); 43852 char *s = toStringO(r); 43853 ck_assert_str_eq(s, "qwe"); 43854 free(s); 43855 terminateO(self); 43856 43857 } 43858 43859 43860 void setTopNFreeSmallJsonGT(void) { 43861 43862 smallJsont* r; 43863 smallJsont *self = allocG(rtSmallJsont); 43864 baset *value = (baset*)allocSmallInt(2); 43865 43866 r = setTopNFreeSmallJsonG(self, value); 43867 ck_assert_ptr_ne(r, null); 43868 char *s = toStringO(r); 43869 ck_assert_str_eq(s, "2"); 43870 free(s); 43871 terminateO(self); 43872 43873 } 43874 43875 43876 void setTopNFreeBoolSmallJsonGT(void) { 43877 43878 smallJsont* r; 43879 smallJsont *self = allocG(rtSmallJsont); 43880 43881 r = setTopNFreeBoolSmallJsonG(self, true); 43882 ck_assert_ptr_ne(r, null); 43883 char *s = toStringO(r); 43884 ck_assert_str_eq(s, "true"); 43885 free(s); 43886 terminateO(self); 43887 43888 } 43889 43890 43891 void setTopNFreeDoubleSmallJsonGT(void) { 43892 43893 smallJsont* r; 43894 smallJsont *self = allocG(rtSmallJsont); 43895 43896 r = setTopNFreeDoubleSmallJsonG(self, 2); 43897 ck_assert_ptr_ne(r, null); 43898 char *s = toStringO(r); 43899 ck_assert_str_eq(s, "2.000000e+00"); 43900 free(s); 43901 terminateO(self); 43902 43903 } 43904 43905 43906 void setTopNFreeIntSmallJsonGT(void) { 43907 43908 smallJsont* r; 43909 smallJsont *self = allocG(rtSmallJsont); 43910 43911 r = setTopNFreeIntSmallJsonG(self, 2); 43912 ck_assert_ptr_ne(r, null); 43913 char *s = toStringO(r); 43914 ck_assert_str_eq(s, "2"); 43915 free(s); 43916 terminateO(self); 43917 43918 } 43919 43920 43921 void setTopNFreeStringSmallJsonGT(void) { 43922 43923 smallJsont* r; 43924 smallJsont *self = allocG(rtSmallJsont); 43925 char *value = strdup("qwe"); 43926 43927 r = setTopNFreeStringSmallJsonG(self, value); 43928 ck_assert_ptr_ne(r, null); 43929 char *s = toStringO(r); 43930 ck_assert_str_eq(s, "qwe"); 43931 free(s); 43932 terminateO(self); 43933 43934 } 43935 43936 43937 void setTopNFreeDictSmallJsonGT(void) { 43938 43939 smallJsont* r; 43940 smallJsont *self = allocG(rtSmallJsont); 43941 smallDictt *value = allocSmallDict(); 43942 43943 r = setTopNFreeDictSmallJsonG(self, value); 43944 ck_assert_ptr_ne(r, null); 43945 char *s = toStringO(r); 43946 ck_assert_str_eq(s, "{}"); 43947 free(s); 43948 terminateO(self); 43949 43950 } 43951 43952 43953 void setTopNFreeArraySmallJsonGT(void) { 43954 43955 smallJsont* r; 43956 smallJsont *self = allocG(rtSmallJsont); 43957 smallArrayt *value = allocSmallArray(); 43958 43959 r = setTopNFreeArraySmallJsonG(self, value); 43960 ck_assert_ptr_ne(r, null); 43961 char *s = toStringO(r); 43962 ck_assert_str_eq(s, "[]"); 43963 free(s); 43964 terminateO(self); 43965 43966 } 43967 43968 43969 void setTopNFreeArraycSmallJsonGT(void) { 43970 43971 smallJsont* r; 43972 smallJsont *self = allocG(rtSmallJsont); 43973 char **value = listCreateS("a","bb"); 43974 43975 r = setTopNFreeArraycSmallJsonG(self, value); 43976 ck_assert_ptr_ne(r, null); 43977 char *s = toStringO(r); 43978 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 43979 free(s); 43980 terminateO(self); 43981 43982 } 43983 43984 43985 void setTopNFreeSmallBoolSmallJsonGT(void) { 43986 43987 smallJsont* r; 43988 smallJsont *self = allocG(rtSmallJsont); 43989 smallBoolt *value = allocSmallBool(true); 43990 43991 r = setTopNFreeSmallBoolSmallJsonG(self, value); 43992 ck_assert_ptr_ne(r, null); 43993 char *s = toStringO(r); 43994 ck_assert_str_eq(s, "true"); 43995 free(s); 43996 terminateO(self); 43997 43998 } 43999 44000 44001 void setTopNFreeSmallDoubleSmallJsonGT(void) { 44002 44003 smallJsont* r; 44004 smallJsont *self = allocG(rtSmallJsont); 44005 smallDoublet *value = allocSmallDouble(2); 44006 44007 r = setTopNFreeSmallDoubleSmallJsonG(self, value); 44008 ck_assert_ptr_ne(r, null); 44009 char *s = toStringO(r); 44010 ck_assert_str_eq(s, "2.000000e+00"); 44011 free(s); 44012 terminateO(self); 44013 44014 } 44015 44016 44017 void setTopNFreeSmallIntSmallJsonGT(void) { 44018 44019 smallJsont* r; 44020 smallJsont *self = allocG(rtSmallJsont); 44021 smallIntt *value = allocSmallInt(2); 44022 44023 r = setTopNFreeSmallIntSmallJsonG(self, value); 44024 ck_assert_ptr_ne(r, null); 44025 char *s = toStringO(r); 44026 ck_assert_str_eq(s, "2"); 44027 free(s); 44028 terminateO(self); 44029 44030 } 44031 44032 44033 void setTopNFreeSmallJsonSmallJsonGT(void) { 44034 44035 smallJsont* r; 44036 smallJsont *self = allocG(rtSmallJsont); 44037 smallJsont *value = allocSmallJson(); 44038 44039 r = setTopNFreeSmallJsonSmallJsonG(self, value); 44040 ck_assert_ptr_ne(r, null); 44041 char *s = toStringO(r); 44042 ck_assert_str_eq(s, "{}"); 44043 free(s); 44044 terminateO(self); 44045 44046 } 44047 44048 44049 void setTopNFreeSmallStringSmallJsonGT(void) { 44050 44051 smallJsont* r; 44052 smallJsont *self = allocG(rtSmallJsont); 44053 smallStringt *value = allocSmallString("qwe"); 44054 44055 r = setTopNFreeSmallStringSmallJsonG(self, value); 44056 ck_assert_ptr_ne(r, null); 44057 char *s = toStringO(r); 44058 ck_assert_str_eq(s, "qwe"); 44059 free(s); 44060 terminateO(self); 44061 44062 } 44063 44064 44065 void fromArraySmallJsonGT(void) { 44066 44067 smallJsont* r; 44068 smallJsont *self = allocSmallJson(); 44069 44070 char *array[] = {"1", "22", "333"}; 44071 r = fromArraySmallJsonG(self, array, 3); 44072 ck_assert_ptr_ne(r, NULL); 44073 char *s = toStringO(r); 44074 ck_assert_str_eq(s, "[\"1\",\"22\",\"333\"]"); 44075 free(s); 44076 terminateO(self); 44077 44078 } 44079 44080 44081 void fromCArraySmallJsonGT(void) { 44082 44083 smallJsont* r; 44084 smallJsont *self = allocSmallJson(); 44085 44086 const char *array[] = {"1", "22", "333"}; 44087 r = fromCArraySmallJsonG(self, array, 3); 44088 ck_assert_ptr_ne(r, NULL); 44089 char *s = toStringO(r); 44090 ck_assert_str_eq(s, "[\"1\",\"22\",\"333\"]"); 44091 free(s); 44092 terminateO(self); 44093 44094 } 44095 44096 44097 void getTopSmallJsonGT(void) { 44098 44099 baset* r; 44100 smallJsont *self = allocG(rtSmallJsont); 44101 44102 setTopIntO(self, 987); 44103 r = getTopSmallJsonG(self, null); 44104 ck_assert_ptr_ne(r, null); 44105 ck_assert_str_eq(r->type, "smallInt"); 44106 finishO(r); 44107 terminateO(self); 44108 44109 } 44110 44111 44112 void getTopUndefinedSmallJsonGT(void) { 44113 44114 undefinedt* r = allocUndefined();; 44115 smallJsont *self = allocG(rtSmallJsont); 44116 44117 setTopO(self, (baset*) r); 44118 finishO(r); 44119 r = getTopUndefinedSmallJsonG(self, null); 44120 ck_assert_ptr_ne(r, null); 44121 char *s = toStringO(r); 44122 finishO(r); 44123 ck_assert_str_eq(s, "null"); 44124 free(s); 44125 terminateO(self); 44126 44127 } 44128 44129 44130 void getTopBoolSmallJsonGT(void) { 44131 44132 bool r; 44133 smallJsont *self = allocG(rtSmallJsont); 44134 44135 setTopBoolO(self, true); 44136 r = getTopBoolSmallJsonG(self, true); 44137 ck_assert(r); 44138 terminateO(self); 44139 44140 } 44141 44142 44143 void getTopBoolPSmallJsonGT(void) { 44144 44145 bool* r; 44146 smallJsont *self = allocG(rtSmallJsont); 44147 44148 setTopBoolO(self, true); 44149 r = getTopBoolPSmallJsonG(self, null); 44150 ck_assert_ptr_ne(r, null); 44151 ck_assert(*r); 44152 terminateO(self); 44153 44154 } 44155 44156 44157 void getTopDoubleSmallJsonGT(void) { 44158 44159 double r; 44160 smallJsont *self = allocG(rtSmallJsont); 44161 44162 setTopDoubleO(self, 2); 44163 r = getTopDoubleSmallJsonG(self, 0); 44164 ck_assert(r==2); 44165 terminateO(self); 44166 44167 } 44168 44169 44170 void getTopDoublePSmallJsonGT(void) { 44171 44172 double* r; 44173 smallJsont *self = allocG(rtSmallJsont); 44174 44175 setTopDoubleO(self, 2); 44176 r = getTopDoublePSmallJsonG(self, null); 44177 ck_assert_ptr_ne(r, null); 44178 ck_assert(*r==2); 44179 terminateO(self); 44180 44181 } 44182 44183 44184 void getTopIntSmallJsonGT(void) { 44185 44186 int64_t r; 44187 smallJsont *self = allocG(rtSmallJsont); 44188 44189 setTopIntO(self, 3); 44190 r = getTopIntSmallJsonG(self, 0); 44191 ck_assert_int_eq(r, 3); 44192 terminateO(self); 44193 44194 } 44195 44196 44197 void getTopIntPSmallJsonGT(void) { 44198 44199 int64_t* r; 44200 smallJsont *self = allocG(rtSmallJsont); 44201 44202 setTopIntO(self, 3); 44203 r = getTopIntPSmallJsonG(self, null); 44204 ck_assert_ptr_ne(r, null); 44205 ck_assert_int_eq(*r, 3); 44206 terminateO(self); 44207 44208 } 44209 44210 44211 void getTopInt32SmallJsonGT(void) { 44212 44213 int32_t r; 44214 smallJsont *self = allocG(rtSmallJsont); 44215 44216 setTopIntO(self, 3); 44217 r = getTopInt32SmallJsonG(self, 0); 44218 ck_assert_int_eq(r, 3); 44219 terminateO(self); 44220 44221 } 44222 44223 44224 void getTopInt32PSmallJsonGT(void) { 44225 44226 int32_t* r; 44227 smallJsont *self = allocG(rtSmallJsont); 44228 44229 setTopIntO(self, 3); 44230 r = getTopInt32PSmallJsonG(self, null); 44231 ck_assert_ptr_ne(r, null); 44232 ck_assert_int_eq(*r, 3); 44233 terminateO(self); 44234 44235 } 44236 44237 44238 void getTopUintSmallJsonGT(void) { 44239 44240 uint64_t r; 44241 smallJsont *self = allocG(rtSmallJsont); 44242 44243 setTopIntO(self, 3); 44244 r = getTopUintSmallJsonG(self, 0); 44245 ck_assert_int_eq(r, 3); 44246 terminateO(self); 44247 44248 } 44249 44250 44251 void getTopUintPSmallJsonGT(void) { 44252 44253 uint64_t* r; 44254 smallJsont *self = allocG(rtSmallJsont); 44255 44256 setTopIntO(self, 3); 44257 r = getTopUintPSmallJsonG(self, null); 44258 ck_assert_ptr_ne(r, null); 44259 ck_assert_int_eq(*r, 3); 44260 terminateO(self); 44261 44262 } 44263 44264 44265 void getTopUint32SmallJsonGT(void) { 44266 44267 uint32_t r; 44268 smallJsont *self = allocG(rtSmallJsont); 44269 44270 setTopIntO(self, 3); 44271 r = getTopUint32SmallJsonG(self, 0); 44272 ck_assert_int_eq(r, 3); 44273 terminateO(self); 44274 44275 } 44276 44277 44278 void getTopUint32PSmallJsonGT(void) { 44279 44280 uint32_t* r; 44281 smallJsont *self = allocG(rtSmallJsont); 44282 44283 setTopIntO(self, 3); 44284 r = getTopUint32PSmallJsonG(self, null); 44285 ck_assert_ptr_ne(r, null); 44286 ck_assert_int_eq(*r, 3); 44287 terminateO(self); 44288 44289 } 44290 44291 44292 void getTopSSmallJsonGT(void) { 44293 44294 char* r; 44295 smallJsont *self = allocG(rtSmallJsont); 44296 44297 setTopStringO(self, "qwe"); 44298 r = getTopSSmallJsonG(self, null); 44299 ck_assert_ptr_ne(r, null); 44300 ck_assert_str_eq(r, "qwe"); 44301 terminateO(self); 44302 44303 } 44304 44305 44306 void getTopDictSmallJsonGT(void) { 44307 44308 smallDictt* r = allocSmallDict(); 44309 smallJsont *self = allocG(rtSmallJsont); 44310 44311 setTopNFreeDictO(self, r); 44312 r = getTopDictSmallJsonG(self, null); 44313 ck_assert_ptr_ne(r, null); 44314 char *s = toStringO(r); 44315 finishO(r); 44316 ck_assert_str_eq(s, "{}"); 44317 free(s); 44318 terminateO(self); 44319 44320 } 44321 44322 44323 void getTopArraySmallJsonGT(void) { 44324 44325 smallArrayt* r = allocSmallArray(); 44326 smallJsont *self = allocG(rtSmallJsont); 44327 44328 setTopNFreeArrayO(self, r); 44329 r = getTopArraySmallJsonG(self, null); 44330 ck_assert_ptr_ne(r, null); 44331 char *s = toStringO(r); 44332 finishO(r); 44333 ck_assert_str_eq(s, "[]"); 44334 free(s); 44335 terminateO(self); 44336 44337 } 44338 44339 44340 void getTopSmallBoolSmallJsonGT(void) { 44341 44342 smallBoolt* r = allocSmallBool(true); 44343 smallJsont *self = allocG(rtSmallJsont); 44344 44345 setTopNFreeSmallBoolO(self, r); 44346 r = getTopSmallBoolSmallJsonG(self, null); 44347 ck_assert_ptr_ne(r, null); 44348 char *s = toStringO(r); 44349 finishO(r); 44350 ck_assert_str_eq(s, "true"); 44351 free(s); 44352 terminateO(self); 44353 44354 } 44355 44356 44357 void getTopSmallDoubleSmallJsonGT(void) { 44358 44359 smallDoublet* r = allocSmallDouble(2); 44360 smallJsont *self = allocG(rtSmallJsont); 44361 44362 setTopNFreeSmallDoubleO(self, r); 44363 r = getTopSmallDoubleSmallJsonG(self, null); 44364 ck_assert_ptr_ne(r, null); 44365 char *s = toStringO(r); 44366 finishO(r); 44367 ck_assert_str_eq(s, "2.000000e+00"); 44368 free(s); 44369 terminateO(self); 44370 44371 } 44372 44373 44374 void getTopSmallIntSmallJsonGT(void) { 44375 44376 smallIntt* r = allocSmallInt(2); 44377 smallJsont *self = allocG(rtSmallJsont); 44378 44379 setTopNFreeSmallIntO(self, r); 44380 r = getTopSmallIntSmallJsonG(self, null); 44381 ck_assert_ptr_ne(r, null); 44382 char *s = toStringO(r); 44383 finishO(r); 44384 ck_assert_str_eq(s, "2"); 44385 free(s); 44386 terminateO(self); 44387 44388 } 44389 44390 44391 void getTopSmallStringSmallJsonGT(void) { 44392 44393 smallStringt* r = allocSmallString("qwe"); 44394 smallJsont *self = allocG(rtSmallJsont); 44395 44396 setTopNFreeSmallStringO(self, r); 44397 r = getTopSmallStringSmallJsonG(self, null); 44398 ck_assert_ptr_ne(r, null); 44399 char *s = toStringO(r); 44400 finishO(r); 44401 ck_assert_str_eq(s, "qwe"); 44402 free(s); 44403 terminateO(self); 44404 44405 } 44406 44407 44408 void pushSmallJsonGT(void) { 44409 44410 smallJsont* r; 44411 smallJsont *self = allocSmallJson(); 44412 baset *value = (baset*) allocSmallInt(1); 44413 44414 r = pushSmallJsonG(self, value); 44415 ck_assert_ptr_ne(r, null); 44416 finishO(value); 44417 char *s = toStringO(r); 44418 ck_assert_str_eq(s, "[1]"); 44419 free(s); 44420 terminateO(self); 44421 44422 } 44423 44424 44425 void pushUndefinedSmallJsonGT(void) { 44426 44427 smallJsont* r; 44428 smallJsont *self = allocSmallJson(); 44429 44430 r = pushUndefinedSmallJsonG(self, NULL); 44431 ck_assert_ptr_ne(r, null); 44432 char *s = toStringO(r); 44433 ck_assert_str_eq(s, "[null]"); 44434 free(s); 44435 terminateO(self); 44436 44437 } 44438 44439 44440 void pushBoolSmallJsonGT(void) { 44441 44442 smallJsont* r; 44443 smallJsont *self = allocSmallJson(); 44444 44445 r = pushBoolSmallJsonG(self, true); 44446 ck_assert_ptr_ne(r, null); 44447 char *s = toStringO(r); 44448 ck_assert_str_eq(s, "[true]"); 44449 free(s); 44450 terminateO(self); 44451 44452 } 44453 44454 44455 void pushDoubleSmallJsonGT(void) { 44456 44457 smallJsont* r; 44458 smallJsont *self = allocSmallJson(); 44459 44460 r = pushDoubleSmallJsonG(self, 1); 44461 ck_assert_ptr_ne(r, null); 44462 char *s = toStringO(r); 44463 ck_assert_str_eq(s, "[1.000000e+00]"); 44464 free(s); 44465 terminateO(self); 44466 44467 } 44468 44469 44470 void pushIntSmallJsonGT(void) { 44471 44472 smallJsont* r; 44473 smallJsont *self = allocSmallJson(); 44474 44475 r = pushIntSmallJsonG(self, 1); 44476 ck_assert_ptr_ne(r, null); 44477 char *s = toStringO(r); 44478 ck_assert_str_eq(s, "[1]"); 44479 free(s); 44480 terminateO(self); 44481 44482 } 44483 44484 44485 void pushSSmallJsonGT(void) { 44486 44487 smallJsont* r; 44488 smallJsont *self = allocSmallJson(); 44489 44490 r = pushSSmallJsonG(self, "qwe"); 44491 ck_assert_ptr_ne(r, null); 44492 char *s = toStringO(r); 44493 ck_assert_str_eq(s, "[\"qwe\"]"); 44494 free(s); 44495 terminateO(self); 44496 44497 } 44498 44499 44500 void pushCharSmallJsonGT(void) { 44501 44502 smallJsont* r; 44503 smallJsont *self = allocSmallJson(); 44504 44505 r = pushCharSmallJsonG(self, 'Q'); 44506 ck_assert_ptr_ne(r, null); 44507 char *s = toStringO(r); 44508 ck_assert_str_eq(s, "[\"Q\"]"); 44509 free(s); 44510 terminateO(self); 44511 44512 } 44513 44514 44515 void pushDictSmallJsonGT(void) { 44516 44517 smallJsont* r; 44518 smallJsont *self = allocSmallJson(); 44519 smallDictt *dict = allocSmallDict(); 44520 44521 r = pushDictSmallJsonG(self, dict); 44522 ck_assert_ptr_ne(r, null); 44523 finishO(dict); 44524 char *s = toStringO(r); 44525 ck_assert_str_eq(s, "[{}]"); 44526 free(s); 44527 terminateO(self); 44528 44529 } 44530 44531 44532 void pushArraySmallJsonGT(void) { 44533 44534 smallJsont* r; 44535 smallJsont *self = allocSmallJson(); 44536 smallArrayt *array = allocSmallArray(); 44537 44538 r = pushArraySmallJsonG(self, array); 44539 ck_assert_ptr_ne(r, null); 44540 finishO(array); 44541 char *s = toStringO(r); 44542 ck_assert_str_eq(s, "[[]]"); 44543 free(s); 44544 terminateO(self); 44545 44546 } 44547 44548 44549 void pushArraycSmallJsonGT(void) { 44550 44551 smallJsont* r; 44552 smallJsont *self = allocSmallJson(); 44553 char **array = listCreateS("a","bb"); 44554 44555 r = pushArraycSmallJsonG(self, array); 44556 ck_assert_ptr_ne(r, null); 44557 ck_assert_int_eq(lenO(r), 1); 44558 listFreeS(array); 44559 char *s = toStringO(r); 44560 ck_assert_str_eq(s, "[[\"a\",\"bb\"]]"); 44561 free(s); 44562 terminateO(self); 44563 44564 } 44565 44566 44567 void pushCArraycSmallJsonGT(void) { 44568 44569 smallJsont* r; 44570 smallJsont *self = allocSmallJson(); 44571 const char *array[] = {"a", "bb", NULL}; 44572 44573 r = pushCArraycSmallJsonG(self, array); 44574 ck_assert_ptr_ne(r, null); 44575 ck_assert_int_eq(lenO(r), 1); 44576 char *s = toStringO(r); 44577 ck_assert_str_eq(s, "[[\"a\",\"bb\"]]"); 44578 free(s); 44579 terminateO(self); 44580 44581 } 44582 44583 44584 void pushVoidSmallJsonGT(void) { 44585 44586 smallJsont* r; 44587 smallJsont *self = allocSmallJson(); 44588 44589 // NULL value 44590 r = pushVoidSmallJsonG(self, NULL); 44591 ck_assert_ptr_ne(r, null); 44592 char *s = toStringO(r); 44593 ck_assert_str_eq(s, "[null]"); 44594 free(s); 44595 // value 44596 r = pushVoidSmallJsonG(self, r); 44597 s = toStringO(r); 44598 ck_assert_str_eq(s, "[null,\"<data container>\"]"); 44599 free(s); 44600 terminateO(self); 44601 44602 } 44603 44604 44605 void pushSmallBoolSmallJsonGT(void) { 44606 44607 smallJsont* r; 44608 smallJsont *self = allocSmallJson(); 44609 smallBoolt *value = allocSmallBool(true); 44610 44611 r = pushSmallBoolSmallJsonG(self, value); 44612 ck_assert_ptr_ne(r, null); 44613 finishO(value); 44614 char *s = toStringO(r); 44615 ck_assert_str_eq(s, "[true]"); 44616 free(s); 44617 terminateO(self); 44618 44619 } 44620 44621 44622 void pushSmallBytesSmallJsonGT(void) { 44623 44624 smallJsont* r; 44625 smallJsont *self = allocSmallJson(); 44626 smallBytest *value = allocSmallBytes("qwe", 3); 44627 44628 r = pushSmallBytesSmallJsonG(self, value); 44629 ck_assert_ptr_ne(r, null); 44630 finishO(value); 44631 char *s = toStringO(r); 44632 ck_assert_str_eq(s, "[[0x71,0x77,0x65]]"); 44633 free(s); 44634 terminateO(self); 44635 44636 } 44637 44638 44639 void pushSmallDoubleSmallJsonGT(void) { 44640 44641 smallJsont* r; 44642 smallJsont *self = allocSmallJson(); 44643 smallDoublet *value = allocSmallDouble(1); 44644 44645 r = pushSmallDoubleSmallJsonG(self, value); 44646 ck_assert_ptr_ne(r, null); 44647 finishO(value); 44648 char *s = toStringO(r); 44649 ck_assert_str_eq(s, "[1.000000e+00]"); 44650 free(s); 44651 terminateO(self); 44652 44653 } 44654 44655 44656 void pushSmallIntSmallJsonGT(void) { 44657 44658 smallJsont* r; 44659 smallJsont *self = allocSmallJson(); 44660 smallIntt *value = allocSmallInt(1); 44661 44662 r = pushSmallIntSmallJsonG(self, value); 44663 ck_assert_ptr_ne(r, null); 44664 finishO(value); 44665 char *s = toStringO(r); 44666 ck_assert_str_eq(s, "[1]"); 44667 free(s); 44668 terminateO(self); 44669 44670 } 44671 44672 44673 void pushSmallJsonSmallJsonGT(void) { 44674 44675 smallJsont* r; 44676 smallJsont *self = allocSmallJson(); 44677 smallJsont *value = allocSmallJson(); 44678 44679 r = pushSmallJsonSmallJsonG(self, value); 44680 ck_assert_ptr_ne(r, null); 44681 finishO(value); 44682 char *s = toStringO(r); 44683 ck_assert_str_eq(s, "[{}]"); 44684 free(s); 44685 terminateO(self); 44686 44687 } 44688 44689 44690 void pushSmallStringSmallJsonGT(void) { 44691 44692 smallJsont* r; 44693 smallJsont *self = allocSmallJson(); 44694 smallStringt *string = allocSmallString("qwe"); 44695 44696 r = pushSmallStringSmallJsonG(self, string); 44697 ck_assert_ptr_ne(r, null); 44698 finishO(string); 44699 char *s = toStringO(r); 44700 ck_assert_str_eq(s, "[\"qwe\"]"); 44701 free(s); 44702 terminateO(self); 44703 44704 } 44705 44706 44707 void pushSmallContainerSmallJsonGT(void) { 44708 44709 smallJsont* r; 44710 smallJsont *self = allocSmallJson(); 44711 44712 createSmallContainer(c); 44713 r = pushSmallContainerSmallJsonG(self, &c); 44714 ck_assert_ptr_ne(r, null); 44715 char *s = toStringO(r); 44716 ck_assert_str_eq(s, "[\"<data container>\"]"); 44717 free(s); 44718 terminateO(self); 44719 44720 } 44721 44722 44723 void pushNFreeSmallJsonGT(void) { 44724 44725 smallJsont* r; 44726 smallJsont *self = allocSmallJson(); 44727 baset *value = (baset*) allocSmallInt(1); 44728 44729 r = pushNFreeSmallJsonG(self, value); 44730 ck_assert_ptr_ne(r, null); 44731 char *s = toStringO(r); 44732 ck_assert_str_eq(s, "[1]"); 44733 free(s); 44734 terminateO(self); 44735 44736 } 44737 44738 44739 void pushNFreeUndefinedSmallJsonGT(void) { 44740 44741 smallJsont* r; 44742 smallJsont *self = allocSmallJson(); 44743 undefinedt *value = allocUndefined(); 44744 44745 r = pushNFreeUndefinedSmallJsonG(self, value); 44746 ck_assert_ptr_ne(r, null); 44747 char *s = toStringO(r); 44748 ck_assert_str_eq(s, "[null]"); 44749 free(s); 44750 terminateO(self); 44751 44752 } 44753 44754 44755 void pushNFreeSSmallJsonGT(void) { 44756 44757 smallJsont* r; 44758 smallJsont *self = allocSmallJson(); 44759 44760 r = pushNFreeSSmallJsonG(self, strdup("qwe")); 44761 ck_assert_ptr_ne(r, null); 44762 char *s = toStringO(r); 44763 ck_assert_str_eq(s, "[\"qwe\"]"); 44764 free(s); 44765 terminateO(self); 44766 44767 } 44768 44769 44770 void pushNFreeDictSmallJsonGT(void) { 44771 44772 smallJsont* r; 44773 smallJsont *self = allocSmallJson(); 44774 smallDictt *dict = allocSmallDict(); 44775 44776 r = pushNFreeDictSmallJsonG(self, dict); 44777 ck_assert_ptr_ne(r, null); 44778 char *s = toStringO(r); 44779 ck_assert_str_eq(s, "[{}]"); 44780 free(s); 44781 terminateO(self); 44782 44783 } 44784 44785 44786 void pushNFreeArraySmallJsonGT(void) { 44787 44788 smallJsont* r; 44789 smallJsont *self = allocSmallJson(); 44790 smallArrayt *array = allocSmallArray(); 44791 44792 r = pushNFreeArraySmallJsonG(self, array); 44793 ck_assert_ptr_ne(r, null); 44794 char *s = toStringO(r); 44795 ck_assert_str_eq(s, "[[]]"); 44796 free(s); 44797 terminateO(self); 44798 44799 } 44800 44801 44802 void pushNFreeArraycSmallJsonGT(void) { 44803 44804 smallJsont* r; 44805 smallJsont *self = allocSmallJson(); 44806 char **array = listCreateS("a","bb"); 44807 44808 r = pushNFreeArraycSmallJsonG(self, array); 44809 ck_assert_ptr_ne(r, null); 44810 ck_assert_int_eq(lenO(r), 1); 44811 char *s = toStringO(r); 44812 ck_assert_str_eq(s, "[[\"a\",\"bb\"]]"); 44813 free(s); 44814 terminateO(self); 44815 44816 } 44817 44818 44819 void pushNFreeSmallBoolSmallJsonGT(void) { 44820 44821 smallJsont* r; 44822 smallJsont *self = allocSmallJson(); 44823 smallBoolt *value = allocSmallBool(true); 44824 44825 r = pushNFreeSmallBoolSmallJsonG(self, value); 44826 ck_assert_ptr_ne(r, null); 44827 char *s = toStringO(r); 44828 ck_assert_str_eq(s, "[true]"); 44829 free(s); 44830 terminateO(self); 44831 44832 } 44833 44834 44835 void pushNFreeSmallBytesSmallJsonGT(void) { 44836 44837 smallJsont* r; 44838 smallJsont *self = allocSmallJson(); 44839 smallBytest *value = allocSmallBytes("qwe", 3); 44840 44841 r = pushNFreeSmallBytesSmallJsonG(self, value); 44842 ck_assert_ptr_ne(r, null); 44843 char *s = toStringO(r); 44844 ck_assert_str_eq(s, "[[0x71,0x77,0x65]]"); 44845 free(s); 44846 terminateO(self); 44847 44848 } 44849 44850 44851 void pushNFreeSmallDoubleSmallJsonGT(void) { 44852 44853 smallJsont* r; 44854 smallJsont *self = allocSmallJson(); 44855 smallDoublet *value = allocSmallDouble(1); 44856 44857 r = pushNFreeSmallDoubleSmallJsonG(self, value); 44858 ck_assert_ptr_ne(r, null); 44859 char *s = toStringO(r); 44860 ck_assert_str_eq(s, "[1.000000e+00]"); 44861 free(s); 44862 terminateO(self); 44863 44864 } 44865 44866 44867 void pushNFreeSmallIntSmallJsonGT(void) { 44868 44869 smallJsont* r; 44870 smallJsont *self = allocSmallJson(); 44871 smallIntt *value = allocSmallInt(1); 44872 44873 r = pushNFreeSmallIntSmallJsonG(self, value); 44874 ck_assert_ptr_ne(r, null); 44875 char *s = toStringO(r); 44876 ck_assert_str_eq(s, "[1]"); 44877 free(s); 44878 terminateO(self); 44879 44880 } 44881 44882 44883 void pushNFreeSmallJsonSmallJsonGT(void) { 44884 44885 smallJsont* r; 44886 smallJsont *self = allocSmallJson(); 44887 smallJsont *value = allocSmallJson(); 44888 44889 r = pushNFreeSmallJsonSmallJsonG(self, value); 44890 ck_assert_ptr_ne(r, null); 44891 char *s = toStringO(r); 44892 ck_assert_str_eq(s, "[{}]"); 44893 free(s); 44894 terminateO(self); 44895 44896 } 44897 44898 44899 void pushNFreeSmallStringSmallJsonGT(void) { 44900 44901 smallJsont* r; 44902 smallJsont *self = allocSmallJson(); 44903 smallStringt *string = allocSmallString("qwe"); 44904 44905 r = pushNFreeSmallStringSmallJsonG(self, string); 44906 ck_assert_ptr_ne(r, null); 44907 char *s = toStringO(r); 44908 ck_assert_str_eq(s, "[\"qwe\"]"); 44909 free(s); 44910 terminateO(self); 44911 44912 } 44913 44914 44915 void pushNFreeSmallContainerSmallJsonGT(void) { 44916 44917 smallJsont* r; 44918 smallJsont *self = allocSmallJson(); 44919 44920 createAllocateSmallContainer(c); 44921 r = pushNFreeSmallContainerSmallJsonG(self, c); 44922 ck_assert_ptr_ne(r, null); 44923 char *s = toStringO(r); 44924 ck_assert_str_eq(s, "[\"<data container>\"]"); 44925 free(s); 44926 terminateO(self); 44927 44928 } 44929 44930 44931 void popSmallJsonGT(void) { 44932 44933 baset* r; 44934 smallJsont *self = allocSmallJson(); 44935 44936 smallJsont *r2 = self->f->pushInt(self, 1); 44937 ck_assert_ptr_ne(r2, null); 44938 r = popSmallJsonG(self, NULL); 44939 ck_assert_ptr_ne(r, null); 44940 char *s = toStringO(r); 44941 terminateO(r); 44942 ck_assert_str_eq(s, "1"); 44943 free(s); 44944 terminateO(self); 44945 44946 } 44947 44948 44949 void popUndefinedSmallJsonGT(void) { 44950 44951 undefinedt* r; 44952 smallJsont *self = allocSmallJson(); 44953 44954 smallJsont *r2 = self->f->pushUndefined(self); 44955 ck_assert_ptr_ne(r2, null); 44956 r = popUndefinedSmallJsonG(self, null); 44957 ck_assert_ptr_ne(r, null); 44958 char *s = toStringO(r); 44959 terminateO(r); 44960 ck_assert_str_eq(s, "null"); 44961 free(s); 44962 terminateO(self); 44963 44964 } 44965 44966 44967 void popBoolSmallJsonGT(void) { 44968 44969 bool r; 44970 smallJsont *self = allocSmallJson(); 44971 44972 smallJsont *r2 = self->f->pushBool(self, TRUE); 44973 ck_assert_ptr_ne(r2, null); 44974 r = popBoolSmallJsonG(self, null); 44975 ck_assert(r); 44976 terminateO(self); 44977 44978 } 44979 44980 44981 void popDoubleSmallJsonGT(void) { 44982 44983 double r; 44984 smallJsont *self = allocSmallJson(); 44985 44986 smallJsont *r2 = self->f->pushDouble(self, 2.0); 44987 ck_assert_ptr_ne(r2, null); 44988 r = popDoubleSmallJsonG(self, 0); 44989 ck_assert(r==2.0); 44990 terminateO(self); 44991 44992 } 44993 44994 44995 void popIntSmallJsonGT(void) { 44996 44997 int64_t r; 44998 smallJsont *self = allocSmallJson(); 44999 45000 smallJsont *r2 = self->f->pushInt(self, 2); 45001 ck_assert_ptr_ne(r2, null); 45002 r = popIntSmallJsonG(self, 0); 45003 ck_assert_int_eq(r, 2); 45004 terminateO(self); 45005 45006 } 45007 45008 45009 void popInt32SmallJsonGT(void) { 45010 45011 int32_t r; 45012 smallJsont *self = allocSmallJson(); 45013 45014 smallJsont *r2 = self->f->pushInt(self, 2); 45015 ck_assert_ptr_ne(r2, null); 45016 r = popInt32SmallJsonG(self, 0); 45017 ck_assert_int_eq(r, 2); 45018 terminateO(self); 45019 45020 } 45021 45022 45023 void popUintSmallJsonGT(void) { 45024 45025 uint64_t r; 45026 smallJsont *self = allocSmallJson(); 45027 45028 smallJsont *r2 = self->f->pushInt(self, 2); 45029 ck_assert_ptr_ne(r2, null); 45030 r = popUintSmallJsonG(self, 0); 45031 ck_assert_int_eq(r, 2); 45032 terminateO(self); 45033 45034 } 45035 45036 45037 void popUint32SmallJsonGT(void) { 45038 45039 uint32_t r; 45040 smallJsont *self = allocSmallJson(); 45041 45042 smallJsont *r2 = self->f->pushInt(self, 2); 45043 ck_assert_ptr_ne(r2, null); 45044 r = popUint32SmallJsonG(self, 0); 45045 ck_assert_int_eq(r, 2); 45046 terminateO(self); 45047 45048 } 45049 45050 45051 void popSSmallJsonGT(void) { 45052 45053 char* r; 45054 smallJsont *self = allocSmallJson(); 45055 45056 smallJsont *r2 = self->f->pushS(self, "2"); 45057 ck_assert_ptr_ne(r2, null); 45058 r = popSSmallJsonG(self, null); 45059 ck_assert_str_eq(r, "2"); 45060 free(r); 45061 terminateO(self); 45062 45063 } 45064 45065 45066 void popDictSmallJsonGT(void) { 45067 45068 smallDictt* r; 45069 smallJsont *self = allocSmallJson(); 45070 45071 createSmallDict(d); 45072 smallJsont *r2 = self->f->pushDict(self, &d); 45073 ck_assert_ptr_ne(r2, null); 45074 r = popDictSmallJsonG(self, null); 45075 ck_assert_ptr_ne(r, null); 45076 char *s = toStringO(r); 45077 ck_assert_str_eq(s, "{}"); 45078 free(s); 45079 terminateO(r); 45080 terminateO(self); 45081 45082 } 45083 45084 45085 void popArraySmallJsonGT(void) { 45086 45087 smallArrayt* r; 45088 smallJsont *self = allocSmallJson(); 45089 45090 createSmallArray(a); 45091 smallJsont *r2 = self->f->pushArray(self, &a); 45092 ck_assert_ptr_ne(r2, null); 45093 r = popArraySmallJsonG(self, null); 45094 ck_assert_ptr_ne(r, null); 45095 char *s = toStringO(r); 45096 ck_assert_str_eq(s, "[]"); 45097 free(s); 45098 terminateO(r); 45099 terminateO(self); 45100 45101 } 45102 45103 45104 void popSmallBoolSmallJsonGT(void) { 45105 45106 smallBoolt* r; 45107 smallJsont *self = allocSmallJson(); 45108 45109 smallJsont *r2 = self->f->pushBool(self, true); 45110 ck_assert_ptr_ne(r2, null); 45111 r = popSmallBoolSmallJsonG(self, null); 45112 ck_assert_ptr_ne(r, null); 45113 char *s = toStringO(r); 45114 ck_assert_str_eq(s, "true"); 45115 free(s); 45116 terminateO(r); 45117 terminateO(self); 45118 45119 } 45120 45121 45122 void popSmallBytesSmallJsonGT(void) { 45123 45124 smallBytest* r; 45125 smallJsont *self = allocSmallJson(); 45126 45127 createSmallBytes(b); 45128 smallJsont *r2 = self->f->pushSmallBytes(self, &b); 45129 ck_assert_ptr_ne(r2, null); 45130 r = popSmallBytesSmallJsonG(self, null); 45131 ck_assert_ptr_ne(r, null); 45132 char *s = toStringO(r); 45133 ck_assert_str_eq(s, "[]"); 45134 free(s); 45135 terminateO(r); 45136 terminateO(self); 45137 45138 } 45139 45140 45141 void popSmallDoubleSmallJsonGT(void) { 45142 45143 smallDoublet* r; 45144 smallJsont *self = allocSmallJson(); 45145 45146 smallJsont *r2 = self->f->pushDouble(self, 1); 45147 ck_assert_ptr_ne(r2, null); 45148 r = popSmallDoubleSmallJsonG(self, null); 45149 ck_assert_ptr_ne(r, null); 45150 char *s = toStringO(r); 45151 ck_assert_str_eq(s, "1.000000e+00"); 45152 free(s); 45153 terminateO(r); 45154 terminateO(self); 45155 45156 } 45157 45158 45159 void popSmallIntSmallJsonGT(void) { 45160 45161 smallIntt* r; 45162 smallJsont *self = allocSmallJson(); 45163 45164 smallJsont *r2 = self->f->pushInt(self, 1); 45165 ck_assert_ptr_ne(r2, null); 45166 r = popSmallIntSmallJsonG(self, null); 45167 ck_assert_ptr_ne(r, null); 45168 char *s = toStringO(r); 45169 ck_assert_str_eq(s, "1"); 45170 free(s); 45171 terminateO(r); 45172 terminateO(self); 45173 45174 } 45175 45176 45177 void popSmallJsonSmallJsonGT(void) { 45178 45179 smallJsont* r; 45180 smallJsont *self = allocSmallJson(); 45181 45182 createSmallJson(j); 45183 smallJsont *r2 = self->f->pushSmallJson(self, &j); 45184 ck_assert_ptr_ne(r2, null); 45185 r = popSmallJsonSmallJsonG(self, null); 45186 ck_assert_ptr_ne(r, null); 45187 char *s = toStringO(r); 45188 ck_assert_str_eq(s, "{}"); 45189 free(s); 45190 terminateO(r); 45191 terminateO(self); 45192 45193 } 45194 45195 45196 void popSmallStringSmallJsonGT(void) { 45197 45198 smallStringt* r; 45199 smallJsont *self = allocSmallJson(); 45200 45201 createSmallString(S); 45202 smallJsont *r2 = self->f->pushSmallString(self, &S); 45203 ck_assert_ptr_ne(r2, null); 45204 r = popSmallStringSmallJsonG(self, null); 45205 ck_assert_ptr_ne(r, null); 45206 char *s = toStringO(r); 45207 ck_assert_str_eq(s, ""); 45208 free(s); 45209 terminateO(r); 45210 terminateO(self); 45211 45212 } 45213 45214 45215 void popVoidSmallJsonGT(void) { 45216 45217 void* r; 45218 smallJsont *self = allocSmallJson(); 45219 45220 createSmallContainer(c); 45221 setValO(&c, &r); 45222 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 45223 ck_assert_ptr_ne(r2, null); 45224 r = popVoidSmallJsonG(self, null); 45225 ck_assert_ptr_eq(r, &r); 45226 terminateO(self); 45227 45228 } 45229 45230 45231 void popSmallContainerSmallJsonGT(void) { 45232 45233 smallContainert* r; 45234 smallJsont *self = allocSmallJson(); 45235 45236 createSmallContainer(c); 45237 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 45238 ck_assert_ptr_ne(r2, null); 45239 r = popSmallContainerSmallJsonG(self, null); 45240 ck_assert_ptr_ne(r, null); 45241 char *s = toStringO(r); 45242 ck_assert_str_eq(s, "<data smallContainer>"); 45243 free(s); 45244 terminateO(r); 45245 terminateO(self); 45246 45247 } 45248 45249 45250 void setSmallJsonGT(void) { 45251 45252 smallJsont* r; 45253 smallJsont *self = allocSmallJson(); 45254 baset *value = (baset*) allocSmallInt(2); 45255 45256 r = setSmallJsonG(self, "1", value); 45257 ck_assert_ptr_ne(r, null); 45258 finishO(value); 45259 char *s = toStringO(r); 45260 ck_assert_str_eq(s, "{\"1\":2}"); 45261 free(s); 45262 terminateO(self); 45263 45264 } 45265 45266 45267 void setUndefinedSmallJsonGT(void) { 45268 45269 smallJsont* r; 45270 smallJsont *self = allocSmallJson(); 45271 45272 r = setUndefinedSmallJsonG(self, "1", null); 45273 ck_assert_ptr_ne(r, null); 45274 char *s = toStringO(r); 45275 ck_assert_str_eq(s, "{\"1\":null}"); 45276 free(s); 45277 terminateO(self); 45278 45279 } 45280 45281 45282 void setBoolSmallJsonGT(void) { 45283 45284 smallJsont* r; 45285 smallJsont *self = allocSmallJson(); 45286 45287 r = setBoolSmallJsonG(self, "1", true); 45288 ck_assert_ptr_ne(r, null); 45289 char *s = toStringO(r); 45290 ck_assert_str_eq(s, "{\"1\":true}"); 45291 free(s); 45292 terminateO(self); 45293 45294 } 45295 45296 45297 void setDoubleSmallJsonGT(void) { 45298 45299 smallJsont* r; 45300 smallJsont *self = allocSmallJson(); 45301 45302 r = setDoubleSmallJsonG(self, "1", 2.2); 45303 ck_assert_ptr_ne(r, null); 45304 char *s = toStringO(r); 45305 ck_assert_str_eq(s, "{\"1\":2.200000e+00}"); 45306 free(s); 45307 terminateO(self); 45308 45309 } 45310 45311 45312 void setIntSmallJsonGT(void) { 45313 45314 smallJsont* r; 45315 smallJsont *self = allocSmallJson(); 45316 45317 r = setIntSmallJsonG(self, "1", 2); 45318 ck_assert_ptr_ne(r, null); 45319 char *s = toStringO(r); 45320 ck_assert_str_eq(s, "{\"1\":2}"); 45321 free(s); 45322 terminateO(self); 45323 45324 } 45325 45326 45327 void setSSmallJsonGT(void) { 45328 45329 smallJsont* r; 45330 smallJsont *self = allocSmallJson(); 45331 45332 r = setSSmallJsonG(self, "1", "qwe"); 45333 ck_assert_ptr_ne(r, null); 45334 char *s = toStringO(r); 45335 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 45336 free(s); 45337 terminateO(self); 45338 45339 } 45340 45341 45342 void setCharSmallJsonGT(void) { 45343 45344 smallJsont* r; 45345 smallJsont *self = allocSmallJson(); 45346 45347 r = setCharSmallJsonG(self, "1", 'x'); 45348 ck_assert_ptr_ne(r, null); 45349 char *s = toStringO(r); 45350 ck_assert_str_eq(s, "{\"1\":\"x\"}"); 45351 free(s); 45352 terminateO(self); 45353 45354 } 45355 45356 45357 void setDictSmallJsonGT(void) { 45358 45359 smallJsont* r; 45360 smallJsont *self = allocSmallJson(); 45361 smallDictt *dict = allocSmallDict(); 45362 45363 r = setDictSmallJsonG(self, "1", dict); 45364 ck_assert_ptr_ne(r, null); 45365 finishO(dict); 45366 char *s = toStringO(r); 45367 ck_assert_str_eq(s, "{\"1\":{}}"); 45368 free(s); 45369 terminateO(self); 45370 45371 } 45372 45373 45374 void setArraySmallJsonGT(void) { 45375 45376 smallJsont* r; 45377 smallJsont *self = allocSmallJson(); 45378 smallArrayt *array = allocSmallArray(); 45379 45380 r = setArraySmallJsonG(self, "1", array); 45381 ck_assert_ptr_ne(r, null); 45382 finishO(array); 45383 char *s = toStringO(r); 45384 ck_assert_str_eq(s, "{\"1\":[]}"); 45385 free(s); 45386 terminateO(self); 45387 45388 } 45389 45390 45391 void setArraycSmallJsonGT(void) { 45392 45393 smallJsont* r; 45394 smallJsont *self = allocSmallJson(); 45395 char **array = listCreateS("a", "b"); 45396 45397 r = setArraycSmallJsonG(self, "1", array); 45398 ck_assert_ptr_ne(r, null); 45399 listFreeS(array); 45400 char *s = toStringO(r); 45401 ck_assert_str_eq(s, "{\"1\":[\"a\",\"b\"]}"); 45402 free(s); 45403 terminateO(self); 45404 45405 } 45406 45407 45408 void setCArraycSmallJsonGT(void) { 45409 45410 smallJsont* r; 45411 smallJsont *self = allocSmallJson(); 45412 const char *array[] = {"a", "b", null}; 45413 45414 r = setCArraycSmallJsonG(self, "1", array); 45415 ck_assert_ptr_ne(r, null); 45416 char *s = toStringO(r); 45417 ck_assert_str_eq(s, "{\"1\":[\"a\",\"b\"]}"); 45418 free(s); 45419 terminateO(self); 45420 45421 } 45422 45423 45424 void setVoidSmallJsonGT(void) { 45425 45426 smallJsont* r; 45427 smallJsont *self = allocSmallJson(); 45428 45429 r = setVoidSmallJsonG(self, "1", null); 45430 ck_assert_ptr_ne(r, null); 45431 char *s = toStringO(r); 45432 ck_assert_str_eq(s, "{\"1\":null}"); 45433 free(s); 45434 r = setVoidSmallJsonG(self, "1", &r); 45435 ck_assert_ptr_ne(r, null); 45436 s = toStringO(r); 45437 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 45438 free(s); 45439 // null key 45440 r = setVoidSmallJsonG(self, null, &r); 45441 ck_assert_ptr_eq(r, null); 45442 terminateO(self); 45443 45444 } 45445 45446 45447 void setSmallBoolSmallJsonGT(void) { 45448 45449 smallJsont* r; 45450 smallJsont *self = allocSmallJson(); 45451 smallBoolt *value = allocSmallBool(true); 45452 45453 r = setSmallBoolSmallJsonG(self, "1", value); 45454 ck_assert_ptr_ne(r, null); 45455 finishO(value); 45456 char *s = toStringO(r); 45457 ck_assert_str_eq(s, "{\"1\":true}"); 45458 free(s); 45459 terminateO(self); 45460 45461 } 45462 45463 45464 void setSmallBytesSmallJsonGT(void) { 45465 45466 smallJsont* r; 45467 smallJsont *self = allocSmallJson(); 45468 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 45469 45470 r = setSmallBytesSmallJsonG(self, "1", value); 45471 ck_assert_ptr_ne(r, null); 45472 finishO(value); 45473 char *s = toStringO(r); 45474 ck_assert_str_eq(s, "{\"1\":[0x71,0x77,0x65,0x00]}"); 45475 free(s); 45476 terminateO(self); 45477 45478 } 45479 45480 45481 void setSmallDoubleSmallJsonGT(void) { 45482 45483 smallJsont* r; 45484 smallJsont *self = allocSmallJson(); 45485 smallDoublet *value = allocSmallDouble(2.2); 45486 45487 r = setSmallDoubleSmallJsonG(self, "1", value); 45488 ck_assert_ptr_ne(r, null); 45489 finishO(value); 45490 char *s = toStringO(r); 45491 ck_assert_str_eq(s, "{\"1\":2.200000e+00}"); 45492 free(s); 45493 terminateO(self); 45494 45495 } 45496 45497 45498 void setSmallIntSmallJsonGT(void) { 45499 45500 smallJsont* r; 45501 smallJsont *self = allocSmallJson(); 45502 smallIntt *value = allocSmallInt(2); 45503 45504 r = setSmallIntSmallJsonG(self, "1", value); 45505 ck_assert_ptr_ne(r, null); 45506 finishO(value); 45507 char *s = toStringO(r); 45508 ck_assert_str_eq(s, "{\"1\":2}"); 45509 free(s); 45510 terminateO(self); 45511 45512 } 45513 45514 45515 void setSmallJsonSmallJsonGT(void) { 45516 45517 smallJsont* r; 45518 smallJsont *self = allocSmallJson(); 45519 smallJsont *value = allocSmallJson(); 45520 45521 setTopIntO(value, 2); 45522 r = setSmallJsonSmallJsonG(self, "1", value); 45523 ck_assert_ptr_ne(r, null); 45524 finishO(value); 45525 char *s = toStringO(r); 45526 ck_assert_str_eq(s, "{\"1\":2}"); 45527 free(s); 45528 terminateO(self); 45529 45530 } 45531 45532 45533 void setSmallStringSmallJsonGT(void) { 45534 45535 smallJsont* r; 45536 smallJsont *self = allocSmallJson(); 45537 smallStringt *string = allocSmallString("qwe"); 45538 45539 r = setSmallStringSmallJsonG(self, "1", string); 45540 ck_assert_ptr_ne(r, null); 45541 finishO(string); 45542 char *s = toStringO(r); 45543 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 45544 free(s); 45545 terminateO(self); 45546 45547 } 45548 45549 45550 void setSmallContainerSmallJsonGT(void) { 45551 45552 smallJsont* r; 45553 smallJsont *self = allocSmallJson(); 45554 smallContainert *container = allocSmallContainer(null); 45555 45556 r = setSmallContainerSmallJsonG(self, "1", container); 45557 ck_assert_ptr_ne(r, null); 45558 finishO(container); 45559 char *s = toStringO(r); 45560 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 45561 free(s); 45562 terminateO(self); 45563 45564 } 45565 45566 45567 void setNFreeSmallJsonGT(void) { 45568 45569 smallJsont* r; 45570 smallJsont *self = allocSmallJson(); 45571 baset *value; 45572 45573 value = (baset*)allocUndefined(); 45574 r = setNFreeSmallJsonG(self, "1", value); 45575 ck_assert_ptr_ne(r, null); 45576 char *s = toStringO(r); 45577 ck_assert_str_eq(s, "{\"1\":null}"); 45578 free(s); 45579 terminateO(self); 45580 45581 } 45582 45583 45584 void setNFreeUndefinedSmallJsonGT(void) { 45585 45586 smallJsont* r; 45587 smallJsont *self = allocSmallJson(); 45588 undefinedt *undefined = allocUndefined(); 45589 45590 r = setNFreeUndefinedSmallJsonG(self, "1", undefined); 45591 ck_assert_ptr_ne(r, null); 45592 char *s = toStringO(r); 45593 ck_assert_str_eq(s, "{\"1\":null}"); 45594 free(s); 45595 terminateO(self); 45596 45597 } 45598 45599 45600 void setNFreeSSmallJsonGT(void) { 45601 45602 smallJsont* r; 45603 smallJsont *self = allocSmallJson(); 45604 char *string = strdup("qwe"); 45605 45606 r = setNFreeSSmallJsonG(self, "1", string); 45607 ck_assert_ptr_ne(r, null); 45608 char *s = toStringO(r); 45609 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 45610 free(s); 45611 terminateO(self); 45612 45613 } 45614 45615 45616 void setNFreeDictSmallJsonGT(void) { 45617 45618 smallJsont* r; 45619 smallJsont *self = allocSmallJson(); 45620 smallDictt *dict = allocSmallDict(); 45621 45622 r = setNFreeDictSmallJsonG(self, "1", dict); 45623 ck_assert_ptr_ne(r, null); 45624 char *s = toStringO(r); 45625 ck_assert_str_eq(s, "{\"1\":{}}"); 45626 free(s); 45627 terminateO(self); 45628 45629 } 45630 45631 45632 void setNFreeArraySmallJsonGT(void) { 45633 45634 smallJsont* r; 45635 smallJsont *self = allocSmallJson(); 45636 smallArrayt *array = allocSmallArray(); 45637 45638 r = setNFreeArraySmallJsonG(self, "1", array); 45639 ck_assert_ptr_ne(r, null); 45640 char *s = toStringO(r); 45641 ck_assert_str_eq(s, "{\"1\":[]}"); 45642 free(s); 45643 terminateO(self); 45644 45645 } 45646 45647 45648 void setNFreeArraycSmallJsonGT(void) { 45649 45650 smallJsont* r; 45651 smallJsont *self = allocSmallJson(); 45652 char **array = listCreateS("a", "b"); 45653 45654 r = setNFreeArraycSmallJsonG(self, "1", array); 45655 ck_assert_ptr_ne(r, null); 45656 char *s = toStringO(r); 45657 ck_assert_str_eq(s, "{\"1\":[\"a\",\"b\"]}"); 45658 free(s); 45659 terminateO(self); 45660 45661 } 45662 45663 45664 void setNFreeSmallBoolSmallJsonGT(void) { 45665 45666 smallJsont* r; 45667 smallJsont *self = allocSmallJson(); 45668 smallBoolt *value = allocSmallBool(true); 45669 45670 r = setNFreeSmallBoolSmallJsonG(self, "1", value); 45671 ck_assert_ptr_ne(r, null); 45672 char *s = toStringO(r); 45673 ck_assert_str_eq(s, "{\"1\":true}"); 45674 free(s); 45675 terminateO(self); 45676 45677 } 45678 45679 45680 void setNFreeSmallBytesSmallJsonGT(void) { 45681 45682 smallJsont* r; 45683 smallJsont *self = allocSmallJson(); 45684 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 45685 45686 r = setNFreeSmallBytesSmallJsonG(self, "1", value); 45687 ck_assert_ptr_ne(r, null); 45688 char *s = toStringO(r); 45689 ck_assert_str_eq(s, "{\"1\":[0x71,0x77,0x65,0x00]}"); 45690 free(s); 45691 terminateO(self); 45692 45693 } 45694 45695 45696 void setNFreeSmallDoubleSmallJsonGT(void) { 45697 45698 smallJsont* r; 45699 smallJsont *self = allocSmallJson(); 45700 smallDoublet *value = allocSmallDouble(2.2); 45701 45702 r = setNFreeSmallDoubleSmallJsonG(self, "1", value); 45703 ck_assert_ptr_ne(r, null); 45704 char *s = toStringO(r); 45705 ck_assert_str_eq(s, "{\"1\":2.200000e+00}"); 45706 free(s); 45707 terminateO(self); 45708 45709 } 45710 45711 45712 void setNFreeSmallIntSmallJsonGT(void) { 45713 45714 smallJsont* r; 45715 smallJsont *self = allocSmallJson(); 45716 smallIntt *value = allocSmallInt(2); 45717 45718 r = setNFreeSmallIntSmallJsonG(self, "1", value); 45719 ck_assert_ptr_ne(r, null); 45720 char *s = toStringO(r); 45721 ck_assert_str_eq(s, "{\"1\":2}"); 45722 free(s); 45723 terminateO(self); 45724 45725 } 45726 45727 45728 void setNFreeSmallJsonSmallJsonGT(void) { 45729 45730 smallJsont* r; 45731 smallJsont *self = allocSmallJson(); 45732 smallJsont *value = allocSmallJson(); 45733 45734 setTopIntO(value, 2); 45735 r = setNFreeSmallJsonSmallJsonG(self, "1", value); 45736 ck_assert_ptr_ne(r, null); 45737 char *s = toStringO(r); 45738 ck_assert_str_eq(s, "{\"1\":2}"); 45739 free(s); 45740 terminateO(self); 45741 45742 } 45743 45744 45745 void setNFreeSmallStringSmallJsonGT(void) { 45746 45747 smallJsont* r; 45748 smallJsont *self = allocSmallJson(); 45749 smallStringt *string = allocSmallString("qwe"); 45750 45751 r = setNFreeSmallStringSmallJsonG(self, "1", string); 45752 ck_assert_ptr_ne(r, null); 45753 char *s = toStringO(r); 45754 ck_assert_str_eq(s, "{\"1\":\"qwe\"}"); 45755 free(s); 45756 terminateO(self); 45757 45758 } 45759 45760 45761 void setNFreeSmallContainerSmallJsonGT(void) { 45762 45763 smallJsont* r; 45764 smallJsont *self = allocSmallJson(); 45765 smallContainert *container = allocSmallContainer(null); 45766 45767 r = setNFreeSmallContainerSmallJsonG(self, "1", container); 45768 ck_assert_ptr_ne(r, null); 45769 char *s = toStringO(r); 45770 ck_assert_str_eq(s, "{\"1\":\"<data container>\"}"); 45771 free(s); 45772 terminateO(self); 45773 45774 } 45775 45776 45777 void setPDictSmallJsonGT(void) { 45778 45779 smallJsont* r; 45780 smallJsont *self = allocSmallJson(); 45781 smallDictt *dict; 45782 45783 dict = allocSmallDict(); 45784 r = self->f->setDict(self, "1", dict); 45785 ck_assert_ptr_ne(r, null); 45786 dict->f->setInt(dict, "a", 1); 45787 r = setPDictSmallJsonG(self, "1", dict); 45788 ck_assert_ptr_ne(r, null); 45789 char *s = toStringO(r); 45790 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 45791 free(s); 45792 finishO(dict); 45793 terminateO(self); 45794 45795 } 45796 45797 45798 void setPArraySmallJsonGT(void) { 45799 45800 smallJsont* r; 45801 smallJsont *self = allocSmallJson(); 45802 smallArrayt *array; 45803 45804 array = allocSmallArray(); 45805 r = self->f->setArray(self, "1", array); 45806 ck_assert_ptr_ne(r, null); 45807 array->f->pushInt(array, 1); 45808 r = setPArraySmallJsonG(self, "1", array); 45809 ck_assert_ptr_ne(r, null); 45810 char *s = toStringO(r); 45811 ck_assert_str_eq(s, "{\"1\":[1]}"); 45812 free(s); 45813 finishO(array); 45814 terminateO(self); 45815 45816 } 45817 45818 45819 void setPSmallJsonSmallJsonGT(void) { 45820 45821 smallJsont* r; 45822 smallJsont *self = allocSmallJson(); 45823 smallJsont *json; 45824 45825 json = allocSmallJson(); 45826 r = self->f->setSmallJson(self, "1", json); 45827 ck_assert_ptr_ne(r, null); 45828 json->f->setInt(json, "a", 1); 45829 r = setPSmallJsonSmallJsonG(self, "1", json); 45830 ck_assert_ptr_ne(r, null); 45831 finishO(json); 45832 char *s = toStringO(r); 45833 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 45834 free(s); 45835 terminateO(self); 45836 45837 } 45838 45839 45840 void setPSmallStringSmallJsonGT(void) { 45841 45842 smallJsont* r; 45843 smallJsont *self = allocSmallJson(); 45844 smallStringt *string; 45845 45846 string = allocSmallString(""); 45847 r = self->f->setSmallString(self, "1", string); 45848 ck_assert_ptr_ne(r, null); 45849 string->f->appendS(string, "s"); 45850 r = setPSmallStringSmallJsonG(self, "1", string); 45851 ck_assert_ptr_ne(r, null); 45852 finishO(string); 45853 char *s = toStringO(r); 45854 ck_assert_str_eq(s, "{\"1\":\"s\"}"); 45855 free(s); 45856 terminateO(self); 45857 45858 } 45859 45860 45861 void setNFreePDictSmallJsonGT(void) { 45862 45863 smallJsont* r; 45864 smallJsont *self = allocSmallJson(); 45865 smallDictt *value; 45866 45867 value = allocSmallDict(); 45868 r = self->f->setDict(self, "1", value); 45869 ck_assert_ptr_ne(r, null); 45870 value->f->setInt(value, "a", 1); 45871 r = setNFreePDictSmallJsonG(self, "1", value); 45872 ck_assert_ptr_ne(r, null); 45873 char *s = toStringO(r); 45874 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 45875 free(s); 45876 terminateO(self); 45877 45878 } 45879 45880 45881 void setNFreePArraySmallJsonGT(void) { 45882 45883 smallJsont* r; 45884 smallJsont *self = allocSmallJson(); 45885 smallArrayt *value; 45886 45887 value = allocSmallArray(); 45888 r = self->f->setArray(self, "1", value); 45889 ck_assert_ptr_ne(r, null); 45890 value->f->pushInt(value, 2); 45891 r = setNFreePArraySmallJsonG(self, "1", value); 45892 ck_assert_ptr_ne(r, null); 45893 char *s = toStringO(r); 45894 ck_assert_str_eq(s, "{\"1\":[2]}"); 45895 free(s); 45896 terminateO(self); 45897 45898 } 45899 45900 45901 void setNFreePSmallJsonSmallJsonGT(void) { 45902 45903 smallJsont* r; 45904 smallJsont *self = allocSmallJson(); 45905 smallJsont *value; 45906 45907 value = allocSmallJson(); 45908 r = self->f->setSmallJson(self, "1", value); 45909 ck_assert_ptr_ne(r, null); 45910 value->f->setInt(value, "a", 1); 45911 r = setNFreePSmallJsonSmallJsonG(self, "1", value); 45912 ck_assert_ptr_ne(r, null); 45913 char *s = toStringO(r); 45914 ck_assert_str_eq(s, "{\"1\":{\"a\":1}}"); 45915 free(s); 45916 terminateO(self); 45917 45918 } 45919 45920 45921 void setNFreePSmallStringSmallJsonGT(void) { 45922 45923 smallJsont* r; 45924 smallJsont *self = allocSmallJson(); 45925 smallStringt *value; 45926 45927 value = allocSmallString(""); 45928 r = self->f->setSmallString(self, "1", value); 45929 ck_assert_ptr_ne(r, null); 45930 value->f->appendS(value, "2"); 45931 r = setNFreePSmallStringSmallJsonG(self, "1", value); 45932 ck_assert_ptr_ne(r, null); 45933 char *s = toStringO(r); 45934 ck_assert_str_eq(s, "{\"1\":\"2\"}"); 45935 free(s); 45936 terminateO(self); 45937 45938 } 45939 45940 45941 void setAtSmallJsonGT(void) { 45942 45943 smallJsont* r; 45944 smallJsont *self = allocSmallJson(); 45945 baset *value = (baset*) allocSmallInt(1); 45946 45947 r = pushSmallJsonG(self, value); 45948 ck_assert_ptr_ne(r, null); 45949 finishO(value); 45950 value = (baset*) allocSmallInt(2); 45951 r = setAtSmallJsonG(self, 0, value); 45952 ck_assert_ptr_ne(r, null); 45953 finishO(value); 45954 char *s = toStringO(r); 45955 ck_assert_str_eq(s, "[2]"); 45956 free(s); 45957 terminateO(self); 45958 45959 } 45960 45961 45962 void setAtUndefinedSmallJsonGT(void) { 45963 45964 smallJsont* r; 45965 smallJsont *self = allocSmallJson(); 45966 baset *value = (baset*) allocSmallInt(1); 45967 45968 r = pushSmallJsonG(self, value); 45969 ck_assert_ptr_ne(r, null); 45970 finishO(value); 45971 char *v = strdup("freed by setAtUndefinedSmallJsonG"); 45972 r = setAtUndefinedSmallJsonG(self, 0, v); 45973 ck_assert_ptr_ne(r, null); 45974 char *s = toStringO(r); 45975 ck_assert_str_eq(s, "[null]"); 45976 free(s); 45977 terminateO(self); 45978 45979 } 45980 45981 45982 void setAtBoolSmallJsonGT(void) { 45983 45984 smallJsont* r; 45985 smallJsont *self = allocSmallJson(); 45986 45987 r = pushBoolSmallJsonG(self, true); 45988 ck_assert_ptr_ne(r, null); 45989 r = setAtBoolSmallJsonG(self, 0, false); 45990 ck_assert_ptr_ne(r, null); 45991 char *s = toStringO(r); 45992 ck_assert_str_eq(s, "[false]"); 45993 free(s); 45994 terminateO(self); 45995 45996 } 45997 45998 45999 void setAtDoubleSmallJsonGT(void) { 46000 46001 smallJsont* r; 46002 smallJsont *self = allocSmallJson(); 46003 46004 r = pushDoubleSmallJsonG(self, 1); 46005 ck_assert_ptr_ne(r, null); 46006 r = setAtDoubleSmallJsonG(self, 0, 2); 46007 ck_assert_ptr_ne(r, null); 46008 char *s = toStringO(r); 46009 ck_assert_str_eq(s, "[2.000000e+00]"); 46010 free(s); 46011 terminateO(self); 46012 46013 } 46014 46015 46016 void setAtIntSmallJsonGT(void) { 46017 46018 smallJsont* r; 46019 smallJsont *self = allocSmallJson(); 46020 46021 r = pushIntSmallJsonG(self, 1); 46022 ck_assert_ptr_ne(r, null); 46023 r = setAtIntSmallJsonG(self, 0, 2); 46024 ck_assert_ptr_ne(r, null); 46025 char *s = toStringO(r); 46026 ck_assert_str_eq(s, "[2]"); 46027 free(s); 46028 terminateO(self); 46029 46030 } 46031 46032 46033 void setAtSSmallJsonGT(void) { 46034 46035 smallJsont* r; 46036 smallJsont *self = allocSmallJson(); 46037 46038 r = pushSSmallJsonG(self, "qwe"); 46039 ck_assert_ptr_ne(r, null); 46040 r = setAtSSmallJsonG(self, 0, "asd"); 46041 ck_assert_ptr_ne(r, null); 46042 char *s = toStringO(r); 46043 ck_assert_str_eq(s, "[\"asd\"]"); 46044 free(s); 46045 terminateO(self); 46046 46047 } 46048 46049 46050 void setAtCharSmallJsonGT(void) { 46051 46052 smallJsont* r; 46053 smallJsont *self = allocSmallJson(); 46054 46055 r = pushCharSmallJsonG(self, 'Q'); 46056 ck_assert_ptr_ne(r, null); 46057 r = setAtCharSmallJsonG(self, 0, 'x'); 46058 ck_assert_ptr_ne(r, null); 46059 char *s = toStringO(r); 46060 ck_assert_str_eq(s, "[\"x\"]"); 46061 free(s); 46062 terminateO(self); 46063 46064 } 46065 46066 46067 void setAtDictSmallJsonGT(void) { 46068 46069 smallJsont* r; 46070 smallJsont *self = allocSmallJson(); 46071 smallDictt *dict = allocSmallDict(); 46072 46073 r = pushDictSmallJsonG(self, dict); 46074 ck_assert_ptr_ne(r, null); 46075 resetO(dict); 46076 dict->f->setInt(dict, "a", 1); 46077 r = setAtDictSmallJsonG(self, 0, dict); 46078 ck_assert_ptr_ne(r, null); 46079 finishO(dict); 46080 char *s = toStringO(r); 46081 ck_assert_str_eq(s, "[{\"a\":1}]"); 46082 free(s); 46083 terminateO(self); 46084 46085 } 46086 46087 46088 void setAtArraySmallJsonGT(void) { 46089 46090 smallJsont* r; 46091 smallJsont *self = allocSmallJson(); 46092 smallArrayt *array = allocSmallArray(); 46093 46094 r = pushArraySmallJsonG(self, array); 46095 ck_assert_ptr_ne(r, null); 46096 resetO(array); 46097 array->f->pushInt(array, 1); 46098 r = setAtArraySmallJsonG(self, 0, array); 46099 ck_assert_ptr_ne(r, null); 46100 finishO(array); 46101 char *s = toStringO(r); 46102 ck_assert_str_eq(s, "[[1]]"); 46103 free(s); 46104 terminateO(self); 46105 46106 } 46107 46108 46109 void setAtArraycSmallJsonGT(void) { 46110 46111 smallJsont* r; 46112 smallJsont *self = allocSmallJson(); 46113 char **array = listCreateS("a","bb"); 46114 46115 r = pushArraycSmallJsonG(self, array); 46116 ck_assert_ptr_ne(r, null); 46117 listFreeS(array); 46118 array = listCreateS("1","22"); 46119 r = setAtArraycSmallJsonG(self, 0, array); 46120 ck_assert_ptr_ne(r, null); 46121 ck_assert_int_eq(lenO(r), 1); 46122 listFreeS(array); 46123 char *s = toStringO(r); 46124 ck_assert_str_eq(s, "[[\"1\",\"22\"]]"); 46125 free(s); 46126 terminateO(self); 46127 46128 } 46129 46130 46131 void setAtCArraycSmallJsonGT(void) { 46132 46133 smallJsont* r; 46134 smallJsont *self = allocSmallJson(); 46135 const char *array[] = {"a", "bb", NULL}; 46136 46137 r = pushCArraycSmallJsonG(self, array); 46138 ck_assert_ptr_ne(r, null); 46139 const char *array2[] = {"1", "22", NULL}; 46140 r = setAtCArraycSmallJsonG(self, 0, array2); 46141 ck_assert_ptr_ne(r, null); 46142 ck_assert_int_eq(lenO(r), 1); 46143 char *s = toStringO(r); 46144 ck_assert_str_eq(s, "[[\"1\",\"22\"]]"); 46145 free(s); 46146 terminateO(self); 46147 46148 } 46149 46150 46151 void setAtVoidSmallJsonGT(void) { 46152 46153 smallJsont* r; 46154 smallJsont *self = allocSmallJson(); 46155 46156 // NULL value 46157 r = pushVoidSmallJsonG(self, NULL); 46158 ck_assert_ptr_ne(r, null); 46159 r = setAtVoidSmallJsonG(self, 0, null); 46160 ck_assert_ptr_ne(r, null); 46161 r = setAtVoidSmallJsonG(self, 0, r); 46162 ck_assert_ptr_ne(r, null); 46163 char *s = toStringO(r); 46164 ck_assert_str_eq(s, "[\"<data container>\"]"); 46165 free(s); 46166 terminateO(self); 46167 46168 } 46169 46170 46171 void setAtSmallBoolSmallJsonGT(void) { 46172 46173 smallJsont* r; 46174 smallJsont *self = allocSmallJson(); 46175 smallBoolt *value = allocSmallBool(true); 46176 46177 r = pushBoolSmallJsonG(self, false); 46178 ck_assert_ptr_ne(r, null); 46179 r = setAtSmallBoolSmallJsonG(self, 0, value); 46180 ck_assert_ptr_ne(r, null); 46181 finishO(value); 46182 char *s = toStringO(r); 46183 ck_assert_str_eq(s, "[true]"); 46184 free(s); 46185 terminateO(self); 46186 46187 } 46188 46189 46190 void setAtSmallBytesSmallJsonGT(void) { 46191 46192 smallJsont* r; 46193 smallJsont *self = allocSmallJson(); 46194 smallBytest *value = allocSmallBytes("qwe", 3); 46195 46196 r = pushSmallBytesSmallJsonG(self, value); 46197 ck_assert_ptr_ne(r, null); 46198 finishO(value); 46199 value = allocSmallBytes("asd", 3); 46200 r = setAtSmallBytesSmallJsonG(self, 0, value); 46201 ck_assert_ptr_ne(r, null); 46202 finishO(value); 46203 char *s = toStringO(r); 46204 ck_assert_str_eq(s, "[[0x61,0x73,0x64]]"); 46205 free(s); 46206 terminateO(self); 46207 46208 } 46209 46210 46211 void setAtSmallDoubleSmallJsonGT(void) { 46212 46213 smallJsont* r; 46214 smallJsont *self = allocSmallJson(); 46215 smallDoublet *value = allocSmallDouble(1); 46216 46217 r = pushDoubleSmallJsonG(self, 2); 46218 ck_assert_ptr_ne(r, null); 46219 r = setAtSmallDoubleSmallJsonG(self, 0, value); 46220 ck_assert_ptr_ne(r, null); 46221 finishO(value); 46222 char *s = toStringO(r); 46223 ck_assert_str_eq(s, "[1.000000e+00]"); 46224 free(s); 46225 46226 terminateO(self); 46227 46228 } 46229 46230 46231 void setAtSmallIntSmallJsonGT(void) { 46232 46233 smallJsont* r; 46234 smallJsont *self = allocSmallJson(); 46235 smallIntt *value = allocSmallInt(1); 46236 46237 r = pushIntSmallJsonG(self, 2); 46238 ck_assert_ptr_ne(r, null); 46239 r = setAtSmallIntSmallJsonG(self, 0, value); 46240 ck_assert_ptr_ne(r, null); 46241 finishO(value); 46242 char *s = toStringO(r); 46243 ck_assert_str_eq(s, "[1]"); 46244 free(s); 46245 terminateO(self); 46246 46247 } 46248 46249 46250 void setAtSmallJsonSmallJsonGT(void) { 46251 46252 smallJsont* r; 46253 smallJsont *self = allocSmallJson(); 46254 smallJsont *value = allocSmallJson(); 46255 46256 r = pushSmallJsonSmallJsonG(self, value); 46257 ck_assert_ptr_ne(r, null); 46258 finishO(value); 46259 value = allocSmallJson(); 46260 value->f->setInt(value, "a", 1); 46261 r = setAtSmallJsonSmallJsonG(self, 0, value); 46262 ck_assert_ptr_ne(r, null); 46263 finishO(value); 46264 char *s = toStringO(r); 46265 ck_assert_str_eq(s, "[{\"a\":1}]"); 46266 free(s); 46267 terminateO(self); 46268 46269 } 46270 46271 46272 void setAtSmallStringSmallJsonGT(void) { 46273 46274 smallJsont* r; 46275 smallJsont *self = allocSmallJson(); 46276 smallStringt *string = allocSmallString("qwe"); 46277 46278 r = pushSSmallJsonG(self, "asd"); 46279 ck_assert_ptr_ne(r, null); 46280 r = setAtSmallStringSmallJsonG(self, 0, string); 46281 ck_assert_ptr_ne(r, null); 46282 finishO(string); 46283 char *s = toStringO(r); 46284 ck_assert_str_eq(s, "[\"qwe\"]"); 46285 free(s); 46286 terminateO(self); 46287 46288 } 46289 46290 46291 void setAtSmallContainerSmallJsonGT(void) { 46292 46293 smallJsont* r; 46294 smallJsont *self = allocSmallJson(); 46295 46296 createSmallContainer(c); 46297 r = pushSmallContainerSmallJsonG(self, &c); 46298 ck_assert_ptr_ne(r, null); 46299 createSmallContainer(c2); 46300 r = setAtSmallContainerSmallJsonG(self, 0, &c2); 46301 ck_assert_ptr_ne(r, null); 46302 char *s = toStringO(r); 46303 ck_assert_str_eq(s, "[\"<data container>\"]"); 46304 free(s); 46305 terminateO(self); 46306 46307 } 46308 46309 46310 void setAtNFreeSmallJsonGT(void) { 46311 46312 smallJsont* r; 46313 smallJsont *self = allocSmallJson(); 46314 baset *value = (baset*) allocSmallInt(1); 46315 46316 r = pushSmallJsonG(self, value); 46317 ck_assert_ptr_ne(r, null); 46318 finishO(value); 46319 value = (baset*) allocSmallInt(2); 46320 r = setAtNFreeSmallJsonG(self, 0, value); 46321 ck_assert_ptr_ne(r, null); 46322 char *s = toStringO(r); 46323 ck_assert_str_eq(s, "[2]"); 46324 free(s); 46325 terminateO(self); 46326 46327 } 46328 46329 46330 void setAtNFreeUndefinedSmallJsonGT(void) { 46331 46332 smallJsont* r; 46333 smallJsont *self = allocSmallJson(); 46334 baset *value = (baset*) allocSmallInt(1); 46335 46336 r = pushSmallJsonG(self, value); 46337 ck_assert_ptr_ne(r, null); 46338 finishO(value); 46339 r = setAtNFreeUndefinedSmallJsonG(self, 0, null); 46340 ck_assert_ptr_ne(r, null); 46341 char *s = toStringO(r); 46342 ck_assert_str_eq(s, "[null]"); 46343 free(s); 46344 terminateO(self); 46345 46346 } 46347 46348 46349 void setAtNFreeSSmallJsonGT(void) { 46350 46351 smallJsont* r; 46352 smallJsont *self = allocSmallJson(); 46353 46354 r = pushSSmallJsonG(self, "qwe"); 46355 ck_assert_ptr_ne(r, null); 46356 r = setAtNFreeSSmallJsonG(self, 0, strdup("asd")); 46357 ck_assert_ptr_ne(r, null); 46358 char *s = toStringO(r); 46359 ck_assert_str_eq(s, "[\"asd\"]"); 46360 free(s); 46361 terminateO(self); 46362 46363 } 46364 46365 46366 void setAtNFreeDictSmallJsonGT(void) { 46367 46368 smallJsont* r; 46369 smallJsont *self = allocSmallJson(); 46370 smallDictt *dict = allocSmallDict(); 46371 46372 r = pushDictSmallJsonG(self, dict); 46373 ck_assert_ptr_ne(r, null); 46374 resetO(dict); 46375 dict->f->setInt(dict, "a", 1); 46376 r = setAtNFreeDictSmallJsonG(self, 0, dict); 46377 ck_assert_ptr_ne(r, null); 46378 char *s = toStringO(r); 46379 ck_assert_str_eq(s, "[{\"a\":1}]"); 46380 free(s); 46381 terminateO(self); 46382 46383 } 46384 46385 46386 void setAtNFreeArraySmallJsonGT(void) { 46387 46388 smallJsont* r; 46389 smallJsont *self = allocSmallJson(); 46390 smallArrayt *array = allocSmallArray(); 46391 46392 r = pushArraySmallJsonG(self, array); 46393 ck_assert_ptr_ne(r, null); 46394 resetO(array); 46395 array->f->pushInt(array, 1); 46396 r = setAtNFreeArraySmallJsonG(self, 0, array); 46397 ck_assert_ptr_ne(r, null); 46398 char *s = toStringO(r); 46399 ck_assert_str_eq(s, "[[1]]"); 46400 free(s); 46401 terminateO(self); 46402 46403 } 46404 46405 46406 void setAtNFreeArraycSmallJsonGT(void) { 46407 46408 smallJsont* r; 46409 smallJsont *self = allocSmallJson(); 46410 char **array = listCreateS("a","bb"); 46411 46412 r = pushArraycSmallJsonG(self, array); 46413 ck_assert_ptr_ne(r, null); 46414 listFreeS(array); 46415 array = listCreateS("1","22"); 46416 r = setAtNFreeArraycSmallJsonG(self, 0, array); 46417 ck_assert_ptr_ne(r, null); 46418 ck_assert_int_eq(lenO(r), 1); 46419 char *s = toStringO(r); 46420 ck_assert_str_eq(s, "[[\"1\",\"22\"]]"); 46421 free(s); 46422 terminateO(self); 46423 46424 } 46425 46426 46427 void setAtNFreeSmallBoolSmallJsonGT(void) { 46428 46429 smallJsont* r; 46430 smallJsont *self = allocSmallJson(); 46431 smallBoolt *value = allocSmallBool(true); 46432 46433 r = pushBoolSmallJsonG(self, false); 46434 ck_assert_ptr_ne(r, null); 46435 r = setAtNFreeSmallBoolSmallJsonG(self, 0, value); 46436 ck_assert_ptr_ne(r, null); 46437 char *s = toStringO(r); 46438 ck_assert_str_eq(s, "[true]"); 46439 free(s); 46440 terminateO(self); 46441 46442 } 46443 46444 46445 void setAtNFreeSmallBytesSmallJsonGT(void) { 46446 46447 smallJsont* r; 46448 smallJsont *self = allocSmallJson(); 46449 smallBytest *value = allocSmallBytes("qwe", 3); 46450 46451 r = pushSmallBytesSmallJsonG(self, value); 46452 ck_assert_ptr_ne(r, null); 46453 finishO(value); 46454 value = allocSmallBytes("asd", 3); 46455 r = setAtNFreeSmallBytesSmallJsonG(self, 0, value); 46456 ck_assert_ptr_ne(r, null); 46457 char *s = toStringO(r); 46458 ck_assert_str_eq(s, "[[0x61,0x73,0x64]]"); 46459 free(s); 46460 terminateO(self); 46461 46462 } 46463 46464 46465 void setAtNFreeSmallDoubleSmallJsonGT(void) { 46466 46467 smallJsont* r; 46468 smallJsont *self = allocSmallJson(); 46469 smallDoublet *value = allocSmallDouble(1); 46470 46471 r = pushDoubleSmallJsonG(self, 2); 46472 ck_assert_ptr_ne(r, null); 46473 r = setAtNFreeSmallDoubleSmallJsonG(self, 0, value); 46474 ck_assert_ptr_ne(r, null); 46475 char *s = toStringO(r); 46476 ck_assert_str_eq(s, "[1.000000e+00]"); 46477 free(s); 46478 terminateO(self); 46479 46480 } 46481 46482 46483 void setAtNFreeSmallIntSmallJsonGT(void) { 46484 46485 smallJsont* r; 46486 smallJsont *self = allocSmallJson(); 46487 smallIntt *value = allocSmallInt(1); 46488 46489 r = pushIntSmallJsonG(self, 2); 46490 ck_assert_ptr_ne(r, null); 46491 r = setAtNFreeSmallIntSmallJsonG(self, 0, value); 46492 ck_assert_ptr_ne(r, null); 46493 char *s = toStringO(r); 46494 ck_assert_str_eq(s, "[1]"); 46495 free(s); 46496 terminateO(self); 46497 46498 } 46499 46500 46501 void setAtNFreeSmallJsonSmallJsonGT(void) { 46502 46503 smallJsont* r; 46504 smallJsont *self = allocSmallJson(); 46505 smallJsont *value = allocSmallJson(); 46506 46507 r = pushSmallJsonSmallJsonG(self, value); 46508 ck_assert_ptr_ne(r, null); 46509 finishO(value); 46510 value = allocSmallJson(); 46511 value->f->setInt(value, "a", 1); 46512 r = setAtNFreeSmallJsonSmallJsonG(self, 0, value); 46513 ck_assert_ptr_ne(r, null); 46514 char *s = toStringO(r); 46515 ck_assert_str_eq(s, "[{\"a\":1}]"); 46516 free(s); 46517 terminateO(self); 46518 46519 } 46520 46521 46522 void setAtNFreeSmallStringSmallJsonGT(void) { 46523 46524 smallJsont* r; 46525 smallJsont *self = allocSmallJson(); 46526 smallStringt *string = allocSmallString("qwe"); 46527 46528 r = pushSSmallJsonG(self, "asd"); 46529 ck_assert_ptr_ne(r, null); 46530 r = setAtNFreeSmallStringSmallJsonG(self, 0, string); 46531 ck_assert_ptr_ne(r, null); 46532 char *s = toStringO(r); 46533 ck_assert_str_eq(s, "[\"qwe\"]"); 46534 free(s); 46535 terminateO(self); 46536 46537 } 46538 46539 46540 void setAtNFreeSmallContainerSmallJsonGT(void) { 46541 46542 smallJsont* r; 46543 smallJsont *self = allocSmallJson(); 46544 46545 createSmallContainer(c); 46546 r = pushSmallContainerSmallJsonG(self, &c); 46547 ck_assert_ptr_ne(r, null); 46548 createAllocateSmallContainer(c2); 46549 r = setAtNFreeSmallContainerSmallJsonG(self, 0, c2); 46550 ck_assert_ptr_ne(r, null); 46551 char *s = toStringO(r); 46552 ck_assert_str_eq(s, "[\"<data container>\"]"); 46553 free(s); 46554 terminateO(self); 46555 46556 } 46557 46558 46559 void setPAtDictSmallJsonGT(void) { 46560 46561 smallJsont* r; 46562 smallJsont *self = allocSmallJson(); 46563 smallDictt *dict = allocSmallDict(); 46564 46565 r = pushDictSmallJsonG(self, dict); 46566 ck_assert_ptr_ne(r, null); 46567 finishO(dict); 46568 dict = getAtDictSmallJsonG(self, null, 0); 46569 ck_assert_ptr_ne(dict, null); 46570 dict->f->setInt(dict, "a", 1); 46571 r = setPAtDictSmallJsonG(self, 0, dict); 46572 ck_assert_ptr_ne(r, null); 46573 finishO(dict); 46574 char *s = toStringO(r); 46575 ck_assert_str_eq(s, "[{\"a\":1}]"); 46576 free(s); 46577 terminateO(self); 46578 46579 } 46580 46581 46582 void setPAtArraySmallJsonGT(void) { 46583 46584 smallJsont* r; 46585 smallJsont *self = allocSmallJson(); 46586 smallArrayt *array = allocSmallArray(); 46587 46588 r = pushArraySmallJsonG(self, array); 46589 ck_assert_ptr_ne(r, null); 46590 finishO(array); 46591 array = getAtArraySmallJsonG(self, null, 0); 46592 ck_assert_ptr_ne(array, null); 46593 array->f->pushInt(array, 1); 46594 r = setPAtArraySmallJsonG(self, 0, array); 46595 ck_assert_ptr_ne(r, null); 46596 finishO(array); 46597 char *s = toStringO(r); 46598 ck_assert_str_eq(s, "[[1]]"); 46599 free(s); 46600 terminateO(self); 46601 46602 } 46603 46604 46605 void setPAtSmallJsonSmallJsonGT(void) { 46606 46607 smallJsont* r; 46608 smallJsont *self = allocSmallJson(); 46609 smallJsont *value = allocSmallJson(); 46610 46611 r = pushSmallJsonSmallJsonG(self, value); 46612 ck_assert_ptr_ne(r, null); 46613 finishO(value); 46614 value = getAtSmallJsonSmallJsonG(self, null, 0); 46615 value->f->setInt(value, "a", 1); 46616 r = setPAtSmallJsonSmallJsonG(self, 0, value); 46617 ck_assert_ptr_ne(r, null); 46618 finishO(value); 46619 char *s = toStringO(r); 46620 ck_assert_str_eq(s, "[{\"a\":1}]"); 46621 free(s); 46622 terminateO(self); 46623 46624 } 46625 46626 46627 void setPAtSmallStringSmallJsonGT(void) { 46628 46629 smallJsont* r; 46630 smallJsont *self = allocSmallJson(); 46631 smallStringt *string; 46632 46633 r = pushSSmallJsonG(self, "asd"); 46634 ck_assert_ptr_ne(r, null); 46635 string = getAtSmallStringSmallJsonG(self, null, 0); 46636 setValO(string, "qwe"); 46637 r = setPAtSmallStringSmallJsonG(self, 0, string); 46638 ck_assert_ptr_ne(r, null); 46639 finishO(string); 46640 char *s = toStringO(r); 46641 ck_assert_str_eq(s, "[\"qwe\"]"); 46642 free(s); 46643 terminateO(self); 46644 46645 } 46646 46647 46648 void setPAtNFreeDictSmallJsonGT(void) { 46649 46650 smallJsont* r; 46651 smallJsont *self = allocSmallJson(); 46652 smallDictt *dict = allocSmallDict(); 46653 46654 r = pushDictSmallJsonG(self, dict); 46655 ck_assert_ptr_ne(r, null); 46656 finishO(dict); 46657 dict = getAtDictSmallJsonG(self, null, 0); 46658 ck_assert_ptr_ne(dict, null); 46659 dict->f->setInt(dict, "a", 1); 46660 r = setPAtNFreeDictSmallJsonG(self, 0, dict); 46661 ck_assert_ptr_ne(r, null); 46662 char *s = toStringO(r); 46663 ck_assert_str_eq(s, "[{\"a\":1}]"); 46664 free(s); 46665 terminateO(self); 46666 46667 } 46668 46669 46670 void setPAtNFreeArraySmallJsonGT(void) { 46671 46672 smallJsont* r; 46673 smallJsont *self = allocSmallJson(); 46674 smallArrayt *array = allocSmallArray(); 46675 46676 r = pushArraySmallJsonG(self, array); 46677 ck_assert_ptr_ne(r, null); 46678 finishO(array); 46679 array = getAtArraySmallJsonG(self, null, 0); 46680 ck_assert_ptr_ne(array, null); 46681 array->f->pushInt(array, 1); 46682 r = setPAtNFreeArraySmallJsonG(self, 0, array); 46683 ck_assert_ptr_ne(r, null); 46684 char *s = toStringO(r); 46685 ck_assert_str_eq(s, "[[1]]"); 46686 free(s); 46687 terminateO(self); 46688 46689 } 46690 46691 46692 void setPAtNFreeSmallJsonSmallJsonGT(void) { 46693 46694 smallJsont* r; 46695 smallJsont *self = allocSmallJson(); 46696 smallJsont *value = allocSmallJson(); 46697 46698 r = pushSmallJsonSmallJsonG(self, value); 46699 ck_assert_ptr_ne(r, null); 46700 finishO(value); 46701 value = getAtSmallJsonSmallJsonG(self, null, 0); 46702 value->f->setInt(value, "a", 1); 46703 r = setPAtNFreeSmallJsonSmallJsonG(self, 0, value); 46704 ck_assert_ptr_ne(r, null); 46705 char *s = toStringO(r); 46706 ck_assert_str_eq(s, "[{\"a\":1}]"); 46707 free(s); 46708 terminateO(self); 46709 46710 } 46711 46712 46713 void setPAtNFreeSmallStringSmallJsonGT(void) { 46714 46715 smallJsont* r; 46716 smallJsont *self = allocSmallJson(); 46717 smallStringt *string; 46718 46719 r = pushSSmallJsonG(self, "asd"); 46720 ck_assert_ptr_ne(r, null); 46721 string = getAtSmallStringSmallJsonG(self, null, 0); 46722 setValO(string, "qwe"); 46723 r = setPAtNFreeSmallStringSmallJsonG(self, 0, string); 46724 ck_assert_ptr_ne(r, null); 46725 char *s = toStringO(r); 46726 ck_assert_str_eq(s, "[\"qwe\"]"); 46727 free(s); 46728 terminateO(self); 46729 46730 } 46731 46732 46733 void getSmallJsonGT(void) { 46734 46735 baset* r; 46736 smallJsont *self = allocSmallJson(); 46737 46738 self->f->setInt(self, "1", 2); 46739 r = getSmallJsonG(self, null, "1"); 46740 ck_assert_ptr_ne(r, null); 46741 char *s = toStringO(r); 46742 finishO(r); 46743 ck_assert_str_eq(s, "2"); 46744 free(s); 46745 terminateO(self); 46746 46747 } 46748 46749 46750 void getUndefinedSmallJsonGT(void) { 46751 46752 undefinedt* r; 46753 smallJsont *self = allocSmallJson(); 46754 46755 smallJsont *r2 = self->f->setUndefined(self, "1"); 46756 ck_assert_ptr_ne(r2, null); 46757 r = getUndefinedSmallJsonG(self, null, "1"); 46758 ck_assert_ptr_ne(r, null); 46759 finishO(r); 46760 terminateO(self); 46761 46762 } 46763 46764 46765 void getBoolSmallJsonGT(void) { 46766 46767 bool r; 46768 smallJsont *self = allocSmallJson(); 46769 46770 smallJsont *r2 = self->f->setBool(self, "1", true); 46771 ck_assert_ptr_ne(r2, null); 46772 r = getBoolSmallJsonG(self, false, "1"); 46773 ck_assert(r); 46774 terminateO(self); 46775 46776 } 46777 46778 46779 void getBoolPSmallJsonGT(void) { 46780 46781 bool* r; 46782 smallJsont *self = allocSmallJson(); 46783 46784 smallJsont *r2 = self->f->setBool(self, "1", true); 46785 ck_assert_ptr_ne(r2, null); 46786 r = getBoolPSmallJsonG(self, null, "1"); 46787 ck_assert_ptr_ne(r, null); 46788 ck_assert(*r); 46789 terminateO(self); 46790 46791 } 46792 46793 46794 void getDoubleSmallJsonGT(void) { 46795 46796 double r; 46797 smallJsont *self = allocSmallJson(); 46798 46799 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 46800 ck_assert_ptr_ne(r2, null); 46801 r = getDoubleSmallJsonG(self, 0, "1"); 46802 ck_assert(r == 2.2); 46803 terminateO(self); 46804 46805 } 46806 46807 46808 void getDoublePSmallJsonGT(void) { 46809 46810 double* r; 46811 smallJsont *self = allocSmallJson(); 46812 46813 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 46814 ck_assert_ptr_ne(r2, null); 46815 r = getDoublePSmallJsonG(self, null, "1"); 46816 ck_assert_ptr_ne(r, null); 46817 ck_assert(*r == 2.2); 46818 terminateO(self); 46819 46820 } 46821 46822 46823 void getIntSmallJsonGT(void) { 46824 46825 int64_t r; 46826 smallJsont *self = allocSmallJson(); 46827 46828 smallJsont *r2 = self->f->setInt(self, "1", 2); 46829 ck_assert_ptr_ne(r2, null); 46830 r = getIntSmallJsonG(self, 0, "1"); 46831 ck_assert_int_eq(r, 2); 46832 terminateO(self); 46833 46834 } 46835 46836 46837 void getIntPSmallJsonGT(void) { 46838 46839 int64_t* r; 46840 smallJsont *self = allocSmallJson(); 46841 46842 smallJsont *r2 = self->f->setInt(self, "1", 2); 46843 ck_assert_ptr_ne(r2, null); 46844 r = getIntPSmallJsonG(self, null, "1"); 46845 ck_assert_ptr_ne(r, null); 46846 ck_assert_int_eq(*r, 2); 46847 terminateO(self); 46848 46849 } 46850 46851 46852 void getInt32SmallJsonGT(void) { 46853 46854 int32_t r; 46855 smallJsont *self = allocSmallJson(); 46856 46857 smallJsont *r2 = self->f->setInt(self, "1", 2); 46858 ck_assert_ptr_ne(r2, null); 46859 r = getInt32SmallJsonG(self, 0, "1"); 46860 ck_assert_int_eq(r, 2); 46861 terminateO(self); 46862 46863 } 46864 46865 46866 void getInt32PSmallJsonGT(void) { 46867 46868 int32_t* r; 46869 smallJsont *self = allocSmallJson(); 46870 46871 smallJsont *r2 = self->f->setInt(self, "1", 2); 46872 ck_assert_ptr_ne(r2, null); 46873 r = getInt32PSmallJsonG(self, null, "1"); 46874 ck_assert_ptr_ne(r, null); 46875 ck_assert_int_eq(*r, 2); 46876 terminateO(self); 46877 46878 } 46879 46880 46881 void getUintSmallJsonGT(void) { 46882 46883 uint64_t r; 46884 smallJsont *self = allocSmallJson(); 46885 46886 smallJsont *r2 = self->f->setInt(self, "1", 2); 46887 ck_assert_ptr_ne(r2, null); 46888 r = getUintSmallJsonG(self, 0, "1"); 46889 ck_assert_int_eq(r, 2); 46890 terminateO(self); 46891 46892 } 46893 46894 46895 void getUintPSmallJsonGT(void) { 46896 46897 uint64_t* r; 46898 smallJsont *self = allocSmallJson(); 46899 46900 smallJsont *r2 = self->f->setInt(self, "1", 2); 46901 ck_assert_ptr_ne(r2, null); 46902 r = getUintPSmallJsonG(self, null, "1"); 46903 ck_assert_ptr_ne(r, null); 46904 ck_assert_int_eq(*r, 2); 46905 terminateO(self); 46906 46907 } 46908 46909 46910 void getUint32SmallJsonGT(void) { 46911 46912 uint32_t r; 46913 smallJsont *self = allocSmallJson(); 46914 46915 smallJsont *r2 = self->f->setInt(self, "1", 2); 46916 ck_assert_ptr_ne(r2, null); 46917 r = getUint32SmallJsonG(self, 0, "1"); 46918 ck_assert_int_eq(r, 2); 46919 terminateO(self); 46920 46921 } 46922 46923 46924 void getUint32PSmallJsonGT(void) { 46925 46926 uint32_t* r; 46927 smallJsont *self = allocSmallJson(); 46928 46929 smallJsont *r2 = self->f->setInt(self, "1", 2); 46930 ck_assert_ptr_ne(r2, null); 46931 r = getUint32PSmallJsonG(self, null, "1"); 46932 ck_assert_ptr_ne(r, null); 46933 ck_assert_int_eq(*r, 2); 46934 terminateO(self); 46935 46936 } 46937 46938 46939 void getSSmallJsonGT(void) { 46940 46941 char* r; 46942 smallJsont *self = allocSmallJson(); 46943 46944 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 46945 ck_assert_ptr_ne(r2, null); 46946 r = getSSmallJsonG(self, null, "1"); 46947 ck_assert_ptr_ne(r, null); 46948 ck_assert_str_eq(r, "qwe"); 46949 terminateO(self); 46950 46951 } 46952 46953 46954 void getDictSmallJsonGT(void) { 46955 46956 smallJsont* r2; 46957 smallDictt* r; 46958 smallJsont *self = allocSmallJson(); 46959 smallDictt *dict = allocSmallDict(); 46960 46961 r2 = self->f->setNFreeDict(self, "1", dict); 46962 ck_assert_ptr_ne(r2, null); 46963 r = getDictSmallJsonG(self, null, "1"); 46964 ck_assert_ptr_ne(r, null); 46965 char *s = toStringO(r); 46966 finishO(r); 46967 ck_assert_str_eq(s, "{}"); 46968 free(s); 46969 terminateO(self); 46970 46971 } 46972 46973 46974 void getArraySmallJsonGT(void) { 46975 46976 smallArrayt *r; 46977 smallJsont *self = allocSmallJson(); 46978 smallArrayt *array = allocSmallArray(); 46979 46980 smallJsont *r2 = self->f->setNFreeArray(self, "1", array); 46981 ck_assert_ptr_ne(r2, null); 46982 r = getArraySmallJsonG(self, null, "1"); 46983 ck_assert_ptr_ne(r, null); 46984 char *s = toStringO(r); 46985 finishO(r); 46986 ck_assert_str_eq(s, "[]"); 46987 free(s); 46988 terminateO(self); 46989 46990 } 46991 46992 46993 void getSmallBoolSmallJsonGT(void) { 46994 46995 smallBoolt* r; 46996 smallJsont *self = allocSmallJson(); 46997 46998 smallJsont *r2 = self->f->setBool(self, "1", true); 46999 ck_assert_ptr_ne(r2, null); 47000 r = getSmallBoolSmallJsonG(self, null, "1"); 47001 ck_assert_ptr_ne(r, null); 47002 char *s = toStringO(r); 47003 finishO(r); 47004 ck_assert_str_eq(s, "true"); 47005 free(s); 47006 terminateO(self); 47007 47008 } 47009 47010 47011 void getSmallBytesSmallJsonGT(void) { 47012 47013 smallBytest* r; 47014 smallJsont *self = allocSmallJson(); 47015 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 47016 47017 smallJsont *r2 = self->f->setNFreeSmallBytes(self, "1", value); 47018 ck_assert_ptr_ne(r2, null); 47019 r = getSmallBytesSmallJsonG(self, null, "1"); 47020 ck_assert_ptr_ne(r, null); 47021 char *s = toStringO(r); 47022 finishO(r); 47023 ck_assert_str_eq(s, "[0x71,0x77,0x65,0x00]"); 47024 free(s); 47025 terminateO(self); 47026 47027 } 47028 47029 47030 void getSmallDoubleSmallJsonGT(void) { 47031 47032 smallDoublet* r; 47033 smallJsont *self = allocSmallJson(); 47034 47035 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 47036 ck_assert_ptr_ne(r2, null); 47037 r = getSmallDoubleSmallJsonG(self, null, "1"); 47038 ck_assert_ptr_ne(r, null); 47039 char *s = toStringO(r); 47040 finishO(r); 47041 ck_assert_str_eq(s, "2.200000e+00"); 47042 free(s); 47043 terminateO(self); 47044 47045 } 47046 47047 47048 void getSmallIntSmallJsonGT(void) { 47049 47050 smallIntt* r; 47051 smallJsont *self = allocSmallJson(); 47052 47053 smallJsont *r2 = self->f->setInt(self, "1", 2); 47054 ck_assert_ptr_ne(r2, null); 47055 r = getSmallIntSmallJsonG(self, null, "1"); 47056 ck_assert_ptr_ne(r, null); 47057 char *s = toStringO(r); 47058 finishO(r); 47059 ck_assert_str_eq(s, "2"); 47060 free(s); 47061 terminateO(self); 47062 47063 } 47064 47065 47066 void getSmallJsonSmallJsonGT(void) { 47067 47068 smallJsont* r; 47069 smallJsont *self = allocSmallJson(); 47070 smallJsont *value = allocSmallJson(); 47071 47072 setTopIntO(value, 2); 47073 smallJsont *r2 = self->f->setNFreeSmallJson(self, "1", value); 47074 ck_assert_ptr_ne(r2, null); 47075 r = getSmallJsonSmallJsonG(self, null, "1"); 47076 ck_assert_ptr_ne(r, null); 47077 char *s = toStringO(r); 47078 finishO(r); 47079 ck_assert_str_eq(s, "2"); 47080 free(s); 47081 terminateO(self); 47082 47083 } 47084 47085 47086 void getSmallStringSmallJsonGT(void) { 47087 47088 smallStringt* r; 47089 smallJsont *self = allocSmallJson(); 47090 47091 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 47092 ck_assert_ptr_ne(r2, null); 47093 r = getSmallStringSmallJsonG(self, null, "1"); 47094 ck_assert_ptr_ne(r, null); 47095 char *s = toStringO(r); 47096 finishO(r); 47097 ck_assert_str_eq(s, "qwe"); 47098 free(s); 47099 terminateO(self); 47100 47101 } 47102 47103 47104 void getVoidSmallJsonGT(void) { 47105 47106 void* r; 47107 smallJsont *self = allocSmallJson(); 47108 47109 createSmallContainer(c); 47110 setValO(&c, &r); 47111 smallJsont *r2 = self->f->setSmallContainer(self, "1", &c); 47112 ck_assert_ptr_ne(r2, null); 47113 r = getVoidSmallJsonG(self, null, "1"); 47114 ck_assert_ptr_eq(r, &r); 47115 terminateO(self); 47116 47117 } 47118 47119 47120 void getSmallContainerSmallJsonGT(void) { 47121 47122 smallContainert* r; 47123 smallJsont *self = allocSmallJson(); 47124 47125 createSmallContainer(c); 47126 setValO(&c, &r); 47127 smallJsont *r2 = self->f->setSmallContainer(self, "1", &c); 47128 ck_assert_ptr_ne(r2, null); 47129 r = getSmallContainerSmallJsonG(self, null, "1"); 47130 ck_assert_ptr_ne(r, null); 47131 char *s = toStringO(r); 47132 finishO(r); 47133 ck_assert_str_eq(s, "<data smallContainer>"); 47134 free(s); 47135 terminateO(self); 47136 47137 } 47138 47139 47140 void getNDupSmallJsonGT(void) { 47141 47142 baset* r; 47143 smallJsont *self = allocSmallJson(); 47144 47145 self->f->setInt(self, "1", 2); 47146 r = getNDupSmallJsonG(self, null, "1"); 47147 ck_assert_ptr_ne(r, null); 47148 char *s = toStringO(r); 47149 terminateO(r); 47150 ck_assert_str_eq(s, "2"); 47151 free(s); 47152 terminateO(self); 47153 47154 } 47155 47156 47157 void getNDupUndefinedSmallJsonGT(void) { 47158 47159 undefinedt* r; 47160 smallJsont *self = allocSmallJson(); 47161 47162 smallJsont *r2 = self->f->setUndefined(self, "1"); 47163 ck_assert_ptr_ne(r2, null); 47164 r = getNDupUndefinedSmallJsonG(self, null, "1"); 47165 ck_assert_ptr_ne(r, null); 47166 terminateO(r); 47167 terminateO(self); 47168 47169 } 47170 47171 47172 void getNDupBoolSmallJsonGT(void) { 47173 47174 bool r; 47175 smallJsont *self = allocSmallJson(); 47176 47177 smallJsont *r2 = self->f->setBool(self, "1", true); 47178 ck_assert_ptr_ne(r2, null); 47179 r = getNDupBoolSmallJsonG(self, false, "1"); 47180 ck_assert(r); 47181 terminateO(self); 47182 47183 } 47184 47185 47186 void getNDupDoubleSmallJsonGT(void) { 47187 47188 double r; 47189 smallJsont *self = allocSmallJson(); 47190 47191 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 47192 ck_assert_ptr_ne(r2, null); 47193 r = getNDupDoubleSmallJsonG(self, 0, "1"); 47194 ck_assert(r == 2.2); 47195 terminateO(self); 47196 47197 } 47198 47199 47200 void getNDupIntSmallJsonGT(void) { 47201 47202 int64_t r; 47203 smallJsont *self = allocSmallJson(); 47204 47205 smallJsont *r2 = self->f->setInt(self, "1", 2); 47206 ck_assert_ptr_ne(r2, null); 47207 r = getNDupIntSmallJsonG(self, 0, "1"); 47208 ck_assert_int_eq(r, 2); 47209 terminateO(self); 47210 47211 } 47212 47213 47214 void getNDupInt32SmallJsonGT(void) { 47215 47216 int32_t r; 47217 smallJsont *self = allocSmallJson(); 47218 47219 smallJsont *r2 = self->f->setInt(self, "1", 2); 47220 ck_assert_ptr_ne(r2, null); 47221 r = getNDupInt32SmallJsonG(self, 0, "1"); 47222 ck_assert_int_eq(r, 2); 47223 terminateO(self); 47224 47225 } 47226 47227 47228 void getNDupUintSmallJsonGT(void) { 47229 47230 uint64_t r; 47231 smallJsont *self = allocSmallJson(); 47232 47233 smallJsont *r2 = self->f->setInt(self, "1", 2); 47234 ck_assert_ptr_ne(r2, null); 47235 r = getNDupUintSmallJsonG(self, 0, "1"); 47236 ck_assert_int_eq(r, 2); 47237 terminateO(self); 47238 47239 } 47240 47241 47242 void getNDupUint32SmallJsonGT(void) { 47243 47244 uint32_t r; 47245 smallJsont *self = allocSmallJson(); 47246 47247 smallJsont *r2 = self->f->setInt(self, "1", 2); 47248 ck_assert_ptr_ne(r2, null); 47249 r = getNDupUint32SmallJsonG(self, 0, "1"); 47250 ck_assert_int_eq(r, 2); 47251 terminateO(self); 47252 47253 } 47254 47255 47256 void getNDupSSmallJsonGT(void) { 47257 47258 char* r; 47259 smallJsont *self = allocSmallJson(); 47260 47261 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 47262 ck_assert_ptr_ne(r2, null); 47263 r = getNDupSSmallJsonG(self, null, "1"); 47264 ck_assert_ptr_ne(r, null); 47265 ck_assert_str_eq(r, "qwe"); 47266 free(r); 47267 terminateO(self); 47268 47269 } 47270 47271 47272 void getNDupDictSmallJsonGT(void) { 47273 47274 smallJsont* r2; 47275 smallDictt* r; 47276 smallJsont *self = allocSmallJson(); 47277 smallDictt *dict = allocSmallDict(); 47278 47279 r2 = self->f->setNFreeDict(self, "1", dict); 47280 ck_assert_ptr_ne(r2, null); 47281 r = getNDupDictSmallJsonG(self, null, "1"); 47282 ck_assert_ptr_ne(r, null); 47283 char *s = toStringO(r); 47284 terminateO(r); 47285 ck_assert_str_eq(s, "{}"); 47286 free(s); 47287 terminateO(self); 47288 47289 } 47290 47291 47292 void getNDupArraySmallJsonGT(void) { 47293 47294 smallArrayt* r; 47295 smallJsont *self = allocSmallJson(); 47296 smallArrayt *array = allocSmallArray(); 47297 47298 smallJsont *r2 = self->f->setNFreeArray(self, "1", array); 47299 ck_assert_ptr_ne(r2, null); 47300 r = getNDupArraySmallJsonG(self, null, "1"); 47301 ck_assert_ptr_ne(r, null); 47302 char *s = toStringO(r); 47303 terminateO(r); 47304 ck_assert_str_eq(s, "[]"); 47305 free(s); 47306 terminateO(self); 47307 47308 } 47309 47310 47311 void getNDupSmallBoolSmallJsonGT(void) { 47312 47313 smallBoolt* r; 47314 smallJsont *self = allocSmallJson(); 47315 47316 smallJsont *r2 = self->f->setBool(self, "1", true); 47317 ck_assert_ptr_ne(r2, null); 47318 r = getNDupSmallBoolSmallJsonG(self, null, "1"); 47319 ck_assert_ptr_ne(r, null); 47320 char *s = toStringO(r); 47321 terminateO(r); 47322 ck_assert_str_eq(s, "true"); 47323 free(s); 47324 terminateO(self); 47325 47326 } 47327 47328 47329 void getNDupSmallBytesSmallJsonGT(void) { 47330 47331 smallBytest* r; 47332 smallJsont *self = allocSmallJson(); 47333 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 47334 47335 smallJsont *r2 = self->f->setNFreeSmallBytes(self, "1", value); 47336 ck_assert_ptr_ne(r2, null); 47337 r = getNDupSmallBytesSmallJsonG(self, null, "1"); 47338 ck_assert_ptr_ne(r, null); 47339 char *s = toStringO(r); 47340 terminateO(r); 47341 ck_assert_str_eq(s, "[0x71,0x77,0x65,0x00]"); 47342 free(s); 47343 terminateO(self); 47344 47345 } 47346 47347 47348 void getNDupSmallDoubleSmallJsonGT(void) { 47349 47350 smallDoublet* r; 47351 smallJsont *self = allocSmallJson(); 47352 47353 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 47354 ck_assert_ptr_ne(r2, null); 47355 r = getNDupSmallDoubleSmallJsonG(self, null, "1"); 47356 ck_assert_ptr_ne(r, null); 47357 char *s = toStringO(r); 47358 terminateO(r); 47359 ck_assert_str_eq(s, "2.200000e+00"); 47360 free(s); 47361 terminateO(self); 47362 47363 } 47364 47365 47366 void getNDupSmallIntSmallJsonGT(void) { 47367 47368 smallIntt* r; 47369 smallJsont *self = allocSmallJson(); 47370 47371 smallJsont *r2 = self->f->setInt(self, "1", 2); 47372 ck_assert_ptr_ne(r2, null); 47373 r = getNDupSmallIntSmallJsonG(self, null, "1"); 47374 ck_assert_ptr_ne(r, null); 47375 char *s = toStringO(r); 47376 terminateO(r); 47377 ck_assert_str_eq(s, "2"); 47378 free(s); 47379 terminateO(self); 47380 47381 } 47382 47383 47384 void getNDupSmallJsonSmallJsonGT(void) { 47385 47386 smallJsont* r; 47387 smallJsont *self = allocSmallJson(); 47388 smallJsont *value = allocSmallJson(); 47389 47390 setTopIntO(value, 2); 47391 smallJsont *r2 = self->f->setNFreeSmallJson(self, "1", value); 47392 ck_assert_ptr_ne(r2, null); 47393 r = getNDupSmallJsonSmallJsonG(self, null, "1"); 47394 ck_assert_ptr_ne(r, null); 47395 char *s = toStringO(r); 47396 terminateO(r); 47397 ck_assert_str_eq(s, "2"); 47398 free(s); 47399 terminateO(self); 47400 47401 } 47402 47403 47404 void getNDupSmallStringSmallJsonGT(void) { 47405 47406 smallStringt* r; 47407 smallJsont *self = allocSmallJson(); 47408 47409 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 47410 ck_assert_ptr_ne(r2, null); 47411 r = getNDupSmallStringSmallJsonG(self, null, "1"); 47412 ck_assert_ptr_ne(r, null); 47413 char *s = toStringO(r); 47414 terminateO(r); 47415 ck_assert_str_eq(s, "qwe"); 47416 free(s); 47417 terminateO(self); 47418 47419 } 47420 47421 47422 void getNDupVoidSmallJsonGT(void) { 47423 47424 void* r; 47425 smallJsont *self = allocSmallJson(); 47426 47427 createSmallContainer(c); 47428 setValO(&c, &r); 47429 smallJsont *r2 = self->f->setSmallContainer(self, "1", &c); 47430 ck_assert_ptr_ne(r2, null); 47431 r = getNDupVoidSmallJsonG(self, null, "1"); 47432 ck_assert_ptr_eq(r, null); 47433 terminateO(self); 47434 47435 } 47436 47437 47438 void getNDupSmallContainerSmallJsonGT(void) { 47439 47440 smallContainert* r; 47441 smallJsont *self = allocSmallJson(); 47442 47443 createSmallContainer(c); 47444 setValO(&c, &r); 47445 smallJsont *r2 = self->f->setSmallContainer(self, "1", &c); 47446 ck_assert_ptr_ne(r2, null); 47447 r = getNDupSmallContainerSmallJsonG(self, null, "1"); 47448 ck_assert_ptr_ne(r, null); 47449 char *s = toStringO(r); 47450 terminateO(r); 47451 ck_assert_str_eq(s, "<data smallContainer>"); 47452 free(s); 47453 terminateO(self); 47454 47455 } 47456 47457 47458 void getAtSmallJsonGT(void) { 47459 47460 baset* r; 47461 smallJsont *self = allocSmallJson(); 47462 47463 smallJsont *r2 = self->f->pushInt(self, 1); 47464 ck_assert_ptr_ne(r2, null); 47465 r = getAtSmallJsonG(self, NULL, 0); 47466 ck_assert_ptr_ne(r, null); 47467 char *s = toStringO(r); 47468 finishO(r); 47469 ck_assert_str_eq(s, "1"); 47470 free(s); 47471 terminateO(self); 47472 47473 } 47474 47475 47476 void getAtUndefinedSmallJsonGT(void) { 47477 47478 undefinedt* r; 47479 smallJsont *self = allocSmallJson(); 47480 47481 smallJsont *r2 = self->f->pushUndefined(self); 47482 ck_assert_ptr_ne(r2, null); 47483 r = getAtUndefinedSmallJsonG(self, null, 0); 47484 ck_assert_ptr_ne(r, null); 47485 char *s = toStringO(r); 47486 finishO(r); 47487 ck_assert_str_eq(s, "null"); 47488 free(s); 47489 terminateO(self); 47490 47491 } 47492 47493 47494 void getAtBoolSmallJsonGT(void) { 47495 47496 bool r; 47497 smallJsont *self = allocSmallJson(); 47498 47499 smallJsont *r2 = self->f->pushBool(self, TRUE); 47500 ck_assert_ptr_ne(r2, null); 47501 r = getAtBoolSmallJsonG(self, null, 0); 47502 ck_assert(r); 47503 terminateO(self); 47504 47505 } 47506 47507 47508 void getAtBoolPSmallJsonGT(void) { 47509 47510 bool* r; 47511 smallJsont *self = allocSmallJson(); 47512 47513 smallJsont *r2 = self->f->pushBool(self, TRUE); 47514 ck_assert_ptr_ne(r2, null); 47515 r = getAtBoolPSmallJsonG(self, null, 0); 47516 ck_assert_ptr_ne(r, null); 47517 ck_assert(*r); 47518 terminateO(self); 47519 47520 } 47521 47522 47523 void getAtDoubleSmallJsonGT(void) { 47524 47525 double r; 47526 smallJsont *self = allocSmallJson(); 47527 47528 smallJsont *r2 = self->f->pushDouble(self, 2.0); 47529 ck_assert_ptr_ne(r2, null); 47530 r = getAtDoubleSmallJsonG(self, 0, 0); 47531 ck_assert(r==2.0); 47532 terminateO(self); 47533 47534 } 47535 47536 47537 void getAtDoublePSmallJsonGT(void) { 47538 47539 double* r; 47540 smallJsont *self = allocSmallJson(); 47541 47542 smallJsont *r2 = self->f->pushDouble(self, 2.0); 47543 ck_assert_ptr_ne(r2, null); 47544 r = getAtDoublePSmallJsonG(self, 0, 0); 47545 ck_assert_ptr_ne(r, null); 47546 ck_assert(*r==2.0); 47547 terminateO(self); 47548 47549 } 47550 47551 47552 void getAtIntSmallJsonGT(void) { 47553 47554 int64_t r; 47555 smallJsont *self = allocSmallJson(); 47556 47557 smallJsont *r2 = self->f->pushInt(self, 2); 47558 ck_assert_ptr_ne(r2, null); 47559 r = getAtIntSmallJsonG(self, 0, 0); 47560 ck_assert_int_eq(r, 2); 47561 terminateO(self); 47562 47563 } 47564 47565 47566 void getAtIntPSmallJsonGT(void) { 47567 47568 int64_t* r; 47569 smallJsont *self = allocSmallJson(); 47570 47571 smallJsont *r2 = self->f->pushInt(self, 2); 47572 ck_assert_ptr_ne(r2, null); 47573 r = getAtIntPSmallJsonG(self, 0, 0); 47574 ck_assert_ptr_ne(r, null); 47575 ck_assert_int_eq(*r, 2); 47576 terminateO(self); 47577 47578 } 47579 47580 47581 void getAtInt32SmallJsonGT(void) { 47582 47583 int32_t r; 47584 smallJsont *self = allocSmallJson(); 47585 47586 smallJsont *r2 = self->f->pushInt(self, 2); 47587 ck_assert_ptr_ne(r2, null); 47588 r = getAtInt32SmallJsonG(self, 0, 0); 47589 ck_assert_int_eq(r, 2); 47590 terminateO(self); 47591 47592 } 47593 47594 47595 void getAtInt32PSmallJsonGT(void) { 47596 47597 int32_t* r; 47598 smallJsont *self = allocSmallJson(); 47599 47600 smallJsont *r2 = self->f->pushInt(self, 2); 47601 ck_assert_ptr_ne(r2, null); 47602 r = getAtInt32PSmallJsonG(self, 0, 0); 47603 ck_assert_ptr_ne(r, null); 47604 ck_assert_int_eq(*r, 2); 47605 terminateO(self); 47606 47607 } 47608 47609 47610 void getAtUintSmallJsonGT(void) { 47611 47612 uint64_t r; 47613 smallJsont *self = allocSmallJson(); 47614 47615 smallJsont *r2 = self->f->pushInt(self, 2); 47616 ck_assert_ptr_ne(r2, null); 47617 r = getAtUintSmallJsonG(self, 0, 0); 47618 ck_assert_int_eq(r, 2); 47619 terminateO(self); 47620 47621 } 47622 47623 47624 void getAtUintPSmallJsonGT(void) { 47625 47626 uint64_t* r; 47627 smallJsont *self = allocSmallJson(); 47628 47629 smallJsont *r2 = self->f->pushInt(self, 2); 47630 ck_assert_ptr_ne(r2, null); 47631 r = getAtUintPSmallJsonG(self, 0, 0); 47632 ck_assert_ptr_ne(r, null); 47633 ck_assert_int_eq(*r, 2); 47634 terminateO(self); 47635 47636 } 47637 47638 47639 void getAtUint32SmallJsonGT(void) { 47640 47641 uint32_t r; 47642 smallJsont *self = allocSmallJson(); 47643 47644 smallJsont *r2 = self->f->pushInt(self, 2); 47645 ck_assert_ptr_ne(r2, null); 47646 r = getAtUint32SmallJsonG(self, 0, 0); 47647 ck_assert_int_eq(r, 2); 47648 terminateO(self); 47649 47650 } 47651 47652 47653 void getAtUint32PSmallJsonGT(void) { 47654 47655 uint32_t* r; 47656 smallJsont *self = allocSmallJson(); 47657 47658 smallJsont *r2 = self->f->pushInt(self, 2); 47659 ck_assert_ptr_ne(r2, null); 47660 r = getAtUint32PSmallJsonG(self, 0, 0); 47661 ck_assert_ptr_ne(r, null); 47662 ck_assert_int_eq(*r, 2); 47663 terminateO(self); 47664 47665 } 47666 47667 47668 void getAtSSmallJsonGT(void) { 47669 47670 char* r; 47671 smallJsont *self = allocSmallJson(); 47672 47673 smallJsont *r2 = self->f->pushS(self, "2"); 47674 ck_assert_ptr_ne(r2, null); 47675 r = getAtSSmallJsonG(self, null, 0); 47676 ck_assert_str_eq(r, "2"); 47677 terminateO(self); 47678 47679 } 47680 47681 47682 void getAtDictSmallJsonGT(void) { 47683 47684 smallDictt* r; 47685 smallJsont *self = allocSmallJson(); 47686 47687 createSmallDict(d); 47688 smallJsont *r2 = self->f->pushDict(self, &d); 47689 ck_assert_ptr_ne(r2, null); 47690 r = getAtDictSmallJsonG(self, null, 0); 47691 ck_assert_ptr_ne(r, null); 47692 char *s = toStringO(r); 47693 ck_assert_str_eq(s, "{}"); 47694 free(s); 47695 finishO(r); 47696 terminateO(self); 47697 47698 } 47699 47700 47701 void getAtArraySmallJsonGT(void) { 47702 47703 smallArrayt* r; 47704 smallJsont *self = allocSmallJson(); 47705 47706 createSmallArray(a); 47707 smallJsont *r2 = self->f->pushArray(self, &a); 47708 ck_assert_ptr_ne(r2, null); 47709 r = getAtArraySmallJsonG(self, null, 0); 47710 ck_assert_ptr_ne(r, null); 47711 char *s = toStringO(r); 47712 ck_assert_str_eq(s, "[]"); 47713 free(s); 47714 finishO(r); 47715 terminateO(self); 47716 47717 } 47718 47719 47720 void getAtSmallBoolSmallJsonGT(void) { 47721 47722 smallBoolt* r; 47723 smallJsont *self = allocSmallJson(); 47724 47725 smallJsont *r2 = self->f->pushBool(self, true); 47726 ck_assert_ptr_ne(r2, null); 47727 r = getAtSmallBoolSmallJsonG(self, null, 0); 47728 ck_assert_ptr_ne(r, null); 47729 char *s = toStringO(r); 47730 ck_assert_str_eq(s, "true"); 47731 free(s); 47732 finishO(r); 47733 terminateO(self); 47734 47735 } 47736 47737 47738 void getAtSmallBytesSmallJsonGT(void) { 47739 47740 smallBytest* r; 47741 smallJsont *self = allocSmallJson(); 47742 47743 createSmallBytes(b); 47744 smallJsont *r2 = self->f->pushSmallBytes(self, &b); 47745 ck_assert_ptr_ne(r2, null); 47746 r = getAtSmallBytesSmallJsonG(self, null, 0); 47747 ck_assert_ptr_ne(r, null); 47748 char *s = toStringO(r); 47749 ck_assert_str_eq(s, "[]"); 47750 free(s); 47751 finishO(r); 47752 terminateO(self); 47753 47754 } 47755 47756 47757 void getAtSmallDoubleSmallJsonGT(void) { 47758 47759 smallDoublet* r; 47760 smallJsont *self = allocSmallJson(); 47761 47762 smallJsont *r2 = self->f->pushDouble(self, 1); 47763 ck_assert_ptr_ne(r2, null); 47764 r = getAtSmallDoubleSmallJsonG(self, null, 0); 47765 ck_assert_ptr_ne(r, null); 47766 char *s = toStringO(r); 47767 ck_assert_str_eq(s, "1.000000e+00"); 47768 free(s); 47769 finishO(r); 47770 terminateO(self); 47771 47772 } 47773 47774 47775 void getAtSmallIntSmallJsonGT(void) { 47776 47777 smallIntt* r; 47778 smallJsont *self = allocSmallJson(); 47779 47780 smallJsont *r2 = self->f->pushInt(self, 1); 47781 ck_assert_ptr_ne(r2, null); 47782 r = getAtSmallIntSmallJsonG(self, null, 0); 47783 ck_assert_ptr_ne(r, null); 47784 char *s = toStringO(r); 47785 ck_assert_str_eq(s, "1"); 47786 free(s); 47787 finishO(r); 47788 terminateO(self); 47789 47790 } 47791 47792 47793 void getAtSmallJsonSmallJsonGT(void) { 47794 47795 smallJsont* r; 47796 smallJsont *self = allocSmallJson(); 47797 47798 createSmallJson(j); 47799 smallJsont *r2 = self->f->pushSmallJson(self, &j); 47800 ck_assert_ptr_ne(r2, null); 47801 r = getAtSmallJsonSmallJsonG(self, null, 0); 47802 ck_assert_ptr_ne(r, null); 47803 char *s = toStringO(r); 47804 ck_assert_str_eq(s, "{}"); 47805 free(s); 47806 finishO(r); 47807 terminateO(self); 47808 47809 } 47810 47811 47812 void getAtSmallStringSmallJsonGT(void) { 47813 47814 smallStringt* r; 47815 smallJsont *self = allocSmallJson(); 47816 47817 createSmallString(S); 47818 smallJsont *r2 = self->f->pushSmallString(self, &S); 47819 ck_assert_ptr_ne(r2, null); 47820 r = getAtSmallStringSmallJsonG(self, null, 0); 47821 ck_assert_ptr_ne(r, null); 47822 char *s = toStringO(r); 47823 ck_assert_str_eq(s, ""); 47824 free(s); 47825 finishO(r); 47826 terminateO(self); 47827 47828 } 47829 47830 47831 void getAtVoidSmallJsonGT(void) { 47832 47833 void* r; 47834 smallJsont *self = allocSmallJson(); 47835 47836 createSmallContainer(c); 47837 setValO(&c, &r); 47838 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 47839 ck_assert_ptr_ne(r2, null); 47840 r = getAtVoidSmallJsonG(self, null, 0); 47841 ck_assert_ptr_eq(r, &r); 47842 terminateO(self); 47843 47844 } 47845 47846 47847 void getAtSmallContainerSmallJsonGT(void) { 47848 47849 smallContainert* r; 47850 smallJsont *self = allocSmallJson(); 47851 47852 createSmallContainer(c); 47853 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 47854 ck_assert_ptr_ne(r2, null); 47855 r = getAtSmallContainerSmallJsonG(self, null, 0); 47856 ck_assert_ptr_ne(r, null); 47857 char *s = toStringO(r); 47858 ck_assert_str_eq(s, "<data smallContainer>"); 47859 free(s); 47860 finishO(r); 47861 terminateO(self); 47862 47863 } 47864 47865 47866 void getAtNDupSmallJsonGT(void) { 47867 47868 baset* r; 47869 smallJsont *self = allocSmallJson(); 47870 47871 smallJsont *r2 = self->f->pushInt(self, 1); 47872 ck_assert_ptr_ne(r2, null); 47873 r = getAtNDupSmallJsonG(self, NULL, 0); 47874 ck_assert_ptr_ne(r, null); 47875 char *s = toStringO(r); 47876 terminateO(r); 47877 ck_assert_str_eq(s, "1"); 47878 free(s); 47879 terminateO(self); 47880 47881 } 47882 47883 47884 void getAtNDupUndefinedSmallJsonGT(void) { 47885 47886 undefinedt* r; 47887 smallJsont *self = allocSmallJson(); 47888 47889 smallJsont *r2 = self->f->pushUndefined(self); 47890 ck_assert_ptr_ne(r2, null); 47891 r = getAtNDupUndefinedSmallJsonG(self, null, 0); 47892 ck_assert_ptr_ne(r, null); 47893 char *s = toStringO(r); 47894 terminateO(r); 47895 ck_assert_str_eq(s, "null"); 47896 free(s); 47897 terminateO(self); 47898 47899 } 47900 47901 47902 void getAtNDupBoolSmallJsonGT(void) { 47903 47904 bool r; 47905 smallJsont *self = allocSmallJson(); 47906 47907 smallJsont *r2 = self->f->pushBool(self, TRUE); 47908 ck_assert_ptr_ne(r2, null); 47909 r = getAtNDupBoolSmallJsonG(self, null, 0); 47910 ck_assert(r); 47911 terminateO(self); 47912 47913 } 47914 47915 47916 void getAtNDupDoubleSmallJsonGT(void) { 47917 47918 double r; 47919 smallJsont *self = allocSmallJson(); 47920 47921 smallJsont *r2 = self->f->pushDouble(self, 2.0); 47922 ck_assert_ptr_ne(r2, null); 47923 r = getAtNDupDoubleSmallJsonG(self, 0, 0); 47924 ck_assert(r==2.0); 47925 terminateO(self); 47926 47927 } 47928 47929 47930 void getAtNDupIntSmallJsonGT(void) { 47931 47932 int64_t r; 47933 smallJsont *self = allocSmallJson(); 47934 47935 smallJsont *r2 = self->f->pushInt(self, 2); 47936 ck_assert_ptr_ne(r2, null); 47937 r = getAtNDupIntSmallJsonG(self, 0, 0); 47938 ck_assert_int_eq(r, 2); 47939 terminateO(self); 47940 47941 } 47942 47943 47944 void getAtNDupInt32SmallJsonGT(void) { 47945 47946 int32_t r; 47947 smallJsont *self = allocSmallJson(); 47948 47949 smallJsont *r2 = self->f->pushInt(self, 2); 47950 ck_assert_ptr_ne(r2, null); 47951 r = getAtNDupInt32SmallJsonG(self, 0, 0); 47952 ck_assert_int_eq(r, 2); 47953 terminateO(self); 47954 47955 } 47956 47957 47958 void getAtNDupUintSmallJsonGT(void) { 47959 47960 uint64_t r; 47961 smallJsont *self = allocSmallJson(); 47962 47963 smallJsont *r2 = self->f->pushInt(self, 2); 47964 ck_assert_ptr_ne(r2, null); 47965 r = getAtNDupUintSmallJsonG(self, 0, 0); 47966 ck_assert_int_eq(r, 2); 47967 terminateO(self); 47968 47969 } 47970 47971 47972 void getAtNDupUint32SmallJsonGT(void) { 47973 47974 uint32_t r; 47975 smallJsont *self = allocSmallJson(); 47976 47977 smallJsont *r2 = self->f->pushInt(self, 2); 47978 ck_assert_ptr_ne(r2, null); 47979 r = getAtNDupUint32SmallJsonG(self, 0, 0); 47980 ck_assert_int_eq(r, 2); 47981 terminateO(self); 47982 47983 } 47984 47985 47986 void getAtNDupSSmallJsonGT(void) { 47987 47988 char* r; 47989 smallJsont *self = allocSmallJson(); 47990 47991 smallJsont *r2 = self->f->pushS(self, "2"); 47992 ck_assert_ptr_ne(r2, null); 47993 r = getAtNDupSSmallJsonG(self, null, 0); 47994 ck_assert_str_eq(r, "2"); 47995 free(r); 47996 terminateO(self); 47997 47998 } 47999 48000 48001 void getAtNDupDictSmallJsonGT(void) { 48002 48003 smallDictt* r; 48004 smallJsont *self = allocSmallJson(); 48005 48006 createSmallDict(d); 48007 smallJsont *r2 = self->f->pushDict(self, &d); 48008 ck_assert_ptr_ne(r2, null); 48009 r = getAtNDupDictSmallJsonG(self, null, 0); 48010 ck_assert_ptr_ne(r, null); 48011 char *s = toStringO(r); 48012 ck_assert_str_eq(s, "{}"); 48013 free(s); 48014 terminateO(r); 48015 terminateO(self); 48016 48017 } 48018 48019 48020 void getAtNDupArraySmallJsonGT(void) { 48021 48022 smallArrayt* r; 48023 smallJsont *self = allocSmallJson(); 48024 48025 createSmallArray(a); 48026 smallJsont *r2 = self->f->pushArray(self, &a); 48027 ck_assert_ptr_ne(r2, null); 48028 r = getAtNDupArraySmallJsonG(self, null, 0); 48029 ck_assert_ptr_ne(r, null); 48030 char *s = toStringO(r); 48031 ck_assert_str_eq(s, "[]"); 48032 free(s); 48033 terminateO(r); 48034 terminateO(self); 48035 48036 } 48037 48038 48039 void getAtNDupSmallBoolSmallJsonGT(void) { 48040 48041 smallBoolt* r; 48042 smallJsont *self = allocSmallJson(); 48043 48044 smallJsont *r2 = self->f->pushBool(self, true); 48045 ck_assert_ptr_ne(r2, null); 48046 r = getAtNDupSmallBoolSmallJsonG(self, null, 0); 48047 ck_assert_ptr_ne(r, null); 48048 char *s = toStringO(r); 48049 ck_assert_str_eq(s, "true"); 48050 free(s); 48051 terminateO(r); 48052 terminateO(self); 48053 48054 } 48055 48056 48057 void getAtNDupSmallBytesSmallJsonGT(void) { 48058 48059 smallBytest* r; 48060 smallJsont *self = allocSmallJson(); 48061 48062 createSmallBytes(b); 48063 smallJsont *r2 = self->f->pushSmallBytes(self, &b); 48064 ck_assert_ptr_ne(r2, null); 48065 r = getAtNDupSmallBytesSmallJsonG(self, null, 0); 48066 ck_assert_ptr_ne(r, null); 48067 char *s = toStringO(r); 48068 ck_assert_str_eq(s, "[]"); 48069 free(s); 48070 terminateO(r); 48071 terminateO(self); 48072 48073 } 48074 48075 48076 void getAtNDupSmallDoubleSmallJsonGT(void) { 48077 48078 smallDoublet* r; 48079 smallJsont *self = allocSmallJson(); 48080 48081 smallJsont *r2 = self->f->pushDouble(self, 1); 48082 ck_assert_ptr_ne(r2, null); 48083 r = getAtNDupSmallDoubleSmallJsonG(self, null, 0); 48084 ck_assert_ptr_ne(r, null); 48085 char *s = toStringO(r); 48086 ck_assert_str_eq(s, "1.000000e+00"); 48087 free(s); 48088 terminateO(r); 48089 terminateO(self); 48090 48091 } 48092 48093 48094 void getAtNDupSmallIntSmallJsonGT(void) { 48095 48096 smallIntt* r; 48097 smallJsont *self = allocSmallJson(); 48098 48099 smallJsont *r2 = self->f->pushInt(self, 1); 48100 ck_assert_ptr_ne(r2, null); 48101 r = getAtNDupSmallIntSmallJsonG(self, null, 0); 48102 ck_assert_ptr_ne(r, null); 48103 char *s = toStringO(r); 48104 ck_assert_str_eq(s, "1"); 48105 free(s); 48106 terminateO(r); 48107 terminateO(self); 48108 48109 } 48110 48111 48112 void getAtNDupSmallJsonSmallJsonGT(void) { 48113 48114 smallJsont* r; 48115 smallJsont *self = allocSmallJson(); 48116 48117 createSmallJson(j); 48118 smallJsont *r2 = self->f->pushSmallJson(self, &j); 48119 ck_assert_ptr_ne(r2, null); 48120 r = getAtNDupSmallJsonSmallJsonG(self, null, 0); 48121 ck_assert_ptr_ne(r, null); 48122 char *s = toStringO(r); 48123 ck_assert_str_eq(s, "{}"); 48124 free(s); 48125 terminateO(r); 48126 terminateO(self); 48127 48128 } 48129 48130 48131 void getAtNDupSmallStringSmallJsonGT(void) { 48132 48133 smallStringt* r; 48134 smallJsont *self = allocSmallJson(); 48135 48136 createSmallString(S); 48137 smallJsont *r2 = self->f->pushSmallString(self, &S); 48138 ck_assert_ptr_ne(r2, null); 48139 r = getAtNDupSmallStringSmallJsonG(self, null, 0); 48140 ck_assert_ptr_ne(r, null); 48141 char *s = toStringO(r); 48142 ck_assert_str_eq(s, ""); 48143 free(s); 48144 terminateO(r); 48145 terminateO(self); 48146 48147 } 48148 48149 48150 void getAtNDupVoidSmallJsonGT(void) { 48151 48152 void* r; 48153 smallJsont *self = allocSmallJson(); 48154 48155 createSmallContainer(c); 48156 setValO(&c, &r); 48157 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 48158 ck_assert_ptr_ne(r2, null); 48159 r = getAtNDupVoidSmallJsonG(self, null, 0); 48160 ck_assert_ptr_eq(r, NULL); 48161 terminateO(self); 48162 48163 } 48164 48165 48166 void getAtNDupSmallContainerSmallJsonGT(void) { 48167 48168 smallContainert* r; 48169 smallJsont *self = allocSmallJson(); 48170 48171 createSmallContainer(c); 48172 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 48173 ck_assert_ptr_ne(r2, null); 48174 r = getAtNDupSmallContainerSmallJsonG(self, null, 0); 48175 ck_assert_ptr_ne(r, null); 48176 char *s = toStringO(r); 48177 ck_assert_str_eq(s, "<data smallContainer>"); 48178 free(s); 48179 terminateO(r); 48180 terminateO(self); 48181 48182 } 48183 48184 48185 void getNumSmallJsonGT(void) { 48186 48187 double r; 48188 smallJsont *self = allocSmallJson(); 48189 smallJsont *r2; 48190 48191 r2 = self->f->setInt(self, "1", 1); 48192 ck_assert_ptr_ne(r2, null); 48193 r2 = self->f->setDouble(self, "2", 2.2); 48194 ck_assert_ptr_ne(r2, null); 48195 r2 = self->f->setS(self, "3", "2"); 48196 ck_assert_ptr_ne(r2, null); 48197 r = getNumSmallJsonG(self, "1"); 48198 ck_assert(r == 1); 48199 r = getNumSmallJsonG(self, "2"); 48200 ck_assert(r == 2.2); 48201 terminateO(self); 48202 48203 } 48204 48205 48206 void getNumAtSmallJsonGT(void) { 48207 48208 double r; 48209 smallJsont *self = allocSmallJson(); 48210 smallJsont *r2; 48211 48212 r2 = self->f->pushDouble(self, 1); 48213 ck_assert_ptr_ne(r2, NULL); 48214 r = getNumAtSmallJsonG(self, 0); 48215 ck_assert(r==1); 48216 terminateO(self); 48217 48218 } 48219 48220 48221 void delKeySmallJsonGT(void) { 48222 48223 smallJsont* r; 48224 smallJsont *self = allocG(rtSmallJsont); 48225 48226 r = self->f->setInt(self, "1", 1); 48227 ck_assert_ptr_ne(r, null); 48228 r = self->f->setDouble(self, "2", 2.2); 48229 ck_assert_ptr_ne(r, null); 48230 r = delKeySmallJsonG(self, "2", 0); 48231 ck_assert_ptr_ne(r, null); 48232 char *s = toStringO(r); 48233 ck_assert_str_eq(s, "{\"1\":1}"); 48234 free(s); 48235 terminateO(self); 48236 48237 } 48238 48239 48240 void delSmallJsonGT(void) { 48241 48242 smallJsont* r; 48243 smallJsont *self = allocSmallJson(); 48244 48245 r = self->f->pushInt(self, 1); 48246 ck_assert_ptr_ne(r, null); 48247 r = self->f->pushInt(self, 2); 48248 ck_assert_ptr_ne(r, null); 48249 r = self->f->pushInt(self, 3); 48250 ck_assert_ptr_ne(r, null); 48251 r = self->f->pushInt(self, 4); 48252 ck_assert_ptr_ne(r, null); 48253 r = delSmallJsonG(self, 1, -1); 48254 ck_assert_ptr_ne(r, null); 48255 char *s = toStringO(r); 48256 ck_assert_str_eq(s, "[1,4]"); 48257 free(s); 48258 terminateO(self); 48259 48260 } 48261 48262 48263 void delElemSmallJsonGT(void) { 48264 48265 smallJsont* r; 48266 smallJsont *self = allocG(rtSmallJsont); 48267 48268 r = self->f->setInt(self, "1", 1); 48269 ck_assert_ptr_ne(r, null); 48270 r = self->f->setDouble(self, "2", 2.2); 48271 ck_assert_ptr_ne(r, null); 48272 r = delElemSmallJsonG(self, "2"); 48273 ck_assert_ptr_ne(r, null); 48274 char *s = toStringO(r); 48275 ck_assert_str_eq(s, "{\"1\":1}"); 48276 free(s); 48277 terminateO(self); 48278 48279 } 48280 48281 48282 void delElemIndexSmallJsonGT(void) { 48283 48284 smallJsont* r; 48285 smallJsont *self = allocSmallJson(); 48286 48287 r = self->f->pushInt(self, 1); 48288 ck_assert_ptr_ne(r, null); 48289 r = self->f->pushInt(self, 2); 48290 ck_assert_ptr_ne(r, null); 48291 r = self->f->pushInt(self, 3); 48292 ck_assert_ptr_ne(r, null); 48293 r = self->f->pushInt(self, 4); 48294 ck_assert_ptr_ne(r, null); 48295 r = delElemIndexSmallJsonG(self, 0); 48296 ck_assert_ptr_ne(r, null); 48297 char *s = toStringO(r); 48298 ck_assert_str_eq(s, "[2,3,4]"); 48299 free(s); 48300 r = delElemIndexSmallJsonG(self, -1); 48301 ck_assert_ptr_ne(r, null); 48302 s = toStringO(r); 48303 ck_assert_str_eq(s, "[2,3]"); 48304 free(s); 48305 r = delElemIndexSmallJsonG(self, 5); 48306 ck_assert_ptr_eq(r, null); 48307 r = delElemIndexSmallJsonG(self, -5); 48308 ck_assert_ptr_eq(r, null); 48309 terminateO(self); 48310 48311 } 48312 48313 48314 void prependSmallJsonGT(void) { 48315 48316 smallJsont* r; 48317 smallJsont *self = allocSmallJson(); 48318 baset *value = (baset*) allocSmallInt(1); 48319 48320 r = prependSmallJsonG(self, value); 48321 ck_assert_ptr_ne(r, null); 48322 finishO(value); 48323 char *s = toStringO(r); 48324 ck_assert_str_eq(s, "[1]"); 48325 free(s); 48326 terminateO(self); 48327 48328 } 48329 48330 48331 void prependUndefinedSmallJsonGT(void) { 48332 48333 smallJsont* r; 48334 smallJsont *self = allocSmallJson(); 48335 48336 r = prependUndefinedSmallJsonG(self, NULL); 48337 ck_assert_ptr_ne(r, null); 48338 char *s = toStringO(r); 48339 ck_assert_str_eq(s, "[null]"); 48340 free(s); 48341 terminateO(self); 48342 48343 } 48344 48345 48346 void prependBoolSmallJsonGT(void) { 48347 48348 smallJsont* r; 48349 smallJsont *self = allocSmallJson(); 48350 48351 r = prependBoolSmallJsonG(self, true); 48352 ck_assert_ptr_ne(r, null); 48353 char *s = toStringO(r); 48354 ck_assert_str_eq(s, "[true]"); 48355 free(s); 48356 terminateO(self); 48357 48358 } 48359 48360 48361 void prependDoubleSmallJsonGT(void) { 48362 48363 smallJsont* r; 48364 smallJsont *self = allocSmallJson(); 48365 48366 r = prependDoubleSmallJsonG(self, 1); 48367 ck_assert_ptr_ne(r, null); 48368 char *s = toStringO(r); 48369 ck_assert_str_eq(s, "[1.000000e+00]"); 48370 free(s); 48371 terminateO(self); 48372 48373 } 48374 48375 48376 void prependIntSmallJsonGT(void) { 48377 48378 smallJsont* r; 48379 smallJsont *self = allocSmallJson(); 48380 48381 r = prependIntSmallJsonG(self, 1); 48382 ck_assert_ptr_ne(r, null); 48383 char *s = toStringO(r); 48384 ck_assert_str_eq(s, "[1]"); 48385 free(s); 48386 terminateO(self); 48387 48388 } 48389 48390 48391 void prependSSmallJsonGT(void) { 48392 48393 smallJsont* r; 48394 smallJsont *self = allocSmallJson(); 48395 48396 r = prependSSmallJsonG(self, "qwe"); 48397 ck_assert_ptr_ne(r, null); 48398 char *s = toStringO(r); 48399 ck_assert_str_eq(s, "[\"qwe\"]"); 48400 free(s); 48401 terminateO(self); 48402 48403 } 48404 48405 48406 void prependCharSmallJsonGT(void) { 48407 48408 smallJsont* r; 48409 smallJsont *self = allocSmallJson(); 48410 48411 r = prependCharSmallJsonG(self, 'Q'); 48412 ck_assert_ptr_ne(r, null); 48413 char *s = toStringO(r); 48414 ck_assert_str_eq(s, "[\"Q\"]"); 48415 free(s); 48416 terminateO(self); 48417 48418 } 48419 48420 48421 void prependDictSmallJsonGT(void) { 48422 48423 smallJsont* r; 48424 smallJsont *self = allocSmallJson(); 48425 smallDictt *dict = allocSmallDict(); 48426 48427 r = prependDictSmallJsonG(self, dict); 48428 ck_assert_ptr_ne(r, null); 48429 finishO(dict); 48430 char *s = toStringO(r); 48431 ck_assert_str_eq(s, "[{}]"); 48432 free(s); 48433 terminateO(self); 48434 48435 } 48436 48437 48438 void prependArraySmallJsonGT(void) { 48439 48440 smallJsont* r; 48441 smallJsont *self = allocSmallJson(); 48442 smallArrayt *array = allocSmallArray(); 48443 48444 r = prependArraySmallJsonG(self, array); 48445 ck_assert_ptr_ne(r, null); 48446 finishO(array); 48447 char *s = toStringO(r); 48448 ck_assert_str_eq(s, "[[]]"); 48449 free(s); 48450 terminateO(self); 48451 48452 } 48453 48454 48455 void prependArraycSmallJsonGT(void) { 48456 48457 smallJsont* r; 48458 smallJsont *self = allocSmallJson(); 48459 char **array = listCreateS("a","bb"); 48460 48461 r = prependArraycSmallJsonG(self, array); 48462 ck_assert_ptr_ne(r, null); 48463 ck_assert_int_eq(lenO(r), 1); 48464 listFreeS(array); 48465 char *s = toStringO(r); 48466 ck_assert_str_eq(s, "[[\"a\",\"bb\"]]"); 48467 free(s); 48468 terminateO(self); 48469 48470 } 48471 48472 48473 void prependCArraycSmallJsonGT(void) { 48474 48475 smallJsont* r; 48476 smallJsont *self = allocSmallJson(); 48477 const char *array[] = {"a", "bb", NULL}; 48478 48479 r = prependCArraycSmallJsonG(self, array); 48480 ck_assert_ptr_ne(r, null); 48481 ck_assert_int_eq(lenO(r), 1); 48482 char *s = toStringO(r); 48483 ck_assert_str_eq(s, "[[\"a\",\"bb\"]]"); 48484 free(s); 48485 terminateO(self); 48486 48487 } 48488 48489 48490 void prependVoidSmallJsonGT(void) { 48491 48492 smallJsont* r; 48493 smallJsont *self = allocSmallJson(); 48494 48495 // NULL value 48496 r = prependVoidSmallJsonG(self, NULL); 48497 ck_assert_ptr_ne(r, null); 48498 char *s = toStringO(r); 48499 ck_assert_str_eq(s, "[null]"); 48500 free(s); 48501 // value 48502 r = prependVoidSmallJsonG(self, r); 48503 s = toStringO(r); 48504 ck_assert_str_eq(s, "[\"<data container>\",null]"); 48505 free(s); 48506 terminateO(self); 48507 48508 } 48509 48510 48511 void prependSmallBoolSmallJsonGT(void) { 48512 48513 smallJsont* r; 48514 smallJsont *self = allocSmallJson(); 48515 smallBoolt *value = allocSmallBool(true); 48516 48517 r = prependSmallBoolSmallJsonG(self, value); 48518 ck_assert_ptr_ne(r, null); 48519 finishO(value); 48520 char *s = toStringO(r); 48521 ck_assert_str_eq(s, "[true]"); 48522 free(s); 48523 terminateO(self); 48524 48525 } 48526 48527 48528 void prependSmallBytesSmallJsonGT(void) { 48529 48530 smallJsont* r; 48531 smallJsont *self = allocSmallJson(); 48532 smallBytest *value = allocSmallBytes("qwe", 3); 48533 48534 r = prependSmallBytesSmallJsonG(self, value); 48535 ck_assert_ptr_ne(r, null); 48536 finishO(value); 48537 char *s = toStringO(r); 48538 ck_assert_str_eq(s, "[[0x71,0x77,0x65]]"); 48539 free(s); 48540 terminateO(self); 48541 48542 } 48543 48544 48545 void prependSmallDoubleSmallJsonGT(void) { 48546 48547 smallJsont* r; 48548 smallJsont *self = allocSmallJson(); 48549 smallDoublet *value = allocSmallDouble(1); 48550 48551 r = prependSmallDoubleSmallJsonG(self, value); 48552 ck_assert_ptr_ne(r, null); 48553 finishO(value); 48554 char *s = toStringO(r); 48555 ck_assert_str_eq(s, "[1.000000e+00]"); 48556 free(s); 48557 terminateO(self); 48558 48559 } 48560 48561 48562 void prependSmallIntSmallJsonGT(void) { 48563 48564 smallJsont* r; 48565 smallJsont *self = allocSmallJson(); 48566 smallIntt *value = allocSmallInt(1); 48567 48568 r = prependSmallIntSmallJsonG(self, value); 48569 ck_assert_ptr_ne(r, null); 48570 finishO(value); 48571 char *s = toStringO(r); 48572 ck_assert_str_eq(s, "[1]"); 48573 free(s); 48574 terminateO(self); 48575 48576 } 48577 48578 48579 void prependSmallJsonSmallJsonGT(void) { 48580 48581 smallJsont* r; 48582 smallJsont *self = allocSmallJson(); 48583 smallJsont *value = allocSmallJson(); 48584 48585 r = prependSmallJsonSmallJsonG(self, value); 48586 ck_assert_ptr_ne(r, null); 48587 finishO(value); 48588 char *s = toStringO(r); 48589 ck_assert_str_eq(s, "[{}]"); 48590 free(s); 48591 terminateO(self); 48592 48593 } 48594 48595 48596 void prependSmallStringSmallJsonGT(void) { 48597 48598 smallJsont* r; 48599 smallJsont *self = allocSmallJson(); 48600 smallStringt *string = allocSmallString("qwe"); 48601 48602 r = prependSmallStringSmallJsonG(self, string); 48603 ck_assert_ptr_ne(r, null); 48604 finishO(string); 48605 char *s = toStringO(r); 48606 ck_assert_str_eq(s, "[\"qwe\"]"); 48607 free(s); 48608 terminateO(self); 48609 48610 } 48611 48612 48613 void prependSmallContainerSmallJsonGT(void) { 48614 48615 smallJsont* r; 48616 smallJsont *self = allocSmallJson(); 48617 48618 createSmallContainer(c); 48619 r = prependSmallContainerSmallJsonG(self, &c); 48620 ck_assert_ptr_ne(r, null); 48621 char *s = toStringO(r); 48622 ck_assert_str_eq(s, "[\"<data container>\"]"); 48623 free(s); 48624 terminateO(self); 48625 48626 } 48627 48628 48629 void prependNFreeSmallJsonGT(void) { 48630 48631 smallJsont* r; 48632 smallJsont *self = allocSmallJson(); 48633 baset *value = (baset*) allocSmallInt(1); 48634 48635 r = prependNFreeSmallJsonG(self, value); 48636 ck_assert_ptr_ne(r, null); 48637 char *s = toStringO(r); 48638 ck_assert_str_eq(s, "[1]"); 48639 free(s); 48640 terminateO(self); 48641 48642 } 48643 48644 48645 void prependNFreeUndefinedSmallJsonGT(void) { 48646 48647 smallJsont* r; 48648 smallJsont *self = allocSmallJson(); 48649 undefinedt *value = allocUndefined(); 48650 48651 r = prependNFreeUndefinedSmallJsonG(self, value); 48652 ck_assert_ptr_ne(r, null); 48653 char *s = toStringO(r); 48654 ck_assert_str_eq(s, "[null]"); 48655 free(s); 48656 terminateO(self); 48657 48658 } 48659 48660 48661 void prependNFreeSSmallJsonGT(void) { 48662 48663 smallJsont* r; 48664 smallJsont *self = allocSmallJson(); 48665 48666 r = prependNFreeSSmallJsonG(self, strdup("qwe")); 48667 ck_assert_ptr_ne(r, null); 48668 char *s = toStringO(r); 48669 ck_assert_str_eq(s, "[\"qwe\"]"); 48670 free(s); 48671 terminateO(self); 48672 48673 } 48674 48675 48676 void prependNFreeDictSmallJsonGT(void) { 48677 48678 smallJsont* r; 48679 smallJsont *self = allocSmallJson(); 48680 smallDictt *dict = allocSmallDict(); 48681 48682 r = prependNFreeDictSmallJsonG(self, dict); 48683 ck_assert_ptr_ne(r, null); 48684 char *s = toStringO(r); 48685 ck_assert_str_eq(s, "[{}]"); 48686 free(s); 48687 terminateO(self); 48688 48689 } 48690 48691 48692 void prependNFreeArraySmallJsonGT(void) { 48693 48694 smallJsont* r; 48695 smallJsont *self = allocSmallJson(); 48696 smallArrayt *array = allocSmallArray(); 48697 48698 r = prependNFreeArraySmallJsonG(self, array); 48699 ck_assert_ptr_ne(r, null); 48700 char *s = toStringO(r); 48701 ck_assert_str_eq(s, "[[]]"); 48702 free(s); 48703 terminateO(self); 48704 48705 } 48706 48707 48708 void prependNFreeArraycSmallJsonGT(void) { 48709 48710 smallJsont* r; 48711 smallJsont *self = allocSmallJson(); 48712 char **array = listCreateS("a","bb"); 48713 48714 r = prependNFreeArraycSmallJsonG(self, array); 48715 ck_assert_ptr_ne(r, null); 48716 ck_assert_int_eq(lenO(r), 1); 48717 char *s = toStringO(r); 48718 ck_assert_str_eq(s, "[[\"a\",\"bb\"]]"); 48719 free(s); 48720 terminateO(self); 48721 48722 } 48723 48724 48725 void prependNFreeSmallBoolSmallJsonGT(void) { 48726 48727 smallJsont* r; 48728 smallJsont *self = allocSmallJson(); 48729 smallBoolt *value = allocSmallBool(true); 48730 48731 r = prependNFreeSmallBoolSmallJsonG(self, value); 48732 ck_assert_ptr_ne(r, null); 48733 char *s = toStringO(r); 48734 ck_assert_str_eq(s, "[true]"); 48735 free(s); 48736 terminateO(self); 48737 48738 } 48739 48740 48741 void prependNFreeSmallBytesSmallJsonGT(void) { 48742 48743 smallJsont* r; 48744 smallJsont *self = allocSmallJson(); 48745 smallBytest *value = allocSmallBytes("qwe", 3); 48746 48747 r = prependNFreeSmallBytesSmallJsonG(self, value); 48748 ck_assert_ptr_ne(r, null); 48749 char *s = toStringO(r); 48750 ck_assert_str_eq(s, "[[0x71,0x77,0x65]]"); 48751 free(s); 48752 terminateO(self); 48753 48754 } 48755 48756 48757 void prependNFreeSmallDoubleSmallJsonGT(void) { 48758 48759 smallJsont* r; 48760 smallJsont *self = allocSmallJson(); 48761 smallDoublet *value = allocSmallDouble(1); 48762 48763 r = prependNFreeSmallDoubleSmallJsonG(self, value); 48764 ck_assert_ptr_ne(r, null); 48765 char *s = toStringO(r); 48766 ck_assert_str_eq(s, "[1.000000e+00]"); 48767 free(s); 48768 terminateO(self); 48769 48770 } 48771 48772 48773 void prependNFreeSmallIntSmallJsonGT(void) { 48774 48775 smallJsont* r; 48776 smallJsont *self = allocSmallJson(); 48777 smallIntt *value = allocSmallInt(1); 48778 48779 r = prependNFreeSmallIntSmallJsonG(self, value); 48780 ck_assert_ptr_ne(r, null); 48781 char *s = toStringO(r); 48782 ck_assert_str_eq(s, "[1]"); 48783 free(s); 48784 terminateO(self); 48785 48786 } 48787 48788 48789 void prependNFreeSmallJsonSmallJsonGT(void) { 48790 48791 smallJsont* r; 48792 smallJsont *self = allocSmallJson(); 48793 smallJsont *value = allocSmallJson(); 48794 48795 r = prependNFreeSmallJsonSmallJsonG(self, value); 48796 ck_assert_ptr_ne(r, null); 48797 char *s = toStringO(r); 48798 ck_assert_str_eq(s, "[{}]"); 48799 free(s); 48800 terminateO(self); 48801 48802 } 48803 48804 48805 void prependNFreeSmallStringSmallJsonGT(void) { 48806 48807 smallJsont* r; 48808 smallJsont *self = allocSmallJson(); 48809 smallStringt *string = allocSmallString("qwe"); 48810 48811 r = prependNFreeSmallStringSmallJsonG(self, string); 48812 ck_assert_ptr_ne(r, null); 48813 char *s = toStringO(r); 48814 ck_assert_str_eq(s, "[\"qwe\"]"); 48815 free(s); 48816 terminateO(self); 48817 48818 } 48819 48820 48821 void prependNFreeSmallContainerSmallJsonGT(void) { 48822 48823 smallJsont* r; 48824 smallJsont *self = allocSmallJson(); 48825 48826 createAllocateSmallContainer(c); 48827 r = prependNFreeSmallContainerSmallJsonG(self, c); 48828 ck_assert_ptr_ne(r, null); 48829 char *s = toStringO(r); 48830 ck_assert_str_eq(s, "[\"<data container>\"]"); 48831 free(s); 48832 terminateO(self); 48833 48834 } 48835 48836 48837 void dequeueSmallJsonGT(void) { 48838 48839 baset* r; 48840 smallJsont *self = allocSmallJson(); 48841 48842 smallJsont *r2 = self->f->pushInt(self, 1); 48843 ck_assert_ptr_ne(r2, null); 48844 r = dequeueSmallJsonG(self, NULL); 48845 ck_assert_ptr_ne(r, null); 48846 char *s = toStringO(r); 48847 terminateO(r); 48848 ck_assert_str_eq(s, "1"); 48849 free(s); 48850 terminateO(self); 48851 48852 } 48853 48854 48855 void dequeueUndefinedSmallJsonGT(void) { 48856 48857 undefinedt* r; 48858 smallJsont *self = allocSmallJson(); 48859 48860 smallJsont *r2 = self->f->pushUndefined(self); 48861 ck_assert_ptr_ne(r2, null); 48862 r = dequeueUndefinedSmallJsonG(self, null); 48863 ck_assert_ptr_ne(r, null); 48864 char *s = toStringO(r); 48865 terminateO(r); 48866 ck_assert_str_eq(s, "null"); 48867 free(s); 48868 terminateO(self); 48869 48870 } 48871 48872 48873 void dequeueBoolSmallJsonGT(void) { 48874 48875 bool r; 48876 smallJsont *self = allocSmallJson(); 48877 48878 smallJsont *r2 = self->f->pushBool(self, TRUE); 48879 ck_assert_ptr_ne(r2, null); 48880 r = dequeueBoolSmallJsonG(self, null); 48881 ck_assert(r); 48882 terminateO(self); 48883 48884 } 48885 48886 48887 void dequeueDoubleSmallJsonGT(void) { 48888 48889 double r; 48890 smallJsont *self = allocSmallJson(); 48891 48892 smallJsont *r2 = self->f->pushDouble(self, 2.0); 48893 ck_assert_ptr_ne(r2, null); 48894 r = dequeueDoubleSmallJsonG(self, 0); 48895 ck_assert(r==2.0); 48896 terminateO(self); 48897 48898 } 48899 48900 48901 void dequeueIntSmallJsonGT(void) { 48902 48903 int64_t r; 48904 smallJsont *self = allocSmallJson(); 48905 48906 smallJsont *r2 = self->f->pushInt(self, 2); 48907 ck_assert_ptr_ne(r2, null); 48908 r = dequeueIntSmallJsonG(self, 0); 48909 ck_assert_int_eq(r, 2); 48910 terminateO(self); 48911 48912 } 48913 48914 48915 void dequeueInt32SmallJsonGT(void) { 48916 48917 int32_t r; 48918 smallJsont *self = allocSmallJson(); 48919 48920 smallJsont *r2 = self->f->pushInt(self, 2); 48921 ck_assert_ptr_ne(r2, null); 48922 r = dequeueInt32SmallJsonG(self, 0); 48923 ck_assert_int_eq(r, 2); 48924 terminateO(self); 48925 48926 } 48927 48928 48929 void dequeueUintSmallJsonGT(void) { 48930 48931 uint64_t r; 48932 smallJsont *self = allocSmallJson(); 48933 48934 smallJsont *r2 = self->f->pushInt(self, 2); 48935 ck_assert_ptr_ne(r2, null); 48936 r = dequeueUintSmallJsonG(self, 0); 48937 ck_assert_int_eq(r, 2); 48938 terminateO(self); 48939 48940 } 48941 48942 48943 void dequeueUint32SmallJsonGT(void) { 48944 48945 uint32_t r; 48946 smallJsont *self = allocSmallJson(); 48947 48948 smallJsont *r2 = self->f->pushInt(self, 2); 48949 ck_assert_ptr_ne(r2, null); 48950 r = dequeueUint32SmallJsonG(self, 0); 48951 ck_assert_int_eq(r, 2); 48952 terminateO(self); 48953 48954 } 48955 48956 48957 void dequeueSSmallJsonGT(void) { 48958 48959 char* r; 48960 smallJsont *self = allocSmallJson(); 48961 48962 smallJsont *r2 = self->f->pushS(self, "2"); 48963 ck_assert_ptr_ne(r2, null); 48964 r = dequeueSSmallJsonG(self, null); 48965 ck_assert_str_eq(r, "2"); 48966 free(r); 48967 terminateO(self); 48968 48969 } 48970 48971 48972 void dequeueDictSmallJsonGT(void) { 48973 48974 smallDictt* r; 48975 smallJsont *self = allocSmallJson(); 48976 48977 createSmallDict(d); 48978 smallJsont *r2 = self->f->pushDict(self, &d); 48979 ck_assert_ptr_ne(r2, null); 48980 r = dequeueDictSmallJsonG(self, null); 48981 ck_assert_ptr_ne(r, null); 48982 char *s = toStringO(r); 48983 ck_assert_str_eq(s, "{}"); 48984 free(s); 48985 terminateO(r); 48986 terminateO(self); 48987 48988 } 48989 48990 48991 void dequeueArraySmallJsonGT(void) { 48992 48993 smallArrayt* r; 48994 smallJsont *self = allocSmallJson(); 48995 48996 createSmallArray(a); 48997 smallJsont *r2 = self->f->pushArray(self, &a); 48998 ck_assert_ptr_ne(r2, null); 48999 r = dequeueArraySmallJsonG(self, null); 49000 ck_assert_ptr_ne(r, null); 49001 char *s = toStringO(r); 49002 ck_assert_str_eq(s, "[]"); 49003 free(s); 49004 terminateO(r); 49005 terminateO(self); 49006 49007 } 49008 49009 49010 void dequeueSmallBoolSmallJsonGT(void) { 49011 49012 smallBoolt* r; 49013 smallJsont *self = allocSmallJson(); 49014 49015 smallJsont *r2 = self->f->pushBool(self, true); 49016 ck_assert_ptr_ne(r2, null); 49017 r = dequeueSmallBoolSmallJsonG(self, null); 49018 ck_assert_ptr_ne(r, null); 49019 char *s = toStringO(r); 49020 ck_assert_str_eq(s, "true"); 49021 free(s); 49022 terminateO(r); 49023 terminateO(self); 49024 49025 } 49026 49027 49028 void dequeueSmallBytesSmallJsonGT(void) { 49029 49030 smallBytest* r; 49031 smallJsont *self = allocSmallJson(); 49032 49033 createSmallBytes(b); 49034 smallJsont *r2 = self->f->pushSmallBytes(self, &b); 49035 ck_assert_ptr_ne(r2, null); 49036 r = dequeueSmallBytesSmallJsonG(self, null); 49037 ck_assert_ptr_ne(r, null); 49038 char *s = toStringO(r); 49039 ck_assert_str_eq(s, "[]"); 49040 free(s); 49041 terminateO(r); 49042 terminateO(self); 49043 49044 } 49045 49046 49047 void dequeueSmallDoubleSmallJsonGT(void) { 49048 49049 smallDoublet* r; 49050 smallJsont *self = allocSmallJson(); 49051 49052 smallJsont *r2 = self->f->pushDouble(self, 1); 49053 ck_assert_ptr_ne(r2, null); 49054 r = dequeueSmallDoubleSmallJsonG(self, null); 49055 ck_assert_ptr_ne(r, null); 49056 char *s = toStringO(r); 49057 ck_assert_str_eq(s, "1.000000e+00"); 49058 free(s); 49059 terminateO(r); 49060 terminateO(self); 49061 49062 } 49063 49064 49065 void dequeueSmallIntSmallJsonGT(void) { 49066 49067 smallIntt* r; 49068 smallJsont *self = allocSmallJson(); 49069 49070 smallJsont *r2 = self->f->pushInt(self, 1); 49071 ck_assert_ptr_ne(r2, null); 49072 r = dequeueSmallIntSmallJsonG(self, null); 49073 ck_assert_ptr_ne(r, null); 49074 char *s = toStringO(r); 49075 ck_assert_str_eq(s, "1"); 49076 free(s); 49077 terminateO(r); 49078 terminateO(self); 49079 49080 } 49081 49082 49083 void dequeueSmallJsonSmallJsonGT(void) { 49084 49085 smallJsont* r; 49086 smallJsont *self = allocSmallJson(); 49087 49088 createSmallJson(j); 49089 smallJsont *r2 = self->f->pushSmallJson(self, &j); 49090 ck_assert_ptr_ne(r2, null); 49091 r = dequeueSmallJsonSmallJsonG(self, null); 49092 ck_assert_ptr_ne(r, null); 49093 char *s = toStringO(r); 49094 ck_assert_str_eq(s, "{}"); 49095 free(s); 49096 terminateO(r); 49097 terminateO(self); 49098 49099 } 49100 49101 49102 void dequeueSmallStringSmallJsonGT(void) { 49103 49104 smallStringt* r; 49105 smallJsont *self = allocSmallJson(); 49106 49107 createSmallString(S); 49108 smallJsont *r2 = self->f->pushSmallString(self, &S); 49109 ck_assert_ptr_ne(r2, null); 49110 r = dequeueSmallStringSmallJsonG(self, null); 49111 ck_assert_ptr_ne(r, null); 49112 char *s = toStringO(r); 49113 ck_assert_str_eq(s, ""); 49114 free(s); 49115 terminateO(r); 49116 terminateO(self); 49117 49118 } 49119 49120 49121 void dequeueVoidSmallJsonGT(void) { 49122 49123 void* r; 49124 smallJsont *self = allocSmallJson(); 49125 49126 createSmallContainer(c); 49127 setValO(&c, &r); 49128 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 49129 ck_assert_ptr_ne(r2, null); 49130 r = dequeueVoidSmallJsonG(self, null); 49131 ck_assert_ptr_eq(r, &r); 49132 terminateO(self); 49133 49134 } 49135 49136 49137 void dequeueSmallContainerSmallJsonGT(void) { 49138 49139 smallContainert* r; 49140 smallJsont *self = allocSmallJson(); 49141 49142 createSmallContainer(c); 49143 smallJsont *r2 = self->f->pushSmallContainer(self, &c); 49144 ck_assert_ptr_ne(r2, null); 49145 r = dequeueSmallContainerSmallJsonG(self, null); 49146 ck_assert_ptr_ne(r, null); 49147 char *s = toStringO(r); 49148 ck_assert_str_eq(s, "<data smallContainer>"); 49149 free(s); 49150 terminateO(r); 49151 terminateO(self); 49152 49153 } 49154 49155 49156 void reverseSmallJsonGT(void) { 49157 49158 smallJsont* r; 49159 smallJsont *self = allocSmallJson(); 49160 49161 self->f->pushInt(self, 1); 49162 self->f->pushInt(self, 2); 49163 r = reverseSmallJsonG(self); 49164 ck_assert_ptr_ne(r, NULL); 49165 char *s = toStringO(r); 49166 ck_assert_str_eq(s, "[2,1]"); 49167 free(s); 49168 terminateO(self); 49169 49170 } 49171 49172 49173 void mergeDictSmallJsonGT(void) { 49174 49175 smallJsont* r; 49176 smallJsont *self = allocG(rtSmallJsont); 49177 smallDictt *value = allocSmallDict(); 49178 49179 self->f->setS(self, "1", "2"); 49180 self->f->setS(self, "3", "4"); 49181 value->f->setS(value, "3", "#"); 49182 value->f->setInt(value, "4", 0); 49183 r = mergeDictSmallJsonG(self, value); 49184 ck_assert_ptr_ne(r, null); 49185 char *s = toStringO(r); 49186 ck_assert_str_eq(s, "{\"1\":\"2\",\"3\":\"#\",\"4\":0}"); 49187 free(s); 49188 smashO(value); 49189 terminateO(self); 49190 49191 } 49192 49193 49194 void mergeDictNSmashSmallJsonGT(void) { 49195 49196 smallJsont* r; 49197 smallJsont *self = allocG(rtSmallJsont); 49198 smallDictt *value = allocSmallDict(); 49199 49200 self->f->setS(self, "1", "2"); 49201 self->f->setS(self, "3", "4"); 49202 value->f->setS(value, "3", "#"); 49203 value->f->setInt(value, "4", 0); 49204 r = mergeDictNSmashSmallJsonG(self, value); 49205 ck_assert_ptr_ne(r, null); 49206 char *s = toStringO(r); 49207 ck_assert_str_eq(s, "{\"1\":\"2\",\"3\":\"#\",\"4\":0}"); 49208 free(s); 49209 terminateO(self); 49210 49211 } 49212 49213 49214 void mergeSmallJsonGT(void) { 49215 49216 smallJsont* r; 49217 smallJsont *self = allocSmallJson(); 49218 smallJsont *json = allocSmallJson(); 49219 49220 r = self->f->pushInt(self, 1); 49221 ck_assert_ptr_ne(r, null); 49222 json->f->pushInt(json, 1); 49223 json->f->pushInt(json, 2); 49224 r = mergeSmallJsonG(self, json); 49225 ck_assert_ptr_ne(r, NULL); 49226 smashO(json); 49227 char *s = toStringO(r); 49228 ck_assert_str_eq(s, "[1,1,2]"); 49229 free(s); 49230 terminateO(self); 49231 49232 } 49233 49234 49235 void mergeNSmashSmallJsonGT(void) { 49236 49237 smallJsont* r; 49238 smallJsont *self = allocSmallJson(); 49239 smallJsont *json = allocSmallJson(); 49240 49241 r = self->f->pushInt(self, 1); 49242 ck_assert_ptr_ne(r, null); 49243 json->f->pushInt(json, 1); 49244 json->f->pushInt(json, 2); 49245 r = mergeNSmashSmallJsonG(self, json); 49246 ck_assert_ptr_ne(r, NULL); 49247 char *s = toStringO(r); 49248 ck_assert_str_eq(s, "[1,1,2]"); 49249 free(s); 49250 terminateO(self); 49251 49252 } 49253 49254 49255 void appendSmallJsonGT(void) { 49256 49257 smallJsont* r; 49258 smallJsont *self = allocSmallJson(); 49259 smallArrayt *array = allocSmallArray(); 49260 49261 r = self->f->pushInt(self, 1); 49262 ck_assert_ptr_ne(r, null); 49263 array->f->pushInt(array, 1); 49264 array->f->pushInt(array, 2); 49265 r = appendSmallJsonG(self, array); 49266 ck_assert_ptr_ne(r, NULL); 49267 smashO(array); 49268 char *s = toStringO(r); 49269 ck_assert_str_eq(s, "[1,1,2]"); 49270 free(s); 49271 terminateO(self); 49272 49273 } 49274 49275 49276 void appendNSmashSmallJsonGT(void) { 49277 49278 smallJsont* r; 49279 smallJsont *self = allocSmallJson(); 49280 smallArrayt *array = allocSmallArray(); 49281 49282 r = self->f->pushInt(self, 1); 49283 ck_assert_ptr_ne(r, null); 49284 array->f->pushInt(array, 1); 49285 array->f->pushInt(array, 2); 49286 r = appendNSmashSmallJsonG(self, array); 49287 ck_assert_ptr_ne(r, NULL); 49288 char *s = toStringO(r); 49289 ck_assert_str_eq(s, "[1,1,2]"); 49290 free(s); 49291 terminateO(self); 49292 49293 } 49294 49295 49296 void appendArraySmallJsonGT(void) { 49297 49298 smallJsont* r; 49299 smallJsont *self = allocSmallJson(); 49300 char **array = listCreateS("1", "2"); 49301 49302 r = self->f->pushInt(self, 1); 49303 ck_assert_ptr_ne(r, null); 49304 r = appendArraySmallJsonG(self, array); 49305 ck_assert_ptr_ne(r, NULL); 49306 listFreeS(array); 49307 char *s = toStringO(r); 49308 ck_assert_str_eq(s, "[1,\"1\",\"2\"]"); 49309 free(s); 49310 terminateO(self); 49311 49312 } 49313 49314 49315 void appendNSmashArraySmallJsonGT(void) { 49316 49317 smallJsont* r; 49318 smallJsont *self = allocSmallJson(); 49319 char **array = listCreateS("1", "2"); 49320 49321 r = self->f->pushInt(self, 1); 49322 ck_assert_ptr_ne(r, null); 49323 r = appendNSmashArraySmallJsonG(self, array); 49324 ck_assert_ptr_ne(r, NULL); 49325 char *s = toStringO(r); 49326 ck_assert_str_eq(s, "[1,\"1\",\"2\"]"); 49327 free(s); 49328 terminateO(self); 49329 49330 } 49331 49332 49333 void appendCArraySmallJsonGT(void) { 49334 49335 smallJsont* r; 49336 smallJsont *self = allocSmallJson(); 49337 const char *array[] = {"1", "2", null}; 49338 49339 r = self->f->pushInt(self, 1); 49340 ck_assert_ptr_ne(r, null); 49341 r = appendCArraySmallJsonG(self, array); 49342 ck_assert_ptr_ne(r, NULL); 49343 char *s = toStringO(r); 49344 ck_assert_str_eq(s, "[1,\"1\",\"2\"]"); 49345 free(s); 49346 terminateO(self); 49347 49348 } 49349 49350 49351 void shiftSmallJsonGT(void) { 49352 49353 smallJsont* r; 49354 smallJsont *self = allocSmallJson(); 49355 smallArrayt *array = allocSmallArray(); 49356 49357 r = self->f->pushInt(self, 1); 49358 ck_assert_ptr_ne(r, null); 49359 array->f->pushInt(array, 1); 49360 array->f->pushInt(array, 2); 49361 r = shiftSmallJsonG(self, array); 49362 ck_assert_ptr_ne(r, NULL); 49363 smashO(array); 49364 char *s = toStringO(r); 49365 ck_assert_str_eq(s, "[1,2,1]"); 49366 free(s); 49367 terminateO(self); 49368 49369 } 49370 49371 49372 void shiftNSmashSmallJsonGT(void) { 49373 49374 smallJsont* r; 49375 smallJsont *self = allocSmallJson(); 49376 smallArrayt *array = allocSmallArray(); 49377 49378 r = self->f->pushInt(self, 1); 49379 ck_assert_ptr_ne(r, null); 49380 array->f->pushInt(array, 1); 49381 array->f->pushInt(array, 2); 49382 r = shiftNSmashSmallJsonG(self, array); 49383 ck_assert_ptr_ne(r, NULL); 49384 char *s = toStringO(r); 49385 ck_assert_str_eq(s, "[1,2,1]"); 49386 free(s); 49387 terminateO(self); 49388 49389 } 49390 49391 49392 void shiftSmallJsonSmallJsonGT(void) { 49393 49394 smallJsont* r; 49395 smallJsont *self = allocSmallJson(); 49396 smallJsont *json = allocSmallJson(); 49397 49398 r = self->f->pushInt(self, 1); 49399 ck_assert_ptr_ne(r, null); 49400 json->f->pushInt(json, 1); 49401 json->f->pushInt(json, 2); 49402 r = shiftSmallJsonSmallJsonG(self, json); 49403 ck_assert_ptr_ne(r, NULL); 49404 smashO(json); 49405 char *s = toStringO(r); 49406 ck_assert_str_eq(s, "[1,2,1]"); 49407 free(s); 49408 terminateO(self); 49409 49410 } 49411 49412 49413 void shiftNSmashSmallJsonSmallJsonGT(void) { 49414 49415 smallJsont* r; 49416 smallJsont *self = allocSmallJson(); 49417 smallJsont *json = allocSmallJson(); 49418 49419 r = self->f->pushInt(self, 1); 49420 ck_assert_ptr_ne(r, null); 49421 json->f->pushInt(json, 1); 49422 json->f->pushInt(json, 2); 49423 r = shiftNSmashSmallJsonSmallJsonG(self, json); 49424 ck_assert_ptr_ne(r, NULL); 49425 char *s = toStringO(r); 49426 ck_assert_str_eq(s, "[1,2,1]"); 49427 free(s); 49428 terminateO(self); 49429 49430 } 49431 49432 49433 void addSmallJsonGT(void) { 49434 49435 smallJsont* r; 49436 smallJsont *self = allocSmallJson(); 49437 createAllocateSmallArray(a); 49438 49439 // add an element to check that the second array is added 49440 // at the end 49441 r = self->f->pushInt(self, 1); 49442 ck_assert_ptr_ne(r, null); 49443 49444 // add array 49445 a->f->pushInt(a, 2); 49446 r = addSmallJsonG(self, a); 49447 smashO(a); 49448 ck_assert_ptr_ne(r, null); 49449 char *s = toStringO(r); 49450 terminateO(r); 49451 ck_assert_str_eq(s, "[1,2]"); 49452 free(s); 49453 terminateO(self); 49454 49455 } 49456 49457 49458 void addJsonSmallJsonGT(void) { 49459 49460 smallJsont* r; 49461 smallJsont *self = allocG(rtSmallJsont); 49462 smallJsont *a = allocSmallJson(); 49463 49464 // add an element to check that the second array is added 49465 // at the end 49466 r = self->f->pushInt(self, 1); 49467 ck_assert_ptr_ne(r, null); 49468 49469 // add array 49470 a->f->pushInt(a, 2); 49471 r = addJsonSmallJsonG(self, a); 49472 smashO(a); 49473 ck_assert_ptr_ne(r, null); 49474 char *s = toStringO(r); 49475 terminateO(r); 49476 ck_assert_str_eq(s, "[1,2]"); 49477 free(s); 49478 terminateO(self); 49479 49480 } 49481 49482 49483 void sliceSmallJsonGT(void) { 49484 49485 smallJsont* r; 49486 smallJsont *self = allocSmallJson(); 49487 49488 r = self->f->pushInt(self, 1); 49489 ck_assert_ptr_ne(r, null); 49490 r = self->f->pushInt(self, 2); 49491 ck_assert_ptr_ne(r, null); 49492 r = self->f->pushInt(self, 3); 49493 ck_assert_ptr_ne(r, null); 49494 r = self->f->pushInt(self, 4); 49495 ck_assert_ptr_ne(r, null); 49496 r = sliceSmallJsonG(self, 1, -1); 49497 ck_assert_ptr_ne(r, null); 49498 char *s = toStringO(r); 49499 ck_assert_str_eq(s, "[2,3]"); 49500 free(s); 49501 terminateO(self); 49502 49503 } 49504 49505 49506 void cropSmallJsonGT(void) { 49507 49508 smallJsont* r; 49509 smallJsont *self = allocSmallJson(); 49510 49511 r = self->f->pushInt(self, 1); 49512 ck_assert_ptr_ne(r, null); 49513 r = self->f->pushInt(self, 2); 49514 ck_assert_ptr_ne(r, null); 49515 r = self->f->pushInt(self, 3); 49516 ck_assert_ptr_ne(r, null); 49517 r = self->f->pushInt(self, 4); 49518 ck_assert_ptr_ne(r, null); 49519 r = cropSmallJsonG(self, 1, -1); 49520 ck_assert_ptr_ne(r, null); 49521 char *s = toStringO(r); 49522 terminateO(r); 49523 ck_assert_str_eq(s, "[2,3]"); 49524 free(s); 49525 s = toStringO(self); 49526 ck_assert_str_eq(s, "[1,4]"); 49527 free(s); 49528 terminateO(self); 49529 49530 } 49531 49532 49533 void cropSSmallJsonGT(void) { 49534 49535 char* s; 49536 smallJsont *self = allocG(rtSmallJsont); 49537 49538 setTopSO(self, "sheepy"); 49539 s = cropSSmallJsonG(self, 0,2); 49540 ck_assert_str_eq(s, "sh"); 49541 ck_assert_str_eq(sjGet(self), "eepy"); 49542 free(s); 49543 terminateO(self); 49544 49545 } 49546 49547 49548 void cropSmallStringSmallJsonGT(void) { 49549 49550 smallStringt* r; 49551 smallJsont *self = allocG(rtSmallJsont); 49552 49553 setTopSO(self, "sheepy"); 49554 r = cropSmallStringSmallJsonG(self, 0,2); 49555 ck_assert_ptr_ne(r, null); 49556 ck_assert_str_eq(ssGet(r), "sh"); 49557 ck_assert_str_eq(sjGet(self), "eepy"); 49558 terminateO(r); 49559 terminateO(self); 49560 49561 } 49562 49563 49564 void cropElemAtSmallJsonGT(void) { 49565 49566 baset* r; 49567 smallJsont *self = allocSmallJson(); 49568 49569 smallJsont *r2 = self->f->pushInt(self, 1); 49570 ck_assert_ptr_ne(r2, null); 49571 r = cropElemAtSmallJsonG(self, 0); 49572 ck_assert_ptr_ne(r, null); 49573 char *s = toStringO(r); 49574 terminateO(r); 49575 ck_assert_str_eq(s, "1"); 49576 free(s); 49577 terminateO(self); 49578 49579 } 49580 49581 49582 void cropElemAtUndefinedSmallJsonGT(void) { 49583 49584 undefinedt* r; 49585 smallJsont *self = allocSmallJson(); 49586 49587 smallJsont *r2 = self->f->pushUndefined(self); 49588 ck_assert_ptr_ne(r2, null); 49589 r = cropElemAtUndefinedSmallJsonG(self, 0); 49590 ck_assert_ptr_ne(r, null); 49591 char *s = toStringO(r); 49592 terminateO(r); 49593 ck_assert_str_eq(s, "null"); 49594 free(s); 49595 terminateO(self); 49596 49597 } 49598 49599 49600 void cropElemAtBoolSmallJsonGT(void) { 49601 49602 bool r; 49603 smallJsont *self = allocSmallJson(); 49604 49605 smallJsont *r2 = self->f->pushBool(self, true); 49606 ck_assert_ptr_ne(r2, null); 49607 r = cropElemAtBoolSmallJsonG(self, 0); 49608 ck_assert(r); 49609 terminateO(self); 49610 49611 } 49612 49613 49614 void cropElemAtDoubleSmallJsonGT(void) { 49615 49616 double r; 49617 smallJsont *self = allocSmallJson(); 49618 49619 smallJsont *r2 = self->f->pushDouble(self, 1); 49620 ck_assert_ptr_ne(r2, null); 49621 r = cropElemAtDoubleSmallJsonG(self, 0); 49622 ck_assert(r==1); 49623 terminateO(self); 49624 49625 } 49626 49627 49628 void cropElemAtIntSmallJsonGT(void) { 49629 49630 int64_t r; 49631 smallJsont *self = allocSmallJson(); 49632 49633 smallJsont *r2 = self->f->pushInt(self, 2); 49634 ck_assert_ptr_ne(r2, null); 49635 r = cropElemAtIntSmallJsonG(self, 0); 49636 ck_assert_int_eq(r, 2); 49637 terminateO(self); 49638 49639 } 49640 49641 49642 void cropElemAtInt32SmallJsonGT(void) { 49643 49644 int32_t r; 49645 smallJsont *self = allocSmallJson(); 49646 49647 smallJsont *r2 = self->f->pushInt(self, 2); 49648 ck_assert_ptr_ne(r2, null); 49649 r = cropElemAtInt32SmallJsonG(self, 0); 49650 ck_assert_int_eq(r, 2); 49651 terminateO(self); 49652 49653 } 49654 49655 49656 void cropElemAtUintSmallJsonGT(void) { 49657 49658 uint64_t r; 49659 smallJsont *self = allocSmallJson(); 49660 49661 smallJsont *r2 = self->f->pushInt(self, 2); 49662 ck_assert_ptr_ne(r2, null); 49663 r = cropElemAtUintSmallJsonG(self, 0); 49664 ck_assert_int_eq(r, 2); 49665 terminateO(self); 49666 49667 } 49668 49669 49670 void cropElemAtUint32SmallJsonGT(void) { 49671 49672 uint32_t r; 49673 smallJsont *self = allocSmallJson(); 49674 49675 smallJsont *r2 = self->f->pushInt(self, 2); 49676 ck_assert_ptr_ne(r2, null); 49677 r = cropElemAtUint32SmallJsonG(self, 0); 49678 ck_assert_int_eq(r, 2); 49679 terminateO(self); 49680 49681 } 49682 49683 49684 void cropElemAtSSmallJsonGT(void) { 49685 49686 char* r; 49687 smallJsont *self = allocSmallJson(); 49688 49689 smallJsont *r2 = self->f->pushS(self, "qwe"); 49690 ck_assert_ptr_ne(r2, null); 49691 r = cropElemAtSSmallJsonG(self, 0); 49692 ck_assert_str_eq(r, "qwe"); 49693 free(r); 49694 terminateO(self); 49695 49696 } 49697 49698 49699 void cropElemAtCharSmallJsonGT(void) { 49700 49701 char r; 49702 smallJsont *self = allocG(rtSmallJsont); 49703 49704 setTopSO(self, "sheepy"); 49705 r = cropElemAtCharSmallJsonG(self, 0); 49706 ck_assert_int_eq(r, 's'); 49707 ck_assert_str_eq(sjGet(self), "heepy"); 49708 terminateO(self); 49709 49710 } 49711 49712 49713 void cropElemAtDictSmallJsonGT(void) { 49714 49715 smallDictt* r; 49716 smallJsont *self = allocSmallJson(); 49717 49718 createSmallDict(d); 49719 (&d)->f->setInt(&d, "a", 1); 49720 smallJsont *r2 = self->f->pushDict(self, &d); 49721 ck_assert_ptr_ne(r2, null); 49722 r = cropElemAtDictSmallJsonG(self, 0); 49723 ck_assert_ptr_ne(r, null); 49724 char *s = toStringO(r); 49725 terminateO(r); 49726 ck_assert_str_eq(s, "{\"a\":1}"); 49727 free(s); 49728 terminateO(self); 49729 49730 } 49731 49732 49733 void cropElemAtArraySmallJsonGT(void) { 49734 49735 smallArrayt* r; 49736 smallJsont *self = allocSmallJson(); 49737 49738 r = allocSmallArray(); 49739 r->f->pushInt(r, 1); 49740 smallJsont *r2 = self->f->pushNFreeArray(self, r); 49741 ck_assert_ptr_ne(r2, null); 49742 r = cropElemAtArraySmallJsonG(self, 0); 49743 ck_assert_ptr_ne(r, null); 49744 char *s = toStringO(r); 49745 terminateO(r); 49746 ck_assert_str_eq(s, "[1]"); 49747 free(s); 49748 terminateO(self); 49749 49750 } 49751 49752 49753 void cropElemAtSmallBoolSmallJsonGT(void) { 49754 49755 smallBoolt* r; 49756 smallJsont *self = allocSmallJson(); 49757 49758 smallJsont *r2 = self->f->pushBool(self, true); 49759 ck_assert_ptr_ne(r2, null); 49760 r = cropElemAtSmallBoolSmallJsonG(self, 0); 49761 ck_assert_ptr_ne(r, null); 49762 char *s = toStringO(r); 49763 terminateO(r); 49764 ck_assert_str_eq(s, "true"); 49765 free(s); 49766 terminateO(self); 49767 49768 } 49769 49770 49771 void cropElemAtSmallBytesSmallJsonGT(void) { 49772 49773 smallBytest* r; 49774 smallJsont *self = allocSmallJson(); 49775 49776 r = allocSmallBytes("qwe", 3); 49777 smallJsont *r2 = self->f->pushNFreeSmallBytes(self, r); 49778 ck_assert_ptr_ne(r2, null); 49779 r = cropElemAtSmallBytesSmallJsonG(self, 0); 49780 ck_assert_ptr_ne(r, null); 49781 char *s = toStringO(r); 49782 terminateO(r); 49783 ck_assert_str_eq(s, "[0x71,0x77,0x65]"); 49784 free(s); 49785 terminateO(self); 49786 49787 } 49788 49789 49790 void cropElemAtSmallDoubleSmallJsonGT(void) { 49791 49792 smallDoublet* r; 49793 smallJsont *self = allocSmallJson(); 49794 49795 smallJsont *r2 = self->f->pushDouble(self, 1); 49796 ck_assert_ptr_ne(r2, null); 49797 r = cropElemAtSmallDoubleSmallJsonG(self, 0); 49798 ck_assert_ptr_ne(r, null); 49799 char *s = toStringO(r); 49800 terminateO(r); 49801 ck_assert_str_eq(s, "1.000000e+00"); 49802 free(s); 49803 terminateO(self); 49804 49805 } 49806 49807 49808 void cropElemAtSmallIntSmallJsonGT(void) { 49809 49810 smallIntt* r; 49811 smallJsont *self = allocSmallJson(); 49812 49813 smallJsont *r2 = self->f->pushInt(self, 1); 49814 ck_assert_ptr_ne(r2, null); 49815 r = cropElemAtSmallIntSmallJsonG(self, 0); 49816 ck_assert_ptr_ne(r, null); 49817 char *s = toStringO(r); 49818 terminateO(r); 49819 ck_assert_str_eq(s, "1"); 49820 free(s); 49821 terminateO(self); 49822 49823 } 49824 49825 49826 void cropElemAtSmallJsonSmallJsonGT(void) { 49827 49828 smallJsont* r; 49829 smallJsont *self = allocSmallJson(); 49830 49831 r = allocSmallJson(); 49832 r->f->setInt(r, "a", 1); 49833 smallJsont *r2 = self->f->pushNFreeSmallJson(self, r); 49834 ck_assert_ptr_ne(r2, null); 49835 r = cropElemAtSmallJsonSmallJsonG(self, 0); 49836 ck_assert_ptr_ne(r, null); 49837 char *s = toStringO(r); 49838 terminateO(r); 49839 ck_assert_str_eq(s, "{\"a\":1}"); 49840 free(s); 49841 terminateO(self); 49842 49843 } 49844 49845 49846 void cropElemAtSmallStringSmallJsonGT(void) { 49847 49848 smallStringt* r; 49849 smallJsont *self = allocSmallJson(); 49850 49851 smallJsont *r2 = self->f->pushS(self, "qwe"); 49852 ck_assert_ptr_ne(r2, null); 49853 r = cropElemAtSmallStringSmallJsonG(self, 0); 49854 ck_assert_ptr_ne(r, null); 49855 char *s = toStringO(r); 49856 terminateO(r); 49857 ck_assert_str_eq(s, "qwe"); 49858 free(s); 49859 terminateO(self); 49860 49861 } 49862 49863 49864 void cropElemAtVoidSmallJsonGT(void) { 49865 49866 void* r; 49867 smallJsont *self = allocSmallJson(); 49868 49869 smallJsont *r2 = pushVoidSmallJsonG(self, &r); 49870 ck_assert_ptr_ne(r2, null); 49871 r = cropElemAtVoidSmallJsonG(self, 0); 49872 ck_assert_ptr_eq(r, &r); 49873 terminateO(self); 49874 49875 } 49876 49877 49878 void cropElemAtSmallContainerSmallJsonGT(void) { 49879 49880 smallContainert* r; 49881 smallJsont *self = allocSmallJson(); 49882 49883 createSmallContainer(e2); 49884 smallJsont *r2 = self->f->pushSmallContainer(self, &e2); 49885 ck_assert_ptr_ne(r2, null); 49886 r = cropElemAtSmallContainerSmallJsonG(self, 0); 49887 ck_assert_ptr_ne(r, null); 49888 char *s = toStringO(r); 49889 terminateO(r); 49890 ck_assert_str_eq(s, "<data smallContainer>"); 49891 free(s); 49892 terminateO(self); 49893 49894 } 49895 49896 49897 void cropElemKeySmallJsonGT(void) { 49898 49899 baset* r; 49900 smallJsont *self = allocSmallJson(); 49901 smallJsont *r2; 49902 49903 r2 = self->f->setInt(self, "1", 1); 49904 ck_assert_ptr_ne(r2, null); 49905 r2 = self->f->setDouble(self, "2", 2.2); 49906 ck_assert_ptr_ne(r2, null); 49907 r2 = self->f->setS(self, "3", "2"); 49908 ck_assert_ptr_ne(r2, null); 49909 r2 = self->f->setUndefined(self, "u"); 49910 ck_assert_ptr_ne(r2, null); 49911 createSmallContainer(c); 49912 r2 = self->f->setSmallContainer(self, "c", &c); 49913 ck_assert_ptr_ne(r2, null); 49914 createAllocateSmallInt(I); 49915 setValG(I, 11); 49916 I->type = "anothertype"; 49917 r2 = self->f->set(self, "b", (baset*)I); 49918 ck_assert_ptr_ne(r2, null); 49919 // crop string 49920 r = cropElemKeySmallJsonG(self, "3"); 49921 ck_assert_ptr_ne(r, null); 49922 char *s = toStringO(r); 49923 terminateO(r); 49924 ck_assert_str_eq(s, "2"); 49925 free(s); 49926 s = toStringO(self); 49927 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"u\":null,\"c\":\"<data container>\",\"b\":\"<data container>\"}"); 49928 free(s); 49929 terminateO(self); 49930 49931 } 49932 49933 49934 void cropElemKeyUndefinedSmallJsonGT(void) { 49935 49936 undefinedt* r; 49937 smallJsont *self = allocSmallJson(); 49938 smallJsont *r2; 49939 49940 r2 = self->f->setInt(self, "1", 1); 49941 ck_assert_ptr_ne(r2, null); 49942 r2 = self->f->setDouble(self, "2", 2.2); 49943 ck_assert_ptr_ne(r2, null); 49944 r2 = self->f->setUndefined(self, "u"); 49945 ck_assert_ptr_ne(r2, null); 49946 r = cropElemKeyUndefinedSmallJsonG(self, "u"); 49947 ck_assert_ptr_ne(r, null); 49948 char *s = toStringO(r); 49949 terminateO(r); 49950 ck_assert_str_eq(s, "null"); 49951 free(s); 49952 s = toStringO(self); 49953 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00}"); 49954 free(s); 49955 terminateO(self); 49956 49957 } 49958 49959 49960 void cropElemKeyBoolSmallJsonGT(void) { 49961 49962 bool r; 49963 smallJsont *self = allocSmallJson(); 49964 smallJsont *r2; 49965 49966 r2 = self->f->setInt(self, "1", 1); 49967 ck_assert_ptr_ne(r2, null); 49968 r2 = self->f->setDouble(self, "2", 2.2); 49969 ck_assert_ptr_ne(r2, null); 49970 r2 = self->f->setBool(self, "b", true); 49971 ck_assert_ptr_ne(r2, null); 49972 createAllocateSmallInt(I); 49973 setValG(I, 11); 49974 I->type = "anothertype"; 49975 r2 = self->f->set(self, "B", (baset*)I); 49976 ck_assert_ptr_ne(r2, null); 49977 r = cropElemKeyBoolSmallJsonG(self, "b"); 49978 ck_assert(r); 49979 char *s = toStringO(self); 49980 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 49981 free(s); 49982 terminateO(self); 49983 49984 } 49985 49986 49987 void cropElemKeyDoubleSmallJsonGT(void) { 49988 49989 double r; 49990 smallJsont *self = allocSmallJson(); 49991 smallJsont *r2; 49992 49993 r2 = self->f->setInt(self, "1", 1); 49994 ck_assert_ptr_ne(r2, null); 49995 r2 = self->f->setDouble(self, "2", 2.2); 49996 ck_assert_ptr_ne(r2, null); 49997 r2 = self->f->setDouble(self, "b", 3.3); 49998 ck_assert_ptr_ne(r2, null); 49999 createAllocateSmallInt(I); 50000 setValG(I, 11); 50001 I->type = "anothertype"; 50002 r2 = self->f->set(self, "B", (baset*)I); 50003 ck_assert_ptr_ne(r2, null); 50004 r = cropElemKeyDoubleSmallJsonG(self, "b"); 50005 ck_assert(r == 3.3); 50006 char *s = toStringO(self); 50007 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50008 free(s); 50009 terminateO(self); 50010 50011 } 50012 50013 50014 void cropElemKeyIntSmallJsonGT(void) { 50015 50016 int64_t r; 50017 smallJsont *self = allocSmallJson(); 50018 smallJsont *r2; 50019 50020 r2 = self->f->setInt(self, "1", 1); 50021 ck_assert_ptr_ne(r2, null); 50022 r2 = self->f->setDouble(self, "2", 2.2); 50023 ck_assert_ptr_ne(r2, null); 50024 r2 = self->f->setInt(self, "b", 2); 50025 ck_assert_ptr_ne(r2, null); 50026 createAllocateSmallInt(I); 50027 setValG(I, 11); 50028 I->type = "anothertype"; 50029 r2 = self->f->set(self, "B", (baset*)I); 50030 ck_assert_ptr_ne(r2, null); 50031 r = cropElemKeyIntSmallJsonG(self, "b"); 50032 ck_assert_int_eq(r, 2); 50033 char *s = toStringO(self); 50034 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50035 free(s); 50036 terminateO(self); 50037 50038 } 50039 50040 50041 void cropElemKeyInt32SmallJsonGT(void) { 50042 50043 int32_t r; 50044 smallJsont *self = allocSmallJson(); 50045 smallJsont *r2; 50046 50047 r2 = self->f->setInt(self, "1", 1); 50048 ck_assert_ptr_ne(r2, null); 50049 r2 = self->f->setDouble(self, "2", 2.2); 50050 ck_assert_ptr_ne(r2, null); 50051 r2 = self->f->setInt(self, "b", 2); 50052 ck_assert_ptr_ne(r2, null); 50053 createAllocateSmallInt(I); 50054 setValG(I, 11); 50055 I->type = "anothertype"; 50056 r2 = self->f->set(self, "B", (baset*)I); 50057 ck_assert_ptr_ne(r2, null); 50058 r = cropElemKeyInt32SmallJsonG(self, "b"); 50059 ck_assert_int_eq(r, 2); 50060 char *s = toStringO(self); 50061 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50062 free(s); 50063 terminateO(self); 50064 50065 } 50066 50067 50068 void cropElemKeyUintSmallJsonGT(void) { 50069 50070 uint64_t r; 50071 smallJsont *self = allocSmallJson(); 50072 smallJsont *r2; 50073 50074 r2 = self->f->setInt(self, "1", 1); 50075 ck_assert_ptr_ne(r2, null); 50076 r2 = self->f->setDouble(self, "2", 2.2); 50077 ck_assert_ptr_ne(r2, null); 50078 r2 = self->f->setInt(self, "b", 2); 50079 ck_assert_ptr_ne(r2, null); 50080 createAllocateSmallInt(I); 50081 setValG(I, 11); 50082 I->type = "anothertype"; 50083 r2 = self->f->set(self, "B", (baset*)I); 50084 ck_assert_ptr_ne(r2, null); 50085 r = cropElemKeyUintSmallJsonG(self, "b"); 50086 ck_assert_int_eq(r, 2); 50087 char *s = toStringO(self); 50088 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50089 free(s); 50090 terminateO(self); 50091 50092 } 50093 50094 50095 void cropElemKeyUint32SmallJsonGT(void) { 50096 50097 uint32_t r; 50098 smallJsont *self = allocSmallJson(); 50099 smallJsont *r2; 50100 50101 r2 = self->f->setInt(self, "1", 1); 50102 ck_assert_ptr_ne(r2, null); 50103 r2 = self->f->setDouble(self, "2", 2.2); 50104 ck_assert_ptr_ne(r2, null); 50105 r2 = self->f->setInt(self, "b", 2); 50106 ck_assert_ptr_ne(r2, null); 50107 createAllocateSmallInt(I); 50108 setValG(I, 11); 50109 I->type = "anothertype"; 50110 r2 = self->f->set(self, "B", (baset*)I); 50111 ck_assert_ptr_ne(r2, null); 50112 r = cropElemKeyUint32SmallJsonG(self, "b"); 50113 ck_assert_int_eq(r, 2); 50114 char *s = toStringO(self); 50115 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50116 free(s); 50117 terminateO(self); 50118 50119 } 50120 50121 50122 void cropElemKeySSmallJsonGT(void) { 50123 50124 char* r; 50125 smallJsont *self = allocSmallJson(); 50126 smallJsont *r2; 50127 50128 r2 = self->f->setInt(self, "1", 1); 50129 ck_assert_ptr_ne(r2, null); 50130 r2 = self->f->setDouble(self, "2", 2.2); 50131 ck_assert_ptr_ne(r2, null); 50132 r2 = self->f->setS(self, "b", "qwe"); 50133 ck_assert_ptr_ne(r2, null); 50134 createAllocateSmallInt(I); 50135 setValG(I, 11); 50136 I->type = "anothertype"; 50137 r2 = self->f->set(self, "B", (baset*)I); 50138 ck_assert_ptr_ne(r2, null); 50139 r = cropElemKeySSmallJsonG(self, "b"); 50140 ck_assert_str_eq(r, "qwe"); 50141 free(r); 50142 char *s = toStringO(self); 50143 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50144 free(s); 50145 terminateO(self); 50146 50147 } 50148 50149 50150 void cropElemKeyDictSmallJsonGT(void) { 50151 50152 smallDictt* r; 50153 smallJsont *self = allocSmallJson(); 50154 smallJsont *r2; 50155 50156 r2 = self->f->setInt(self, "1", 1); 50157 ck_assert_ptr_ne(r2, null); 50158 r2 = self->f->setDouble(self, "2", 2.2); 50159 ck_assert_ptr_ne(r2, null); 50160 createAllocateSmallDict(d); 50161 r2 = self->f->setNFreeDict(self, "b", d); 50162 ck_assert_ptr_ne(r2, null); 50163 createAllocateSmallInt(I); 50164 setValG(I, 11); 50165 I->type = "anothertype"; 50166 r2 = self->f->set(self, "B", (baset*)I); 50167 ck_assert_ptr_ne(r2, null); 50168 r = cropElemKeyDictSmallJsonG(self, "b"); 50169 ck_assert_ptr_ne(r, null); 50170 char *s = toStringO(r); 50171 terminateO(r); 50172 ck_assert_str_eq(s, "{}"); 50173 free(s); 50174 s = toStringO(self); 50175 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50176 free(s); 50177 terminateO(self); 50178 50179 } 50180 50181 50182 void cropElemKeyArraySmallJsonGT(void) { 50183 50184 smallArrayt* r; 50185 smallJsont *self = allocSmallJson(); 50186 smallJsont *r2; 50187 50188 r2 = self->f->setInt(self, "1", 1); 50189 ck_assert_ptr_ne(r2, null); 50190 r2 = self->f->setDouble(self, "2", 2.2); 50191 ck_assert_ptr_ne(r2, null); 50192 createAllocateSmallArray(d); 50193 r2 = self->f->setNFreeArray(self, "b", d); 50194 ck_assert_ptr_ne(r2, null); 50195 createAllocateSmallInt(I); 50196 setValG(I, 11); 50197 I->type = "anothertype"; 50198 r2 = self->f->set(self, "B", (baset*)I); 50199 ck_assert_ptr_ne(r2, null); 50200 r = cropElemKeyArraySmallJsonG(self, "b"); 50201 ck_assert_ptr_ne(r, null); 50202 char *s = toStringO(r); 50203 terminateO(r); 50204 ck_assert_str_eq(s, "[]"); 50205 free(s); 50206 s = toStringO(self); 50207 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50208 free(s); 50209 terminateO(self); 50210 50211 } 50212 50213 50214 void cropElemKeySmallBoolSmallJsonGT(void) { 50215 50216 smallBoolt* r; 50217 smallJsont *self = allocSmallJson(); 50218 smallJsont *r2; 50219 50220 r2 = self->f->setInt(self, "1", 1); 50221 ck_assert_ptr_ne(r2, null); 50222 r2 = self->f->setDouble(self, "2", 2.2); 50223 ck_assert_ptr_ne(r2, null); 50224 r2 = self->f->setBool(self, "b", true); 50225 ck_assert_ptr_ne(r2, null); 50226 createAllocateSmallInt(I); 50227 setValG(I, 11); 50228 I->type = "anothertype"; 50229 r2 = self->f->set(self, "B", (baset*)I); 50230 ck_assert_ptr_ne(r2, null); 50231 r = cropElemKeySmallBoolSmallJsonG(self, "b"); 50232 ck_assert_ptr_ne(r, null); 50233 char *s = toStringO(r); 50234 terminateO(r); 50235 ck_assert_str_eq(s, "true"); 50236 free(s); 50237 s = toStringO(self); 50238 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50239 free(s); 50240 terminateO(self); 50241 50242 } 50243 50244 50245 void cropElemKeySmallBytesSmallJsonGT(void) { 50246 50247 smallBytest* r; 50248 smallJsont *self = allocSmallJson(); 50249 smallJsont *r2; 50250 50251 r2 = self->f->setInt(self, "1", 1); 50252 ck_assert_ptr_ne(r2, null); 50253 r2 = self->f->setDouble(self, "2", 2.2); 50254 ck_assert_ptr_ne(r2, null); 50255 createAllocateSmallBytes(d); 50256 r2 = self->f->setNFreeSmallBytes(self, "b", d); 50257 ck_assert_ptr_ne(r2, null); 50258 createAllocateSmallInt(I); 50259 setValG(I, 11); 50260 I->type = "anothertype"; 50261 r2 = self->f->set(self, "B", (baset*)I); 50262 ck_assert_ptr_ne(r2, null); 50263 r = cropElemKeySmallBytesSmallJsonG(self, "b"); 50264 ck_assert_ptr_ne(r, null); 50265 char *s = toStringO(r); 50266 terminateO(r); 50267 ck_assert_str_eq(s, "[]"); 50268 free(s); 50269 s = toStringO(self); 50270 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50271 free(s); 50272 terminateO(self); 50273 50274 } 50275 50276 50277 void cropElemKeySmallDoubleSmallJsonGT(void) { 50278 50279 smallDoublet* r; 50280 smallJsont *self = allocSmallJson(); 50281 smallJsont *r2; 50282 50283 r2 = self->f->setInt(self, "1", 1); 50284 ck_assert_ptr_ne(r2, null); 50285 r2 = self->f->setDouble(self, "2", 2.2); 50286 ck_assert_ptr_ne(r2, null); 50287 r2 = self->f->setDouble(self, "b", 3.3); 50288 ck_assert_ptr_ne(r2, null); 50289 createAllocateSmallInt(I); 50290 setValG(I, 11); 50291 I->type = "anothertype"; 50292 r2 = self->f->set(self, "B", (baset*)I); 50293 ck_assert_ptr_ne(r2, null); 50294 r = cropElemKeySmallDoubleSmallJsonG(self, "b"); 50295 ck_assert_ptr_ne(r, null); 50296 char *s = toStringO(r); 50297 terminateO(r); 50298 ck_assert_str_eq(s, "3.300000e+00"); 50299 free(s); 50300 s = toStringO(self); 50301 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50302 free(s); 50303 terminateO(self); 50304 50305 } 50306 50307 50308 void cropElemKeySmallIntSmallJsonGT(void) { 50309 50310 smallIntt* r; 50311 smallJsont *self = allocSmallJson(); 50312 smallJsont *r2; 50313 50314 r2 = self->f->setInt(self, "1", 1); 50315 ck_assert_ptr_ne(r2, null); 50316 r2 = self->f->setDouble(self, "2", 2.2); 50317 ck_assert_ptr_ne(r2, null); 50318 r2 = self->f->setInt(self, "b", 2); 50319 ck_assert_ptr_ne(r2, null); 50320 createAllocateSmallInt(I); 50321 setValG(I, 11); 50322 I->type = "anothertype"; 50323 r2 = self->f->set(self, "B", (baset*)I); 50324 ck_assert_ptr_ne(r2, null); 50325 r = cropElemKeySmallIntSmallJsonG(self, "b"); 50326 ck_assert_ptr_ne(r, null); 50327 char *s = toStringO(r); 50328 terminateO(r); 50329 ck_assert_str_eq(s, "2"); 50330 free(s); 50331 s = toStringO(self); 50332 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50333 free(s); 50334 terminateO(self); 50335 50336 } 50337 50338 50339 void cropElemKeySmallJsonSmallJsonGT(void) { 50340 50341 smallJsont* r; 50342 smallJsont *self = allocSmallJson(); 50343 smallJsont *r2; 50344 50345 r2 = self->f->setInt(self, "1", 1); 50346 ck_assert_ptr_ne(r2, null); 50347 createAllocateSmallBytes(b); 50348 r2 = self->f->setNFreeSmallBytes(self, "2", b); 50349 ck_assert_ptr_ne(r2, null); 50350 createAllocateSmallJson(d); 50351 r2 = self->f->setNFreeSmallJson(self, "b", d); 50352 ck_assert_ptr_ne(r2, null); 50353 createAllocateSmallInt(I); 50354 setValG(I, 11); 50355 I->type = "anothertype"; 50356 r2 = self->f->set(self, "B", (baset*)I); 50357 ck_assert_ptr_ne(r2, null); 50358 r = cropElemKeySmallJsonSmallJsonG(self, "b"); 50359 ck_assert_ptr_ne(r, null); 50360 char *s = toStringO(r); 50361 terminateO(r); 50362 ck_assert_str_eq(s, "{}"); 50363 free(s); 50364 s = toStringO(self); 50365 ck_assert_str_eq(s, "{\"1\":1,\"2\":[],\"B\":\"<data container>\"}"); 50366 free(s); 50367 terminateO(self); 50368 50369 } 50370 50371 50372 void cropElemKeySmallStringSmallJsonGT(void) { 50373 50374 smallStringt* r; 50375 smallJsont *self = allocSmallJson(); 50376 smallJsont *r2; 50377 50378 r2 = self->f->setInt(self, "1", 1); 50379 ck_assert_ptr_ne(r2, null); 50380 r2 = self->f->setDouble(self, "2", 2.2); 50381 ck_assert_ptr_ne(r2, null); 50382 r2 = self->f->setS(self, "b", "qwe"); 50383 ck_assert_ptr_ne(r2, null); 50384 createAllocateSmallInt(I); 50385 setValG(I, 11); 50386 I->type = "anothertype"; 50387 r2 = self->f->set(self, "B", (baset*)I); 50388 ck_assert_ptr_ne(r2, null); 50389 r = cropElemKeySmallStringSmallJsonG(self, "b"); 50390 ck_assert_ptr_ne(r, null); 50391 char *s = toStringO(r); 50392 terminateO(r); 50393 ck_assert_str_eq(s, "qwe"); 50394 free(s); 50395 s = toStringO(self); 50396 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50397 free(s); 50398 terminateO(self); 50399 50400 } 50401 50402 50403 void cropElemKeyVoidSmallJsonGT(void) { 50404 50405 void* r; 50406 smallJsont *self = allocSmallJson(); 50407 smallJsont *r2; 50408 50409 r2 = self->f->setInt(self, "1", 1); 50410 ck_assert_ptr_ne(r2, null); 50411 r2 = self->f->setDouble(self, "2", 2.2); 50412 ck_assert_ptr_ne(r2, null); 50413 smallContainert *c = allocSmallContainer(&r); 50414 r2 = self->f->setNFreeSmallContainer(self, "b", c); 50415 ck_assert_ptr_ne(r2, null); 50416 createAllocateSmallInt(I); 50417 setValG(I, 11); 50418 I->type = "anothertype"; 50419 r2 = self->f->set(self, "B", (baset*)I); 50420 ck_assert_ptr_ne(r2, null); 50421 r = cropElemKeyVoidSmallJsonG(self, "b"); 50422 ck_assert_ptr_eq(r, &r); 50423 char *s = toStringO(self); 50424 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50425 free(s); 50426 terminateO(self); 50427 50428 } 50429 50430 50431 void cropElemKeySmallContainerSmallJsonGT(void) { 50432 50433 smallContainert* r; 50434 smallJsont *self = allocSmallJson(); 50435 smallJsont *r2; 50436 50437 r2 = self->f->setInt(self, "1", 1); 50438 ck_assert_ptr_ne(r2, null); 50439 r2 = self->f->setDouble(self, "2", 2.2); 50440 ck_assert_ptr_ne(r2, null); 50441 smallContainert *c = allocSmallContainer(&r); 50442 r2 = self->f->setNFreeSmallContainer(self, "b", c); 50443 ck_assert_ptr_ne(r2, null); 50444 createAllocateSmallInt(I); 50445 setValG(I, 11); 50446 I->type = "anothertype"; 50447 r2 = self->f->set(self, "B", (baset*)I); 50448 ck_assert_ptr_ne(r2, null); 50449 r = cropElemKeySmallContainerSmallJsonG(self, "b"); 50450 ck_assert_ptr_ne(r, null); 50451 char *s = toStringO(r); 50452 terminateO(r); 50453 ck_assert_str_eq(s, "<data smallContainer>"); 50454 free(s); 50455 s = toStringO(self); 50456 ck_assert_str_eq(s, "{\"1\":1,\"2\":2.200000e+00,\"B\":\"<data container>\"}"); 50457 free(s); 50458 terminateO(self); 50459 50460 } 50461 50462 50463 void copySmallJsonGT(void) { 50464 50465 smallJsont* r; 50466 smallJsont *self = allocSmallJson(); 50467 50468 // add elements to self 50469 r = self->f->pushInt(self, 1); 50470 ck_assert_ptr_ne(r, null); 50471 r = self->f->pushInt(self, 2); 50472 ck_assert_ptr_ne(r, null); 50473 r = self->f->pushInt(self, 3); 50474 ck_assert_ptr_ne(r, null); 50475 r = self->f->pushInt(self, 4); 50476 ck_assert_ptr_ne(r, null); 50477 r = copySmallJsonG(self, 1, -1); 50478 ck_assert_ptr_ne(r, null); 50479 ck_assert_int_eq(lenO(r), 2); 50480 char *s = toStringO(r); 50481 terminateO(r); 50482 ck_assert_str_eq(s, "[2,3]"); 50483 free(s); 50484 s = toStringO(self); 50485 ck_assert_str_eq(s, "[1,2,3,4]"); 50486 free(s); 50487 terminateO(self); 50488 50489 } 50490 50491 50492 void insertSmallJsonGT(void) { 50493 50494 smallJsont* r; 50495 smallJsont *self = allocSmallJson(); 50496 smallArrayt *toInsert = allocSmallArray(); 50497 50498 toInsert->f->pushInt(toInsert, 3); 50499 r = insertSmallJsonG(self, 0, toInsert); 50500 smashO(toInsert); 50501 ck_assert_ptr_ne(r, null); 50502 char *s = toStringO(r); 50503 ck_assert_str_eq(s, "[3]"); 50504 free(s); 50505 terminateO(self); 50506 50507 } 50508 50509 50510 void insertNSmashSmallJsonGT(void) { 50511 50512 smallJsont* r; 50513 smallJsont *self = allocSmallJson(); 50514 smallArrayt *toInsert = allocSmallArray(); 50515 50516 toInsert->f->pushInt(toInsert, 3); 50517 r = insertNSmashSmallJsonG(self, 0, toInsert); 50518 ck_assert_ptr_ne(r, null); 50519 char *s = toStringO(r); 50520 ck_assert_str_eq(s, "[3]"); 50521 free(s); 50522 terminateO(self); 50523 50524 } 50525 50526 50527 void insertSmallJsonSmallJsonGT(void) { 50528 50529 smallJsont* r; 50530 smallJsont *self = allocSmallJson(); 50531 setTypeArrayO(self); 50532 smallJsont *toInsert = allocSmallJson(); 50533 50534 toInsert->f->pushInt(toInsert, 3); 50535 r = insertSmallJsonSmallJsonG(self, 0, toInsert); 50536 smashO(toInsert); 50537 ck_assert_ptr_ne(r, null); 50538 char *s = toStringO(r); 50539 ck_assert_str_eq(s, "[3]"); 50540 free(s); 50541 terminateO(self); 50542 50543 } 50544 50545 50546 void insertNSmashSmallJsonSmallJsonGT(void) { 50547 50548 smallJsont* r; 50549 smallJsont *self = allocSmallJson(); 50550 setTypeArrayO(self); 50551 smallJsont *toInsert = allocSmallJson(); 50552 50553 toInsert->f->pushInt(toInsert, 3); 50554 r = insertNSmashSmallJsonSmallJsonG(self, 0, toInsert); 50555 ck_assert_ptr_ne(r, null); 50556 char *s = toStringO(r); 50557 ck_assert_str_eq(s, "[3]"); 50558 free(s); 50559 terminateO(self); 50560 50561 } 50562 50563 50564 void insertStringSmallJsonGT(void) { 50565 50566 smallJsont* r; 50567 smallJsont *self = allocG(rtSmallJsont); 50568 smallStringt *toInsert = allocSmallString("lib"); 50569 50570 setTopSO(self, "sheepy"); 50571 r = insertStringSmallJsonG(self, 0, toInsert); 50572 ck_assert_ptr_ne(r, null); 50573 char *s = toStringO(r); 50574 ck_assert_str_eq(s, "libsheepy"); 50575 free(s); 50576 terminateO(toInsert); 50577 terminateO(self); 50578 50579 } 50580 50581 50582 void insertSSmallJsonGT(void) { 50583 50584 smallJsont* r; 50585 smallJsont *self = allocG(rtSmallJsont); 50586 50587 setTopSO(self, "sheepy"); 50588 r = insertSSmallJsonG(self, 0, "lib"); 50589 ck_assert_ptr_ne(r, null); 50590 char *s = toStringO(r); 50591 ck_assert_str_eq(s, "libsheepy"); 50592 free(s); 50593 terminateO(self); 50594 50595 } 50596 50597 50598 void insertNFreeSmallJsonGT(void) { 50599 50600 smallJsont* r; 50601 smallJsont *self = allocG(rtSmallJsont); 50602 smallStringt *toInsert = allocSmallString("lib"); 50603 50604 setTopSO(self, "sheepy"); 50605 r = insertNFreeStringSmallJsonG(self, 0, toInsert); 50606 ck_assert_ptr_ne(r, null); 50607 char *s = toStringO(r); 50608 ck_assert_str_eq(s, "libsheepy"); 50609 free(s); 50610 terminateO(self); 50611 50612 } 50613 50614 50615 void insertSNFreeStringSmallJsonGT(void) { 50616 50617 smallJsont* r; 50618 smallJsont *self = allocG(rtSmallJsont); 50619 50620 setTopSO(self, "sheepy"); 50621 r = insertNFreeSSmallJsonG(self, 0, strdup("lib")); 50622 ck_assert_ptr_ne(r, null); 50623 char *s = toStringO(r); 50624 ck_assert_str_eq(s, "libsheepy"); 50625 free(s); 50626 terminateO(self); 50627 50628 } 50629 50630 50631 void injectSmallJsonGT(void) { 50632 50633 smallJsont* r; 50634 smallJsont *self = allocSmallJson(); 50635 baset *value = (baset*) allocSmallInt(8); 50636 50637 r = injectSmallJsonG(self, 0, value); 50638 ck_assert_ptr_ne(r, null); 50639 finishO(value); 50640 char *s = toStringO(r); 50641 ck_assert_str_eq(s, "[8]"); 50642 free(s); 50643 terminateO(self); 50644 50645 } 50646 50647 50648 void injectUndefinedSmallJsonGT(void) { 50649 50650 smallJsont* r; 50651 smallJsont *self = allocSmallJson(); 50652 50653 r = injectUndefinedSmallJsonG(self, 0, null); 50654 ck_assert_ptr_ne(r, null); 50655 char *s = toStringO(r); 50656 ck_assert_str_eq(s, "[null]"); 50657 free(s); 50658 terminateO(self); 50659 50660 } 50661 50662 50663 void injectBoolSmallJsonGT(void) { 50664 50665 smallJsont* r; 50666 smallJsont *self = allocSmallJson(); 50667 50668 r = injectBoolSmallJsonG(self, 0, true); 50669 ck_assert_ptr_ne(r, null); 50670 char *s = toStringO(r); 50671 ck_assert_str_eq(s, "[true]"); 50672 free(s); 50673 terminateO(self); 50674 50675 } 50676 50677 50678 void injectDoubleSmallJsonGT(void) { 50679 50680 smallJsont* r; 50681 smallJsont *self = allocSmallJson(); 50682 50683 r = injectDoubleSmallJsonG(self, 0, 1); 50684 ck_assert_ptr_ne(r, null); 50685 char *s = toStringO(r); 50686 ck_assert_str_eq(s, "[1.000000e+00]"); 50687 free(s); 50688 terminateO(self); 50689 50690 } 50691 50692 50693 void injectIntSmallJsonGT(void) { 50694 50695 smallJsont* r; 50696 smallJsont *self = allocSmallJson(); 50697 50698 r = injectIntSmallJsonG(self, 0, 2); 50699 ck_assert_ptr_ne(r, null); 50700 char *s = toStringO(r); 50701 ck_assert_str_eq(s, "[2]"); 50702 free(s); 50703 terminateO(self); 50704 50705 } 50706 50707 50708 void injectSSmallJsonGT(void) { 50709 50710 smallJsont* r; 50711 smallJsont *self = allocSmallJson(); 50712 50713 r = injectSSmallJsonG(self, 0, "qwe"); 50714 ck_assert_ptr_ne(r, null); 50715 char *s = toStringO(r); 50716 ck_assert_str_eq(s, "[\"qwe\"]"); 50717 free(s); 50718 terminateO(self); 50719 50720 } 50721 50722 50723 void injectCharSmallJsonGT(void) { 50724 50725 smallJsont* r; 50726 smallJsont *self = allocSmallJson(); 50727 50728 r = injectCharSmallJsonG(self, 0, 'a'); 50729 ck_assert_ptr_ne(r, null); 50730 char *s = toStringO(r); 50731 ck_assert_str_eq(s, "[\"a\"]"); 50732 free(s); 50733 terminateO(self); 50734 50735 } 50736 50737 50738 void injectDictSmallJsonGT(void) { 50739 50740 smallJsont* r; 50741 smallJsont *self = allocSmallJson(); 50742 50743 createSmallDict(d); 50744 r = injectDictSmallJsonG(self, 0, &d); 50745 ck_assert_ptr_ne(r, null); 50746 char *s = toStringO(r); 50747 ck_assert_str_eq(s, "[{}]"); 50748 free(s); 50749 terminateO(self); 50750 50751 } 50752 50753 50754 void injectArraySmallJsonGT(void) { 50755 50756 smallJsont* r; 50757 smallJsont *self = allocSmallJson(); 50758 50759 createSmallArray(a); 50760 r = injectArraySmallJsonG(self, 0, &a); 50761 ck_assert_ptr_ne(r, null); 50762 char *s = toStringO(r); 50763 ck_assert_str_eq(s, "[[]]"); 50764 free(s); 50765 terminateO(self); 50766 50767 } 50768 50769 50770 void injectArraycSmallJsonGT(void) { 50771 50772 smallJsont* r; 50773 smallJsont *self = allocSmallJson(); 50774 char **array = listCreateS("a","b"); 50775 50776 r = injectArraycSmallJsonG(self, 0, array); 50777 ck_assert_ptr_ne(r, null); 50778 listFreeS(array); 50779 char *s = toStringO(r); 50780 ck_assert_str_eq(s, "[[\"a\",\"b\"]]"); 50781 free(s); 50782 terminateO(self); 50783 50784 } 50785 50786 50787 void injectCArraycSmallJsonGT(void) { 50788 50789 smallJsont* r; 50790 smallJsont *self = allocSmallJson(); 50791 const char *array[] = {"a","b",null}; 50792 50793 r = injectCArraycSmallJsonG(self, 0, array); 50794 ck_assert_ptr_ne(r, null); 50795 char *s = toStringO(r); 50796 ck_assert_str_eq(s, "[[\"a\",\"b\"]]"); 50797 free(s); 50798 terminateO(self); 50799 50800 } 50801 50802 50803 void injectVoidSmallJsonGT(void) { 50804 50805 smallJsont* r; 50806 smallJsont *self = allocSmallJson(); 50807 50808 r = injectVoidSmallJsonG(self, 0, null); 50809 ck_assert_ptr_ne(r, null); 50810 char *s = toStringO(r); 50811 ck_assert_str_eq(s, "[null]"); 50812 free(s); 50813 r = injectVoidSmallJsonG(self, 0, &r); 50814 ck_assert_ptr_ne(r, null); 50815 s = toStringO(r); 50816 ck_assert_str_eq(s, "[\"<data container>\",null]"); 50817 free(s); 50818 terminateO(self); 50819 50820 } 50821 50822 50823 void injectSmallBoolSmallJsonGT(void) { 50824 50825 smallJsont* r; 50826 smallJsont *self = allocSmallJson(); 50827 50828 smallBoolt *b = allocSmallBool(true); 50829 r = injectSmallBoolSmallJsonG(self, 0, b); 50830 ck_assert_ptr_ne(r, null); 50831 finishO(b); 50832 char *s = toStringO(r); 50833 ck_assert_str_eq(s, "[true]"); 50834 free(s); 50835 terminateO(self); 50836 50837 } 50838 50839 50840 void injectSmallBytesSmallJsonGT(void) { 50841 50842 smallJsont* r; 50843 smallJsont *self = allocSmallJson(); 50844 smallBytest *b = allocSmallBytes("qwe", 3); 50845 50846 r = injectSmallBytesSmallJsonG(self, 0, b); 50847 ck_assert_ptr_ne(r, null); 50848 finishO(b); 50849 char *s = toStringO(r); 50850 ck_assert_str_eq(s, "[[0x71,0x77,0x65]]"); 50851 free(s); 50852 terminateO(self); 50853 50854 } 50855 50856 50857 void injectSmallDoubleSmallJsonGT(void) { 50858 50859 smallJsont* r; 50860 smallJsont *self = allocSmallJson(); 50861 smallDoublet *value = allocSmallDouble(1); 50862 50863 r = injectSmallDoubleSmallJsonG(self, 0, value); 50864 ck_assert_ptr_ne(r, null); 50865 finishO(value); 50866 char *s = toStringO(r); 50867 ck_assert_str_eq(s, "[1.000000e+00]"); 50868 free(s); 50869 terminateO(self); 50870 50871 } 50872 50873 50874 void injectSmallIntSmallJsonGT(void) { 50875 50876 smallJsont* r; 50877 smallJsont *self = allocSmallJson(); 50878 smallIntt *value = allocSmallInt(1); 50879 50880 r = injectSmallIntSmallJsonG(self, 0, value); 50881 ck_assert_ptr_ne(r, null); 50882 finishO(value); 50883 char *s = toStringO(r); 50884 ck_assert_str_eq(s, "[1]"); 50885 free(s); 50886 terminateO(self); 50887 50888 } 50889 50890 50891 void injectSmallJsonSmallJsonGT(void) { 50892 50893 smallJsont* r; 50894 smallJsont *self = allocSmallJson(); 50895 smallJsont *string = allocSmallJson(); 50896 50897 r = injectSmallJsonSmallJsonG(self, 0, string); 50898 ck_assert_ptr_ne(r, null); 50899 finishO(string); 50900 char *s = toStringO(r); 50901 ck_assert_str_eq(s, "[{}]"); 50902 free(s); 50903 terminateO(self); 50904 50905 } 50906 50907 50908 void injectSmallStringSmallJsonGT(void) { 50909 50910 smallJsont* r; 50911 smallJsont *self = allocSmallJson(); 50912 smallStringt *string = allocSmallString("qwe"); 50913 50914 r = injectSmallStringSmallJsonG(self, 0, string); 50915 ck_assert_ptr_ne(r, null); 50916 finishO(string); 50917 char *s = toStringO(r); 50918 ck_assert_str_eq(s, "[\"qwe\"]"); 50919 free(s); 50920 terminateO(self); 50921 50922 } 50923 50924 50925 void injectSmallContainerSmallJsonGT(void) { 50926 50927 smallJsont* r; 50928 smallJsont *self = allocSmallJson(); 50929 smallContainert *value = allocSmallContainer(null); 50930 50931 r = injectSmallContainerSmallJsonG(self, 0, value); 50932 ck_assert_ptr_ne(r, null); 50933 finishO(value); 50934 char *s = toStringO(r); 50935 ck_assert_str_eq(s, "[\"<data container>\"]"); 50936 free(s); 50937 terminateO(self); 50938 50939 } 50940 50941 50942 void injectNFreeSmallJsonGT(void) { 50943 50944 smallJsont* r; 50945 smallJsont *self = allocSmallJson(); 50946 baset *value = (baset*) allocSmallInt(8); 50947 50948 r = injectNFreeSmallJsonG(self, 0, value); 50949 ck_assert_ptr_ne(r, null); 50950 char *s = toStringO(r); 50951 ck_assert_str_eq(s, "[8]"); 50952 free(s); 50953 terminateO(self); 50954 50955 } 50956 50957 50958 void injectNFreeUndefinedSmallJsonGT(void) { 50959 50960 smallJsont* r; 50961 smallJsont *self = allocSmallJson(); 50962 50963 createAllocateUndefined(u); 50964 r = injectNFreeUndefinedSmallJsonG(self, 0, u); 50965 ck_assert_ptr_ne(r, null); 50966 char *s = toStringO(r); 50967 ck_assert_str_eq(s, "[null]"); 50968 free(s); 50969 terminateO(self); 50970 50971 } 50972 50973 50974 void injectNFreeSSmallJsonGT(void) { 50975 50976 smallJsont* r; 50977 smallJsont *self = allocSmallJson(); 50978 char *string = strdup("qwe"); 50979 50980 r = injectNFreeSSmallJsonG(self, 0, string); 50981 ck_assert_ptr_ne(r, null); 50982 char *s = toStringO(r); 50983 ck_assert_str_eq(s, "[\"qwe\"]"); 50984 free(s); 50985 terminateO(self); 50986 50987 } 50988 50989 50990 void injectNFreeDictSmallJsonGT(void) { 50991 50992 smallJsont* r; 50993 smallJsont *self = allocSmallJson(); 50994 50995 createAllocateSmallDict(d); 50996 r = injectNFreeDictSmallJsonG(self, 0, d); 50997 ck_assert_ptr_ne(r, null); 50998 char *s = toStringO(r); 50999 ck_assert_str_eq(s, "[{}]"); 51000 free(s); 51001 terminateO(self); 51002 51003 } 51004 51005 51006 void injectNFreeArraySmallJsonGT(void) { 51007 51008 smallJsont* r; 51009 smallJsont *self = allocSmallJson(); 51010 51011 createAllocateSmallArray(a); 51012 r = injectNFreeArraySmallJsonG(self, 0, a); 51013 ck_assert_ptr_ne(r, null); 51014 char *s = toStringO(r); 51015 ck_assert_str_eq(s, "[[]]"); 51016 free(s); 51017 terminateO(self); 51018 51019 } 51020 51021 51022 void injectNFreeArraycSmallJsonGT(void) { 51023 51024 smallJsont* r; 51025 smallJsont *self = allocSmallJson(); 51026 char **array = listCreateS("a","b"); 51027 51028 r = injectNFreeArraycSmallJsonG(self, 0, array); 51029 ck_assert_ptr_ne(r, null); 51030 char *s = toStringO(r); 51031 ck_assert_str_eq(s, "[[\"a\",\"b\"]]"); 51032 free(s); 51033 terminateO(self); 51034 51035 } 51036 51037 51038 void injectNFreeSmallBoolSmallJsonGT(void) { 51039 51040 smallJsont* r; 51041 smallJsont *self = allocSmallJson(); 51042 51043 smallBoolt *b = allocSmallBool(true); 51044 r = injectNFreeSmallBoolSmallJsonG(self, 0, b); 51045 ck_assert_ptr_ne(r, null); 51046 char *s = toStringO(r); 51047 ck_assert_str_eq(s, "[true]"); 51048 free(s); 51049 terminateO(self); 51050 51051 } 51052 51053 51054 void injectNFreeSmallBytesSmallJsonGT(void) { 51055 51056 smallJsont* r; 51057 smallJsont *self = allocSmallJson(); 51058 smallBytest *b = allocSmallBytes("qwe", 3); 51059 51060 r = injectNFreeSmallBytesSmallJsonG(self, 0, b); 51061 ck_assert_ptr_ne(r, null); 51062 char *s = toStringO(r); 51063 ck_assert_str_eq(s, "[[0x71,0x77,0x65]]"); 51064 free(s); 51065 terminateO(self); 51066 51067 } 51068 51069 51070 void injectNFreeSmallDoubleSmallJsonGT(void) { 51071 51072 smallJsont* r; 51073 smallJsont *self = allocSmallJson(); 51074 smallDoublet *value = allocSmallDouble(1); 51075 51076 r = injectNFreeSmallDoubleSmallJsonG(self, 0, value); 51077 ck_assert_ptr_ne(r, null); 51078 char *s = toStringO(r); 51079 ck_assert_str_eq(s, "[1.000000e+00]"); 51080 free(s); 51081 terminateO(self); 51082 51083 } 51084 51085 51086 void injectNFreeSmallIntSmallJsonGT(void) { 51087 51088 smallJsont* r; 51089 smallJsont *self = allocSmallJson(); 51090 smallIntt *value = allocSmallInt(1); 51091 51092 r = injectNFreeSmallIntSmallJsonG(self, 0, value); 51093 ck_assert_ptr_ne(r, null); 51094 char *s = toStringO(r); 51095 ck_assert_str_eq(s, "[1]"); 51096 free(s); 51097 terminateO(self); 51098 51099 } 51100 51101 51102 void injectNFreeSmallJsonSmallJsonGT(void) { 51103 51104 smallJsont* r; 51105 smallJsont *self = allocSmallJson(); 51106 smallJsont *string = allocSmallJson(); 51107 51108 r = injectNFreeSmallJsonSmallJsonG(self, 0, string); 51109 ck_assert_ptr_ne(r, null); 51110 char *s = toStringO(r); 51111 ck_assert_str_eq(s, "[{}]"); 51112 free(s); 51113 terminateO(self); 51114 51115 } 51116 51117 51118 void injectNFreeSmallStringSmallJsonGT(void) { 51119 51120 smallJsont* r; 51121 smallJsont *self = allocSmallJson(); 51122 smallStringt *string = allocSmallString("qwe"); 51123 51124 r = injectNFreeSmallStringSmallJsonG(self, 0, string); 51125 ck_assert_ptr_ne(r, null); 51126 char *s = toStringO(r); 51127 ck_assert_str_eq(s, "[\"qwe\"]"); 51128 free(s); 51129 terminateO(self); 51130 51131 } 51132 51133 51134 void injectNFreeSmallContainerSmallJsonGT(void) { 51135 51136 smallJsont* r; 51137 smallJsont *self = allocSmallJson(); 51138 smallContainert *value = allocSmallContainer(null); 51139 51140 r = injectNFreeSmallContainerSmallJsonG(self, 0, value); 51141 ck_assert_ptr_ne(r, null); 51142 char *s = toStringO(r); 51143 ck_assert_str_eq(s, "[\"<data container>\"]"); 51144 free(s); 51145 terminateO(self); 51146 51147 } 51148 51149 51150 void uniqSmallJsonGT(void) { 51151 51152 smallJsont* r; 51153 smallJsont *self = allocSmallJson(); 51154 51155 self->f->pushUndefined(self); 51156 self->f->pushBool(self, true); 51157 self->f->pushNFreeDict(self, allocSmallDict()); 51158 self->f->pushDouble(self, 1); 51159 self->f->pushInt(self, 2); 51160 self->f->pushS(self, ""); 51161 self->f->pushNFreeArray(self, allocSmallArray()); 51162 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 51163 self->f->pushUndefined(self); 51164 self->f->pushBool(self, true); 51165 self->f->pushNFreeDict(self, allocSmallDict()); 51166 self->f->pushDouble(self, 1); 51167 self->f->pushInt(self, 2); 51168 self->f->pushS(self, ""); 51169 self->f->pushNFreeArray(self, allocSmallArray()); 51170 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 51171 r = uniqSmallJsonG(self, 0); 51172 ck_assert_ptr_ne(r, NULL); 51173 char *s = toStringO(r); 51174 ck_assert_str_eq(s, "[null,true,{},1.000000e+00,2,\"\",[],[0x71,0x77,0x65,0x00]]"); 51175 free(s); 51176 // json string 51177 freeO(self); 51178 setTopSO(self, "/qwd///"); 51179 r = uniqSmallJsonG(self, '/'); 51180 ck_assert_ptr_ne(r, null); 51181 s = toStringO(r); 51182 ck_assert_str_eq(s, "/qwd/"); 51183 free(s); 51184 terminateO(self); 51185 51186 } 51187 51188 51189 void sortSmallJsonGT(void) { 51190 51191 smallJsont* r; 51192 smallJsont *self = allocSmallJson(); 51193 51194 self->f->pushS(self, "bb"); 51195 self->f->pushS(self, "a"); 51196 r = sortSmallJsonG(self); 51197 ck_assert_ptr_ne(r, null); 51198 char *s = toStringO(r); 51199 ck_assert_str_eq(s, "[\"a\",\"bb\"]"); 51200 free(s); 51201 terminateO(self); 51202 51203 } 51204 51205 51206 void sortFSmallJsonGT(void) { 51207 51208 smallJsont* r; 51209 smallJsont *self = allocSmallJson(); 51210 51211 // sort dict 51212 smallDictt *d[4]; 51213 arange(i,d) d[i] = allocSmallDict(); 51214 d[0]->f->setInt(d[0], "a", 1); 51215 d[1]->f->setInt(d[1], "a", 0); 51216 d[3]->f->setInt(d[3], "a", 0); 51217 d[3]->f->setInt(d[3], "b", 0); 51218 arange(i,d) self->f->pushNFreeDict(self, d[i]); 51219 r = sortFSmallJsonG(self, sortFOCmp); 51220 ck_assert_ptr_ne(r, null); 51221 char *s = toStringO(r); 51222 ck_assert_str_eq(s, "[{},{\"a\":0},{\"a\":1},{\"a\":0,\"b\":0}]"); 51223 free(s); 51224 terminateO(self); 51225 51226 } 51227 51228 51229 void icSortSmallJsonGT(void) { 51230 51231 smallJsont* r; 51232 smallJsont *self = allocSmallJson(); 51233 51234 self->f->pushS(self, "bb"); 51235 self->f->pushS(self, "A"); 51236 r = icSortSmallJsonG(self); 51237 ck_assert_ptr_ne(r, null); 51238 char *s = toStringO(r); 51239 ck_assert_str_eq(s, "[\"A\",\"bb\"]"); 51240 free(s); 51241 terminateO(self); 51242 51243 } 51244 51245 51246 void icUniqSmallJsonGT(void) { 51247 51248 smallJsont* r; 51249 smallJsont *self = allocSmallJson(); 51250 51251 self->f->pushUndefined(self); 51252 self->f->pushBool(self, true); 51253 self->f->pushNFreeDict(self, allocSmallDict()); 51254 self->f->pushDouble(self, 1); 51255 self->f->pushInt(self, 2); 51256 self->f->pushS(self, "ASD"); 51257 self->f->pushNFreeArray(self, allocSmallArray()); 51258 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 51259 self->f->pushUndefined(self); 51260 self->f->pushBool(self, true); 51261 self->f->pushNFreeDict(self, allocSmallDict()); 51262 self->f->pushDouble(self, 1); 51263 self->f->pushInt(self, 2); 51264 self->f->pushS(self, "asd"); 51265 self->f->pushNFreeArray(self, allocSmallArray()); 51266 self->f->pushNFreeSmallBytes(self, allocSmallBytes("qwe",4)); 51267 r = icUniqSmallJsonG(self, 0); 51268 ck_assert_ptr_ne(r, NULL); 51269 char *s = toStringO(r); 51270 ck_assert_str_eq(s, "[null,true,{},1.000000e+00,2,\"ASD\",[],[0x71,0x77,0x65,0x00]]"); 51271 free(s); 51272 // json string 51273 freeO(self); 51274 setTopSO(self, "/qQwd///"); 51275 r = icUniqSmallJsonG(self, 'q'); 51276 ck_assert_ptr_ne(r, null); 51277 s = toStringO(r); 51278 ck_assert_str_eq(s, "/qwd///"); 51279 free(s); 51280 terminateO(self); 51281 51282 } 51283 51284 51285 void hasSmallJsonGT(void) { 51286 51287 bool r; 51288 smallJsont *self = allocSmallJson(); 51289 51290 r = hasSmallJsonG(self, null); 51291 ck_assert(!r); 51292 terminateO(self); 51293 51294 } 51295 51296 51297 void hasUndefinedSmallJsonGT(void) { 51298 51299 bool r; 51300 smallJsont *self = allocSmallJson(); 51301 51302 r = hasUndefinedSmallJsonG(self, null); 51303 ck_assert(!r); 51304 terminateO(self); 51305 51306 } 51307 51308 51309 void hasBoolSmallJsonGT(void) { 51310 51311 bool r; 51312 smallJsont *self = allocSmallJson(); 51313 51314 r = hasBoolSmallJsonG(self, true); 51315 ck_assert(!r); 51316 terminateO(self); 51317 51318 } 51319 51320 51321 void hasDoubleSmallJsonGT(void) { 51322 51323 bool r; 51324 smallJsont *self = allocSmallJson(); 51325 51326 r = hasDoubleSmallJsonG(self, 1); 51327 ck_assert(!r); 51328 terminateO(self); 51329 51330 } 51331 51332 51333 void hasIntSmallJsonGT(void) { 51334 51335 bool r; 51336 smallJsont *self = allocSmallJson(); 51337 51338 r = hasIntSmallJsonG(self, 1); 51339 ck_assert(!r); 51340 terminateO(self); 51341 51342 } 51343 51344 51345 void hasSSmallJsonGT(void) { 51346 51347 bool r; 51348 smallJsont *self = allocSmallJson(); 51349 51350 r = hasSSmallJsonG(self, null); 51351 ck_assert(!r); 51352 terminateO(self); 51353 51354 } 51355 51356 51357 void hasCharSmallJsonGT(void) { 51358 51359 bool r; 51360 smallJsont *self = allocSmallJson(); 51361 51362 r = hasCharSmallJsonG(self, ' '); 51363 ck_assert(!r); 51364 terminateO(self); 51365 51366 } 51367 51368 51369 void hasDictSmallJsonGT(void) { 51370 51371 bool r; 51372 smallJsont *self = allocSmallJson(); 51373 51374 r = hasDictSmallJsonG(self, null); 51375 ck_assert(!r); 51376 terminateO(self); 51377 51378 } 51379 51380 51381 void hasArraySmallJsonGT(void) { 51382 51383 bool r; 51384 smallJsont *self = allocSmallJson(); 51385 51386 r = hasArraySmallJsonG(self, null); 51387 ck_assert(!r); 51388 terminateO(self); 51389 51390 } 51391 51392 51393 void hasArraycSmallJsonGT(void) { 51394 51395 bool r; 51396 smallJsont *self = allocSmallJson(); 51397 51398 r = hasArraycSmallJsonG(self, null); 51399 ck_assert(!r); 51400 terminateO(self); 51401 51402 } 51403 51404 51405 void hasCArraycSmallJsonGT(void) { 51406 51407 bool r; 51408 smallJsont *self = allocSmallJson(); 51409 51410 r = hasCArraycSmallJsonG(self, null); 51411 ck_assert(!r); 51412 terminateO(self); 51413 51414 } 51415 51416 51417 void hasSmallBoolSmallJsonGT(void) { 51418 51419 bool r; 51420 smallJsont *self = allocSmallJson(); 51421 51422 r = hasSmallBoolSmallJsonG(self, null); 51423 ck_assert(!r); 51424 terminateO(self); 51425 51426 } 51427 51428 51429 void hasSmallBytesSmallJsonGT(void) { 51430 51431 bool r; 51432 smallJsont *self = allocSmallJson(); 51433 51434 r = hasSmallBytesSmallJsonG(self, null); 51435 ck_assert(!r); 51436 terminateO(self); 51437 51438 } 51439 51440 51441 void hasSmallDoubleSmallJsonGT(void) { 51442 51443 bool r; 51444 smallJsont *self = allocSmallJson(); 51445 51446 r = hasSmallDoubleSmallJsonG(self, null); 51447 ck_assert(!r); 51448 terminateO(self); 51449 51450 } 51451 51452 51453 void hasSmallIntSmallJsonGT(void) { 51454 51455 bool r; 51456 smallJsont *self = allocSmallJson(); 51457 51458 r = hasSmallIntSmallJsonG(self, null); 51459 ck_assert(!r); 51460 terminateO(self); 51461 51462 } 51463 51464 51465 void hasSmallJsonSmallJsonGT(void) { 51466 51467 bool r; 51468 smallJsont *self = allocSmallJson(); 51469 51470 r = hasSmallJsonSmallJsonG(self, null); 51471 ck_assert(!r); 51472 terminateO(self); 51473 51474 } 51475 51476 51477 void hasSmallStringSmallJsonGT(void) { 51478 51479 bool r; 51480 smallJsont *self = allocSmallJson(); 51481 51482 r = hasSmallStringSmallJsonG(self, null); 51483 ck_assert(!r); 51484 terminateO(self); 51485 51486 } 51487 51488 51489 void hasSmallContainerSmallJsonGT(void) { 51490 51491 bool r; 51492 smallJsont *self = allocSmallJson(); 51493 51494 r = hasSmallContainerSmallJsonG(self, null); 51495 ck_assert(!r); 51496 terminateO(self); 51497 51498 } 51499 51500 51501 void findSmallJsonGT(void) { 51502 51503 smallJsont* r; 51504 smallJsont *self = allocG(rtSmallJsont); 51505 51506 // find string in the middle 51507 freeO(self); 51508 setTopSO(self, "sheepy"); 51509 r = findSmallJsonG(self, "ee"); 51510 ck_assert_ptr_ne(r, null); 51511 ck_assert_str_eq(sjGet(r), "eepy"); 51512 terminateO(r); 51513 terminateO(self); 51514 51515 } 51516 51517 51518 void findCharSmallJsonGT(void) { 51519 51520 smallJsont* r; 51521 smallJsont *self = allocG(rtSmallJsont); 51522 51523 // find string in the middle 51524 setTopSO(self, "sheepy"); 51525 r = findCharSmallJsonG(self, 'e'); 51526 ck_assert_ptr_ne(r, null); 51527 ck_assert_str_eq(sjGet(r), "eepy"); 51528 terminateO(r); 51529 terminateO(self); 51530 51531 } 51532 51533 51534 void findSmallStringSmallJsonGT(void) { 51535 51536 smallJsont* r; 51537 smallJsont *self = allocG(rtSmallJsont); 51538 smallStringt *needle = allocSmallString("ee"); 51539 51540 // find string in the middle 51541 setTopSO(self, "sheepy"); 51542 r = findSmallStringSmallJsonG(self, needle); 51543 ck_assert_ptr_ne(r, null); 51544 ck_assert_str_eq(sjGet(r), "eepy"); 51545 terminateO(r); 51546 terminateO(needle); 51547 terminateO(self); 51548 51549 } 51550 51551 51552 void findJsonSmallJsonGT(void) { 51553 51554 smallJsont* r; 51555 smallJsont *self = allocG(rtSmallJsont); 51556 smallJsont *needle = allocSmallJson(); 51557 51558 // find string in the middle 51559 setTopSO(self, "sheepy"); 51560 setTopSO(needle, "ee"); 51561 r = findJsonSmallJsonG(self, needle); 51562 ck_assert_ptr_ne(r, null); 51563 ck_assert_str_eq(sjGet(r), "eepy"); 51564 terminateO(r); 51565 terminateO(needle); 51566 terminateO(self); 51567 51568 } 51569 51570 51571 void indexOfSmallJsonGT(void) { 51572 51573 ssize_t r; 51574 smallJsont *self = allocSmallJson(); 51575 51576 r = indexOfSmallJsonG(self, null); 51577 ck_assert_int_eq(r, -1); 51578 terminateO(self); 51579 51580 } 51581 51582 51583 void indexOfUndefinedSmallJsonGT(void) { 51584 51585 ssize_t r; 51586 smallJsont *self = allocSmallJson(); 51587 51588 r = indexOfUndefinedSmallJsonG(self, null); 51589 ck_assert_int_eq(r, -1); 51590 terminateO(self); 51591 51592 } 51593 51594 51595 void indexOfBoolSmallJsonGT(void) { 51596 51597 ssize_t r; 51598 smallJsont *self = allocSmallJson(); 51599 51600 r = indexOfBoolSmallJsonG(self, false); 51601 ck_assert_int_eq(r, -1); 51602 terminateO(self); 51603 51604 } 51605 51606 51607 void indexOfDoubleSmallJsonGT(void) { 51608 51609 ssize_t r; 51610 smallJsont *self = allocSmallJson(); 51611 51612 r = indexOfDoubleSmallJsonG(self, 0); 51613 ck_assert_int_eq(r, -1); 51614 terminateO(self); 51615 51616 } 51617 51618 51619 void indexOfIntSmallJsonGT(void) { 51620 51621 ssize_t r; 51622 smallJsont *self = allocSmallJson(); 51623 51624 r = indexOfIntSmallJsonG(self, 0); 51625 ck_assert_int_eq(r, -1); 51626 terminateO(self); 51627 51628 } 51629 51630 51631 void indexOfSSmallJsonGT(void) { 51632 51633 ssize_t r; 51634 smallJsont *self = allocSmallJson(); 51635 51636 r = indexOfSSmallJsonG(self, null); 51637 ck_assert_int_eq(r, -1); 51638 terminateO(self); 51639 51640 } 51641 51642 51643 void indexOfCharSmallJsonGT(void) { 51644 51645 ssize_t r; 51646 smallJsont *self = allocSmallJson(); 51647 51648 r = indexOfCharSmallJsonG(self, ' '); 51649 ck_assert_int_eq(r, -1); 51650 terminateO(self); 51651 51652 } 51653 51654 51655 void indexOfDictSmallJsonGT(void) { 51656 51657 ssize_t r; 51658 smallJsont *self = allocSmallJson(); 51659 51660 r = indexOfDictSmallJsonG(self, null); 51661 ck_assert_int_eq(r, -1); 51662 terminateO(self); 51663 51664 } 51665 51666 51667 void indexOfArraySmallJsonGT(void) { 51668 51669 ssize_t r; 51670 smallJsont *self = allocSmallJson(); 51671 51672 r = indexOfArraySmallJsonG(self, null); 51673 ck_assert_int_eq(r, -1); 51674 terminateO(self); 51675 51676 } 51677 51678 51679 void indexOfArraycSmallJsonGT(void) { 51680 51681 ssize_t r; 51682 smallJsont *self = allocSmallJson(); 51683 51684 r = indexOfArraycSmallJsonG(self, null); 51685 ck_assert_int_eq(r, -1); 51686 terminateO(self); 51687 51688 } 51689 51690 51691 void indexOfCArraycSmallJsonGT(void) { 51692 51693 ssize_t r; 51694 smallJsont *self = allocSmallJson(); 51695 51696 r = indexOfCArraycSmallJsonG(self, null); 51697 ck_assert_int_eq(r, -1); 51698 terminateO(self); 51699 51700 } 51701 51702 51703 void indexOfSmallBoolSmallJsonGT(void) { 51704 51705 ssize_t r; 51706 smallJsont *self = allocSmallJson(); 51707 51708 r = indexOfSmallBoolSmallJsonG(self, null); 51709 ck_assert_int_eq(r, -1); 51710 terminateO(self); 51711 51712 } 51713 51714 51715 void indexOfSmallBytesSmallJsonGT(void) { 51716 51717 ssize_t r; 51718 smallJsont *self = allocSmallJson(); 51719 51720 r = indexOfSmallBytesSmallJsonG(self, null); 51721 ck_assert_int_eq(r, -1); 51722 terminateO(self); 51723 51724 } 51725 51726 51727 void indexOfSmallDoubleSmallJsonGT(void) { 51728 51729 ssize_t r; 51730 smallJsont *self = allocSmallJson(); 51731 51732 r = indexOfSmallDoubleSmallJsonG(self, null); 51733 ck_assert_int_eq(r, -1); 51734 terminateO(self); 51735 51736 } 51737 51738 51739 void indexOfSmallIntSmallJsonGT(void) { 51740 51741 ssize_t r; 51742 smallJsont *self = allocSmallJson(); 51743 51744 r = indexOfSmallIntSmallJsonG(self, null); 51745 ck_assert_int_eq(r, -1); 51746 terminateO(self); 51747 51748 } 51749 51750 51751 void indexOfSmallJsonSmallJsonGT(void) { 51752 51753 ssize_t r; 51754 smallJsont *self = allocSmallJson(); 51755 51756 r = indexOfSmallJsonSmallJsonG(self, null); 51757 ck_assert_int_eq(r, -1); 51758 terminateO(self); 51759 51760 } 51761 51762 51763 void indexOfSmallStringSmallJsonGT(void) { 51764 51765 ssize_t r; 51766 smallJsont *self = allocSmallJson(); 51767 51768 r = indexOfSmallStringSmallJsonG(self, null); 51769 ck_assert_int_eq(r, -1); 51770 terminateO(self); 51771 51772 } 51773 51774 51775 void indexOfSmallContainerSmallJsonGT(void) { 51776 51777 ssize_t r; 51778 smallJsont *self = allocSmallJson(); 51779 51780 r = indexOfSmallContainerSmallJsonG(self, null); 51781 ck_assert_int_eq(r, -1); 51782 terminateO(self); 51783 51784 } 51785 51786 51787 void binarySearchSmallJsonGT(void) { 51788 51789 ssize_t r; 51790 smallJsont *self = allocSmallJson(); 51791 51792 r = binarySearchSmallJsonG(self, null); 51793 ck_assert_int_eq(r, -1); 51794 terminateO(self); 51795 51796 } 51797 51798 51799 void binarySearchUndefinedSmallJsonGT(void) { 51800 51801 ssize_t r; 51802 smallJsont *self = allocSmallJson(); 51803 51804 r = binarySearchUndefinedSmallJsonG(self, null); 51805 ck_assert_int_eq(r, -1); 51806 terminateO(self); 51807 51808 } 51809 51810 51811 void binarySearchBoolSmallJsonGT(void) { 51812 51813 ssize_t r; 51814 smallJsont *self = allocSmallJson(); 51815 51816 r = binarySearchBoolSmallJsonG(self, false); 51817 ck_assert_int_eq(r, -1); 51818 terminateO(self); 51819 51820 } 51821 51822 51823 void binarySearchDoubleSmallJsonGT(void) { 51824 51825 ssize_t r; 51826 smallJsont *self = allocSmallJson(); 51827 51828 r = binarySearchDoubleSmallJsonG(self, 0); 51829 ck_assert_int_eq(r, -1); 51830 terminateO(self); 51831 51832 } 51833 51834 51835 void binarySearchIntSmallJsonGT(void) { 51836 51837 ssize_t r; 51838 smallJsont *self = allocSmallJson(); 51839 51840 r = binarySearchIntSmallJsonG(self, 0); 51841 ck_assert_int_eq(r, -1); 51842 terminateO(self); 51843 51844 } 51845 51846 51847 void binarySearchSSmallJsonGT(void) { 51848 51849 ssize_t r; 51850 smallJsont *self = allocSmallJson(); 51851 51852 r = binarySearchSSmallJsonG(self, null); 51853 ck_assert_int_eq(r, -1); 51854 terminateO(self); 51855 51856 } 51857 51858 51859 void binarySearchCharSmallJsonGT(void) { 51860 51861 ssize_t r; 51862 smallJsont *self = allocSmallJson(); 51863 51864 r = binarySearchCharSmallJsonG(self, ' '); 51865 ck_assert_int_eq(r, -1); 51866 terminateO(self); 51867 51868 } 51869 51870 51871 void binarySearchDictSmallJsonGT(void) { 51872 51873 ssize_t r; 51874 smallJsont *self = allocSmallJson(); 51875 51876 r = binarySearchDictSmallJsonG(self, null); 51877 ck_assert_int_eq(r, -1); 51878 terminateO(self); 51879 51880 } 51881 51882 51883 void binarySearchArraySmallJsonGT(void) { 51884 51885 ssize_t r; 51886 smallJsont *self = allocSmallJson(); 51887 51888 r = binarySearchArraySmallJsonG(self, null); 51889 ck_assert_int_eq(r, -1); 51890 terminateO(self); 51891 51892 } 51893 51894 51895 void binarySearchArraycSmallJsonGT(void) { 51896 51897 ssize_t r; 51898 smallJsont *self = allocSmallJson(); 51899 51900 r = binarySearchArraycSmallJsonG(self, null); 51901 ck_assert_int_eq(r, -1); 51902 terminateO(self); 51903 51904 } 51905 51906 51907 void binarySearchCArraycSmallJsonGT(void) { 51908 51909 ssize_t r; 51910 smallJsont *self = allocSmallJson(); 51911 51912 r = binarySearchCArraycSmallJsonG(self, null); 51913 ck_assert_int_eq(r, -1); 51914 terminateO(self); 51915 51916 } 51917 51918 51919 void binarySearchSmallBoolSmallJsonGT(void) { 51920 51921 ssize_t r; 51922 smallJsont *self = allocSmallJson(); 51923 51924 r = binarySearchSmallBoolSmallJsonG(self, null); 51925 ck_assert_int_eq(r, -1); 51926 terminateO(self); 51927 51928 } 51929 51930 51931 void binarySearchSmallBytesSmallJsonGT(void) { 51932 51933 ssize_t r; 51934 smallJsont *self = allocSmallJson(); 51935 51936 r = binarySearchSmallBytesSmallJsonG(self, null); 51937 ck_assert_int_eq(r, -1); 51938 terminateO(self); 51939 51940 } 51941 51942 51943 void binarySearchSmallDoubleSmallJsonGT(void) { 51944 51945 ssize_t r; 51946 smallJsont *self = allocSmallJson(); 51947 51948 r = binarySearchSmallDoubleSmallJsonG(self, null); 51949 ck_assert_int_eq(r, -1); 51950 terminateO(self); 51951 51952 } 51953 51954 51955 void binarySearchSmallIntSmallJsonGT(void) { 51956 51957 ssize_t r; 51958 smallJsont *self = allocSmallJson(); 51959 51960 r = binarySearchSmallIntSmallJsonG(self, null); 51961 ck_assert_int_eq(r, -1); 51962 terminateO(self); 51963 51964 } 51965 51966 51967 void binarySearchSmallJsonSmallJsonGT(void) { 51968 51969 ssize_t r; 51970 smallJsont *self = allocSmallJson(); 51971 51972 r = binarySearchSmallJsonSmallJsonG(self, null); 51973 ck_assert_int_eq(r, -1); 51974 terminateO(self); 51975 51976 } 51977 51978 51979 void binarySearchSmallStringSmallJsonGT(void) { 51980 51981 ssize_t r; 51982 smallJsont *self = allocSmallJson(); 51983 51984 r = binarySearchSmallStringSmallJsonG(self, null); 51985 ck_assert_int_eq(r, -1); 51986 terminateO(self); 51987 51988 } 51989 51990 51991 void binarySearchSmallContainerSmallJsonGT(void) { 51992 51993 ssize_t r; 51994 smallJsont *self = allocSmallJson(); 51995 51996 r = binarySearchSmallContainerSmallJsonG(self, null); 51997 ck_assert_int_eq(r, -1); 51998 terminateO(self); 51999 52000 } 52001 52002 52003 void icHasSmallJsonGT(void) { 52004 52005 bool r; 52006 smallJsont *self = allocSmallJson(); 52007 52008 r = icHasSmallJsonG(self, null); 52009 ck_assert(!r); 52010 terminateO(self); 52011 52012 } 52013 52014 52015 void icHasSSmallJsonGT(void) { 52016 52017 bool r; 52018 smallJsont *self = allocSmallJson(); 52019 52020 r = icHasSSmallJsonG(self, null); 52021 ck_assert(!r); 52022 terminateO(self); 52023 52024 } 52025 52026 52027 void icHasCharSmallJsonGT(void) { 52028 52029 bool r; 52030 smallJsont *self = allocSmallJson(); 52031 52032 r = icHasCharSmallJsonG(self, 'a'); 52033 ck_assert(!r); 52034 terminateO(self); 52035 52036 } 52037 52038 52039 void icHasDictSmallJsonGT(void) { 52040 52041 bool r; 52042 smallJsont *self = allocSmallJson(); 52043 52044 r = icHasDictSmallJsonG(self, null); 52045 ck_assert(!r); 52046 terminateO(self); 52047 52048 } 52049 52050 52051 void icHasArraySmallJsonGT(void) { 52052 52053 bool r; 52054 smallJsont *self = allocSmallJson(); 52055 52056 r = icHasArraySmallJsonG(self, null); 52057 ck_assert(!r); 52058 terminateO(self); 52059 52060 } 52061 52062 52063 void icHasArraycSmallJsonGT(void) { 52064 52065 bool r; 52066 smallJsont *self = allocSmallJson(); 52067 52068 r = icHasArraycSmallJsonG(self, null); 52069 ck_assert(!r); 52070 terminateO(self); 52071 52072 } 52073 52074 52075 void icHasCArraycSmallJsonGT(void) { 52076 52077 bool r; 52078 smallJsont *self = allocSmallJson(); 52079 52080 r = icHasCArraycSmallJsonG(self, null); 52081 ck_assert(!r); 52082 terminateO(self); 52083 52084 } 52085 52086 52087 void icHasSmallStringSmallJsonGT(void) { 52088 52089 bool r; 52090 smallJsont *self = allocSmallJson(); 52091 52092 r = icHasSmallStringSmallJsonG(self, null); 52093 ck_assert(!r); 52094 terminateO(self); 52095 52096 } 52097 52098 52099 void icFindSmallJsonGT(void) { 52100 52101 smallJsont* r; 52102 smallJsont *self = allocG(rtSmallJsont); 52103 52104 // icFind string in the middle 52105 setTopSO(self, "sheepy"); 52106 r = icFindSmallJsonG(self, "EE"); 52107 ck_assert_ptr_ne(r, null); 52108 ck_assert_str_eq(sjGet(r), "eepy"); 52109 terminateO(r); 52110 terminateO(self); 52111 52112 } 52113 52114 52115 void icFindCharSmallJsonGT(void) { 52116 52117 smallJsont* r; 52118 smallJsont *self = allocG(rtSmallJsont); 52119 52120 // find string in the middle 52121 setTopSO(self, "sheepy"); 52122 r = icFindCharSmallJsonG(self, 'E'); 52123 ck_assert_ptr_ne(r, null); 52124 ck_assert_str_eq(sjGet(r), "eepy"); 52125 terminateO(r); 52126 terminateO(self); 52127 52128 } 52129 52130 52131 void icFindSmallStringSmallJsonGT(void) { 52132 52133 smallJsont* r; 52134 smallJsont *self = allocG(rtSmallJsont); 52135 smallStringt *needle = allocSmallString("EE"); 52136 52137 // find string in the middle 52138 setTopSO(self, "sheepy"); 52139 r = icFindSmallStringSmallJsonG(self, needle); 52140 ck_assert_ptr_ne(r, null); 52141 ck_assert_str_eq(sjGet(r), "eepy"); 52142 terminateO(r); 52143 terminateO(needle); 52144 terminateO(self); 52145 52146 } 52147 52148 52149 void icFindJsonSmallJsonGT(void) { 52150 52151 smallJsont* r; 52152 smallJsont *self = allocG(rtSmallJsont); 52153 smallJsont *needle = allocSmallJson(); 52154 52155 // find string in the middle 52156 setTopSO(self, "sheepy"); 52157 setTopSO(needle, "EE"); 52158 r = icFindJsonSmallJsonG(self, needle); 52159 ck_assert_ptr_ne(r, null); 52160 ck_assert_str_eq(sjGet(r), "eepy"); 52161 terminateO(r); 52162 terminateO(needle); 52163 terminateO(self); 52164 52165 } 52166 52167 52168 void icIndexOfSmallJsonGT(void) { 52169 52170 ssize_t r; 52171 smallJsont *self = allocSmallJson(); 52172 52173 r = icIndexOfSmallJsonG(self, null); 52174 ck_assert_int_eq(r, -1); 52175 terminateO(self); 52176 52177 } 52178 52179 52180 void icIndexOfSSmallJsonGT(void) { 52181 52182 ssize_t r; 52183 smallJsont *self = allocSmallJson(); 52184 52185 r = icIndexOfSSmallJsonG(self, null); 52186 ck_assert_int_eq(r, -1); 52187 terminateO(self); 52188 52189 } 52190 52191 52192 void icIndexOfCharSmallJsonGT(void) { 52193 52194 ssize_t r; 52195 smallJsont *self = allocSmallJson(); 52196 52197 r = icIndexOfCharSmallJsonG(self, 'A'); 52198 ck_assert_int_eq(r, -1); 52199 terminateO(self); 52200 52201 } 52202 52203 52204 void icIndexOfDictSmallJsonGT(void) { 52205 52206 ssize_t r; 52207 smallJsont *self = allocSmallJson(); 52208 52209 r = icIndexOfDictSmallJsonG(self, null); 52210 ck_assert_int_eq(r, -1); 52211 terminateO(self); 52212 52213 } 52214 52215 52216 void icIndexOfArraySmallJsonGT(void) { 52217 52218 ssize_t r; 52219 smallJsont *self = allocSmallJson(); 52220 52221 r = icIndexOfArraySmallJsonG(self, null); 52222 ck_assert_int_eq(r, -1); 52223 terminateO(self); 52224 52225 } 52226 52227 52228 void icIndexOfArraycSmallJsonGT(void) { 52229 52230 ssize_t r; 52231 smallJsont *self = allocSmallJson(); 52232 52233 r = icIndexOfArraycSmallJsonG(self, null); 52234 ck_assert_int_eq(r, -1); 52235 terminateO(self); 52236 52237 } 52238 52239 52240 void icIndexOfCArraycSmallJsonGT(void) { 52241 52242 ssize_t r; 52243 smallJsont *self = allocSmallJson(); 52244 52245 r = icIndexOfCArraycSmallJsonG(self, null); 52246 ck_assert_int_eq(r, -1); 52247 terminateO(self); 52248 52249 } 52250 52251 52252 void icIndexOfSmallStringSmallJsonGT(void) { 52253 52254 ssize_t r; 52255 smallJsont *self = allocSmallJson(); 52256 52257 r = icIndexOfSmallStringSmallJsonG(self, null); 52258 ck_assert_int_eq(r, -1); 52259 terminateO(self); 52260 52261 } 52262 52263 52264 void icBinarySearchSmallJsonGT(void) { 52265 52266 ssize_t r; 52267 smallJsont *self = allocSmallJson(); 52268 52269 r = icBinarySearchSmallJsonG(self, null); 52270 ck_assert_int_eq(r, -1); 52271 terminateO(self); 52272 52273 } 52274 52275 52276 void icBinarySearchSSmallJsonGT(void) { 52277 52278 ssize_t r; 52279 smallJsont *self = allocSmallJson(); 52280 52281 r = icBinarySearchSSmallJsonG(self, null); 52282 ck_assert_int_eq(r, -1); 52283 terminateO(self); 52284 52285 } 52286 52287 52288 void icBinarySearchCharSmallJsonGT(void) { 52289 52290 ssize_t r; 52291 smallJsont *self = allocSmallJson(); 52292 52293 r = icBinarySearchCharSmallJsonG(self, 'a'); 52294 ck_assert_int_eq(r, -1); 52295 terminateO(self); 52296 52297 } 52298 52299 52300 void icBinarySearchDictSmallJsonGT(void) { 52301 52302 ssize_t r; 52303 smallJsont *self = allocSmallJson(); 52304 52305 r = icBinarySearchDictSmallJsonG(self, null); 52306 ck_assert_int_eq(r, -1); 52307 terminateO(self); 52308 52309 } 52310 52311 52312 void icBinarySearchArraySmallJsonGT(void) { 52313 52314 ssize_t r; 52315 smallJsont *self = allocSmallJson(); 52316 52317 r = icBinarySearchArraySmallJsonG(self, null); 52318 ck_assert_int_eq(r, -1); 52319 terminateO(self); 52320 52321 } 52322 52323 52324 void icBinarySearchArraycSmallJsonGT(void) { 52325 52326 ssize_t r; 52327 smallJsont *self = allocSmallJson(); 52328 52329 r = icBinarySearchArraycSmallJsonG(self, null); 52330 ck_assert_int_eq(r, -1); 52331 terminateO(self); 52332 52333 } 52334 52335 52336 void icBinarySearchCArraycSmallJsonGT(void) { 52337 52338 ssize_t r; 52339 smallJsont *self = allocSmallJson(); 52340 52341 r = icBinarySearchCArraycSmallJsonG(self, null); 52342 ck_assert_int_eq(r, -1); 52343 terminateO(self); 52344 52345 } 52346 52347 52348 void icBinarySearchSmallStringSmallJsonGT(void) { 52349 52350 ssize_t r; 52351 smallJsont *self = allocSmallJson(); 52352 52353 r = icBinarySearchSmallStringSmallJsonG(self, null); 52354 ck_assert_int_eq(r, -1); 52355 terminateO(self); 52356 52357 } 52358 52359 52360 void keyBySmallJsonGT(void) { 52361 52362 char* r; 52363 smallJsont *self = allocSmallJson(); 52364 baset *value; 52365 52366 smallJsont *r2 = self->f->setInt(self, "1", 1); 52367 ck_assert_ptr_ne(r2, null); 52368 value = (baset*) allocSmallInt(1); 52369 r = keyBySmallJsonG(self, value); 52370 ck_assert_str_eq(r, "1"); 52371 terminateO(value); 52372 terminateO(self); 52373 52374 } 52375 52376 52377 void keyByUndefinedSmallJsonGT(void) { 52378 52379 char* r; 52380 smallJsont *self = allocSmallJson(); 52381 undefinedt *value; 52382 52383 smallJsont *r2 = self->f->setUndefined(self, "1"); 52384 ck_assert_ptr_ne(r2, null); 52385 value = allocUndefined(); 52386 r = keyByUndefinedSmallJsonG(self, value); 52387 ck_assert_str_eq(r, "1"); 52388 terminateO(value); 52389 terminateO(self); 52390 52391 } 52392 52393 52394 void keyByBoolSmallJsonGT(void) { 52395 52396 char* r; 52397 smallJsont *self = allocSmallJson(); 52398 52399 smallJsont *r2 = self->f->setBool(self, "1", true); 52400 ck_assert_ptr_ne(r2, null); 52401 r = keyByBoolSmallJsonG(self, true); 52402 ck_assert_str_eq(r, "1"); 52403 terminateO(self); 52404 52405 } 52406 52407 52408 void keyByDoubleSmallJsonGT(void) { 52409 52410 char* r; 52411 smallJsont *self = allocSmallJson(); 52412 52413 smallJsont *r2 = self->f->setDouble(self, "1", 2.2); 52414 ck_assert_ptr_ne(r2, null); 52415 r = keyByDoubleSmallJsonG(self, 2.2); 52416 ck_assert_str_eq(r, "1"); 52417 terminateO(self); 52418 52419 } 52420 52421 52422 void keyByIntSmallJsonGT(void) { 52423 52424 char* r; 52425 smallJsont *self = allocSmallJson(); 52426 52427 smallJsont *r2 = self->f->setInt(self, "1", 2); 52428 ck_assert_ptr_ne(r2, null); 52429 r = keyByIntSmallJsonG(self, 2); 52430 ck_assert_str_eq(r, "1"); 52431 terminateO(self); 52432 52433 } 52434 52435 52436 void keyBySSmallJsonGT(void) { 52437 52438 char* r; 52439 smallJsont *self = allocSmallJson(); 52440 52441 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 52442 ck_assert_ptr_ne(r2, null); 52443 r = keyBySSmallJsonG(self, "qwe"); 52444 ck_assert_str_eq(r, "1"); 52445 terminateO(self); 52446 52447 } 52448 52449 52450 void keyByCharSmallJsonGT(void) { 52451 52452 char* r; 52453 smallJsont *self = allocSmallJson(); 52454 52455 smallJsont *r2 = self->f->setS(self, "1", "q"); 52456 ck_assert_ptr_ne(r2, null); 52457 r = keyByCharSmallJsonG(self, 'q'); 52458 ck_assert_str_eq(r, "1"); 52459 terminateO(self); 52460 52461 } 52462 52463 52464 void keyByDictSmallJsonGT(void) { 52465 52466 char* r; 52467 smallJsont *self = allocSmallJson(); 52468 smallDictt *dict = allocSmallDict(); 52469 52470 createAllocateSmallDict(d); 52471 d->f->setS(d, "another", "dict"); 52472 smallJsont *r2 = self->f->setNFreeDict(self, "d", d); 52473 ck_assert_ptr_ne(r2, null); 52474 r2 = self->f->setNFreeDict(self, "1", dict); 52475 ck_assert_ptr_ne(r2, null); 52476 dict = allocSmallDict(); 52477 r = keyByDictSmallJsonG(self, dict); 52478 ck_assert_str_eq(r, "1"); 52479 terminateO(dict); 52480 terminateO(self); 52481 52482 } 52483 52484 52485 void keyByArraySmallJsonGT(void) { 52486 52487 char* r; 52488 smallJsont *self = allocSmallJson(); 52489 smallArrayt *array = allocSmallArray(); 52490 52491 createAllocateSmallArray(d); 52492 d->f->pushS(d, "another array"); 52493 smallJsont *r2 = self->f->setNFreeArray(self, "d", d); 52494 ck_assert_ptr_ne(r2, null); 52495 r2 = self->f->setNFreeArray(self, "1", array); 52496 ck_assert_ptr_ne(r2, null); 52497 array = allocSmallArray(); 52498 r = keyByArraySmallJsonG(self, array); 52499 ck_assert_str_eq(r, "1"); 52500 terminateO(array); 52501 terminateO(self); 52502 52503 } 52504 52505 52506 void keyByArraycSmallJsonGT(void) { 52507 52508 char* r; 52509 smallJsont *self = allocSmallJson(); 52510 char **array = listCreateS("a","b"); 52511 52512 char **d = listCreateS("asd", "zxcv"); 52513 smallJsont *r2 = self->f->setNFreeArrayc(self, "d", d); 52514 ck_assert_ptr_ne(r2, null); 52515 r2 = self->f->setArrayc(self, "1", array); 52516 ck_assert_ptr_ne(r2, null); 52517 r = keyByArraycSmallJsonG(self, array); 52518 ck_assert_ptr_ne(r, NULL); 52519 ck_assert_str_eq(r, "1"); 52520 listFreeS(array); 52521 terminateO(self); 52522 52523 } 52524 52525 52526 void keyByCArraycSmallJsonGT(void) { 52527 52528 char* r; 52529 smallJsont *self = allocSmallJson(); 52530 char **array = listCreateS("a","b"); 52531 const char *a[] = {"a", "b", null}; 52532 52533 char **d = listCreateS("asd", "zxcv"); 52534 smallJsont *r2 = self->f->setNFreeArrayc(self, "d", d); 52535 ck_assert_ptr_ne(r2, null); 52536 r2 = self->f->setArrayc(self, "1", array); 52537 ck_assert_ptr_ne(r2, null); 52538 r = keyByCArraycSmallJsonG(self, a); 52539 ck_assert_ptr_ne(r, NULL); 52540 ck_assert_str_eq(r, "1"); 52541 listFreeS(array); 52542 terminateO(self); 52543 52544 } 52545 52546 52547 void keyBySmallBoolSmallJsonGT(void) { 52548 52549 char* r; 52550 smallJsont *self = allocSmallJson(); 52551 smallBoolt *value = allocSmallBool(true); 52552 52553 createAllocateSmallBool(d); 52554 setValO(d, false); 52555 smallJsont *r2 = self->f->setNFreeSmallBool(self, "d", d); 52556 ck_assert_ptr_ne(r2, null); 52557 r2 = self->f->setNFreeSmallBool(self, "1", value); 52558 ck_assert_ptr_ne(r2, null); 52559 value = allocSmallBool(true); 52560 r = keyBySmallBoolSmallJsonG(self, value); 52561 ck_assert_str_eq(r, "1"); 52562 terminateO(value); 52563 terminateO(self); 52564 52565 } 52566 52567 52568 void keyBySmallBytesSmallJsonGT(void) { 52569 52570 char* r; 52571 smallJsont *self = allocSmallJson(); 52572 smallBytest *value = allocSmallBytes("qwe", sizeof("qwe")); 52573 52574 smallBytest *d = allocSmallBytes("asd", sizeof("asd")); 52575 smallJsont *r2 = self->f->setNFreeSmallBytes(self, "d", d); 52576 ck_assert_ptr_ne(r2, null); 52577 r2 = self->f->setNFreeSmallBytes(self, "1", value); 52578 ck_assert_ptr_ne(r2, null); 52579 value = allocSmallBytes("qwe", sizeof("qwe")); 52580 r = keyBySmallBytesSmallJsonG(self, value); 52581 ck_assert_str_eq(r, "1"); 52582 terminateO(value); 52583 terminateO(self); 52584 52585 } 52586 52587 52588 void keyBySmallDoubleSmallJsonGT(void) { 52589 52590 char* r; 52591 smallJsont *self = allocSmallJson(); 52592 smallDoublet *value = allocSmallDouble(2.2); 52593 52594 createAllocateSmallDouble(d); 52595 smallJsont *r2 = self->f->setNFreeSmallDouble(self, "d", d); 52596 ck_assert_ptr_ne(r2, null); 52597 r2 = self->f->setNFreeSmallDouble(self, "1", value); 52598 ck_assert_ptr_ne(r2, null); 52599 value = allocSmallDouble(2.2); 52600 r = keyBySmallDoubleSmallJsonG(self, value); 52601 ck_assert_str_eq(r, "1"); 52602 terminateO(value); 52603 terminateO(self); 52604 52605 } 52606 52607 52608 void keyBySmallIntSmallJsonGT(void) { 52609 52610 char* r; 52611 smallJsont *self = allocSmallJson(); 52612 smallIntt *value = allocSmallInt(2); 52613 52614 createAllocateSmallInt(d); 52615 smallJsont *r2 = self->f->setNFreeSmallInt(self, "d", d); 52616 ck_assert_ptr_ne(r2, null); 52617 r2 = self->f->setNFreeSmallInt(self, "1", value); 52618 ck_assert_ptr_ne(r2, null); 52619 value = allocSmallInt(2); 52620 r = keyBySmallIntSmallJsonG(self, value); 52621 ck_assert_str_eq(r, "1"); 52622 terminateO(value); 52623 terminateO(self); 52624 52625 } 52626 52627 52628 void keyBySmallJsonSmallJsonGT(void) { 52629 52630 char* r; 52631 smallJsont *self = allocSmallJson(); 52632 smallJsont *value = allocSmallJson(); 52633 52634 createUndefined(u); 52635 setTopO(value, (baset*)&u); 52636 self->f->setUndefined(self, "1"); 52637 r = keyBySmallJsonSmallJsonG(self, value); 52638 ck_assert_str_eq(r, "1"); 52639 terminateO(value); 52640 terminateO(self); 52641 52642 } 52643 52644 52645 void keyBySmallStringSmallJsonGT(void) { 52646 52647 char* r; 52648 smallJsont *self = allocSmallJson(); 52649 smallStringt *value = allocSmallString("qwe"); 52650 52651 createAllocateSmallString(d); 52652 smallJsont *r2 = self->f->setNFreeSmallString(self, "d", d); 52653 ck_assert_ptr_ne(r2, null); 52654 r2 = self->f->setNFreeSmallString(self, "1", value); 52655 ck_assert_ptr_ne(r2, null); 52656 value = allocSmallString("qwe"); 52657 r = keyBySmallStringSmallJsonG(self, value); 52658 ck_assert_str_eq(r, "1"); 52659 terminateO(value); 52660 terminateO(self); 52661 52662 } 52663 52664 52665 void keyBySmallContainerSmallJsonGT(void) { 52666 52667 char* r; 52668 smallJsont *self = allocSmallJson(); 52669 smallContainert *value = allocSmallContainer(null); 52670 52671 createAllocateSmallString(d); 52672 smallJsont *r2 = self->f->setNFreeSmallString(self, "d", d); 52673 ck_assert_ptr_ne(r2, null); 52674 r = keyBySmallContainerSmallJsonG(self, value); 52675 ck_assert_ptr_eq(r, null); 52676 terminateO(value); 52677 terminateO(self); 52678 52679 } 52680 52681 52682 void icKeyBySmallJsonGT(void) { 52683 52684 char* r; 52685 smallJsont *self = allocSmallJson(); 52686 baset *value; 52687 52688 smallJsont *r2 = self->f->setS(self, "1", "QQ"); 52689 ck_assert_ptr_ne(r2, null); 52690 value = (baset*) allocSmallString("qq"); 52691 r = icKeyBySmallJsonG(self, value); 52692 ck_assert_str_eq(r, "1"); 52693 terminateO(value); 52694 terminateO(self); 52695 52696 } 52697 52698 52699 void icKeyBySSmallJsonGT(void) { 52700 52701 char* r; 52702 smallJsont *self = allocSmallJson(); 52703 52704 smallJsont *r2 = self->f->setS(self, "1", "qwe"); 52705 ck_assert_ptr_ne(r2, null); 52706 r = icKeyBySSmallJsonG(self, "QWE"); 52707 ck_assert_str_eq(r, "1"); 52708 terminateO(self); 52709 52710 } 52711 52712 52713 void icKeyByCharSmallJsonGT(void) { 52714 52715 char* r; 52716 smallJsont *self = allocSmallJson(); 52717 52718 smallJsont *r2 = self->f->setS(self, "1", "q"); 52719 ck_assert_ptr_ne(r2, null); 52720 r = icKeyByCharSmallJsonG(self, 'Q'); 52721 ck_assert_str_eq(r, "1"); 52722 terminateO(self); 52723 52724 } 52725 52726 52727 void icKeyByDictSmallJsonGT(void) { 52728 52729 char* r; 52730 smallJsont *self = allocSmallJson(); 52731 smallDictt *dict = allocSmallDict(); 52732 52733 createAllocateSmallDict(d); 52734 d->f->setS(d, "another", "dict"); 52735 smallJsont *r2 = self->f->setNFreeDict(self, "d", d); 52736 ck_assert_ptr_ne(r2, null); 52737 dict->f->setS(dict, "asd", "asd"); 52738 r2 = self->f->setNFreeDict(self, "1", dict); 52739 ck_assert_ptr_ne(r2, null); 52740 dict = allocSmallDict(); 52741 dict->f->setS(dict, "ASD", "asd"); 52742 r = icKeyByDictSmallJsonG(self, dict); 52743 ck_assert_str_eq(r, "1"); 52744 terminateO(dict); 52745 terminateO(self); 52746 52747 } 52748 52749 52750 void icKeyByArraySmallJsonGT(void) { 52751 52752 char* r; 52753 smallJsont *self = allocSmallJson(); 52754 smallArrayt *array = allocSmallArray(); 52755 52756 createAllocateSmallArray(d); 52757 d->f->pushS(d, "another array"); 52758 smallJsont *r2 = self->f->setNFreeArray(self, "d", d); 52759 ck_assert_ptr_ne(r2, null); 52760 array->f->pushS(array, "the array"); 52761 r2 = self->f->setNFreeArray(self, "1", array); 52762 ck_assert_ptr_ne(r2, null); 52763 array = allocSmallArray(); 52764 array->f->pushS(array, "The array"); 52765 r = icKeyByArraySmallJsonG(self, array); 52766 ck_assert_str_eq(r, "1"); 52767 terminateO(array); 52768 terminateO(self); 52769 52770 } 52771 52772 52773 void icKeyByArraycSmallJsonGT(void) { 52774 52775 char* r; 52776 smallJsont *self = allocSmallJson(); 52777 char **array = listCreateS("a","b"); 52778 52779 char **d = listCreateS("asd", "zxcv"); 52780 smallJsont *r2 = self->f->setNFreeArrayc(self, "d", d); 52781 ck_assert_ptr_ne(r2, null); 52782 r2 = self->f->setArrayc(self, "1", array); 52783 ck_assert_ptr_ne(r2, null); 52784 iUpperS(&array[0]); 52785 r = icKeyByArraycSmallJsonG(self, array); 52786 ck_assert_ptr_ne(r, NULL); 52787 ck_assert_str_eq(r, "1"); 52788 listFreeS(array); 52789 terminateO(self); 52790 52791 } 52792 52793 52794 void icKeyByCArraycSmallJsonGT(void) { 52795 52796 char* r; 52797 smallJsont *self = allocSmallJson(); 52798 const char *a2[] = {"a","b",null}; 52799 char **array = listCreateS("a","b"); 52800 52801 char **d = listCreateS("asd", "zxcv"); 52802 smallJsont *r2 = self->f->setNFreeArrayc(self, "d", d); 52803 ck_assert_ptr_ne(r2, null); 52804 r2 = self->f->setArrayc(self, "1", array); 52805 ck_assert_ptr_ne(r2, null); 52806 iUpperS(&array[0]); 52807 r = icKeyByCArraycSmallJsonG(self, a2); 52808 ck_assert_ptr_ne(r, NULL); 52809 ck_assert_str_eq(r, "1"); 52810 listFreeS(array); 52811 terminateO(self); 52812 52813 } 52814 52815 52816 void icKeyBySmallStringSmallJsonGT(void) { 52817 52818 char* r; 52819 smallJsont *self = allocSmallJson(); 52820 smallStringt *value = allocSmallString("qwe"); 52821 52822 createAllocateSmallString(d); 52823 smallJsont *r2 = self->f->setNFreeSmallString(self, "d", d); 52824 ck_assert_ptr_ne(r2, null); 52825 r2 = self->f->setNFreeSmallString(self, "1", value); 52826 ck_assert_ptr_ne(r2, null); 52827 value = allocSmallString("QWE"); 52828 r = icKeyBySmallStringSmallJsonG(self, value); 52829 ck_assert_str_eq(r, "1"); 52830 terminateO(value); 52831 terminateO(self); 52832 52833 } 52834 52835 52836 void replaceSmallJsonGT(void) { 52837 52838 smallJsont* r; 52839 smallJsont *self = allocG(rtSmallJsont); 52840 setTopSO(self, "#ee#ee#ad"); 52841 52842 // replace string, multiple character new delimeter 52843 r = replaceSmallJsonG(self, "#","^^", 0); 52844 ck_assert_ptr_ne(r, null); 52845 char *s = toStringO(r); 52846 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 52847 free(s); 52848 terminateO(self); 52849 52850 } 52851 52852 52853 void replaceCharSSmallJsonGT(void) { 52854 52855 smallJsont* r; 52856 smallJsont *self = allocG(rtSmallJsont); 52857 52858 // replace string, multiple character new delimeter 52859 setTopSO(self, "#ee#ee#ad"); 52860 r = replaceCharSSmallJsonG(self, '#',"^^", 0); 52861 ck_assert_ptr_ne(r, null); 52862 char *s = toStringO(r); 52863 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 52864 free(s); 52865 terminateO(self); 52866 52867 } 52868 52869 52870 void replaceSCharSmallJsonGT(void) { 52871 52872 smallJsont* r; 52873 smallJsont *self = allocG(rtSmallJsont); 52874 52875 // replace string, multiple character new delimeter 52876 setTopSO(self, "#ee#ee#ad"); 52877 r = replaceSCharSmallJsonG(self, "#",'^',0); 52878 ck_assert_ptr_ne(r, null); 52879 char *s = toStringO(r); 52880 ck_assert_str_eq(s, "^ee^ee^ad"); 52881 free(s); 52882 terminateO(self); 52883 52884 } 52885 52886 52887 void replaceCharCharSmallJsonGT(void) { 52888 52889 smallJsont* r; 52890 smallJsont *self = allocG(rtSmallJsont); 52891 52892 // replace string, multiple character new delimeter 52893 setTopSO(self, "#ee#ee#ad"); 52894 r = replaceCharCharSmallJsonG(self, '#','^', 0); 52895 ck_assert_ptr_ne(r, null); 52896 char *s = toStringO(r); 52897 ck_assert_str_eq(s, "^ee^ee^ad"); 52898 free(s); 52899 terminateO(self); 52900 52901 } 52902 52903 52904 void replaceSmallStringSmallStringSmallJsonGT(void) { 52905 52906 smallJsont* r; 52907 smallJsont *self = allocG(rtSmallJsont); 52908 setTopSO(self, "#ee#ee#ad"); 52909 smallStringt *olds = allocSmallString(""); 52910 smallStringt *news = allocSmallString(""); 52911 52912 setValO(olds, "#"); 52913 setValO(news, "^^"); 52914 r = replaceSmallStringSmallStringSmallJsonG(self, olds, news, 0); 52915 ck_assert_ptr_ne(r, null); 52916 char *s = toStringO(r); 52917 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 52918 free(s); 52919 terminateO(olds); 52920 terminateO(news); 52921 terminateO(self); 52922 52923 } 52924 52925 52926 void replaceSmallStringSSmallJsonGT(void) { 52927 52928 smallJsont* r; 52929 smallJsont *self = allocG(rtSmallJsont); 52930 setTopSO(self, "#ee#ee#ad"); 52931 smallStringt *olds = allocSmallString(""); 52932 const char *news; 52933 52934 // replace string, multiple character new delimeter 52935 setValO(olds, "#"); 52936 news = "^^"; 52937 r = replaceSmallStringSSmallJsonG(self, olds, news, 0); 52938 ck_assert_ptr_ne(r, null); 52939 char *s = toStringO(r); 52940 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 52941 free(s); 52942 terminateO(olds); 52943 terminateO(self); 52944 52945 } 52946 52947 52948 void replaceSmallStringCharSmallJsonGT(void) { 52949 52950 smallJsont* r; 52951 smallJsont *self = allocG(rtSmallJsont); 52952 setTopSO(self, "#ee#ee#ad"); 52953 smallStringt *olds = allocSmallString(""); 52954 char news; 52955 52956 // replace string, multiple character new delimeter 52957 setValO(olds, "#"); 52958 news = '^'; 52959 r = replaceSmallStringCharSmallJsonG(self, olds, news, 0); 52960 ck_assert_ptr_ne(r, null); 52961 char *s = toStringO(r); 52962 ck_assert_str_eq(s, "^ee^ee^ad"); 52963 free(s); 52964 terminateO(olds); 52965 terminateO(self); 52966 52967 } 52968 52969 52970 void replaceSSmallStringSmallJsonGT(void) { 52971 52972 smallJsont* r; 52973 smallJsont *self = allocG(rtSmallJsont); 52974 setTopSO(self, "#ee#ee#ad"); 52975 const char *olds; 52976 smallStringt *news = allocSmallString(""); 52977 52978 // replace string, multiple character new delimeter 52979 olds = "#"; 52980 setValO(news, "^^"); 52981 r = replaceSSmallStringSmallJsonG(self, olds, news, 0); 52982 ck_assert_ptr_ne(r, null); 52983 char *s = toStringO(r); 52984 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 52985 free(s); 52986 terminateO(news); 52987 terminateO(self); 52988 52989 } 52990 52991 52992 void replaceCharSmallStringSmallJsonGT(void) { 52993 52994 smallJsont* r; 52995 smallJsont *self = allocG(rtSmallJsont); 52996 setTopSO(self, "#ee#ee#ad"); 52997 char olds; 52998 smallStringt *news = allocSmallString(""); 52999 53000 // replace string, multiple character new delimeter 53001 olds = '#'; 53002 setValO(news, "^^"); 53003 r = replaceCharSmallStringSmallJsonG(self, olds, news, 0); 53004 ck_assert_ptr_ne(r, null); 53005 char *s = toStringO(r); 53006 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53007 free(s); 53008 terminateO(news); 53009 terminateO(self); 53010 53011 } 53012 53013 53014 void replaceJsonJsonSmallJsonGT(void) { 53015 53016 smallJsont* r; 53017 smallJsont *self = allocG(rtSmallJsont); 53018 setTopSO(self, "#ee#ee#ad"); 53019 smallJsont *olds = allocSmallJson(); 53020 smallJsont *news = allocSmallJson(); 53021 53022 // replace string, multiple character new delimeter 53023 setTopSO(olds, "#"); 53024 setTopSO(news, "^^"); 53025 r = replaceJsonJsonSmallJsonG(self, olds, news, 0); 53026 ck_assert_ptr_ne(r, null); 53027 char *s = toStringO(r); 53028 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53029 free(s); 53030 terminateO(olds); 53031 terminateO(news); 53032 terminateO(self); 53033 53034 } 53035 53036 53037 void replaceJsonSmallStringSmallJsonGT(void) { 53038 53039 smallJsont* r; 53040 smallJsont *self = allocG(rtSmallJsont); 53041 setTopSO(self, "#ee#ee#ad"); 53042 smallJsont *olds = allocSmallJson(); 53043 smallStringt *news = allocSmallString(""); 53044 53045 // replace string, multiple character new delimeter 53046 freeO(olds); 53047 setTopSO(olds, "#"); 53048 setValO(news, "^^"); 53049 r = replaceJsonSmallStringSmallJsonG(self, olds, news, 0); 53050 ck_assert_ptr_ne(r, null); 53051 char *s = toStringO(r); 53052 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53053 free(s); 53054 terminateO(olds); 53055 terminateO(news); 53056 terminateO(self); 53057 53058 } 53059 53060 53061 void replaceJsonSSmallJsonGT(void) { 53062 53063 smallJsont* r; 53064 smallJsont *self = allocG(rtSmallJsont); 53065 setTopSO(self, "#ee#ee#ad"); 53066 smallJsont *olds = allocSmallJson(); 53067 const char *news; 53068 53069 // replace string, multiple character new delimeter 53070 freeO(olds); 53071 setTopSO(olds, "#"); 53072 news = "^^"; 53073 r = replaceJsonSSmallJsonG(self, olds, news, 0); 53074 ck_assert_ptr_ne(r, null); 53075 char *s = toStringO(r); 53076 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53077 free(s); 53078 terminateO(olds); 53079 terminateO(self); 53080 53081 } 53082 53083 53084 void replaceJsonCharSmallJsonGT(void) { 53085 53086 smallJsont* r; 53087 smallJsont *self = allocG(rtSmallJsont); 53088 setTopSO(self, "#ee#ee#ad"); 53089 smallJsont *olds = allocSmallJson(); 53090 char news; 53091 53092 // replace string, multiple character new delimeter 53093 freeO(olds); 53094 setTopSO(olds, "#"); 53095 news = '^'; 53096 r = replaceJsonCharSmallJsonG(self, olds, news, 0); 53097 ck_assert_ptr_ne(r, null); 53098 char *s = toStringO(r); 53099 ck_assert_str_eq(s, "^ee^ee^ad"); 53100 free(s); 53101 terminateO(olds); 53102 terminateO(self); 53103 53104 } 53105 53106 53107 void replaceSmallStringJsonSmallJsonGT(void) { 53108 53109 smallJsont* r; 53110 smallJsont *self = allocG(rtSmallJsont); 53111 setTopSO(self, "#ee#ee#ad"); 53112 smallStringt *olds = allocSmallString(""); 53113 smallJsont *news = allocSmallJson(); 53114 53115 // replace string, multiple character new delimeter 53116 setValO(olds, "#"); 53117 setTopSO(news, "^^"); 53118 r = replaceSmallStringJsonSmallJsonG(self, olds, news, 0); 53119 ck_assert_ptr_ne(r, null); 53120 char *s = toStringO(r); 53121 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53122 free(s); 53123 terminateO(olds); 53124 terminateO(news); 53125 terminateO(self); 53126 53127 } 53128 53129 53130 void replaceSJsonSmallJsonGT(void) { 53131 53132 smallJsont* r; 53133 smallJsont *self = allocG(rtSmallJsont); 53134 setTopSO(self, "#ee#ee#ad"); 53135 const char *olds; 53136 smallJsont *news = allocSmallJson(); 53137 53138 // replace string, multiple character new delimeter 53139 olds = "#"; 53140 setTopSO(news, "^^"); 53141 r = replaceSJsonSmallJsonG(self, olds, news, 0); 53142 ck_assert_ptr_ne(r, null); 53143 char *s = toStringO(r); 53144 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53145 free(s); 53146 terminateO(news); 53147 terminateO(self); 53148 53149 } 53150 53151 53152 void replaceCharJsonSmallJsonGT(void) { 53153 53154 smallJsont* r; 53155 smallJsont *self = allocG(rtSmallJsont); 53156 setTopSO(self, "#ee#ee#ad"); 53157 char olds; 53158 smallJsont *news = allocSmallJson(); 53159 53160 // replace string, multiple character new delimeter 53161 olds = '#'; 53162 setTopSO(news, "^^"); 53163 r = replaceCharJsonSmallJsonG(self, olds, news, 0); 53164 ck_assert_ptr_ne(r, null); 53165 char *s = toStringO(r); 53166 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53167 free(s); 53168 terminateO(news); 53169 terminateO(self); 53170 53171 } 53172 53173 53174 void icReplaceSmallJsonGT(void) { 53175 53176 smallJsont* r; 53177 smallJsont *self = allocG(rtSmallJsont); 53178 setTopSO(self, "BeebeeBad"); 53179 53180 // replace string, multiple character new delimeter 53181 r = icReplaceSmallJsonG(self, "b","^^", 0); 53182 ck_assert_ptr_ne(r, null); 53183 char *s = toStringO(r); 53184 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53185 free(s); 53186 terminateO(self); 53187 53188 } 53189 53190 53191 void icReplaceCharSSmallJsonGT(void) { 53192 53193 smallJsont* r; 53194 smallJsont *self = allocG(rtSmallJsont); 53195 setTopSO(self, ""); 53196 53197 // replace string, multiple character new delimeter 53198 freeO(self); 53199 setTopSO(self, "BeebeeBad"); 53200 r = icReplaceCharSSmallJsonG(self, 'B',"^^", 0); 53201 ck_assert_ptr_ne(r, null); 53202 char *s = toStringO(r); 53203 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53204 free(s); 53205 terminateO(self); 53206 53207 } 53208 53209 53210 void icReplaceSCharSmallJsonGT(void) { 53211 53212 smallJsont* r; 53213 smallJsont *self = allocG(rtSmallJsont); 53214 setTopSO(self, ""); 53215 53216 // replace string, multiple character new delimeter 53217 freeO(self); 53218 setTopSO(self, "BeebeeBad"); 53219 r = icReplaceSCharSmallJsonG(self, "b",'^',0); 53220 ck_assert_ptr_ne(r, null); 53221 char *s = toStringO(r); 53222 ck_assert_str_eq(s, "^ee^ee^ad"); 53223 free(s); 53224 terminateO(self); 53225 53226 } 53227 53228 53229 void icReplaceCharCharSmallJsonGT(void) { 53230 53231 smallJsont* r; 53232 smallJsont *self = allocG(rtSmallJsont); 53233 setTopSO(self, ""); 53234 53235 // replace string, multiple character new delimeter 53236 freeO(self); 53237 setTopSO(self, "beeBeebad"); 53238 r = icReplaceCharCharSmallJsonG(self, 'b','^', 0); 53239 ck_assert_ptr_ne(r, null); 53240 char *s = toStringO(r); 53241 ck_assert_str_eq(s, "^ee^ee^ad"); 53242 free(s); 53243 terminateO(self); 53244 53245 } 53246 53247 53248 void icReplaceSmallStringSmallStringSmallJsonGT(void) { 53249 53250 smallJsont* r; 53251 smallJsont *self = allocG(rtSmallJsont); 53252 setTopSO(self, "beebeebad"); 53253 smallStringt *olds = allocSmallString(""); 53254 smallStringt *news = allocSmallString(""); 53255 53256 // replace string, multiple character new delimeter 53257 setValO(olds, "B"); 53258 setValO(news, "^^"); 53259 r = icReplaceSmallStringSmallStringSmallJsonG(self, olds, news, 0); 53260 ck_assert_ptr_ne(r, null); 53261 char *s = toStringO(r); 53262 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53263 free(s); 53264 terminateO(olds); 53265 terminateO(news); 53266 terminateO(self); 53267 53268 } 53269 53270 53271 void icReplaceSmallStringSSmallJsonGT(void) { 53272 53273 smallJsont* r; 53274 smallJsont *self = allocG(rtSmallJsont); 53275 setTopSO(self, "beebeebad"); 53276 smallStringt *olds = allocSmallString(""); 53277 const char *news; 53278 53279 // replace string, multiple character new delimeter 53280 setValO(olds, "B"); 53281 news = "^^"; 53282 r = icReplaceSmallStringSSmallJsonG(self, olds, news, 0); 53283 ck_assert_ptr_ne(r, null); 53284 char *s = toStringO(r); 53285 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53286 free(s); 53287 terminateO(olds); 53288 terminateO(self); 53289 53290 } 53291 53292 53293 void icReplaceSmallStringCharSmallJsonGT(void) { 53294 53295 smallJsont* r; 53296 smallJsont *self = allocG(rtSmallJsont); 53297 setTopSO(self, "beebeebad"); 53298 smallStringt *olds = allocSmallString(""); 53299 char news; 53300 53301 // replace string, multiple character new delimeter 53302 setValO(olds, "B"); 53303 news = '^'; 53304 r = icReplaceSmallStringCharSmallJsonG(self, olds, news, 0); 53305 ck_assert_ptr_ne(r, null); 53306 char *s = toStringO(r); 53307 ck_assert_str_eq(s, "^ee^ee^ad"); 53308 free(s); 53309 terminateO(olds); 53310 terminateO(self); 53311 53312 } 53313 53314 53315 void icReplaceSSmallStringSmallJsonGT(void) { 53316 53317 smallJsont* r; 53318 smallJsont *self = allocG(rtSmallJsont); 53319 setTopSO(self, "beebeebad"); 53320 const char *olds; 53321 smallStringt *news = allocSmallString(""); 53322 53323 // replace string, multiple character new delimeter 53324 olds = "B"; 53325 setValO(news, "^^"); 53326 r = icReplaceSSmallStringSmallJsonG(self, olds, news, 0); 53327 ck_assert_ptr_ne(r, null); 53328 char *s = toStringO(r); 53329 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53330 free(s); 53331 terminateO(news); 53332 terminateO(self); 53333 53334 } 53335 53336 53337 void icReplaceCharSmallStringSmallJsonGT(void) { 53338 53339 smallJsont* r; 53340 smallJsont *self = allocG(rtSmallJsont); 53341 setTopSO(self, "beebeebad"); 53342 char olds; 53343 smallStringt *news = allocSmallString(""); 53344 53345 // replace string, multiple character new delimeter 53346 olds = 'B'; 53347 setValO(news, "^^"); 53348 r = icReplaceCharSmallStringSmallJsonG(self, olds, news, 0); 53349 ck_assert_ptr_ne(r, null); 53350 char *s = toStringO(r); 53351 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53352 free(s); 53353 terminateO(news); 53354 terminateO(self); 53355 53356 } 53357 53358 53359 void icReplaceJsonJsonSmallJsonGT(void) { 53360 53361 smallJsont* r; 53362 smallJsont *self = allocG(rtSmallJsont); 53363 setTopSO(self, "BeebeeBad"); 53364 smallJsont *olds = allocSmallJson(); 53365 smallJsont *news = allocSmallJson(); 53366 53367 // replace string, multiple character new delimeter 53368 freeO(olds); 53369 freeO(news); 53370 setTopSO(olds, "B"); 53371 setTopSO(news, "^^"); 53372 r = icReplaceJsonJsonSmallJsonG(self, olds, news, 0); 53373 ck_assert_ptr_ne(r, null); 53374 char *s = toStringO(r); 53375 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53376 free(s); 53377 terminateO(olds); 53378 terminateO(news); 53379 terminateO(self); 53380 53381 } 53382 53383 53384 void icReplaceJsonSmallStringSmallJsonGT(void) { 53385 53386 smallJsont* r; 53387 smallJsont *self = allocG(rtSmallJsont); 53388 setTopSO(self, "BeebeeBad"); 53389 smallJsont *olds = allocSmallJson(); 53390 smallStringt *news = allocSmallString(""); 53391 53392 // replace string, multiple character new delimeter 53393 freeO(olds); 53394 setTopSO(olds, "B"); 53395 setValO(news, "^^"); 53396 r = icReplaceJsonSmallStringSmallJsonG(self, olds, news, 0); 53397 ck_assert_ptr_ne(r, null); 53398 char *s = toStringO(r); 53399 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53400 free(s); 53401 terminateO(olds); 53402 terminateO(news); 53403 terminateO(self); 53404 53405 } 53406 53407 53408 void icReplaceJsonSSmallJsonGT(void) { 53409 53410 smallJsont* r; 53411 smallJsont *self = allocG(rtSmallJsont); 53412 setTopSO(self, "BeebeeBad"); 53413 smallJsont *olds = allocSmallJson(); 53414 const char *news; 53415 53416 // replace string, multiple character new delimeter 53417 freeO(olds); 53418 setTopSO(olds, "b"); 53419 news = "^^"; 53420 r = icReplaceJsonSSmallJsonG(self, olds, news, 0); 53421 ck_assert_ptr_ne(r, null); 53422 char *s = toStringO(r); 53423 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53424 free(s); 53425 terminateO(olds); 53426 terminateO(self); 53427 53428 } 53429 53430 53431 void icReplaceJsonCharSmallJsonGT(void) { 53432 53433 smallJsont* r; 53434 smallJsont *self = allocG(rtSmallJsont); 53435 setTopSO(self, "beeBeebad"); 53436 smallJsont *olds = allocSmallJson(); 53437 char news; 53438 53439 // replace string, multiple character new delimeter 53440 freeO(olds); 53441 setTopSO(olds, "B"); 53442 news = '^'; 53443 r = icReplaceJsonCharSmallJsonG(self, olds, news, 0); 53444 ck_assert_ptr_ne(r, null); 53445 char *s = toStringO(r); 53446 ck_assert_str_eq(s, "^ee^ee^ad"); 53447 free(s); 53448 terminateO(olds); 53449 terminateO(self); 53450 53451 } 53452 53453 53454 void icReplaceSmallStringJsonSmallJsonGT(void) { 53455 53456 smallJsont* r; 53457 smallJsont *self = allocG(rtSmallJsont); 53458 setTopSO(self, "BeeBeeBad"); 53459 smallStringt *olds = allocSmallString(""); 53460 smallJsont *news = allocSmallJson(); 53461 53462 // replace string, multiple character new delimeter 53463 freeO(news); 53464 setValO(olds, "b"); 53465 setTopSO(news, "^^"); 53466 r = icReplaceSmallStringJsonSmallJsonG(self, olds, news, 0); 53467 ck_assert_ptr_ne(r, null); 53468 char *s = toStringO(r); 53469 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53470 free(s); 53471 terminateO(olds); 53472 terminateO(news); 53473 terminateO(self); 53474 53475 } 53476 53477 53478 void icReplaceSJsonSmallJsonGT(void) { 53479 53480 smallJsont* r; 53481 smallJsont *self = allocG(rtSmallJsont); 53482 setTopSO(self, "beebeebad"); 53483 const char *olds; 53484 smallJsont *news = allocSmallJson(); 53485 53486 // replace string, multiple character new delimeter 53487 freeO(news); 53488 olds = "B"; 53489 setTopSO(news, "^^"); 53490 r = icReplaceSJsonSmallJsonG(self, olds, news, 0); 53491 ck_assert_ptr_ne(r, null); 53492 char *s = toStringO(r); 53493 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53494 free(s); 53495 terminateO(news); 53496 terminateO(self); 53497 53498 } 53499 53500 53501 void icReplaceCharJsonSmallJsonGT(void) { 53502 53503 smallJsont* r; 53504 smallJsont *self = allocG(rtSmallJsont); 53505 setTopSO(self, "beebeebad"); 53506 char olds; 53507 smallJsont *news = allocSmallJson(); 53508 53509 // replace string, multiple character new delimeter 53510 freeO(news); 53511 olds = 'B'; 53512 setTopSO(news, "^^"); 53513 r = icReplaceCharJsonSmallJsonG(self, olds, news, 0); 53514 ck_assert_ptr_ne(r, null); 53515 char *s = toStringO(r); 53516 ck_assert_str_eq(s, "^^ee^^ee^^ad"); 53517 free(s); 53518 terminateO(news); 53519 terminateO(self); 53520 53521 } 53522 53523 53524 void equalSmallJsonSmallArrayGT(void) { 53525 53526 bool r; 53527 smallJsont *self = allocG(rtSmallJsont); 53528 smallArrayt *array = allocSmallArray(); 53529 53530 // empty arrays 53531 setTypeArrayO(self); 53532 r = equalSmallJsonSmallArrayG(self, array); 53533 ck_assert(r); 53534 // empty self, non empty array 53535 array->f->pushInt(array, 1); 53536 r = equalSmallJsonSmallArrayG(self, array); 53537 ck_assert(!r); 53538 terminateO(array); 53539 terminateO(self); 53540 53541 } 53542 53543 53544 void equalSmallJsonArrayGT(void) { 53545 53546 bool r; 53547 smallJsont *self = allocG(rtSmallJsont); 53548 char ** p2 = NULL; 53549 53550 // empty arrays 53551 setTypeArrayO(self); 53552 r = equalSmallJsonArrayG(self, NULL); 53553 ck_assert(r); 53554 // empty self, non empty array 53555 p2 = listCreateS("a"); 53556 r = equalSmallJsonArrayG(self, p2); 53557 ck_assert(!r); 53558 listFreeS(p2); 53559 terminateO(self); 53560 53561 } 53562 53563 53564 void equalSmallJsonCArrayGT(void) { 53565 53566 bool r; 53567 smallJsont *self = allocG(rtSmallJsont); 53568 const char *p2[] = {"a", null}; 53569 53570 self->f->pushS(self, "a"); 53571 r = equalSmallJsonCArrayG(self, p2); 53572 ck_assert(r); 53573 terminateO(self); 53574 53575 } 53576 53577 53578 void equalSmallJsonBaseGT(void) { 53579 53580 bool r; 53581 smallJsont *self = allocG(rtSmallJsont); 53582 baset* p2; 53583 53584 // json bool 53585 setTopBoolO(self, false); 53586 p2 = (baset*) allocSmallBool(false); 53587 r = equalSmallJsonBaseG(self, p2); 53588 ck_assert(r); 53589 freeO(self); 53590 setTopBoolO(self, true); 53591 r = equalSmallJsonBaseG(self, p2); 53592 ck_assert(!r); 53593 terminateO(p2); 53594 terminateO(self); 53595 53596 } 53597 53598 53599 void equalSmallJsonChaGT(void) { 53600 53601 bool r; 53602 smallJsont* self = allocG(rtSmallJsont); 53603 setTopSO(self, ""); 53604 53605 r = equalSmallJsonChaG(self,'q'); 53606 ck_assert(!r); 53607 freeO(self); 53608 setTopSO(self, "q"); 53609 r = equalSmallJsonChaG(self,'q'); 53610 ck_assert(r); 53611 terminateO(self); 53612 53613 } 53614 53615 53616 void equalSmallJsonCharGT(void) { 53617 53618 bool r; 53619 smallJsont* self = allocG(rtSmallJsont); 53620 setTopSO(self, ""); 53621 53622 r = equalSmallJsonCharG(self,"qwe"); 53623 ck_assert(!r); 53624 freeO(self); 53625 setTopSO(self, "qwe"); 53626 r = equalSmallJsonCharG(self,"qwe"); 53627 ck_assert(r); 53628 terminateO(self); 53629 53630 } 53631 53632 53633 void equalSmallJsonBoolGT(void) { 53634 53635 bool r; 53636 smallJsont* self = allocG(rtSmallJsont); 53637 53638 // empty json 53639 r = equalSmallJsonBoolG(self, false); 53640 ck_assert(!r); 53641 // json bool 53642 freeO(self); 53643 setTypeBoolO(self); 53644 r = equalSmallJsonBoolG(self, false); 53645 ck_assert(r); 53646 terminateO(self); 53647 53648 } 53649 53650 53651 void equalSmallJsonDoubleGT(void) { 53652 53653 bool r; 53654 smallJsont* self = allocG(rtSmallJsont); 53655 53656 // empty json 53657 r = equalSmallJsonDoubleG(self, 0); 53658 ck_assert(!r); 53659 // json bool 53660 freeO(self); 53661 setTypeBoolO(self); 53662 r = equalSmallJsonDoubleG(self, 0); 53663 ck_assert(r); 53664 terminateO(self); 53665 53666 } 53667 53668 53669 void equalSmallJsonInt64GT(void) { 53670 53671 bool r; 53672 smallJsont* self = allocG(rtSmallJsont); 53673 53674 // empty json 53675 r = equalSmallJsonInt64G(self, 0); 53676 ck_assert(!r); 53677 // json bool 53678 freeO(self); 53679 setTypeBoolO(self); 53680 r = equalSmallJsonInt64G(self, 0); 53681 ck_assert(r); 53682 terminateO(self); 53683 53684 } 53685 53686 53687 void equalSmallJsonInt32GT(void) { 53688 53689 bool r; 53690 smallJsont* self = allocG(rtSmallJsont); 53691 53692 // empty json 53693 r = equalSmallJsonInt32G(self, 0); 53694 ck_assert(!r); 53695 // json bool 53696 freeO(self); 53697 setTypeBoolO(self); 53698 r = equalSmallJsonInt32G(self, 0); 53699 ck_assert(r); 53700 terminateO(self); 53701 53702 } 53703 53704 53705 void equalSmallJsonUint32GT(void) { 53706 53707 bool r; 53708 smallJsont* self = allocG(rtSmallJsont); 53709 53710 // empty json 53711 r = equalSmallJsonUint32G(self, 0); 53712 ck_assert(!r); 53713 // json bool 53714 freeO(self); 53715 setTypeBoolO(self); 53716 r = equalSmallJsonUint32G(self, 0); 53717 ck_assert(r); 53718 terminateO(self); 53719 53720 } 53721 53722 53723 void equalSmallJsonUint64GT(void) { 53724 53725 bool r; 53726 smallJsont* self = allocG(rtSmallJsont); 53727 53728 // empty json 53729 r = equalSmallJsonUint64G(self, 0); 53730 ck_assert(!r); 53731 // json bool 53732 freeO(self); 53733 setTypeBoolO(self); 53734 r = equalSmallJsonUint64G(self, 0); 53735 ck_assert(r); 53736 terminateO(self); 53737 53738 } 53739 53740 53741 void equalSmallJsonSmallBoolGT(void) { 53742 53743 bool r; 53744 smallJsont* self = allocG(rtSmallJsont); 53745 smallBoolt* p2 = allocSmallBool(false); 53746 53747 // empty json 53748 r = equalSmallJsonSmallBoolG(self, p2); 53749 ck_assert(!r); 53750 // not equal 53751 setTopBoolO(self, true); 53752 r = equalSmallJsonSmallBoolG(self, p2); 53753 ck_assert(!r); 53754 // equal 53755 setValO(p2, true); 53756 r = equalSmallJsonSmallBoolG(self, p2); 53757 ck_assert(r); 53758 terminateO(p2); 53759 terminateO(self); 53760 53761 } 53762 53763 53764 void equalSmallJsonSmallBytesGT(void) { 53765 53766 smallJsont* self = allocG(rtSmallJsont); 53767 smallBytest* p2 = allocSmallBytes("true", strlen("true")); 53768 53769 // empty json 53770 ck_assert(!equalSmallJsonSmallBytesG(self, p2)); 53771 // json bool 53772 setTopBoolO(self, true); 53773 ck_assert(!equalSmallJsonSmallBytesG(self, p2)); 53774 freeO(p2); 53775 pushBufferO(p2, "true", sizeof("true")); 53776 ck_assert(equalSmallJsonSmallBytesG(self, p2)); 53777 freeO(self); 53778 terminateO(p2); 53779 terminateO(self); 53780 53781 } 53782 53783 53784 void equalSmallJsonSmallDoubleGT(void) { 53785 53786 bool r; 53787 smallJsont* self = allocG(rtSmallJsont); 53788 smallDoublet* p2 = allocSmallDouble(0); 53789 53790 // empty json 53791 r = equalSmallJsonSmallDoubleG(self, p2); 53792 ck_assert(!r); 53793 // json bool 53794 freeO(self); 53795 setTypeBoolO(self); 53796 r = equalSmallJsonSmallDoubleG(self, p2); 53797 ck_assert(r); 53798 terminateO(p2); 53799 terminateO(self); 53800 53801 } 53802 53803 53804 void equalSmallJsonSmallIntGT(void) { 53805 53806 bool r; 53807 smallJsont* self = allocG(rtSmallJsont); 53808 smallIntt* p2 = allocSmallInt(0); 53809 53810 // empty json 53811 r = equalSmallJsonSmallIntG(self, p2); 53812 ck_assert(!r); 53813 // json bool 53814 freeO(self); 53815 setTypeBoolO(self); 53816 r = equalSmallJsonSmallIntG(self, p2); 53817 ck_assert(r); 53818 terminateO(p2); 53819 terminateO(self); 53820 53821 } 53822 53823 53824 void equalSmallJsonSmallJsonGT(void) { 53825 53826 bool r; 53827 smallJsont* self = allocG(rtSmallJsont); 53828 smallJsont* p2 = allocSmallJson(); 53829 53830 // empty json 53831 r = equalSmallJsonSmallJsonG(self, p2); 53832 ck_assert(!r); 53833 // undefined 53834 setTypeUndefinedO(p2); 53835 ck_assert(!equalSmallJsonSmallJsonG(self, p2)); 53836 setTypeUndefinedO(self); 53837 ck_assert(equalSmallJsonSmallJsonG(self, p2)); 53838 terminateO(p2); 53839 terminateO(self); 53840 53841 } 53842 53843 53844 void equalSmallJsonSmallStringGT(void) { 53845 53846 bool r; 53847 smallJsont* self = allocG(rtSmallJsont); 53848 smallStringt* p2 = allocSmallString(""); 53849 53850 // empty json 53851 r = equalSmallJsonSmallStringG(self, p2); 53852 ck_assert(!r); 53853 // json bool 53854 setTypeBoolO(self); 53855 setValO(p2, "false"); 53856 r = equalSmallJsonSmallStringG(self, p2); 53857 ck_assert(r); 53858 setValO(p2, "true"); 53859 r = equalSmallJsonSmallStringG(self, p2); 53860 ck_assert(!r); 53861 terminateO(p2); 53862 terminateO(self); 53863 53864 } 53865 53866 53867 void equalSmallJsonSmallDictGT(void) { 53868 53869 bool r; 53870 smallJsont* self = allocG(rtSmallJsont); 53871 smallDictt* p2 = allocSmallDict(); 53872 53873 // empty json 53874 r = equalSmallJsonSmallDictG(self, p2); 53875 ck_assert(!r); 53876 setTypeDictO(self); 53877 r = equalSmallJsonSmallDictG(self, p2); 53878 ck_assert(!r); 53879 // equal 53880 self->f->setInt(self, "a", 1); 53881 self->f->setInt(self, "b", 2); 53882 self->f->setInt(self, "c", 3); 53883 p2->f->setInt(p2, "b", 2); 53884 p2->f->setInt(p2, "a", 1); 53885 p2->f->setInt(p2, "c", 3); 53886 r = equalSmallJsonSmallDictG(self, p2); 53887 ck_assert(r); 53888 terminateO(p2); 53889 terminateO(self); 53890 53891 } 53892 53893 53894 void icEqualSmallJsonSmallArrayGT(void) { 53895 53896 bool r; 53897 smallJsont *self = allocG(rtSmallJsont); 53898 smallArrayt *array = allocSmallArray(); 53899 53900 self->f->pushS(self, "a"); 53901 array->f->pushS(array, "A"); 53902 r = icEqualSmallJsonSmallArrayG(self, array); 53903 ck_assert(r); 53904 terminateO(array); 53905 terminateO(self); 53906 53907 } 53908 53909 53910 void icEqualSmallJsonArrayGT(void) { 53911 53912 bool r; 53913 smallJsont *self = allocG(rtSmallJsont); 53914 char ** p2 = NULL; 53915 53916 listPushS(&p2, "a"); 53917 self->f->pushS(self, "A"); 53918 r = icEqualSmallJsonArrayG(self, p2); 53919 ck_assert(r); 53920 listFreeS(p2); 53921 terminateO(self); 53922 53923 } 53924 53925 53926 void icEqualSmallJsonCArrayGT(void) { 53927 53928 bool r; 53929 smallJsont *self = allocG(rtSmallJsont); 53930 const char *p2[] = {"a", null}; 53931 53932 self->f->pushS(self, "A"); 53933 r = icEqualSmallJsonCArrayG(self, p2); 53934 ck_assert(r); 53935 terminateO(self); 53936 53937 } 53938 53939 53940 void icEqualSmallJsonBaseGT(void) { 53941 53942 bool r; 53943 smallJsont *self = allocG(rtSmallJsont); 53944 baset* p2; 53945 53946 // json bool 53947 setTopBoolO(self, false); 53948 p2 = (baset*) allocSmallBool(false); 53949 r = icEqualSmallJsonBaseG(self, p2); 53950 ck_assert(r); 53951 terminateO(p2); 53952 terminateO(self); 53953 53954 } 53955 53956 53957 void icEqualSmallJsonSmallDictGT(void) { 53958 53959 bool r; 53960 smallJsont* self = allocG(rtSmallJsont); 53961 smallDictt* p2 = allocSmallDict(); 53962 53963 // equal 53964 self->f->setS(self, "a", "a"); 53965 self->f->setInt(self, "b", 2); 53966 self->f->setInt(self, "c", 3); 53967 p2->f->setInt(p2, "b", 2); 53968 p2->f->setS(p2, "a", "A"); 53969 p2->f->setInt(p2, "c", 3); 53970 r = icEqualSmallJsonSmallDictG(self, p2); 53971 ck_assert(r); 53972 terminateO(p2); 53973 terminateO(self); 53974 53975 } 53976 53977 53978 void icEqualSmallJsonSmallJsonGT(void) { 53979 53980 bool r; 53981 smallJsont* self = allocG(rtSmallJsont); 53982 smallJsont *string = allocSmallJson(); 53983 53984 setTopSO(string, "qwe"); 53985 setTopSO(self, "QWE"); 53986 r = icEqualSmallJsonSmallJsonG(self, string); 53987 ck_assert(r); 53988 terminateO(string); 53989 terminateO(self); 53990 53991 } 53992 53993 53994 void icEqualSmallJsonSmallStringGT(void) { 53995 53996 bool r; 53997 smallJsont* self = allocG(rtSmallJsont); 53998 smallStringt *string = allocSmallString("qwe"); 53999 54000 setTopSO(self, "QWE"); 54001 r = icEqualSmallJsonSmallStringG(self, string); 54002 ck_assert(r); 54003 terminateO(string); 54004 terminateO(self); 54005 54006 } 54007 54008 54009 void icEqualCharSmallJsonGT(void) { 54010 54011 bool r; 54012 smallJsont *self = allocG(rtSmallJsont); 54013 setTopSO(self, ""); 54014 54015 r = icEqualCharSmallJsonG(self,'q'); 54016 ck_assert(!r); 54017 freeO(self); 54018 setTopSO(self, "q"); 54019 r = icEqualCharSmallJsonG(self,'Q'); 54020 ck_assert(r); 54021 terminateO(self); 54022 54023 } 54024 54025 54026 void icEqualSSmallJsonGT(void) { 54027 54028 bool r; 54029 smallJsont *self = allocG(rtSmallJsont); 54030 54031 // empty json 54032 r = icEqualSSmallJsonG(self, "qwe"); 54033 ck_assert(!r); 54034 // equal 54035 setTopSO(self, "QWE"); 54036 r = icEqualSSmallJsonG(self, "qwe"); 54037 ck_assert(r); 54038 terminateO(self); 54039 54040 } 54041 54042 54043 void equalISSmallJsonGT(void) { 54044 54045 smallJsont *self = allocG(rtSmallJsont); 54046 setTopSO(self, "Ashee|"); 54047 54048 ck_assert(equalISSmallJsonG(self, "shee", 1)); 54049 terminateO(self); 54050 54051 } 54052 54053 54054 void equalICharSmallJsonGT(void) { 54055 54056 smallJsont *self = allocG(rtSmallJsont); 54057 setTopSO(self, "Ashee"); 54058 54059 // identical strings 54060 ck_assert(equalICharSmallJsonG(self, 's', 1)); 54061 terminateO(self); 54062 54063 } 54064 54065 54066 void equalIJsonSmallJsonGT(void) { 54067 54068 smallJsont *self = allocG(rtSmallJsont); 54069 setTopSO(self, "Ashee|"); 54070 smallJsont *string = allocSmallJson(); 54071 54072 // identical strings 54073 setTopSO(string, "shee"); 54074 ck_assert(equalIJsonSmallJsonG(self, string, 1)); 54075 terminateO(string); 54076 terminateO(self); 54077 54078 } 54079 54080 54081 void equalISmallStringSmallJsonGT(void) { 54082 54083 smallJsont *self = allocG(rtSmallJsont); 54084 setTopSO(self, "Ashee|"); 54085 smallStringt *string = allocSmallString("shee"); 54086 54087 // identical strings 54088 ck_assert(equalISmallStringSmallJsonG(self, string, 1)); 54089 terminateO(string); 54090 terminateO(self); 54091 54092 } 54093 54094 54095 void startsWithSSmallJsonGT(void) { 54096 54097 smallJsont *self = allocG(rtSmallJsont); 54098 54099 setTopSO(self, "sheepy"); 54100 ck_assert(startsWithSSmallJsonG(self, "shee")); 54101 terminateO(self); 54102 54103 } 54104 54105 54106 void startsWithCharSmallJsonGT(void) { 54107 54108 smallJsont *self = allocG(rtSmallJsont); 54109 setTopSO(self, "shee"); 54110 54111 // identical strings 54112 ck_assert(startsWithCharSmallJsonG(self, 's')); 54113 terminateO(self); 54114 54115 } 54116 54117 54118 void startsWithSmallStringSmallJsonGT(void) { 54119 54120 smallJsont *self = allocG(rtSmallJsont); 54121 setTopSO(self, "sheepy"); 54122 smallStringt *string = allocSmallString("shee"); 54123 54124 // identical strings 54125 ck_assert(startsWithSmallStringSmallJsonG(self, string)); 54126 terminateO(string); 54127 terminateO(self); 54128 54129 } 54130 54131 54132 void startsWithJsonSmallJsonGT(void) { 54133 54134 smallJsont *self = allocG(rtSmallJsont); 54135 setTopSO(self, "sheepy"); 54136 smallJsont *string = allocSmallJson(); 54137 54138 // identical strings 54139 setTopSO(string, "shee"); 54140 ck_assert(startsWithJsonSmallJsonG(self, string)); 54141 terminateO(string); 54142 terminateO(self); 54143 54144 } 54145 54146 54147 void endsWithSSmallJsonGT(void) { 54148 54149 smallJsont *self = allocG(rtSmallJsont); 54150 setTopSO(self, "sheepy"); 54151 54152 ck_assert(endsWithSSmallJsonG(self, "eepy")); 54153 terminateO(self); 54154 54155 } 54156 54157 54158 void endsWithCharSmallJsonGT(void) { 54159 54160 smallJsont *self = allocG(rtSmallJsont); 54161 setTopSO(self, "shee"); 54162 54163 // identical strings 54164 ck_assert(endsWithCharSmallJsonG(self, 'e')); 54165 terminateO(self); 54166 54167 } 54168 54169 54170 void endsWithSmallStringSmallJsonGT(void) { 54171 54172 smallJsont *self = allocG(rtSmallJsont); 54173 setTopSO(self, "shee"); 54174 smallStringt *string = allocSmallString("hee"); 54175 54176 // identical strings 54177 ck_assert(endsWithSmallStringSmallJsonG(self, string)); 54178 terminateO(string); 54179 terminateO(self); 54180 54181 } 54182 54183 54184 void endsWithJsonSmallJsonGT(void) { 54185 54186 smallJsont *self = allocG(rtSmallJsont); 54187 setTopSO(self, "shee"); 54188 smallJsont *string = allocSmallJson(); 54189 54190 // identical strings 54191 setTopSO(string, "hee"); 54192 ck_assert(endsWithJsonSmallJsonG(self, string)); 54193 terminateO(string); 54194 terminateO(self); 54195 54196 } 54197 54198 54199 void countSSmallJsonGT(void) { 54200 54201 smallJsont *self = allocG(rtSmallJsont); 54202 setTopSO(self, "sheepy"); 54203 54204 // positive count 54205 ck_assert_int_eq(countSSmallJsonG(self, "shee"), 1); 54206 terminateO(self); 54207 54208 } 54209 54210 54211 void countCharSmallJsonGT(void) { 54212 54213 smallJsont *self = allocG(rtSmallJsont); 54214 setTopSO(self, "shee"); 54215 54216 // positive count 54217 ck_assert_int_eq(countCharSmallJsonG(self, 's'), 1); 54218 terminateO(self); 54219 54220 } 54221 54222 54223 void countSmallStringSmallJsonGT(void) { 54224 54225 smallJsont *self = allocG(rtSmallJsont); 54226 setTopSO(self, "sheepy"); 54227 smallStringt *string = allocSmallString("shee"); 54228 54229 // positive count 54230 ck_assert_int_eq(countSmallStringSmallJsonG(self, string), 1); 54231 terminateO(string); 54232 terminateO(self); 54233 54234 } 54235 54236 54237 void countJsonSmallJsonGT(void) { 54238 54239 smallJsont *self = allocG(rtSmallJsont); 54240 setTopSO(self, "sheepy"); 54241 smallJsont *string = allocSmallJson(); 54242 54243 // positive count 54244 setTopSO(string, "shee"); 54245 ck_assert_int_eq(countJsonSmallJsonG(self, string), 1); 54246 terminateO(string); 54247 terminateO(self); 54248 54249 } 54250 54251 54252 void icStartsWithSSmallJsonGT(void) { 54253 54254 smallJsont *self = allocG(rtSmallJsont); 54255 setTopSO(self, "shee"); 54256 54257 ck_assert(icStartsWithSSmallJsonG(self, "SH")); 54258 terminateO(self); 54259 54260 } 54261 54262 54263 void icStartsWithCharSmallJsonGT(void) { 54264 54265 smallJsont *self = allocG(rtSmallJsont); 54266 setTopSO(self, "shee"); 54267 54268 ck_assert(icStartsWithCharSmallJsonG(self, 'S')); 54269 terminateO(self); 54270 54271 } 54272 54273 54274 void icStartsWithSmallStringSmallJsonGT(void) { 54275 54276 smallJsont *self = allocG(rtSmallJsont); 54277 setTopSO(self, "shee"); 54278 smallStringt *string = allocSmallString("SH"); 54279 54280 ck_assert(icStartsWithSmallStringSmallJsonG(self, string)); 54281 terminateO(string); 54282 terminateO(self); 54283 54284 } 54285 54286 54287 void icStartsWithJsonSmallJsonGT(void) { 54288 54289 smallJsont *self = allocG(rtSmallJsont); 54290 setTopSO(self, "shee"); 54291 smallJsont *string = allocSmallJson(); 54292 54293 setTopSO(string, "SH"); 54294 ck_assert(icStartsWithJsonSmallJsonG(self, string)); 54295 terminateO(string); 54296 terminateO(self); 54297 54298 } 54299 54300 54301 void icEndsWithSSmallJsonGT(void) { 54302 54303 smallJsont *self = allocG(rtSmallJsont); 54304 54305 setTopSO(self, "sheepy"); 54306 ck_assert(icEndsWithSSmallJsonG(self, "EEPY")); 54307 terminateO(self); 54308 54309 } 54310 54311 54312 void icEndsWithCharSmallJsonGT(void) { 54313 54314 smallJsont *self = allocG(rtSmallJsont); 54315 setTopSO(self, "shee"); 54316 54317 ck_assert(icEndsWithCharSmallJsonG(self, 'E')); 54318 terminateO(self); 54319 54320 } 54321 54322 54323 void icEndsWithSmallStringSmallJsonGT(void) { 54324 54325 smallJsont *self = allocG(rtSmallJsont); 54326 setTopSO(self, "sheepy"); 54327 smallStringt *string = allocSmallString("EEPY"); 54328 54329 ck_assert(icEndsWithSmallStringSmallJsonG(self, string)); 54330 terminateO(string); 54331 terminateO(self); 54332 54333 } 54334 54335 54336 void icEndsWithJsonSmallJsonGT(void) { 54337 54338 smallJsont *self = allocG(rtSmallJsont); 54339 setTopSO(self, "sheepy"); 54340 smallJsont *string = allocSmallJson(); 54341 54342 setTopSO(string, "EEPY"); 54343 ck_assert(icEndsWithJsonSmallJsonG(self, string)); 54344 terminateO(string); 54345 terminateO(self); 54346 54347 } 54348 54349 54350 void icCountSSmallJsonGT(void) { 54351 54352 smallJsont *self = allocG(rtSmallJsont); 54353 setTopSO(self, "sheepy"); 54354 54355 ck_assert_int_eq(icCountSSmallJsonG(self, "SH"), 1); 54356 terminateO(self); 54357 54358 } 54359 54360 54361 void icCountCharSmallJsonGT(void) { 54362 54363 smallJsont *self = allocG(rtSmallJsont); 54364 setTopSO(self, "shee"); 54365 54366 ck_assert_int_eq(icCountCharSmallJsonG(self, 'S'), 1); 54367 terminateO(self); 54368 54369 } 54370 54371 54372 void icCountSmallStringSmallJsonGT(void) { 54373 54374 smallJsont *self = allocG(rtSmallJsont); 54375 setTopSO(self, "sheepy"); 54376 smallStringt *string = allocSmallString("SHEE"); 54377 54378 ck_assert_int_eq(icCountSmallStringSmallJsonG(self, string), 1); 54379 terminateO(string); 54380 terminateO(self); 54381 54382 } 54383 54384 54385 void icCountJsonSmallJsonGT(void) { 54386 54387 smallJsont *self = allocG(rtSmallJsont); 54388 setTopSO(self, "sheepy"); 54389 smallJsont *string = allocSmallJson(); 54390 54391 setTopSO(string, "SH"); 54392 ck_assert_int_eq(icCountJsonSmallJsonG(self, string), 1); 54393 terminateO(string); 54394 terminateO(self); 54395 54396 } 54397 54398 54399 void isNumberSmallJsonGT(void) { 54400 54401 smallJsont *self = allocG(rtSmallJsont); 54402 54403 setTopSO(self, "-12.3"); 54404 ck_assert(isNumberSmallJsonG(self)); 54405 terminateO(self); 54406 54407 } 54408 54409 54410 void isIntSmallJsonGT(void) { 54411 54412 smallJsont *self = allocG(rtSmallJsont); 54413 54414 setTopSO(self, "-123"); 54415 ck_assert(isIntSmallJsonG(self)); 54416 terminateO(self); 54417 54418 } 54419 54420 54421 void parseIntSmallJsonGT(void) { 54422 54423 smallJsont *self = allocG(rtSmallJsont); 54424 54425 setTopSO(self, "123sheepy"); 54426 ck_assert_int_eq(parseIntSmallJsonG(self), 123); 54427 terminateO(self); 54428 54429 } 54430 54431 54432 void parseDoubleSmallJsonGT(void) { 54433 54434 smallJsont *self = allocG(rtSmallJsont); 54435 54436 setTopSO(self, "123.2sheepy"); 54437 ck_assert_int_eq(parseDoubleSmallJsonG(self), 123); 54438 terminateO(self); 54439 54440 } 54441 54442 54443 void intToSmallJsonGT(void) { 54444 54445 smallJsont* r; 54446 smallJsont *self = allocG(rtSmallJsont); 54447 54448 r = intToSmallJsonG(self, 123); 54449 ck_assert_ptr_ne(r, null); 54450 char *s = toStringO(r); 54451 ck_assert_str_eq(s, "123"); 54452 free(s); 54453 terminateO(self); 54454 54455 } 54456 54457 54458 void doubleToSmallJsonGT(void) { 54459 54460 smallJsont* r; 54461 smallJsont *self = allocG(rtSmallJsont); 54462 54463 r = doubleToSmallJsonG(self, 123.4); 54464 ck_assert_ptr_ne(r, null); 54465 char *s = toStringO(r); 54466 ck_assert_str_eq(s, "1.234000e+02"); 54467 free(s); 54468 terminateO(self); 54469 54470 } 54471 54472 54473 void lenSmallJsonGT(void) { 54474 54475 size_t r; 54476 smallJsont *self = allocSmallJson(); 54477 54478 self->f->pushInt(self, 1); 54479 r = lenSmallJsonG(self); 54480 ck_assert_int_eq(r, 1); 54481 terminateO(self); 54482 54483 } 54484 54485 54486 void upperSmallJsonGT(void) { 54487 54488 smallJsont* r; 54489 smallJsont *self = allocG(rtSmallJsont); 54490 setTopSO(self, "sheepy"); 54491 54492 // string 54493 r = upperSmallJsonG(self); 54494 ck_assert_ptr_ne(r, null); 54495 char *s = toStringO(r); 54496 ck_assert_str_eq(s, "SHEEPY"); 54497 free(s); 54498 terminateO(self); 54499 54500 } 54501 54502 54503 void lowerSmallJsonGT(void) { 54504 54505 smallJsont* r; 54506 smallJsont *self = allocG(rtSmallJsont); 54507 setTopSO(self, "SHeePY"); 54508 54509 // string 54510 r = lowerSmallJsonG(self); 54511 ck_assert_ptr_ne(r, null); 54512 char *s = toStringO(r); 54513 ck_assert_str_eq(s, "sheepy"); 54514 free(s); 54515 terminateO(self); 54516 54517 } 54518 54519 54520 void trimSmallJsonGT(void) { 54521 54522 smallJsont* r; 54523 smallJsont *self = allocSmallJson(); 54524 54525 self->f->pushInt(self, 1); 54526 delElemIndexO(self, 0); 54527 r = trimSmallJsonG(self); 54528 ck_assert_ptr_ne(r, null); 54529 ck_assert_int_eq(lenSmallJsonG(self), 0); 54530 terminateO(self); 54531 54532 } 54533 54534 54535 void lTrimSmallJsonGT(void) { 54536 54537 smallJsont* r; 54538 smallJsont *self = allocG(rtSmallJsont); 54539 54540 setTopSO(self, " SHeePY"); 54541 r = lTrimSmallJsonG(self); 54542 ck_assert_ptr_ne(r, null); 54543 char *s = toStringO(r); 54544 ck_assert_str_eq(s, "SHeePY"); 54545 free(s); 54546 terminateO(self); 54547 54548 } 54549 54550 54551 void rTrimSmallJsonGT(void) { 54552 54553 smallJsont* r; 54554 smallJsont *self = allocG(rtSmallJsont); 54555 54556 setTopSO(self, "SHeePY "); 54557 r = rTrimSmallJsonG(self); 54558 ck_assert_ptr_ne(r, null); 54559 char *s = toStringO(r); 54560 ck_assert_str_eq(s, "SHeePY"); 54561 free(s); 54562 terminateO(self); 54563 54564 } 54565 54566 54567 void compactSmallJsonGT(void) { 54568 54569 smallJsont* r; 54570 smallJsont *self = allocSmallJson(); 54571 54572 self->f->pushUndefined(self); 54573 // null element 54574 self->f->pushUndefined(self); 54575 delElemIndexO(self, 1); 54576 self->f->pushBool(self, true); 54577 createSmallContainer(c); 54578 self->f->pushSmallContainer(self, &c); 54579 // empty dict 54580 createSmallDict(d); 54581 self->f->pushDict(self, &d); 54582 resetO(&d); 54583 (&d)->f->setInt(&d, "a", 1); 54584 self->f->pushDict(self, &d); 54585 self->f->pushDouble(self, 2); 54586 self->f->pushInt(self, 5); 54587 self->f->pushS(self, " "); 54588 self->f->pushS(self, "asd"); 54589 // empty Array 54590 createSmallArray(a); 54591 self->f->pushArray(self, &a); 54592 resetO(&a); 54593 (&a)->f->pushInt(&a, 1); 54594 self->f->pushArray(self, &a); 54595 // empty bytes 54596 createSmallBytes(b); 54597 self->f->pushSmallBytes(self, &b); 54598 smallBytest *B = allocSmallBytes("asd", 4); 54599 self->f->pushNFreeSmallBytes(self, B); 54600 r = compactSmallJsonG(self); 54601 ck_assert_ptr_ne(r, NULL); 54602 ck_assert_int_eq(lenO(r), 8); 54603 char *s = toStringO(r); 54604 ck_assert_str_eq(s, "[true,\"<data container>\",{\"a\":1},2.000000e+00,5,\"asd\",[1],[0x61,0x73,0x64,0x00]]"); 54605 free(s); 54606 terminateO(self); 54607 54608 } 54609 54610 54611 void emptySmallJsonGT(void) { 54612 54613 smallJsont* r; 54614 smallJsont *self = allocSmallJson(); 54615 54616 self->f->pushInt(self, 1); 54617 r = emptySmallJsonG(self); 54618 ck_assert_ptr_ne(r, null); 54619 char *s = toStringO(r); 54620 ck_assert_str_eq(s, "[]"); 54621 free(s); 54622 terminateO(self); 54623 54624 } 54625 54626 54627 void isEmptySmallJsonGT(void) { 54628 54629 bool r; 54630 smallJsont *self = allocSmallJson(); 54631 54632 r = isEmptySmallJsonG(self); 54633 ck_assert(r); 54634 terminateO(self); 54635 54636 } 54637 54638 54639 void isBlankSmallJsonGT(void) { 54640 54641 bool r; 54642 smallJsont *self = allocSmallJson(); 54643 54644 r = isBlankSmallJsonG(self); 54645 ck_assert(r); 54646 terminateO(self); 54647 54648 } 54649 54650 54651 void joinSmallJsonGT(void) { 54652 54653 smallStringt* r; 54654 smallJsont *self = allocSmallJson(); 54655 54656 self->f->pushS(self, "a"); 54657 self->f->pushS(self, "b"); 54658 r = joinSmallJsonG(self, "|"); 54659 ck_assert_ptr_ne(r, null); 54660 char *s = toStringO(r); 54661 ck_assert_str_eq(s, "a|b"); 54662 free(s); 54663 terminateO(r); 54664 terminateO(self); 54665 54666 } 54667 54668 54669 void joinCharSmallJsonGT(void) { 54670 54671 smallStringt* r; 54672 smallJsont *self = allocSmallJson(); 54673 54674 self->f->pushS(self, "a"); 54675 self->f->pushS(self, "b"); 54676 r = joinCharSmallJsonG(self, '|'); 54677 ck_assert_ptr_ne(r, null); 54678 char *s = toStringO(r); 54679 ck_assert_str_eq(s, "a|b"); 54680 free(s); 54681 terminateO(r); 54682 terminateO(self); 54683 54684 } 54685 54686 54687 void joinSmallJsonSmallJsonGT(void) { 54688 54689 smallStringt* r; 54690 smallJsont *self = allocSmallJson(); 54691 54692 r = joinSmallJsonSmallJsonG(self, null); 54693 ck_assert_ptr_eq(r, null); 54694 terminateO(self); 54695 54696 } 54697 54698 54699 void joinSmallStringSmallJsonGT(void) { 54700 54701 smallStringt* r; 54702 smallJsont *self = allocSmallJson(); 54703 54704 r = joinSmallStringSmallJsonG(self, null); 54705 ck_assert_ptr_eq(r, null); 54706 terminateO(self); 54707 54708 } 54709 54710 54711 void joinSSmallJsonGT(void) { 54712 54713 char* r; 54714 smallJsont *self = allocSmallJson(); 54715 54716 r = joinSSmallJsonG(self, null); 54717 ck_assert_ptr_eq(r, null); 54718 terminateO(self); 54719 54720 } 54721 54722 54723 void joinCharSSmallJsonGT(void) { 54724 54725 char* r; 54726 smallJsont *self = allocSmallJson(); 54727 54728 r = joinCharSSmallJsonG(self, '#'); 54729 ck_assert_ptr_eq(r, null); 54730 terminateO(self); 54731 54732 } 54733 54734 54735 void joinSmallJsonSSmallJsonGT(void) { 54736 54737 char* r; 54738 smallJsont *self = allocSmallJson(); 54739 54740 r = joinSmallJsonSSmallJsonG(self, null); 54741 ck_assert_ptr_eq(r, null); 54742 terminateO(self); 54743 54744 } 54745 54746 54747 void joinSmallStringSSmallJsonGT(void) { 54748 54749 char* r; 54750 smallJsont *self = allocSmallJson(); 54751 54752 r = joinSmallStringSSmallJsonG(self, null); 54753 ck_assert_ptr_eq(r, null); 54754 terminateO(self); 54755 54756 } 54757 54758 54759 void splitSmallJsonGT(void) { 54760 54761 smallJsont* r; 54762 smallJsont *self = allocG(rtSmallJsont); 54763 54764 setTopSO(self, "one/two"); 54765 r = splitSmallJsonG(self, "/"); 54766 ck_assert_ptr_ne(r, null); 54767 char *s = toStringO(r); 54768 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 54769 free(s); 54770 terminateO(r); 54771 terminateO(self); 54772 54773 } 54774 54775 54776 void splitCharSmallJsonGT(void) { 54777 54778 smallJsont* r; 54779 smallJsont *self = allocG(rtSmallJsont); 54780 54781 setTopSO(self, "one/two"); 54782 r = splitCharSmallJsonG(self, '/'); 54783 ck_assert_ptr_ne(r, null); 54784 char *s = toStringO(r); 54785 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 54786 free(s); 54787 terminateO(r); 54788 terminateO(self); 54789 54790 } 54791 54792 54793 void splitSmallJsonSmallJsonGT(void) { 54794 54795 smallJsont* r; 54796 smallJsont *self = allocG(rtSmallJsont); 54797 smallJsont *delim = allocSmallJson(); 54798 54799 setTopSO(self, "one/two"); 54800 setTopSO(delim, "/"); 54801 r = splitSmallJsonSmallJsonG(self, delim); 54802 ck_assert_ptr_ne(r, null); 54803 char *s = toStringO(r); 54804 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 54805 free(s); 54806 terminateO(r); 54807 terminateO(delim); 54808 terminateO(self); 54809 54810 } 54811 54812 54813 void splitSmallStringSmallJsonGT(void) { 54814 54815 smallJsont* r; 54816 smallJsont *self = allocG(rtSmallJsont); 54817 smallStringt *delim = allocSmallString("/"); 54818 54819 setTopSO(self, "one/two"); 54820 r = splitSmallStringSmallJsonG(self, delim); 54821 ck_assert_ptr_ne(r, null); 54822 char *s = toStringO(r); 54823 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 54824 free(s); 54825 terminateO(r); 54826 terminateO(delim); 54827 terminateO(self); 54828 54829 } 54830 54831 54832 void splitSSmallJsonGT(void) { 54833 54834 char** r; 54835 smallJsont *self = allocG(rtSmallJsont); 54836 54837 setTopSO(self, "one/two"); 54838 r = splitSSmallJsonG(self, "/"); 54839 ck_assert_uint_eq(listLengthS(r),2); 54840 ck_assert_str_eq(r[0], "one"); 54841 ck_assert_str_eq(r[1], "two"); 54842 listFreeS(r); 54843 terminateO(self); 54844 54845 } 54846 54847 54848 void splitCharSSmallJsonGT(void) { 54849 54850 char** r; 54851 smallJsont *self = allocG(rtSmallJsont); 54852 54853 setTopSO(self, "one/two"); 54854 r = splitCharSSmallJsonG(self, '/'); 54855 ck_assert_uint_eq(listLengthS(r),2); 54856 ck_assert_str_eq(r[0], "one"); 54857 ck_assert_str_eq(r[1], "two"); 54858 listFreeS(r); 54859 terminateO(self); 54860 54861 } 54862 54863 54864 void splitSmallJsonSSmallJsonGT(void) { 54865 54866 char** r; 54867 smallJsont *self = allocG(rtSmallJsont); 54868 smallJsont *delim = allocSmallJson(); 54869 54870 setTopSO(self, "one/two"); 54871 setTopSO(delim, "/"); 54872 r = splitSmallJsonSSmallJsonG(self, delim); 54873 ck_assert_uint_eq(listLengthS(r),2); 54874 ck_assert_str_eq(r[0], "one"); 54875 ck_assert_str_eq(r[1], "two"); 54876 listFreeS(r); 54877 terminateO(delim); 54878 terminateO(self); 54879 54880 } 54881 54882 54883 void splitSmallStringSSmallJsonGT(void) { 54884 54885 char** r; 54886 smallJsont *self = allocG(rtSmallJsont); 54887 smallStringt *delim = allocSmallString("/"); 54888 54889 setTopSO(self, "one/two"); 54890 r = splitSmallStringSSmallJsonG(self, delim); 54891 ck_assert_uint_eq(listLengthS(r),2); 54892 ck_assert_str_eq(r[0], "one"); 54893 ck_assert_str_eq(r[1], "two"); 54894 listFreeS(r); 54895 terminateO(delim); 54896 terminateO(self); 54897 54898 } 54899 54900 54901 void extractSmallJsonGT(void) { 54902 54903 smallJsont* r; 54904 smallJsont *self = allocG(rtSmallJsont); 54905 54906 setTopSO(self, "one/two|"); 54907 r = extractSmallJsonG(self, "/", "|"); 54908 ck_assert_ptr_ne(r, null); 54909 char *s = toStringO(r); 54910 ck_assert_str_eq(s, "[\"two\"]"); 54911 free(s); 54912 terminateO(r); 54913 terminateO(self); 54914 54915 } 54916 54917 54918 void extractCharSSmallJsonGT(void) { 54919 54920 smallJsont* r; 54921 smallJsont *self = allocG(rtSmallJsont); 54922 54923 setTopSO(self, "one/two|"); 54924 r = extractCharSSmallJsonG(self, '/', "|"); 54925 ck_assert_ptr_ne(r, null); 54926 char *s = toStringO(r); 54927 ck_assert_str_eq(s, "[\"two\"]"); 54928 free(s); 54929 terminateO(r); 54930 terminateO(self); 54931 54932 } 54933 54934 54935 void extractSCharSmallJsonGT(void) { 54936 54937 smallJsont* r; 54938 smallJsont *self = allocG(rtSmallJsont); 54939 54940 setTopSO(self, "one/two|"); 54941 r = extractSCharSmallJsonG(self, "/", '|'); 54942 ck_assert_ptr_ne(r, null); 54943 char *s = toStringO(r); 54944 ck_assert_str_eq(s, "[\"two\"]"); 54945 free(s); 54946 terminateO(r); 54947 terminateO(self); 54948 54949 } 54950 54951 54952 void extractCharCharSmallJsonGT(void) { 54953 54954 smallJsont* r; 54955 smallJsont *self = allocG(rtSmallJsont); 54956 54957 setTopSO(self, "one/two|"); 54958 r = extractCharCharSmallJsonG(self, '/', '|'); 54959 ck_assert_ptr_ne(r, null); 54960 char *s = toStringO(r); 54961 ck_assert_str_eq(s, "[\"two\"]"); 54962 free(s); 54963 terminateO(r); 54964 terminateO(self); 54965 54966 } 54967 54968 54969 void extractSmallJsonSmallJsonSmallJsonGT(void) { 54970 54971 smallJsont* r; 54972 smallJsont *self = allocG(rtSmallJsont); 54973 smallJsont* delim1 = allocSmallJson(); 54974 smallJsont* delim2 = allocSmallJson(); 54975 54976 setTopSO(self, "one/two|"); 54977 setTopSO(delim1, "/"); 54978 setTopSO(delim2, "|"); 54979 r = extractSmallJsonSmallJsonSmallJsonG(self, delim1, delim2); 54980 ck_assert_ptr_ne(r, null); 54981 char *s = toStringO(r); 54982 ck_assert_str_eq(s, "[\"two\"]"); 54983 free(s); 54984 terminateO(r); 54985 terminateO(delim1); 54986 terminateO(delim2); 54987 terminateO(self); 54988 54989 } 54990 54991 54992 void extractSmallJsonSmallStringSmallJsonGT(void) { 54993 54994 smallJsont* r; 54995 smallJsont *self = allocG(rtSmallJsont); 54996 smallJsont* delim1 = allocSmallJson(); 54997 smallStringt* delim2 = allocSmallString("|"); 54998 54999 setTopSO(self, "one/two|"); 55000 setTopSO(delim1, "/"); 55001 r = extractSmallJsonSmallStringSmallJsonG(self, delim1, delim2); 55002 ck_assert_ptr_ne(r, null); 55003 char *s = toStringO(r); 55004 ck_assert_str_eq(s, "[\"two\"]"); 55005 free(s); 55006 terminateO(r); 55007 terminateO(delim1); 55008 terminateO(delim2); 55009 terminateO(self); 55010 55011 } 55012 55013 55014 void extractSmallJsonSSmallJsonGT(void) { 55015 55016 smallJsont* r; 55017 smallJsont *self = allocG(rtSmallJsont); 55018 smallJsont* delim1 = allocSmallJson(); 55019 55020 setTopSO(self, "one/two|"); 55021 setTopSO(delim1, "/"); 55022 r = extractSmallJsonSSmallJsonG(self, delim1, "|"); 55023 ck_assert_ptr_ne(r, null); 55024 char *s = toStringO(r); 55025 ck_assert_str_eq(s, "[\"two\"]"); 55026 free(s); 55027 terminateO(r); 55028 terminateO(delim1); 55029 terminateO(self); 55030 55031 } 55032 55033 55034 void extractSmallJsonCharSmallJsonGT(void) { 55035 55036 smallJsont* r; 55037 smallJsont *self = allocG(rtSmallJsont); 55038 smallJsont* delim1 = allocSmallJson(); 55039 55040 setTopSO(self, "one/two|"); 55041 setTopSO(delim1, "/"); 55042 r = extractSmallJsonCharSmallJsonG(self, delim1, '|'); 55043 ck_assert_ptr_ne(r, null); 55044 char *s = toStringO(r); 55045 ck_assert_str_eq(s, "[\"two\"]"); 55046 free(s); 55047 terminateO(r); 55048 terminateO(delim1); 55049 terminateO(self); 55050 55051 } 55052 55053 55054 void extractSmallStringSmallJsonSmallJsonGT(void) { 55055 55056 smallJsont* r; 55057 smallJsont *self = allocG(rtSmallJsont); 55058 smallStringt* delim1 = allocSmallString("/"); 55059 smallJsont* delim2 = allocSmallJson(); 55060 55061 setTopSO(self, "one/two|"); 55062 setTopSO(delim2, "|"); 55063 r = extractSmallStringSmallJsonSmallJsonG(self, delim1, delim2); 55064 ck_assert_ptr_ne(r, null); 55065 char *s = toStringO(r); 55066 ck_assert_str_eq(s, "[\"two\"]"); 55067 free(s); 55068 terminateO(r); 55069 terminateO(delim1); 55070 terminateO(delim2); 55071 terminateO(self); 55072 55073 } 55074 55075 55076 void extractSmallStringSmallStringSmallJsonGT(void) { 55077 55078 smallJsont* r; 55079 smallJsont *self = allocG(rtSmallJsont); 55080 smallStringt* delim1 = allocSmallString("/"); 55081 smallStringt* delim2 = allocSmallString("|"); 55082 55083 setTopSO(self, "one/two|"); 55084 r = extractSmallStringSmallStringSmallJsonG(self, delim1, delim2); 55085 ck_assert_ptr_ne(r, null); 55086 char *s = toStringO(r); 55087 ck_assert_str_eq(s, "[\"two\"]"); 55088 free(s); 55089 terminateO(r); 55090 terminateO(delim1); 55091 terminateO(delim2); 55092 terminateO(self); 55093 55094 } 55095 55096 55097 void extractSmallStringSSmallJsonGT(void) { 55098 55099 smallJsont* r; 55100 smallJsont *self = allocG(rtSmallJsont); 55101 smallStringt* delim1 = allocSmallString("/"); 55102 55103 setTopSO(self, "one/two|"); 55104 r = extractSmallStringSSmallJsonG(self, delim1, "|"); 55105 ck_assert_ptr_ne(r, null); 55106 char *s = toStringO(r); 55107 ck_assert_str_eq(s, "[\"two\"]"); 55108 free(s); 55109 terminateO(r); 55110 terminateO(delim1); 55111 terminateO(self); 55112 55113 } 55114 55115 55116 void extractSmallStringCharSmallJsonGT(void) { 55117 55118 smallJsont* r; 55119 smallJsont *self = allocG(rtSmallJsont); 55120 smallStringt* delim1 = allocSmallString("/"); 55121 55122 setTopSO(self, "one/two|"); 55123 r = extractSmallStringCharSmallJsonG(self, delim1, '|'); 55124 ck_assert_ptr_ne(r, null); 55125 char *s = toStringO(r); 55126 ck_assert_str_eq(s, "[\"two\"]"); 55127 free(s); 55128 terminateO(r); 55129 terminateO(delim1); 55130 terminateO(self); 55131 55132 } 55133 55134 55135 void extractSSmallJsonSmallJsonGT(void) { 55136 55137 smallJsont* r; 55138 smallJsont *self = allocG(rtSmallJsont); 55139 smallJsont* delim2 = allocSmallJson(); 55140 55141 setTopSO(self, "one/two|"); 55142 setTopSO(delim2, "|"); 55143 r = extractSSmallJsonSmallJsonG(self, "/", delim2); 55144 ck_assert_ptr_ne(r, null); 55145 char *s = toStringO(r); 55146 ck_assert_str_eq(s, "[\"two\"]"); 55147 free(s); 55148 terminateO(r); 55149 terminateO(delim2); 55150 terminateO(self); 55151 55152 } 55153 55154 55155 void extractSSmallStringSmallJsonGT(void) { 55156 55157 smallJsont* r; 55158 smallJsont *self = allocG(rtSmallJsont); 55159 smallStringt* delim2 = allocSmallString("|"); 55160 55161 setTopSO(self, "one/two|"); 55162 setValO(delim2, "|"); 55163 r = extractSSmallStringSmallJsonG(self, "/", delim2); 55164 ck_assert_ptr_ne(r, null); 55165 char *s = toStringO(r); 55166 ck_assert_str_eq(s, "[\"two\"]"); 55167 free(s); 55168 terminateO(r); 55169 terminateO(delim2); 55170 terminateO(self); 55171 55172 } 55173 55174 55175 void extractCharSmallJsonSmallJsonGT(void) { 55176 55177 smallJsont* r; 55178 smallJsont *self = allocG(rtSmallJsont); 55179 smallJsont* delim2 = allocSmallJson(); 55180 55181 setTopSO(self, "one/two|"); 55182 setTopSO(delim2, "|"); 55183 r = extractCharSmallJsonSmallJsonG(self, '/', delim2); 55184 ck_assert_ptr_ne(r, null); 55185 char *s = toStringO(r); 55186 ck_assert_str_eq(s, "[\"two\"]"); 55187 free(s); 55188 terminateO(r); 55189 terminateO(delim2); 55190 terminateO(self); 55191 55192 } 55193 55194 55195 void extractCharSmallStringSmallJsonGT(void) { 55196 55197 smallJsont* r; 55198 smallJsont *self = allocG(rtSmallJsont); 55199 smallStringt* delim2 = allocSmallString("|"); 55200 55201 setTopSO(self, "one/two|"); 55202 setValO(delim2, "|"); 55203 r = extractCharSmallStringSmallJsonG(self, '/', delim2); 55204 ck_assert_ptr_ne(r, null); 55205 char *s = toStringO(r); 55206 ck_assert_str_eq(s, "[\"two\"]"); 55207 free(s); 55208 terminateO(r); 55209 terminateO(delim2); 55210 terminateO(self); 55211 55212 } 55213 55214 55215 void icSplitSmallJsonGT(void) { 55216 55217 smallJsont* r; 55218 smallJsont *self = allocG(rtSmallJsont); 55219 55220 setTopSO(self, "one/two"); 55221 r = icSplitSmallJsonG(self, "/"); 55222 ck_assert_ptr_ne(r, null); 55223 char *s = toStringO(r); 55224 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 55225 free(s); 55226 terminateO(r); 55227 terminateO(self); 55228 55229 } 55230 55231 55232 void icSplitCharSmallJsonGT(void) { 55233 55234 smallJsont* r; 55235 smallJsont *self = allocG(rtSmallJsont); 55236 55237 setTopSO(self, "one/two"); 55238 r = icSplitCharSmallJsonG(self, 'T'); 55239 ck_assert_ptr_ne(r, null); 55240 char *s = toStringO(r); 55241 ck_assert_str_eq(s, "[\"one/\",\"wo\"]"); 55242 free(s); 55243 terminateO(r); 55244 terminateO(self); 55245 55246 } 55247 55248 55249 void icSplitSmallJsonSmallJsonGT(void) { 55250 55251 smallJsont* r; 55252 smallJsont *self = allocG(rtSmallJsont); 55253 smallJsont *delim = allocSmallJson(); 55254 55255 setTopSO(self, "one/two"); 55256 setTopSO(delim, "/"); 55257 r = icSplitSmallJsonSmallJsonG(self, delim); 55258 ck_assert_ptr_ne(r, null); 55259 char *s = toStringO(r); 55260 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 55261 free(s); 55262 terminateO(r); 55263 terminateO(delim); 55264 terminateO(self); 55265 55266 } 55267 55268 55269 void icSplitSmallStringSmallJsonGT(void) { 55270 55271 smallJsont* r; 55272 smallJsont *self = allocG(rtSmallJsont); 55273 smallStringt *delim = allocSmallString("/"); 55274 55275 setTopSO(self, "one/two"); 55276 r = icSplitSmallStringSmallJsonG(self, delim); 55277 ck_assert_ptr_ne(r, null); 55278 char *s = toStringO(r); 55279 ck_assert_str_eq(s, "[\"one\",\"two\"]"); 55280 free(s); 55281 terminateO(r); 55282 terminateO(delim); 55283 terminateO(self); 55284 55285 } 55286 55287 55288 void icSplitSSmallJsonGT(void) { 55289 55290 char** r; 55291 smallJsont *self = allocG(rtSmallJsont); 55292 55293 setTopSO(self, "one/two"); 55294 r = icSplitSSmallJsonG(self, "/"); 55295 ck_assert_uint_eq(listLengthS(r),2); 55296 ck_assert_str_eq(r[0], "one"); 55297 ck_assert_str_eq(r[1], "two"); 55298 listFreeS(r); 55299 terminateO(self); 55300 55301 } 55302 55303 55304 void icSplitCharSSmallJsonGT(void) { 55305 55306 char** r; 55307 smallJsont *self = allocG(rtSmallJsont); 55308 55309 setTopSO(self, "one/two"); 55310 r = icSplitCharSSmallJsonG(self, 'T'); 55311 ck_assert_uint_eq(listLengthS(r),2); 55312 ck_assert_str_eq(r[0], "one/"); 55313 ck_assert_str_eq(r[1], "wo"); 55314 listFreeS(r); 55315 terminateO(self); 55316 55317 } 55318 55319 55320 void icSplitSmallJsonSSmallJsonGT(void) { 55321 55322 char** r; 55323 smallJsont *self = allocG(rtSmallJsont); 55324 smallJsont *delim = allocSmallJson(); 55325 55326 setTopSO(self, "one/two"); 55327 setTopSO(delim, "/"); 55328 r = icSplitSmallJsonSSmallJsonG(self, delim); 55329 ck_assert_uint_eq(listLengthS(r),2); 55330 ck_assert_str_eq(r[0], "one"); 55331 ck_assert_str_eq(r[1], "two"); 55332 listFreeS(r); 55333 terminateO(delim); 55334 terminateO(self); 55335 55336 } 55337 55338 55339 void icSplitSmallStringSSmallJsonGT(void) { 55340 55341 char** r; 55342 smallJsont *self = allocG(rtSmallJsont); 55343 smallStringt *delim = allocSmallString("/"); 55344 55345 setTopSO(self, "one/two"); 55346 r = icSplitSmallStringSSmallJsonG(self, delim); 55347 ck_assert_uint_eq(listLengthS(r),2); 55348 ck_assert_str_eq(r[0], "one"); 55349 ck_assert_str_eq(r[1], "two"); 55350 listFreeS(r); 55351 terminateO(delim); 55352 terminateO(self); 55353 55354 } 55355 55356 55357 void icExtractSmallJsonGT(void) { 55358 55359 smallJsont* r; 55360 smallJsont *self = allocG(rtSmallJsont); 55361 55362 setTopSO(self, "one/twos"); 55363 r = icExtractSmallJsonG(self, "E", "S"); 55364 ck_assert_ptr_ne(r, null); 55365 char *s = toStringO(r); 55366 ck_assert_str_eq(s, "[\"/two\"]"); 55367 free(s); 55368 terminateO(r); 55369 terminateO(self); 55370 55371 } 55372 55373 55374 void icExtractCharSSmallJsonGT(void) { 55375 55376 smallJsont* r; 55377 smallJsont *self = allocG(rtSmallJsont); 55378 55379 setTopSO(self, "one/twos"); 55380 r = icExtractCharSSmallJsonG(self, 'E', "S"); 55381 ck_assert_ptr_ne(r, null); 55382 char *s = toStringO(r); 55383 ck_assert_str_eq(s, "[\"/two\"]"); 55384 free(s); 55385 terminateO(r); 55386 terminateO(self); 55387 55388 } 55389 55390 55391 void icExtractSCharSmallJsonGT(void) { 55392 55393 smallJsont* r; 55394 smallJsont *self = allocG(rtSmallJsont); 55395 55396 setTopSO(self, "one/twos"); 55397 r = icExtractSCharSmallJsonG(self, "E", 'S'); 55398 ck_assert_ptr_ne(r, null); 55399 char *s = toStringO(r); 55400 ck_assert_str_eq(s, "[\"/two\"]"); 55401 free(s); 55402 terminateO(r); 55403 terminateO(self); 55404 55405 } 55406 55407 55408 void icExtractCharCharSmallJsonGT(void) { 55409 55410 smallJsont* r; 55411 smallJsont *self = allocG(rtSmallJsont); 55412 55413 setTopSO(self, "one/twos"); 55414 r = icExtractCharCharSmallJsonG(self, 'E', 'S'); 55415 ck_assert_ptr_ne(r, null); 55416 char *s = toStringO(r); 55417 ck_assert_str_eq(s, "[\"/two\"]"); 55418 free(s); 55419 terminateO(r); 55420 terminateO(self); 55421 55422 } 55423 55424 55425 void icExtractSmallJsonSmallJsonSmallJsonGT(void) { 55426 55427 smallJsont* r; 55428 smallJsont *self = allocG(rtSmallJsont); 55429 smallJsont* delim1 = allocSmallJson(); 55430 smallJsont* delim2 = allocSmallJson(); 55431 55432 setTopSO(self, "one/twos"); 55433 setTopSO(delim1, "E"); 55434 setTopSO(delim2, "S"); 55435 r = icExtractSmallJsonSmallJsonSmallJsonG(self, delim1, delim2); 55436 ck_assert_ptr_ne(r, null); 55437 char *s = toStringO(r); 55438 ck_assert_str_eq(s, "[\"/two\"]"); 55439 free(s); 55440 terminateO(r); 55441 terminateO(delim1); 55442 terminateO(delim2); 55443 terminateO(self); 55444 55445 } 55446 55447 55448 void icExtractSmallJsonSmallStringSmallJsonGT(void) { 55449 55450 smallJsont* r; 55451 smallJsont *self = allocG(rtSmallJsont); 55452 smallJsont* delim1 = allocSmallJson(); 55453 smallStringt* delim2 = allocSmallString("S"); 55454 55455 setTopSO(self, "one/twos"); 55456 setTopSO(delim1, "E"); 55457 r = icExtractSmallJsonSmallStringSmallJsonG(self, delim1, delim2); 55458 ck_assert_ptr_ne(r, null); 55459 char *s = toStringO(r); 55460 ck_assert_str_eq(s, "[\"/two\"]"); 55461 free(s); 55462 terminateO(r); 55463 terminateO(delim1); 55464 terminateO(delim2); 55465 terminateO(self); 55466 55467 } 55468 55469 55470 void icExtractSmallJsonSSmallJsonGT(void) { 55471 55472 smallJsont* r; 55473 smallJsont *self = allocG(rtSmallJsont); 55474 smallJsont* delim1 = allocSmallJson(); 55475 55476 setTopSO(self, "one/twos"); 55477 setTopSO(delim1, "E"); 55478 r = icExtractSmallJsonSSmallJsonG(self, delim1, "S"); 55479 ck_assert_ptr_ne(r, null); 55480 char *s = toStringO(r); 55481 ck_assert_str_eq(s, "[\"/two\"]"); 55482 free(s); 55483 terminateO(r); 55484 terminateO(delim1); 55485 terminateO(self); 55486 55487 } 55488 55489 55490 void icExtractSmallJsonCharSmallJsonGT(void) { 55491 55492 smallJsont* r; 55493 smallJsont *self = allocG(rtSmallJsont); 55494 smallJsont* delim1 = allocSmallJson(); 55495 55496 setTopSO(self, "one/twos"); 55497 setTopSO(delim1, "E"); 55498 r = icExtractSmallJsonCharSmallJsonG(self, delim1, 'S'); 55499 ck_assert_ptr_ne(r, null); 55500 char *s = toStringO(r); 55501 ck_assert_str_eq(s, "[\"/two\"]"); 55502 free(s); 55503 terminateO(r); 55504 terminateO(delim1); 55505 terminateO(self); 55506 55507 } 55508 55509 55510 void icExtractSmallStringSmallJsonSmallJsonGT(void) { 55511 55512 smallJsont* r; 55513 smallJsont *self = allocG(rtSmallJsont); 55514 smallStringt* delim1 = allocSmallString("E"); 55515 smallJsont* delim2 = allocSmallJson(); 55516 55517 setTopSO(self, "one/twos"); 55518 setTopSO(delim2, "S"); 55519 r = icExtractSmallStringSmallJsonSmallJsonG(self, delim1, delim2); 55520 ck_assert_ptr_ne(r, null); 55521 char *s = toStringO(r); 55522 ck_assert_str_eq(s, "[\"/two\"]"); 55523 free(s); 55524 terminateO(r); 55525 terminateO(delim1); 55526 terminateO(delim2); 55527 terminateO(self); 55528 55529 } 55530 55531 55532 void icExtractSmallStringSmallStringSmallJsonGT(void) { 55533 55534 smallJsont* r; 55535 smallJsont *self = allocG(rtSmallJsont); 55536 smallStringt* delim1 = allocSmallString("E"); 55537 smallStringt* delim2 = allocSmallString("|"); 55538 55539 setTopSO(self, "one/twos"); 55540 setValO(delim2, "S"); 55541 r = icExtractSmallStringSmallStringSmallJsonG(self, delim1, delim2); 55542 ck_assert_ptr_ne(r, null); 55543 char *s = toStringO(r); 55544 ck_assert_str_eq(s, "[\"/two\"]"); 55545 free(s); 55546 terminateO(r); 55547 terminateO(delim1); 55548 terminateO(delim2); 55549 terminateO(self); 55550 55551 } 55552 55553 55554 void icExtractSmallStringSSmallJsonGT(void) { 55555 55556 smallJsont* r; 55557 smallJsont *self = allocG(rtSmallJsont); 55558 smallStringt* delim1 = allocSmallString("E"); 55559 55560 setTopSO(self, "one/twos"); 55561 r = icExtractSmallStringSSmallJsonG(self, delim1, "S"); 55562 ck_assert_ptr_ne(r, null); 55563 char *s = toStringO(r); 55564 ck_assert_str_eq(s, "[\"/two\"]"); 55565 free(s); 55566 terminateO(r); 55567 terminateO(delim1); 55568 terminateO(self); 55569 55570 } 55571 55572 55573 void icExtractSmallStringCharSmallJsonGT(void) { 55574 55575 smallJsont* r; 55576 smallJsont *self = allocG(rtSmallJsont); 55577 smallStringt* delim1 = allocSmallString("E"); 55578 55579 setTopSO(self, "one/twos"); 55580 r = icExtractSmallStringCharSmallJsonG(self, delim1, 'S'); 55581 ck_assert_ptr_ne(r, null); 55582 char *s = toStringO(r); 55583 ck_assert_str_eq(s, "[\"/two\"]"); 55584 free(s); 55585 terminateO(r); 55586 terminateO(delim1); 55587 terminateO(self); 55588 55589 } 55590 55591 55592 void icExtractSSmallJsonSmallJsonGT(void) { 55593 55594 smallJsont* r; 55595 smallJsont *self = allocG(rtSmallJsont); 55596 smallJsont* delim2 = allocSmallJson(); 55597 55598 setTopSO(self, "one/twos"); 55599 setTopSO(delim2, "S"); 55600 r = icExtractSSmallJsonSmallJsonG(self, "E", delim2); 55601 ck_assert_ptr_ne(r, null); 55602 char *s = toStringO(r); 55603 ck_assert_str_eq(s, "[\"/two\"]"); 55604 free(s); 55605 terminateO(r); 55606 terminateO(delim2); 55607 terminateO(self); 55608 55609 } 55610 55611 55612 void icExtractSSmallStringSmallJsonGT(void) { 55613 55614 smallJsont* r; 55615 smallJsont *self = allocG(rtSmallJsont); 55616 smallStringt* delim2 = allocSmallString("|"); 55617 55618 setTopSO(self, "one/twos"); 55619 setValO(delim2, "S"); 55620 r = icExtractSSmallStringSmallJsonG(self, "E", delim2); 55621 ck_assert_ptr_ne(r, null); 55622 char *s = toStringO(r); 55623 ck_assert_str_eq(s, "[\"/two\"]"); 55624 free(s); 55625 terminateO(r); 55626 terminateO(delim2); 55627 terminateO(self); 55628 55629 } 55630 55631 55632 void icExtractCharSmallJsonSmallJsonGT(void) { 55633 55634 smallJsont* r; 55635 smallJsont *self = allocG(rtSmallJsont); 55636 smallJsont* delim2 = allocSmallJson(); 55637 55638 setTopSO(self, "one/twos"); 55639 setTopSO(delim2, "S"); 55640 r = icExtractCharSmallJsonSmallJsonG(self, 'E', delim2); 55641 ck_assert_ptr_ne(r, null); 55642 char *s = toStringO(r); 55643 ck_assert_str_eq(s, "[\"/two\"]"); 55644 free(s); 55645 terminateO(r); 55646 terminateO(delim2); 55647 terminateO(self); 55648 55649 } 55650 55651 55652 void icExtractCharSmallStringSmallJsonGT(void) { 55653 55654 smallJsont* r; 55655 smallJsont *self = allocG(rtSmallJsont); 55656 smallStringt* delim2 = allocSmallString("|"); 55657 55658 setTopSO(self, "one/twos"); 55659 setValO(delim2, "S"); 55660 r = icExtractCharSmallStringSmallJsonG(self, 'E', delim2); 55661 ck_assert_ptr_ne(r, null); 55662 char *s = toStringO(r); 55663 ck_assert_str_eq(s, "[\"/two\"]"); 55664 free(s); 55665 terminateO(r); 55666 terminateO(delim2); 55667 terminateO(self); 55668 55669 } 55670 55671 55672 void zipSmallJsonGT(void) { 55673 55674 smallJsont* r; 55675 smallJsont *self = allocSmallJson(); 55676 smallArrayt *array1 = allocSmallArray(); 55677 smallArrayt *array2 = allocSmallArray(); 55678 55679 // zip arrays 55680 // add an element to self 55681 // array1 has 2 elements 55682 // array2 has 3 elements 55683 // only 2 elements are zipped 55684 self->f->pushS(self, "qwe"); 55685 array1->f->pushS(array1, "a"); 55686 array1->f->pushS(array1, "b"); 55687 array2->f->pushInt(array2, 1); 55688 array2->f->pushInt(array2, 2); 55689 array2->f->pushInt(array2, 3); 55690 r = zipSmallJsonG(self, array1, array2); 55691 ck_assert_ptr_ne(r, NULL); 55692 char *s = toStringO(r); 55693 ck_assert_str_eq(s, "[\"qwe\",[\"a\",1],[\"b\",2]]"); 55694 free(s); 55695 // delete the element not in self 55696 delElemO(array2, 2); 55697 terminateO(self); 55698 smashO(array1); 55699 smashO(array2); 55700 55701 } 55702 55703 55704 void zipArraySmallJsonGT(void) { 55705 55706 smallJsont* r; 55707 smallJsont *self = allocSmallJson(); 55708 char** array1; 55709 smallArrayt *array2 = allocSmallArray(); 55710 55711 self->f->pushS(self, "qwe"); 55712 array1 = listCreateS("a", "b"); 55713 array2->f->pushS(array2, "1"); 55714 array2->f->pushS(array2, "2"); 55715 r = zipArraySmallJsonG(self, array1, array2); 55716 ck_assert_ptr_ne(r, NULL); 55717 char *s = toStringO(r); 55718 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55719 free(s); 55720 terminateO(self); 55721 free(array1); 55722 smashO(array2); 55723 55724 } 55725 55726 55727 void zipCArraySmallJsonGT(void) { 55728 55729 smallJsont* r; 55730 smallJsont *self = allocSmallJson(); 55731 const char* array1[] = {"a", "b", null}; 55732 smallArrayt *array2 = allocSmallArray(); 55733 55734 self->f->pushS(self, "qwe"); 55735 array2->f->pushS(array2, "1"); 55736 array2->f->pushS(array2, "2"); 55737 r = zipCArraySmallJsonG(self, array1, array2); 55738 ck_assert_ptr_ne(r, NULL); 55739 char *s = toStringO(r); 55740 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55741 free(s); 55742 terminateO(self); 55743 smashO(array2); 55744 55745 } 55746 55747 55748 void zipCharSmallJsonGT(void) { 55749 55750 smallJsont* r; 55751 smallJsont *self = allocSmallJson(); 55752 smallArrayt *array1 = allocSmallArray(); 55753 char** array2; 55754 55755 self->f->pushS(self, "qwe"); 55756 array1->f->pushS(array1, "a"); 55757 array1->f->pushS(array1, "b"); 55758 array2 = listCreateS("1", "2"); 55759 r = zipCharSmallJsonG(self, array1, array2); 55760 ck_assert_ptr_ne(r, NULL); 55761 char *s = toStringO(r); 55762 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55763 free(s); 55764 terminateO(self); 55765 smashO(array1); 55766 free(array2); 55767 55768 } 55769 55770 55771 void zipCCharSmallJsonGT(void) { 55772 55773 smallJsont* r; 55774 smallJsont *self = allocSmallJson(); 55775 smallArrayt *array1 = allocSmallArray(); 55776 const char* array2[] = {"1", "2", "3", null}; 55777 55778 self->f->pushS(self, "qwe"); 55779 array1->f->pushS(array1, "a"); 55780 array1->f->pushS(array1, "b"); 55781 r = zipCCharSmallJsonG(self, array1, array2); 55782 ck_assert_ptr_ne(r, NULL); 55783 char *s = toStringO(r); 55784 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55785 free(s); 55786 terminateO(self); 55787 smashO(array1); 55788 55789 } 55790 55791 55792 void zipArrayCharSmallJsonGT(void) { 55793 55794 smallJsont* r; 55795 smallJsont *self = allocSmallJson(); 55796 char** array1; 55797 char** array2; 55798 55799 self->f->pushS(self, "qwe"); 55800 array1 = listCreateS("a", "b"); 55801 array2 = listCreateS("1", "2"); 55802 r = zipArrayCharSmallJsonG(self, array1, array2); 55803 ck_assert_ptr_ne(r, NULL); 55804 char *s = toStringO(r); 55805 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55806 free(s); 55807 terminateO(self); 55808 free(array1); 55809 free(array2); 55810 55811 } 55812 55813 55814 void zipArrayCCharSmallJsonGT(void) { 55815 55816 smallJsont* r; 55817 smallJsont *self = allocSmallJson(); 55818 char** array1; 55819 const char* array2[] = {"1", "2", "3", null}; 55820 55821 self->f->pushS(self, "qwe"); 55822 array1 = listCreateS("a", "b"); 55823 r = zipArrayCCharSmallJsonG(self, array1, array2); 55824 ck_assert_ptr_ne(r, NULL); 55825 char *s = toStringO(r); 55826 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55827 free(s); 55828 terminateO(self); 55829 free(array1); 55830 55831 } 55832 55833 55834 void zipCArrayCharSmallJsonGT(void) { 55835 55836 smallJsont* r; 55837 smallJsont *self = allocSmallJson(); 55838 const char* array1[] = {"a", "b", null}; 55839 char** array2; 55840 55841 self->f->pushS(self, "qwe"); 55842 array2 = listCreateS("1", "2"); 55843 r = zipCArrayCharSmallJsonG(self, array1, array2); 55844 ck_assert_ptr_ne(r, NULL); 55845 char *s = toStringO(r); 55846 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55847 free(s); 55848 terminateO(self); 55849 free(array2); 55850 55851 } 55852 55853 55854 void zipCArrayCCharSmallJsonGT(void) { 55855 55856 smallJsont* r; 55857 smallJsont *self = allocSmallJson(); 55858 const char* array1[] = {"a", "b", null}; 55859 const char* array2[] = {"1", "2", "3", null}; 55860 55861 self->f->pushS(self, "qwe"); 55862 r = zipCArrayCCharSmallJsonG(self, array1, array2); 55863 ck_assert_ptr_ne(r, NULL); 55864 char *s = toStringO(r); 55865 ck_assert_str_eq(s, "[\"qwe\",[\"a\",\"1\"],[\"b\",\"2\"]]"); 55866 free(s); 55867 terminateO(self); 55868 55869 } 55870 55871 55872 void zipJsonSmallJsonGT(void) { 55873 55874 smallJsont* r; 55875 smallJsont *self = allocSmallJson(); 55876 smallJsont *keys = allocSmallJson(); 55877 smallJsont *values = allocSmallJson(); 55878 55879 self->f->setInt(self, "", 1); 55880 // 3 elements in keys 55881 // 2 elements in values 55882 // only 2 key/values are zipped 55883 keys->f->pushS(keys, "a"); 55884 keys->f->pushS(keys, "b"); 55885 keys->f->pushS(keys, "c"); 55886 values->f->pushInt(values, 1); 55887 values->f->pushInt(values, 2); 55888 r = zipJsonSmallJsonG(self, keys, values); 55889 terminateO(keys); 55890 smashO(values); 55891 ck_assert_ptr_ne(r, NULL); 55892 char *s = toStringO(r); 55893 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 55894 free(s); 55895 terminateO(self); 55896 55897 } 55898 55899 55900 void zipJsonSmallArraySmallJsonGT(void) { 55901 55902 smallJsont* r; 55903 smallJsont *self = allocSmallJson(); 55904 smallJsont *keys = allocSmallJson(); 55905 smallArrayt *values = allocSmallArray(); 55906 55907 self->f->setInt(self, "", 1); 55908 // 3 elements in keys 55909 // 2 elements in values 55910 // only 2 key/values are zipped 55911 keys->f->pushS(keys, "a"); 55912 keys->f->pushS(keys, "b"); 55913 keys->f->pushS(keys, "c"); 55914 values->f->pushInt(values, 1); 55915 values->f->pushInt(values, 2); 55916 r = zipJsonSmallArraySmallJsonG(self, keys, values); 55917 terminateO(keys); 55918 smashO(values); 55919 ck_assert_ptr_ne(r, NULL); 55920 char *s = toStringO(r); 55921 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 55922 free(s); 55923 terminateO(self); 55924 55925 } 55926 55927 55928 void zipJsonArraySmallJsonGT(void) { 55929 55930 smallJsont* r; 55931 smallJsont *self = allocSmallJson(); 55932 smallJsont *keys = allocSmallJson(); 55933 char **values; 55934 55935 self->f->setInt(self, "", 1); 55936 // 3 elements in keys 55937 // 2 elements in values 55938 // only 2 key/values are zipped 55939 keys->f->pushS(keys, "a"); 55940 keys->f->pushS(keys, "b"); 55941 keys->f->pushS(keys, "c"); 55942 values = listCreateS("1", "2"); 55943 r = zipJsonArraySmallJsonG(self, keys, values); 55944 terminateO(keys); 55945 listFreeS(values); 55946 ck_assert_ptr_ne(r, NULL); 55947 char *s = toStringO(r); 55948 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 55949 free(s); 55950 terminateO(self); 55951 55952 } 55953 55954 55955 void zipJsonCArraySmallJsonGT(void) { 55956 55957 smallJsont* r; 55958 smallJsont *self = allocG(rtSmallJsont); 55959 smallJsont *keys = allocSmallJson(); 55960 const char* values[] = {"1", "2", null}; 55961 55962 self->f->setInt(self, "", 1); 55963 // 3 elements in keys 55964 // 2 elements in values 55965 // only 2 key/values are zipped 55966 keys->f->pushS(keys, "a"); 55967 keys->f->pushS(keys, "b"); 55968 keys->f->pushS(keys, "c"); 55969 r = zipJsonCArraySmallJsonG(self, keys, values); 55970 terminateO(keys); 55971 ck_assert_ptr_ne(r, NULL); 55972 char *s = toStringO(r); 55973 ck_assert_str_eq(s, "{\"\":1,\"a\":\"1\",\"b\":\"2\"}"); 55974 free(s); 55975 terminateO(self); 55976 55977 } 55978 55979 55980 void zipSmallArrayJsonSmallJsonGT(void) { 55981 55982 smallJsont* r; 55983 smallJsont *self = allocSmallJson(); 55984 smallArrayt *keys = allocSmallArray(); 55985 smallJsont *values = allocSmallJson(); 55986 55987 self->f->setInt(self, "", 1); 55988 // 3 elements in keys 55989 // 2 elements in values 55990 // only 2 key/values are zipped 55991 keys->f->pushS(keys, "a"); 55992 keys->f->pushS(keys, "b"); 55993 keys->f->pushS(keys, "c"); 55994 values->f->pushInt(values, 1); 55995 values->f->pushInt(values, 2); 55996 r = zipSmallArrayJsonSmallJsonG(self, keys, values); 55997 terminateO(keys); 55998 smashO(values); 55999 ck_assert_ptr_ne(r, NULL); 56000 char *s = toStringO(r); 56001 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 56002 free(s); 56003 terminateO(self); 56004 56005 } 56006 56007 56008 void zipArrayJsonSmallJsonGT(void) { 56009 56010 smallJsont* r; 56011 smallJsont *self = allocSmallJson(); 56012 char** keys; 56013 smallJsont *values = allocSmallJson(); 56014 56015 self->f->setInt(self, "", 1); 56016 // 3 elements in keys 56017 // 2 elements in values 56018 // only 2 key/values are zipped 56019 keys = listCreateS("a", "b", "c"); 56020 values->f->pushInt(values, 1); 56021 values->f->pushInt(values, 2); 56022 r = zipArrayJsonSmallJsonG(self, keys, values); 56023 listFreeS(keys); 56024 smashO(values); 56025 ck_assert_ptr_ne(r, NULL); 56026 char *s = toStringO(r); 56027 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 56028 free(s); 56029 terminateO(self); 56030 56031 } 56032 56033 56034 void zipCArrayJsonSmallJsonGT(void) { 56035 56036 smallJsont* r; 56037 smallJsont *self = allocG(rtSmallJsont); 56038 const char* keys[] = {"a", "b", "c", null}; 56039 smallJsont *values = allocSmallJson(); 56040 56041 self->f->setInt(self, "", 1); 56042 // 3 elements in keys 56043 // 2 elements in values 56044 // only 2 key/values are zipped 56045 values->f->pushInt(values, 1); 56046 values->f->pushInt(values, 2); 56047 r = zipCArrayJsonSmallJsonG(self, keys, values); 56048 smashO(values); 56049 ck_assert_ptr_ne(r, NULL); 56050 char *s = toStringO(r); 56051 ck_assert_str_eq(s, "{\"\":1,\"a\":1,\"b\":2}"); 56052 free(s); 56053 terminateO(self); 56054 56055 } 56056 56057 56058 void stringifySmallStringSmallJsonGT(void) { 56059 56060 smallStringt* r; 56061 smallJsont *self = allocG(rtSmallJsont); 56062 56063 self->f->setS(self, "\\\\", "\\erw\\\""); 56064 r = stringifySmallStringSmallJsonG(self, 2); 56065 ck_assert_ptr_ne(r, null); 56066 char *s = toStringO(r); 56067 terminateO(r); 56068 ck_assert_str_eq(s, "{\n \"\\\\\": \"\\\\erw\\\\\\\"\"\n}\n"); 56069 free(s); 56070 terminateO(self); 56071 56072 } 56073 56074 56075 void toYMLSmallStringSmallJsonGT(void) { 56076 56077 smallStringt* r; 56078 smallJsont *self = allocG(rtSmallJsont); 56079 56080 self->f->pushS(self, "qwe"); 56081 r = toYMLSmallStringSmallJsonG(self, 2); 56082 ck_assert_ptr_ne(r, null); 56083 char *s = toStringO(r); 56084 ck_assert_str_eq(s, "---\n - qwe\n"); 56085 free(s); 56086 terminateO(r); 56087 terminateO(self); 56088 56089 } 56090 56091 56092 void parseSmallJsonGT(void) { 56093 56094 bool r; 56095 smallJsont *self = allocG(rtSmallJsont); 56096 56097 r = parseSmallJsonG(self, "true"); 56098 ck_assert(r); 56099 char *s = toStringO(self); 56100 ck_assert_str_eq(s, "true"); 56101 free(s); 56102 terminateO(self); 56103 56104 } 56105 56106 56107 void parseSmallJsonSmallJsonGT(void) { 56108 56109 bool r; 56110 smallJsont *self = allocG(rtSmallJsont); 56111 smallJsont *input = allocSmallJson(); 56112 56113 // non json string 56114 r = parseSmallJsonSmallJsonG(self, input); 56115 ck_assert(!r); 56116 // json string 56117 setTopSO(input, "true"); 56118 r = parseSmallJsonSmallJsonG(self, input); 56119 ck_assert(r); 56120 terminateO(input); 56121 char *s = toStringO(self); 56122 ck_assert_str_eq(s, "true"); 56123 free(s); 56124 terminateO(self); 56125 56126 } 56127 56128 56129 void parseSmallStringSmallJsonGT(void) { 56130 56131 bool r; 56132 smallJsont *self = allocG(rtSmallJsont); 56133 smallStringt *input = allocSmallString("true"); 56134 56135 // string 56136 r = parseSmallStringSmallJsonG(self, input); 56137 ck_assert(r); 56138 terminateO(input); 56139 char *s = toStringO(self); 56140 ck_assert_str_eq(s, "true"); 56141 free(s); 56142 terminateO(self); 56143 56144 } 56145 56146 56147 void parseYMLSmallJsonGT(void) { 56148 56149 bool r; 56150 smallJsont *self = allocG(rtSmallJsont); 56151 56152 //r = parseYMLSmallJsonG(self); 56153 r = parseYMLSmallJsonG(self, "---\n - qwe"); 56154 ck_assert(r); 56155 char *s = toStringO(self); 56156 ck_assert_str_eq(s, "[\"qwe\"]"); 56157 free(s); 56158 terminateO(self); 56159 56160 } 56161 56162 56163 void parseYMLSmallJsonSmallJsonGT(void) { 56164 56165 bool r; 56166 smallJsont *self = allocG(rtSmallJsont); 56167 smallJsont *input = allocSmallJson(); 56168 56169 // non json string 56170 r = parseYMLSmallJsonSmallJsonG(self, input); 56171 ck_assert(!r); 56172 // json string 56173 setTopSO(input, "---\n - qwe"); 56174 r = parseYMLSmallJsonSmallJsonG(self, input); 56175 ck_assert(r); 56176 terminateO(input); 56177 char *s = toStringO(self); 56178 ck_assert_str_eq(s, "[\"qwe\"]"); 56179 free(s); 56180 terminateO(self); 56181 56182 } 56183 56184 56185 void parseYMLSmallStringSmallJsonGT(void) { 56186 56187 bool r; 56188 smallJsont *self = allocG(rtSmallJsont); 56189 smallStringt *input = allocSmallString("---\n - qwe"); 56190 56191 // string 56192 r = parseYMLSmallStringSmallJsonG(self, input); 56193 ck_assert(r); 56194 terminateO(input); 56195 char *s = toStringO(self); 56196 ck_assert_str_eq(s, "[\"qwe\"]"); 56197 free(s); 56198 terminateO(self); 56199 56200 } 56201 56202 56203 void logSmallJsonGT(void) { 56204 56205 smallJsont *self = allocSmallJson(); 56206 56207 self->f->pushS(self, "qwe"); 56208 self->f->pushS(self, "asd"); 56209 delElemIndexO(self, 0); 56210 logSmallJsonG(self); 56211 terminateO(self); 56212 56213 } 56214 56215 56216 void readFileSmallJsonGT(void) { 56217 56218 smallJsont *self = allocG(rtSmallJsont); 56219 56220 self->f->setS(self, "key", "value"); 56221 writeFileO(self, "read.JSON"); 56222 freeO(self); 56223 ck_assert_ptr_ne(readFileSmallJsonG(self, "read.JSON"), null); 56224 rmAll("read.JSON"); 56225 char *s = toStringO(self); 56226 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 56227 free(s); 56228 terminateO(self); 56229 56230 } 56231 56232 56233 void readFileSmallStringSmallJsonGT(void) { 56234 56235 smallJsont *self = allocG(rtSmallJsont); 56236 smallStringt *filePath = allocSmallString("read.json"); 56237 56238 self->f->setS(self, "key", "value"); 56239 writeFileO(self, "read.json"); 56240 freeO(self); 56241 ck_assert_ptr_ne(readFileSmallStringSmallJsonG(self, filePath), null); 56242 char *s = toStringO(self); 56243 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 56244 free(s); 56245 rmAll("read.json"); 56246 terminateO(filePath); 56247 terminateO(self); 56248 56249 } 56250 56251 56252 void readFileJsonSmallJsonGT(void) { 56253 56254 smallJsont *self = allocG(rtSmallJsont); 56255 smallJsont *filePath = allocSmallJson(); 56256 56257 setTopSO(filePath, "read.json"); 56258 self->f->setS(self, "key", "value"); 56259 writeFileO(self, "read.json"); 56260 freeO(self); 56261 ck_assert_ptr_ne(readFileJsonSmallJsonG(self, filePath), null); 56262 char *s = toStringO(self); 56263 ck_assert_str_eq(s, "{\"key\":\"value\"}"); 56264 free(s); 56265 rmAll("read.json"); 56266 terminateO(filePath); 56267 terminateO(self); 56268 56269 } 56270 56271 56272 void readStreamSmallJsonGT(void) { 56273 56274 smallJsont* r; 56275 smallJsont *self = allocG(rtSmallJsont); 56276 FILE *fp; 56277 56278 // stream 56279 fp = fopen("file.json", "r"); 56280 r = readStreamSmallJsonG(self, fp); 56281 fclose(fp); 56282 ck_assert_ptr_ne(r, NULL); 56283 char *s = toStringO(r); 56284 ck_assert_str_eq(s, "{\"dasd\":\"asd\",\"asd\":234,\"dict\":{\"array\":[1,1],\"asd\":true,\"float\":3.434000e+01},\"bool\":false,\"zzz\":null}"); 56285 free(s); 56286 terminateO(self); 56287 56288 } 56289 56290 56291 void writeFileSmallJsonGT(void) { 56292 56293 int r; 56294 smallJsont *self = allocG(rtSmallJsont); 56295 56296 self->f->setInt(self, "", 1); 56297 self->f->setInt(self, "b", 2); 56298 r = writeFileSmallJsonG(self, "smallDictFile.json"); 56299 ck_assert(r); 56300 ck_assert(fileExists("smallDictFile.json")); 56301 char *s = readFileToS("smallDictFile.json"); 56302 ck_assert_str_eq(s, "{\n \"\": 1,\n \"b\": 2\n}\n"); 56303 free(s); 56304 rmAll("smallDictFile.json"); 56305 terminateO(self); 56306 56307 } 56308 56309 56310 void writeFileSmallStringSmallJsonGT(void) { 56311 56312 bool r; 56313 smallJsont *self = allocSmallJson(); 56314 smallStringt *filePath = allocSmallString("smallDictFile.json"); 56315 56316 self->f->setInt(self, "", 1); 56317 self->f->setInt(self, "b", 2); 56318 r = writeFileSmallStringSmallJsonG(self, filePath); 56319 ck_assert(r); 56320 ck_assert(fileExists("smallDictFile.json")); 56321 char *s = readFileToS("smallDictFile.json"); 56322 ck_assert_str_eq(s, "{\n \"\": 1,\n \"b\": 2\n}\n"); 56323 free(s); 56324 rmAll("smallDictFile.json"); 56325 terminateO(filePath); 56326 terminateO(self); 56327 56328 } 56329 56330 56331 void writeFileJsonSmallJsonGT(void) { 56332 56333 bool r; 56334 smallJsont *self = allocSmallJson(); 56335 smallJsont *filePath = allocSmallJson(); 56336 56337 self->f->setInt(self, "", 1); 56338 self->f->setInt(self, "b", 2); 56339 setTopSO(filePath, "smallDictFile.json"); 56340 r = writeFileJsonSmallJsonG(self, filePath); 56341 ck_assert(r); 56342 ck_assert(fileExists("smallDictFile.json")); 56343 char *s = readFileToS("smallDictFile.json"); 56344 ck_assert_str_eq(s, "{\n \"\": 1,\n \"b\": 2\n}\n"); 56345 free(s); 56346 rmAll("smallDictFile.json"); 56347 terminateO(filePath); 56348 terminateO(self); 56349 56350 } 56351 56352 56353 void writeStreamSmallJsonGT(void) { 56354 56355 int r; 56356 smallJsont *self = allocG(rtSmallJsont); 56357 FILE *fp; 56358 56359 // write textOutTest.null 56360 fp = fopen("file.json", "r"); 56361 smallJsont *r2 = readStreamO(self, fp); 56362 fclose(fp); 56363 ck_assert_ptr_ne(r2, NULL); 56364 fp = fopen("outTest.json", "w"); 56365 r = writeStreamSmallJsonG(self, fp); 56366 ck_assert(r); 56367 fclose(fp); 56368 // check textOutTest.null 56369 fp = fopen("outTest.json", "r"); 56370 r2 = readStreamO(self, fp); 56371 fclose(fp); 56372 ck_assert_ptr_ne(r2, NULL); 56373 char *s = toStringO(r2); 56374 ck_assert_str_eq(s, "{\"dasd\":\"asd\",\"asd\":234,\"dict\":{\"array\":[1,1],\"asd\":true,\"float\":3.434000e+01},\"bool\":false,\"zzz\":null}"); 56375 free(s); 56376 rmAll("outTest.json"); 56377 terminateO(self); 56378 56379 } 56380 56381 56382 void appendFileSmallJsonGT(void) { 56383 56384 bool r; 56385 smallJsont *self = allocSmallJson(); 56386 56387 self->f->setInt(self, "", 1); 56388 self->f->setInt(self, "b", 2); 56389 writeFileS("smallDictFile.json", "-"); 56390 r = appendFileSmallJsonG(self, "smallDictFile.json"); 56391 ck_assert(r); 56392 ck_assert(fileExists("smallDictFile.json")); 56393 char *s = readFileToS("smallDictFile.json"); 56394 ck_assert_str_eq(s, "-{\n \"\": 1,\n \"b\": 2\n}\n"); 56395 free(s); 56396 rmAll("smallDictFile.json"); 56397 terminateO(self); 56398 56399 } 56400 56401 56402 void appendFileSmallStringSmallJsonGT(void) { 56403 56404 bool r; 56405 smallJsont *self = allocSmallJson(); 56406 smallStringt *filePath = allocSmallString("smallDictFile.json"); 56407 56408 self->f->setInt(self, "", 1); 56409 self->f->setInt(self, "b", 2); 56410 writeFileS("smallDictFile.json", "-"); 56411 r = appendFileSmallStringSmallJsonG(self, filePath); 56412 ck_assert(r); 56413 ck_assert(fileExists("smallDictFile.json")); 56414 char *s = readFileToS("smallDictFile.json"); 56415 ck_assert_str_eq(s, "-{\n \"\": 1,\n \"b\": 2\n}\n"); 56416 free(s); 56417 rmAll("smallDictFile.json"); 56418 terminateO(filePath); 56419 terminateO(self); 56420 56421 } 56422 56423 56424 void appendFileJsonSmallJsonGT(void) { 56425 56426 int r; 56427 smallJsont *self = allocG(rtSmallJsont); 56428 smallJsont *filePath = allocSmallJson(); 56429 56430 setTopSO(filePath, "smallDictFile.json"); 56431 self->f->setInt(self, "", 1); 56432 self->f->setInt(self, "b", 2); 56433 writeFileS("smallDictFile.json", "-"); 56434 r = appendFileJsonSmallJsonG(self, filePath); 56435 ck_assert(r); 56436 ck_assert(fileExists("smallDictFile.json")); 56437 char *s = readFileToS("smallDictFile.json"); 56438 ck_assert_str_eq(s, "-{\n \"\": 1,\n \"b\": 2\n}\n"); 56439 free(s); 56440 rmAll("smallDictFile.json"); 56441 terminateO(filePath); 56442 terminateO(self); 56443 56444 } 56445 56446 56447 void readTextSmallJsonGT(void) { 56448 56449 smallJsont* r; 56450 smallJsont *self = allocSmallJson(); 56451 56452 r = readTextSmallJsonG(self, "../textTest.null"); 56453 ck_assert_ptr_ne(r, NULL); 56454 char *s = toStringO(r); 56455 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 56456 free(s); 56457 terminateO(self); 56458 56459 } 56460 56461 56462 void readTextSmallStringSmallJsonGT(void) { 56463 56464 smallJsont* r; 56465 smallJsont *self = allocSmallJson(); 56466 smallStringt *filePath = allocSmallString(""); 56467 56468 // text 56469 setValO(filePath, "../textTest.null"); 56470 r = readTextSmallStringSmallJsonG(self, filePath); 56471 ck_assert_ptr_ne(r, NULL); 56472 char *s = toStringO(r); 56473 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 56474 free(s); 56475 terminateO(self); 56476 terminateO(filePath); 56477 56478 } 56479 56480 56481 void readTextJsonSmallJsonGT(void) { 56482 56483 smallJsont* r; 56484 smallJsont *self = allocG(rtSmallJsont); 56485 smallJsont *filePath = allocSmallJson(); 56486 56487 // text 56488 setTopSO(filePath, "../textTest.null"); 56489 r = readTextJsonSmallJsonG(self, filePath); 56490 ck_assert_ptr_ne(r, NULL); 56491 char *s = toStringO(r); 56492 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 56493 free(s); 56494 terminateO(filePath); 56495 terminateO(self); 56496 56497 } 56498 56499 56500 void readTextStreamSmallJsonGT(void) { 56501 56502 smallJsont* r; 56503 smallJsont *self = allocG(rtSmallJsont); 56504 FILE *fp; 56505 56506 fp = fopen("../textTest.null", "r"); 56507 r = readTextStreamSmallJsonG(self, fp); 56508 fclose(fp); 56509 ck_assert_ptr_ne(r, NULL); 56510 char *s = toStringO(r); 56511 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 56512 free(s); 56513 terminateO(self); 56514 56515 } 56516 56517 56518 void writeTextSmallJsonGT(void) { 56519 56520 bool r; 56521 smallJsont *self = allocSmallJson(); 56522 56523 smallJsont *r2 = readTextO(self, "../textTest.null"); 56524 ck_assert_ptr_ne(r2, NULL); 56525 r = writeTextSmallJsonG(self, "../textOutTest.null"); 56526 ck_assert(r); 56527 // check textOutTest.null 56528 emptyO(self); 56529 r2 = readTextO(self, "../textOutTest.null"); 56530 ck_assert_ptr_ne(r2, NULL); 56531 char *s = toStringO(r2); 56532 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 56533 free(s); 56534 rmAll("../textOutTest.null"); 56535 terminateO(self); 56536 56537 } 56538 56539 56540 void writeTextSmallStringSmallJsonGT(void) { 56541 56542 bool r; 56543 smallJsont *self = allocSmallJson(); 56544 smallStringt *filePath = allocSmallString(""); 56545 56546 // write textOutTest.null 56547 smallJsont *r2 = readTextO(self, "../textTest.null"); 56548 ck_assert_ptr_ne(r2, NULL); 56549 setValO(filePath, "../textOutTest.null"); 56550 r = writeTextSmallStringSmallJsonG(self, filePath); 56551 ck_assert(r); 56552 // check textOutTest.null 56553 emptyO(self); 56554 r2 = readTextO(self, "../textOutTest.null"); 56555 ck_assert_ptr_ne(r2, NULL); 56556 char *s = toStringO(r2); 56557 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 56558 free(s); 56559 rmAll("../textOutTest.null"); 56560 terminateO(self); 56561 terminateO(filePath); 56562 56563 } 56564 56565 56566 void writeTextJsonSmallJsonGT(void) { 56567 56568 bool r; 56569 smallJsont *self = allocG(rtSmallJsont); 56570 smallJsont *filePath = allocSmallJson(); 56571 56572 // write textOutTest.null 56573 smallJsont *r2 = readTextO(self, "../textTest.null"); 56574 ck_assert_ptr_ne(r2, NULL); 56575 freeO(filePath); 56576 setTopSO(filePath, "../textOutTest.null"); 56577 r = writeTextJsonSmallJsonG(self, filePath); 56578 ck_assert(r); 56579 // check textOutTest.null 56580 emptyO(self); 56581 r2 = readTextO(self, "../textOutTest.null"); 56582 ck_assert_ptr_ne(r2, NULL); 56583 char *s = toStringO(r2); 56584 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\"]"); 56585 free(s); 56586 rmAll("../textOutTest.null"); 56587 terminateO(filePath); 56588 terminateO(self); 56589 56590 } 56591 56592 56593 void writeTextStreamSmallJsonGT(void) { 56594 56595 bool r; 56596 smallJsont *self = allocG(rtSmallJsont); 56597 FILE *fp; 56598 56599 // non json array 56600 fp = fopen("../textTest.null", "r"); 56601 r = writeTextStreamSmallJsonG(self, fp); 56602 ck_assert(!r); 56603 // write textOutTest.null 56604 smallJsont *r2 = self->f->readTextStream(self, fp); 56605 fclose(fp); 56606 ck_assert_ptr_ne(r2, NULL); 56607 fp = fopen("../textOutTest.null", "w"); 56608 r = writeTextStreamSmallJsonG(self, fp); 56609 fclose(fp); 56610 ck_assert(r); 56611 rmAll("../textOutTest.null"); 56612 terminateO(self); 56613 56614 } 56615 56616 56617 void appendTextSmallStringSmallJsonGT(void) { 56618 56619 bool r; 56620 smallJsont *self = allocSmallJson(); 56621 smallStringt *filePath = allocSmallString(""); 56622 56623 // append to textOutTest.null 56624 smallJsont *r2 = readTextO(self, "../textTest.null"); 56625 ck_assert_ptr_ne(r2, NULL); 56626 r = writeTextO(self, "../textOutTest.null"); 56627 ck_assert(r); 56628 emptyO(self); 56629 self->f->pushS(self, "A"); 56630 self->f->pushS(self, "B"); 56631 setValO(filePath, "../textOutTest.null"); 56632 r = appendTextSmallStringSmallJsonG(self, filePath); 56633 // check textOutTest.null 56634 emptyO(self); 56635 r2 = readTextO(self, "../textOutTest.null"); 56636 char *s = toStringO(r2); 56637 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 56638 free(s); 56639 terminateO(self); 56640 terminateO(filePath); 56641 56642 } 56643 56644 56645 void appendTextJsonSmallJsonGT(void) { 56646 56647 bool r; 56648 smallJsont *self = allocG(rtSmallJsont); 56649 smallJsont *filePath = allocSmallJson(); 56650 56651 // append to textOutTest.null 56652 smallJsont *r2 = readTextO(self, "../textTest.null"); 56653 ck_assert_ptr_ne(r2, NULL); 56654 r = writeTextO(self, "../textOutTest.null"); 56655 ck_assert(r); 56656 emptyO(self); 56657 self->f->pushS(self, "A"); 56658 self->f->pushS(self, "B"); 56659 freeO(filePath); 56660 setTopSO(filePath, "../textOutTest.null"); 56661 r = appendTextJsonSmallJsonG(self, filePath); 56662 // check textOutTest.null 56663 emptyO(self); 56664 r2 = readTextO(self, "../textOutTest.null"); 56665 ck_assert_ptr_ne(r2, NULL); 56666 char *s = toStringO(r2); 56667 ck_assert_str_eq(s, "[\"LINE 1\",\"ANOTHER line\",\"A\",\"B\"]"); 56668 free(s); 56669 rmAll("../textOutTest.null"); 56670 terminateO(filePath); 56671 terminateO(self); 56672 56673 } 56674 56675 56676 void cSmallJsonT(void) { 56677 56678 // local object 56679 createSmallJson(obj); 56680 ck_assert_str_eq(obj.type, "smallJson"); 56681 // object 56682 createAllocateSmallJson(obj2); 56683 ck_assert_str_eq(obj2->type, "smallJson"); 56684 // toString 56685 char *s = obj2->f->toString(obj2); 56686 ck_assert_str_eq(s, "{}"); 56687 free(s); 56688 createAllocateSmallInt(oInt); 56689 oInt->f->set(oInt, 123); 56690 obj2->f->set(obj2, "int", (baset *) oInt); 56691 finishO(oInt); 56692 initiateAllocateSmallInt(&oInt); 56693 oInt->f->set(oInt, 123); 56694 obj2->f->set(obj2, "int2", (baset *) oInt); 56695 finishO(oInt); 56696 // no effect - no push to dictionary 56697 initiateAllocateSmallInt(&oInt); 56698 obj2->f->push(obj2, (baset *) oInt); 56699 finishO(oInt); 56700 s = obj2->f->toString(obj2); 56701 ck_assert_str_eq(s, "{\"int\":123,\"int2\":123}"); 56702 free(s); 56703 terminateO(obj2); 56704 initiateAllocateSmallJson(&obj2); 56705 smallJsont *r = obj2->f->push(obj2, null); 56706 ck_assert_ptr_eq(r, null); 56707 createAllocateSmallInt(oInt2); 56708 oInt2->f->set(oInt2, 123); 56709 obj2->f->push(obj2, (baset *) oInt2); 56710 finishO(oInt2); 56711 initiateAllocateSmallInt(&oInt2); 56712 oInt2->f->set(oInt2, 123); 56713 obj2->f->push(obj2, (baset *) oInt2); 56714 finishO(oInt2); 56715 // no effect - no set with key to array 56716 initiateAllocateSmallInt(&oInt2); 56717 obj2->f->set(obj2, "noEffect", (baset *) oInt2); 56718 finishO(oInt2); 56719 s = obj2->f->toString(obj2); 56720 ck_assert_str_eq(s, "[123,123]"); 56721 free(s); 56722 // duplicate 56723 smallJsont *o; 56724 o = obj2->f->duplicate(obj2); 56725 s = toStringO(o); 56726 ck_assert_str_eq(s, "[123,123]"); 56727 free(s); 56728 terminateO(o); 56729 terminateO(obj2); 56730 initiateAllocateSmallJson(&obj2); 56731 createAllocateSmallInt(oInt3); 56732 oInt3->f->set(oInt3, 123); 56733 obj2->f->set(obj2, "int", (baset *) oInt3); 56734 finishO(oInt3); 56735 o = obj2->f->duplicate(obj2); 56736 s = toStringO(o); 56737 ck_assert_str_eq(s, "{\"int\":123}"); 56738 free(s); 56739 terminateO(o); 56740 // dispose 56741 // array 56742 initiateAllocateSmallJson(&o); 56743 initiateAllocateSmallInt(&oInt); 56744 oInt->f->set(oInt, 123); 56745 o->f->push(o, (baset*)oInt); 56746 finishO(oInt); 56747 ck_assert_uint_eq(o->topA->count, 1); 56748 smallt *i = sArrayGetTiny(o->topA, 0); 56749 o->f->dispose(o); 56750 ck_assert_ptr_eq(o->topA, NULL); 56751 sFree(i); 56752 terminateO(o); 56753 // dictionary 56754 initiateAllocateSmallJson(&o); 56755 initiateAllocateSmallInt(&oInt); 56756 oInt->f->set(oInt, 123); 56757 o->f->set(o, "in", (baset*)oInt); 56758 finishO(oInt); 56759 ck_assert_uint_eq(o->top->count, 1); 56760 smallt *data = o->top->elements.data; 56761 sFree(data); 56762 o->f->dispose(o); 56763 ck_assert_ptr_eq(o->top, NULL); 56764 terminateO(o); 56765 // smash 56766 initiateAllocateSmallJson(&o); 56767 // array 56768 initiateAllocateSmallInt(&oInt); 56769 oInt->f->set(oInt, 123); 56770 o->f->push(o, (baset*)oInt); 56771 finishO(oInt); 56772 ck_assert_uint_eq(o->topA->count, 1); 56773 i = sArrayGetTiny(o->topA, 0); 56774 o->f->smash(&o); 56775 ck_assert_ptr_eq(o, NULL); 56776 sFree(i); 56777 // dict 56778 initiateAllocateSmallJson(&o); 56779 initiateAllocateSmallInt(&oInt); 56780 oInt->f->set(oInt, 123); 56781 o->f->set(o, "in", (baset*)oInt); 56782 finishO(oInt); 56783 ck_assert_uint_eq(o->top->count, 1); 56784 data = o->top->elements.data; 56785 sFree(data); 56786 o->f->smash(&o); 56787 ck_assert_ptr_eq(o, NULL); 56788 // setType* 56789 initiateAllocateSmallJson(&o); 56790 o->f->setTypeUndefined(o); 56791 ck_assert_str_eq(o->f->getTopType(o), "undefined"); 56792 o->f->setTypeBool(o); 56793 ck_assert_str_eq(o->f->getTopType(o), "bool"); 56794 o->f->setTypeDouble(o); 56795 ck_assert_str_eq(o->f->getTopType(o), "double"); 56796 o->f->setTypeInt(o); 56797 ck_assert_str_eq(o->f->getTopType(o), "int"); 56798 o->f->setTypeString(o); 56799 ck_assert_str_eq(o->f->getTopType(o), "string"); 56800 o->f->setTypeDict(o); 56801 ck_assert_str_eq(o->f->getTopType(o), "dict"); 56802 o->f->setTypeArray(o); 56803 ck_assert_str_eq(o->f->getTopType(o), "array"); 56804 terminateO(o); 56805 // getTopTypeJson setTopJson getTopJson - undefined bool double int string 56806 baset *b; 56807 smallJsont *o2; 56808 initiateAllocateSmallJson(&o); 56809 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 56810 // non json object 56811 createAllocateSmallContainer(jcontainer); 56812 // setTop 56813 // null value 56814 ck_assert_ptr_eq(o->f->setTop(o, null), null); 56815 o->f->setTop(o, (baset *)jcontainer); 56816 terminateO(jcontainer); 56817 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 56818 // getTop 56819 b = o->f->getTop(o); 56820 ck_assert_ptr_eq(b, NULL); 56821 // undefined 56822 createAllocateUndefined(jUndef); 56823 // setTop 56824 o->f->setTop(o, (baset *)jUndef); 56825 finishO(jUndef); 56826 // getTopType 56827 ck_assert_str_eq(o->f->getTopType(o), "undefined"); 56828 // getTop 56829 b = o->f->getTop(o); 56830 ck_assert_str_eq(b->type, "undefined"); 56831 finishO(b); 56832 // duplicateO 56833 o2 = duplicateO(o); 56834 // toStringO 56835 s = toStringO(o2); 56836 ck_assert_str_eq(s, "null"); 56837 free(s); 56838 // stringify 56839 s = o->f->stringify(o,2); 56840 ck_assert_str_eq(s, "null"); 56841 free(s); 56842 // toYML 56843 s = o->f->toYML(o,2); 56844 ck_assert_str_eq(s, "---\n null"); 56845 free(s); 56846 // smash 56847 o2->f->smash(&o2); 56848 // freeO 56849 freeO(o); 56850 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 56851 terminateO(o); 56852 // cBool 56853 initiateAllocateSmallJson(&o); 56854 createAllocateSmallBool(jBool); 56855 // setTop 56856 o->f->setTop(o, (baset *)jBool); 56857 finishO(jBool); 56858 // getTopType 56859 ck_assert_str_eq(o->f->getTopType(o), "bool"); 56860 // getTop 56861 b = o->f->getTop(o); 56862 ck_assert_str_eq(b->type, "smallBool"); 56863 finishO(b); 56864 // duplicateO 56865 o2 = duplicateO(o); 56866 // toStringO 56867 s = toStringO(o2); 56868 ck_assert_str_eq(s, "false"); 56869 free(s); 56870 // stringify 56871 s = o->f->stringify(o,2); 56872 ck_assert_str_eq(s, "false"); 56873 free(s); 56874 // toYML 56875 s = o->f->toYML(o,2); 56876 ck_assert_str_eq(s, "---\n false"); 56877 free(s); 56878 // smash 56879 o2->f->smash(&o2); 56880 // freeO 56881 freeO(o); 56882 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 56883 terminateO(o); 56884 // cDouble 56885 initiateAllocateSmallJson(&o); 56886 createAllocateSmallDouble(jDouble); 56887 // setTop 56888 o->f->setTop(o, (baset *)jDouble); 56889 finishO(jDouble); 56890 // getTopType 56891 ck_assert_str_eq(o->f->getTopType(o), "double"); 56892 // getTop 56893 b = o->f->getTop(o); 56894 ck_assert_str_eq(b->type, "smallDouble"); 56895 finishO(b); 56896 // duplicateO 56897 o2 = duplicateO(o); 56898 // toStringO 56899 s = toStringO(o2); 56900 ck_assert_str_eq(s, "0.000000e+00"); 56901 free(s); 56902 // stringify 56903 s = o->f->stringify(o,2); 56904 ck_assert_str_eq(s, "0.000000e+00"); 56905 free(s); 56906 // toYML 56907 s = o->f->toYML(o,2); 56908 ck_assert_str_eq(s, "---\n 0.000000e+00"); 56909 free(s); 56910 // smash 56911 o2->f->smash(&o2); 56912 // freeO 56913 freeO(o); 56914 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 56915 terminateO(o); 56916 // cInt 56917 initiateAllocateSmallJson(&o); 56918 createAllocateSmallInt(jInt); 56919 // setTop 56920 o->f->setTop(o, (baset *)jInt); 56921 finishO(jInt); 56922 // getTopType 56923 ck_assert_str_eq(o->f->getTopType(o), "int"); 56924 // getTop 56925 b = o->f->getTop(o); 56926 ck_assert_str_eq(b->type, "smallInt"); 56927 finishO(b); 56928 // duplicateO 56929 o2 = duplicateO(o); 56930 // toStringO 56931 s = toStringO(o2); 56932 ck_assert_str_eq(s, "0"); 56933 free(s); 56934 // stringify 56935 s = o->f->stringify(o,2); 56936 ck_assert_str_eq(s, "0"); 56937 free(s); 56938 // toYML 56939 s = o->f->toYML(o,2); 56940 ck_assert_str_eq(s, "---\n 0"); 56941 free(s); 56942 // smash 56943 o2->f->smash(&o2); 56944 // freeO 56945 freeO(o); 56946 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 56947 terminateO(o); 56948 // string 56949 initiateAllocateSmallJson(&o); 56950 createAllocateSmallString(jString); 56951 jString->f->set(jString, "sheepy"); 56952 // setTop 56953 o->f->setTop(o, (baset *)jString); 56954 finishO(jString); 56955 // getTopType 56956 ck_assert_str_eq(o->f->getTopType(o), "string"); 56957 // getTop 56958 b = o->f->getTop(o); 56959 ck_assert_str_eq(b->type, "smallString"); 56960 finishO(b); 56961 // duplicateO 56962 o2 = duplicateO(o); 56963 // toStringO 56964 s = toStringO(o2); 56965 ck_assert_str_eq(s, "sheepy"); 56966 free(s); 56967 // stringify 56968 s = o->f->stringify(o,2); 56969 ck_assert_str_eq(s, "\"sheepy\""); 56970 free(s); 56971 // toYML 56972 s = o->f->toYML(o,2); 56973 ck_assert_str_eq(s, "---\n \"sheepy\""); 56974 free(s); 56975 // smash 56976 o2->f->smash(&o2); 56977 // freeO 56978 freeO(o); 56979 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 56980 terminateO(o); 56981 // dict 56982 initiateAllocateSmallJson(&o); 56983 o->f->setS(o, "1", "2"); 56984 createAllocateSmallDict(jdict); 56985 // setTop 56986 // start iteration before setTop to check if 56987 // iterElement is finished 56988 iterStartO(o); 56989 // set json type to SMALLJSON_IS_EMPTY because as of today 56990 // setTop only works when the object is empty 56991 o->topIsA = 0; 56992 o->f->setTop(o, (baset *)jdict); 56993 finishO(jdict); 56994 // getTopType 56995 ck_assert_str_eq(o->f->getTopType(o), "dict"); 56996 // getTop 56997 b = o->f->getTop(o); 56998 ck_assert_str_eq(b->type, "smallDict"); 56999 finishO(b); 57000 // duplicateO 57001 o2 = duplicateO(o); 57002 // toStringO 57003 s = toStringO(o2); 57004 ck_assert_str_eq(s, "{}"); 57005 free(s); 57006 // stringify 57007 s = o->f->stringify(o,2); 57008 ck_assert_str_eq(s, "{}\n"); 57009 free(s); 57010 // toYML 57011 s = o->f->toYML(o,2); 57012 ck_assert_str_eq(s, "---\n {}\n"); 57013 free(s); 57014 // smash 57015 o2->f->smash(&o2); 57016 // freeO 57017 freeO(o); 57018 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 57019 terminateO(o); 57020 // array 57021 initiateAllocateSmallJson(&o); 57022 createAllocateSmallArray(jArray); 57023 // setTop 57024 o->f->setTop(o, (baset *)jArray); 57025 finishO(jArray); 57026 // getTopType 57027 ck_assert_str_eq(o->f->getTopType(o), "array"); 57028 // getTop 57029 b = o->f->getTop(o); 57030 ck_assert_str_eq(b->type, "smallArray"); 57031 finishO(b); 57032 // duplicateO 57033 o2 = duplicateO(o); 57034 // toStringO 57035 s = toStringO(o2); 57036 ck_assert_str_eq(s, "[]"); 57037 free(s); 57038 // stringify 57039 s = o->f->stringify(o,2); 57040 ck_assert_str_eq(s, "[]\n"); 57041 free(s); 57042 // toYML 57043 s = o->f->toYML(o,2); 57044 ck_assert_str_eq(s, "---\n []\n"); 57045 free(s); 57046 // smash 57047 o2->f->smash(&o2); 57048 // freeO 57049 freeO(o); 57050 ck_assert_ptr_eq(o->f->getTopType(o), NULL); 57051 terminateO(o); 57052 // get 57053 smallIntt *in = (smallIntt *) obj2->f->get(obj2, "int"); 57054 ck_assert(in->value->value == 123); 57055 createAllocateSmallDict(oD2); 57056 smallIntt *in2 = duplicateO(in); 57057 oD2->f->set(oD2, "int", (baset *)in2); 57058 finishO(in2); 57059 in2 = duplicateO(in); 57060 oD2->f->set(oD2, "int2", (baset *)in2); 57061 finishO(in2); 57062 obj2->f->set(obj2, "dict", (baset *)oD2); 57063 finishO(oD2); 57064 createAllocateSmallArray(oTA2); 57065 in2 = duplicateO(in); 57066 oTA2->f->push(oTA2, (baset *)in2); 57067 finishO(in2); 57068 in2 = duplicateO(in); 57069 oTA2->f->push(oTA2, (baset *)in2); 57070 finishO(in2); 57071 smashO(in); 57072 obj2->f->set(obj2, "array", (baset *)oTA2); 57073 finishO(oTA2); 57074 // get dict element 57075 in = (smallIntt *) obj2->f->get(obj2, "\"dict\".\"int2\""); 57076 ck_assert(in->value->value == 123); 57077 smashO(in); 57078 // non existing element 57079 in = (smallIntt *) obj2->f->get(obj2, "\"dict\".\"void\""); 57080 ck_assert_ptr_eq(in, NULL); 57081 // missing " at the end 57082 in = (smallIntt *) obj2->f->get(obj2, "\"dict\".\"int2"); 57083 ck_assert_ptr_eq(in, NULL); 57084 // get array element 57085 in = (smallIntt *) obj2->f->get(obj2, "\"array\"[0]"); 57086 ck_assert(in->value->value == 123); 57087 smashO(in); 57088 // missing ] at the end 57089 in = (smallIntt *) obj2->f->get(obj2, "\"array\"[0"); 57090 ck_assert_ptr_eq(in, NULL); 57091 // json array 57092 createAllocateSmallJson(json); 57093 createAllocateSmallInt(oInt4); 57094 oInt4->f->set(oInt4, 345); 57095 json->f->push(json, (baset *) oInt4); 57096 finishO(oInt4); 57097 in = (smallIntt *) json->f->get(json, "[0]"); 57098 ck_assert(in->value->value == 345); 57099 smashO(in); 57100 // set get json path 57101 createSmallJson(jpath); 57102 // dict is top 57103 jpath.f->parse(&jpath, "{ \"a\": {\"a\": true}, \"b\": 234, \"c\": [\"qwe\",32]}"); 57104 // get non existing element in 'c' array 57105 b = jpath.f->get(&jpath,"\"c\"[3]"); 57106 ck_assert_ptr_eq(b, NULL); 57107 finishO(b); 57108 // dictionary keys should not be unescaped 57109 createSmallBool(ba); 57110 jpath.f->set(&jpath, "b\\\\", cBa(&ba)); 57111 jBool = (smallBoolt*)jpath.f->get(&jpath,"b\\\\"); 57112 ck_assert(jBool->value->value == false); 57113 finishO(jBool); 57114 // keys in json paths should be unescaped 57115 createSmallBool(bb); 57116 bb.f->set(&bb, true); 57117 jpath.f->set(&jpath, "\"b\\\\\"", (baset*)&bb); 57118 jBool = (smallBoolt*)jpath.f->get(&jpath,"\"b\\\\\""); 57119 ck_assert(jBool->value->value == true); 57120 finishO(jBool); 57121 freeO(&jpath); 57122 // array is top 57123 // get dict in dict 57124 jpath.f->parse(&jpath, "[1,{\"a\": {\"a\": true}, \"b\": 234, \"c\": [\"qwe\",32]}, [[11],22,33]]"); 57125 b = jpath.f->get(&jpath,"[1].\"a\""); 57126 ck_assert_str_eq(b->type, "smallDict"); 57127 finishO(b); 57128 // get bool in dict 57129 jBool = (smallBoolt*)jpath.f->get(&jpath,"[1]\"a\"\"a\""); 57130 ck_assert(jBool->value->value == true); 57131 finishO(jBool); 57132 // get array in array 57133 jArray = (smallArrayt*)jpath.f->get(&jpath,"[2][0]"); 57134 ck_assert_str_eq(jArray->type, "smallArray"); 57135 ck_assert_uint_eq(lenO(jArray), 1); 57136 finishG(jArray); 57137 // get element in array 57138 in = (smallIntt*)(jpath.f->get(&jpath,"[2][0][0]")); 57139 ck_assert_uint_eq(in->value->value, 11); 57140 finishG(in); 57141 // set element in array with negative index 57142 createSmallBool(be); 57143 jpath.f->set(&jpath, "[-1][0][0]", (baset*)&be); 57144 // get element in array with negative index 57145 jBool = (smallBoolt*)jpath.f->get(&jpath,"[-1][0][0]"); 57146 ck_assert(jBool->value->value == false); 57147 finishG(jBool); 57148 // set new element in dict 57149 createSmallBool(b2); 57150 o2 = jpath.f->set(&jpath, "[1]\"a\"\"b\\\"\"", (baset*)&b2); 57151 ck_assert_ptr_ne(o2, NULL); 57152 jBool = (smallBoolt*)jpath.f->get(&jpath,"[1]\"a\"\"b\\\"\""); 57153 ck_assert(jBool->value->value == false); 57154 finishG(jBool); 57155 createSmallBool(b3); 57156 o2 = jpath.f->set(&jpath, "[1]\"a\"\"b\\\\\"", (baset*)&b3); 57157 ck_assert_ptr_ne(o2, NULL); 57158 jBool = (smallBoolt*)jpath.f->get(&jpath,"[1]\"a\"\"b\\\\\""); 57159 ck_assert(jBool->value->value == false); 57160 finishG(jBool); 57161 // escape key in json path 57162 // \\\"" 57163 char *ks = jpath.f->makeKey(&jpath, "\\\\\\\"\""); 57164 ck_assert_str_eq(ks, "\"\\\\\\\\\\\\\\\"\\\"\""); 57165 createSmallBool(b4); 57166 iPrependS(&ks, "[1]"); 57167 o2 = jpath.f->set(&jpath, ks, (baset*)&b4); 57168 ck_assert_ptr_ne(o2, NULL); 57169 jBool = (smallBoolt*)jpath.f->get(&jpath,ks); 57170 ck_assert(jBool->value->value == false); 57171 finishG(jBool); 57172 free(ks); 57173 // wrong path 57174 b = jpath.f->get(&jpath,"[3][0][0]"); 57175 ck_assert_ptr_eq(b, NULL); 57176 finishG(b); 57177 // missing index 57178 b = jpath.f->get(&jpath,"[][0][0]"); 57179 ck_assert_ptr_eq(b, NULL); 57180 finishG(b); 57181 // try to assign dictionary key to array, wrong 57182 createSmallBool(b0); 57183 o2 = jpath.f->set(&jpath, "[2][0]\"sdf\\\"", (baset*)&b0); 57184 ck_assert_ptr_eq(o2, NULL); 57185 freeO(&jpath); 57186 // len 57187 initiateAllocateSmallJson(&o); 57188 ck_assert_uint_eq(o->f->len(o), 0); 57189 o->f->setTypeUndefined(o); 57190 ck_assert_uint_eq(o->f->len(o), 1); 57191 o->f->setTypeBool(o); 57192 ck_assert_uint_eq(o->f->len(o), 1); 57193 o->f->setTypeDouble(o); 57194 ck_assert_uint_eq(o->f->len(o), 1); 57195 o->f->setTypeInt(o); 57196 ck_assert_uint_eq(o->f->len(o), 1); 57197 o->f->setTypeString(o); 57198 ck_assert_uint_eq(o->f->len(o), 0); 57199 o->f->setTypeDict(o); 57200 ck_assert_uint_eq(o->f->len(o), 0); 57201 o->f->setTypeArray(o); 57202 ck_assert_uint_eq(o->f->len(o), 0); 57203 terminateO(o); 57204 // empty 57205 initiateAllocateSmallJson(&o); 57206 // empty empty 57207 o->f->empty(o); 57208 o->f->setTypeString(o); 57209 sFree((smallt *)o->topS); 57210 o->topS = allocSStringTiny("er"); 57211 o->f->empty(o); 57212 ck_assert_uint_eq(o->f->len(o), 0); 57213 o->f->setTypeDict(o); 57214 initiateAllocateSmallInt(&in); 57215 o->f->set(o, "wer", (baset *)in); 57216 finishO(in); 57217 o->f->empty(o); 57218 ck_assert_uint_eq(o->f->len(o), 0); 57219 o->f->setTypeArray(o); 57220 initiateAllocateSmallInt(&in); 57221 o->f->push(o, (baset *)in); 57222 finishO(in); 57223 o->f->empty(o); 57224 ck_assert_uint_eq(o->f->len(o), 0); 57225 terminateO(o); 57226 // stringify 57227 // array 57228 initiateAllocateSmallString(&jString); 57229 jString->f->set(jString, "sheepy"); 57230 json->f->push(json, (baset *) jString); 57231 finishO(jString); 57232 initiateAllocateSmallDict(&jdict); 57233 json->f->push(json, (baset *) jdict); 57234 finishO(jdict); 57235 initiateAllocateSmallArray(&jArray); 57236 json->f->push(json, (baset *) jArray); 57237 finishO(jArray); 57238 initiateAllocateSmallDict(&jdict); 57239 initiateAllocateSmallString(&jString); 57240 jString->f->set(jString, "sheepy"); 57241 jdict->f->set(jdict, "string", (baset *) jString); 57242 finishO(jString); 57243 initiateAllocateSmallContainer(&jcontainer); 57244 jdict->f->set(jdict, "container", (baset *) jcontainer); 57245 finishO(jcontainer); 57246 json->f->push(json, (baset *) jdict); 57247 finishO(jdict); 57248 initiateAllocateSmallArray(&jArray); 57249 initiateAllocateSmallString(&jString); 57250 jString->f->set(jString, "sheepy"); 57251 jArray->f->push(jArray, (baset *) jString); 57252 finishO(jString); 57253 initiateAllocateSmallContainer(&jcontainer); 57254 jArray->f->push(jArray, (baset *) jcontainer); 57255 finishO(jcontainer); 57256 json->f->push(json, (baset *) jArray); 57257 finishO(jArray); 57258 57259 s = json->f->stringify(json, 2); 57260 ck_assert_str_eq(s, "[\n 345,\n \"sheepy\",\n {},\n [],\n {\n \"string\": \"sheepy\",\n \"container\": \"<data container>\"\n },\n [\n \"sheepy\",\n \"<data container>\"\n ]\n]\n"); 57261 free(s); 57262 // empty 57263 createAllocateSmallJson(json2); 57264 s = json2->f->stringify(json2, 2); 57265 ck_assert_str_eq(s, "{}"); 57266 free(s); 57267 // dict 57268 initiateAllocateSmallString(&jString); 57269 jString->f->set(jString, "sheepy"); 57270 json2->f->set(json2, "s", (baset *) jString); 57271 finishO(jString); 57272 initiateAllocateSmallDict(&jdict); 57273 json2->f->set(json2, "d",(baset *) jdict); 57274 finishO(jdict); 57275 initiateAllocateSmallArray(&jArray); 57276 json2->f->set(json2, "a", (baset *) jArray); 57277 finishO(jArray); 57278 initiateAllocateSmallDict(&jdict); 57279 initiateAllocateSmallString(&jString); 57280 jString->f->set(jString, "sheepy"); 57281 jdict->f->set(jdict, "string", (baset *) jString); 57282 finishO(jString); 57283 initiateAllocateSmallContainer(&jcontainer); 57284 jdict->f->set(jdict, "container", (baset *) jcontainer); 57285 finishO(jcontainer); 57286 json2->f->set(json2, "d2",(baset *) jdict); 57287 finishO(jdict); 57288 initiateAllocateSmallArray(&jArray); 57289 initiateAllocateSmallString(&jString); 57290 jString->f->set(jString, "sheepy"); 57291 jArray->f->push(jArray, (baset *) jString); 57292 finishO(jString); 57293 initiateAllocateSmallContainer(&jcontainer); 57294 jArray->f->push(jArray, (baset *) jcontainer); 57295 finishO(jcontainer); 57296 json2->f->set(json2, "a2", (baset *) jArray); 57297 finishO(jArray); 57298 initiateAllocateSmallInt(&oInt4); 57299 oInt4->f->set(oInt4, 345); 57300 json2->f->set(json2, "int", (baset *) oInt4); 57301 finishO(oInt4); 57302 s = json2->f->stringify(json2, 2); 57303 ck_assert_str_eq(s, "{\n \"s\": \"sheepy\",\n \"d\": {},\n \"a\": [],\n \"d2\": {\n \"string\": \"sheepy\",\n \"container\": \"<data container>\"\n },\n \"a2\": [\n \"sheepy\",\n \"<data container>\"\n ],\n \"int\": 345\n}\n"); 57304 free(s); 57305 // toYML 57306 // array 57307 s = json->f->toYML(json, 2); 57308 ck_assert_str_eq(s, "---\n - 345\n - sheepy\n - {}\n - []\n - string: sheepy\n container: \"<data container>\"\n - - sheepy\n - \"<data container>\"\n"); 57309 free(s); 57310 // empty 57311 createAllocateSmallJson(json3); 57312 s = json3->f->toYML(json3, 2); 57313 ck_assert_str_eq(s, "---\n"); 57314 free(s); 57315 terminateO(json3); 57316 // dict 57317 s = json2->f->toYML(json2, 2); 57318 ck_assert_str_eq(s, "---\n s: sheepy\n d:\n {}\n a:\n []\n d2:\n string: sheepy\n container: \"<data container>\"\n a2:\n - sheepy\n - \"<data container>\"\n int: 345\n"); 57319 free(s); 57320 terminateO(json2); 57321 terminateO(json); 57322 // parse 57323 // top null - undefined 57324 initiateAllocateSmallJson(&json); 57325 json->f->parse(json, "null"); 57326 ck_assert_str_eq(json->f->getTopType(json), "undefined"); 57327 terminateO(json); 57328 // top bool 57329 initiateAllocateSmallJson(&json); 57330 json->f->parse(json, "true"); 57331 ck_assert_str_eq(json->f->getTopType(json), "bool"); 57332 terminateO(json); 57333 // top double 57334 initiateAllocateSmallJson(&json); 57335 json->f->parse(json, "0.01"); 57336 ck_assert_str_eq(json->f->getTopType(json), "double"); 57337 terminateO(json); 57338 // top int 57339 initiateAllocateSmallJson(&json); 57340 json->f->parse(json, "10"); 57341 ck_assert_str_eq(json->f->getTopType(json), "int"); 57342 terminateO(json); 57343 // top string 57344 initiateAllocateSmallJson(&json); 57345 json->f->parse(json, "\"wef\""); 57346 ck_assert_str_eq(json->f->getTopType(json), "string"); 57347 terminateO(json); 57348 // from file dictionary 57349 char **file = readText("file.json"); 57350 char *jsonText = join(file, "\n"); 57351 createAllocateSmallJson(jsOfromF); 57352 jsOfromF->f->parse(jsOfromF, jsonText); 57353 s = toStringO(jsOfromF); 57354 //printf("JSON FILE: %s\n", s); 57355 ck_assert_str_eq(s, "{\"dasd\":\"asd\",\"asd\":234,\"dict\":{\"array\":[1,1],\"asd\":true,\"float\":3.434000e+01},\"bool\":false,\"zzz\":null}"); 57356 free(s); 57357 free(jsonText); 57358 listFreeS(file); 57359 terminateO(jsOfromF); 57360 // json array top 57361 file = readText("fileA.json"); 57362 jsonText = join(file, "\n"); 57363 initiateAllocateSmallJson(&jsOfromF); 57364 jsOfromF->f->parse(jsOfromF, jsonText); 57365 s = toStringO(jsOfromF); 57366 ck_assert_str_eq(s, "[\"asd\",234,{\"array\":[1,1],\"asd\":true,\"float\":3.434000e+01}]"); 57367 free(s); 57368 free(jsonText); 57369 listFreeS(file); 57370 terminateO(jsOfromF); 57371 // wrong json incomplete dict 57372 initiateAllocateSmallJson(&json); 57373 json->f->parse(json, "{\"wef\": {"); 57374 s = toStringO(json); 57375 ck_assert_str_eq(s, "{}"); 57376 free(s); 57377 terminateO(json); 57378 // wrong json incomplete array 57379 initiateAllocateSmallJson(&json); 57380 json->f->parse(json, "{\"wef\": ["); 57381 s = toStringO(json); 57382 ck_assert_str_eq(s, "{}"); 57383 free(s); 57384 terminateO(json); 57385 // wrong json incomplete string 57386 initiateAllocateSmallJson(&json); 57387 json->f->parse(json, "{\"wef\": \"wer"); 57388 s = toStringO(json); 57389 ck_assert_str_eq(s, "{}"); 57390 free(s); 57391 terminateO(json); 57392 // wrong json incomplete top dict 57393 initiateAllocateSmallJson(&json); 57394 json->f->parse(json, "{ \"wef"); 57395 s = toStringO(json); 57396 ck_assert_str_eq(s, "{}"); 57397 free(s); 57398 terminateO(json); 57399 // wrong json incomplete top array 57400 initiateAllocateSmallJson(&json); 57401 json->f->parse(json, "[\"wef"); 57402 s = toStringO(json); 57403 ck_assert_str_eq(s, "{}"); 57404 free(s); 57405 terminateO(json); 57406 // wrong json incomplete top string 57407 initiateAllocateSmallJson(&json); 57408 json->f->parse(json, "\"wef"); 57409 s = toStringO(json); 57410 ck_assert_str_eq(s, "{}"); 57411 free(s); 57412 terminateO(json); 57413 // parseYML 57414 // yml only top dict or array - NO: top null undefined top bool top double top int top string 57415 // from file dictionary 57416 file = readText("file.yml"); 57417 jsonText = join(file, "\n"); 57418 initiateAllocateSmallJson(&jsOfromF); 57419 jsOfromF->f->parseYML(jsOfromF, jsonText); 57420 s = toStringO(jsOfromF); 57421 ck_assert_str_eq(s, "{\"dict\":{\"array\":[1,1],\"float\":3.434000e+01,\"asd\":true},\"dasd\":\"asd\",\"asd\":234,\"bool\":false,\"zzz\":null}"); 57422 free(s); 57423 free(jsonText); 57424 listFreeS(file); 57425 terminateO(jsOfromF); 57426 // json array top 57427 file = readText("fileA.yml"); 57428 jsonText = join(file, "\n"); 57429 initiateAllocateSmallJson(&jsOfromF); 57430 jsOfromF->f->parseYML(jsOfromF, jsonText); 57431 s = toStringO(jsOfromF); 57432 //printf("JSON FILE: %s\n", toStringO(jsOfromF)); 57433 ck_assert_str_eq(s, "[{\"dict\":\"hello\",\"array\":[1,1],\"float\":3.434000e+01,\"asd\":true},\"asd\",234]"); 57434 free(s); 57435 free(jsonText); 57436 listFreeS(file); 57437 terminateO(jsOfromF); 57438 // serial deserial 57439 smallBytest *B; 57440 initiateAllocateSmallJson(&o); 57441 ck_assert_ptr_eq(o->f->serial(o), NULL); 57442 // non json object 57443 initiateAllocateSmallContainer(&jcontainer); 57444 o->f->setTop(o, (baset *)jcontainer); 57445 ck_assert_ptr_eq(o->f->serial(o), NULL); 57446 terminateO(jcontainer); 57447 // undefined 57448 undefinedt *oU = allocUndefined(); 57449 o->f->setTop(o, (baset *)oU); 57450 finishO(oU); 57451 B = o->f->serial(o); 57452 s = sToString((smallt *) B->B); 57453 ck_assert_str_eq(s, "[0x01]"); 57454 free(s); 57455 freeO(o); 57456 o->f->deserial(o, B); 57457 s = toStringO(o); 57458 ck_assert_str_eq(s, "null"); 57459 free(s); 57460 terminateO(B); 57461 terminateO(o); 57462 // Bool 57463 initiateAllocateSmallJson(&o); 57464 smallBoolt *oBool = allocSmallBool(true); 57465 o->f->setTop(o, (baset *)oBool); 57466 finishO(oBool); 57467 B = o->f->serial(o); 57468 s = sToString((smallt *) B->B); 57469 ck_assert_str_eq(s, "[0x02,0x01]"); 57470 free(s); 57471 o->f->deserial(o, B); 57472 s = toStringO(o); 57473 ck_assert_str_eq(s, "true"); 57474 free(s); 57475 terminateO(B); 57476 terminateO(o); 57477 // Double 57478 initiateAllocateSmallJson(&o); 57479 smallDoublet *od = allocSmallDouble(10); 57480 o->f->setTop(o, (baset *)od); 57481 finishO(od); 57482 B = o->f->serial(o); 57483 s = sToString((smallt *) B->B); 57484 ck_assert_str_eq(s, "[0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x40]"); 57485 free(s); 57486 o->f->deserial(o, B); 57487 s = toStringO(o); 57488 ck_assert_str_eq(s, "1.000000e+01"); 57489 free(s); 57490 terminateO(B); 57491 terminateO(o); 57492 // Int 57493 initiateAllocateSmallJson(&o); 57494 oInt = allocSmallInt(85); 57495 o->f->setTop(o, (baset *)oInt); 57496 finishO(oInt); 57497 B = o->f->serial(o); 57498 s = sToString((smallt *) B->B); 57499 ck_assert_str_eq(s, "[0x07,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00]"); 57500 free(s); 57501 o->f->deserial(o, B); 57502 s = toStringO(o); 57503 ck_assert_str_eq(s, "85"); 57504 free(s); 57505 terminateO(B); 57506 terminateO(o); 57507 // string 57508 initiateAllocateSmallJson(&o); 57509 smallStringt *st = allocSmallString("sheepy"); 57510 o->f->setTop(o, (baset *)st); 57511 finishO(st); 57512 B = o->f->serial(o); 57513 s = sToString((smallt *) B->B); 57514 ck_assert_str_eq(s, "[0x08,0x73,0x68,0x65,0x65,0x70,0x79,0x00]"); 57515 free(s); 57516 o->f->deserial(o, B); 57517 s = toStringO(o); 57518 ck_assert_str_eq(s, "sheepy"); 57519 free(s); 57520 terminateO(B); 57521 terminateO(o); 57522 // dict 57523 initiateAllocateSmallJson(&o); 57524 smallDictt *sDD = allocSmallDict(); 57525 o->f->setTop(o, (baset *)sDD); 57526 finishO(sDD); 57527 B = o->f->serial(o); 57528 s = sToString((smallt *) B->B); 57529 ck_assert_str_eq(s, "[0x04,0x00,0x00,0x00,0x00]"); 57530 free(s); 57531 o->f->deserial(o, B); 57532 s = toStringO(o); 57533 ck_assert_str_eq(s, "{}"); 57534 free(s); 57535 terminateO(B); 57536 terminateO(o); 57537 // array 57538 initiateAllocateSmallJson(&o); 57539 smallArrayt *sAA = allocSmallArray(); 57540 o->f->setTop(o, (baset *)sAA); 57541 finishO(sAA); 57542 B = o->f->serial(o); 57543 s = sToString((smallt *) B->B); 57544 ck_assert_str_eq(s, "[0x0a,0x00,0x00,0x00,0x00]"); 57545 free(s); 57546 o->f->deserial(o, B); 57547 s = toStringO(o); 57548 ck_assert_str_eq(s, "[]"); 57549 free(s); 57550 terminateO(B); 57551 terminateO(o); 57552 // deserial non json object 57553 initiateAllocateSmallJson(&o); 57554 initiateAllocateSmallBytes(&B); 57555 sContainert *c = allocSContainer(NULL); 57556 B->B = sSerial((smallt *) c); 57557 sFree((smallt *) c); 57558 o->f->deserial(o, B); 57559 ck_assert_uint_eq(o->topIsA, 0/*=JSON_IS_EMPTY*/); 57560 terminateO(B); 57561 terminateO(o); 57562 // deserial empty sBytest 57563 initiateAllocateSmallJson(&o); 57564 initiateAllocateSmallBytes(&B); 57565 o->f->deserial(o, B); 57566 ck_assert_uint_eq(o->topIsA, 0/*=JSON_IS_EMPTY*/); 57567 terminateO(B); 57568 terminateO(o); 57569 // NULL object 57570 initiateAllocateSmallJson(&o); 57571 o->f->setTypeUndefined(o); 57572 sFree((smallt *) o->topU); 57573 o->topU = NULL; 57574 ck_assert_ptr_eq(o->f->serial(o),NULL); 57575 o->f->deserial(o, NULL); 57576 terminateO(o); 57577 // free local object 57578 obj.f->free(&obj); 57579 ck_assert_str_eq(obj.type, "smallJson"); 57580 // free object 57581 obj2->f->terminate(&obj2); 57582 ck_assert_ptr_eq(obj2, NULL); 57583 initiateAllocateSmallJson(&o); 57584 terminateO(o); 57585 ck_assert_ptr_eq(o, NULL); 57586 // undefined 57587 initiateAllocateSmallJson(&o); 57588 o->f->setTypeUndefined(o); 57589 terminateO(o); 57590 ck_assert_ptr_eq(o, NULL); 57591 // bool 57592 initiateAllocateSmallJson(&o); 57593 o->f->setTypeBool(o); 57594 terminateO(o); 57595 ck_assert_ptr_eq(o, NULL); 57596 // double 57597 initiateAllocateSmallJson(&o); 57598 o->f->setTypeDouble(o); 57599 terminateO(o); 57600 ck_assert_ptr_eq(o, NULL); 57601 // int 57602 initiateAllocateSmallJson(&o); 57603 o->f->setTypeInt(o); 57604 terminateO(o); 57605 ck_assert_ptr_eq(o, NULL); 57606 // string 57607 initiateAllocateSmallJson(&o); 57608 o->f->setTypeString(o); 57609 terminateO(o); 57610 ck_assert_ptr_eq(o, NULL); 57611 // dict 57612 initiateAllocateSmallJson(&o); 57613 o->f->setTypeDict(o); 57614 terminateO(o); 57615 ck_assert_ptr_eq(o, NULL); 57616 // array 57617 initiateAllocateSmallJson(&o); 57618 o->f->setTypeArray(o); 57619 terminateO(o); 57620 ck_assert_ptr_eq(o, NULL); 57621 57622 } 57623 57624 57625 57626 57627 int main(int n UNUSED, char**v UNUSED) { 57628 // disable btrace to make the test run faster 57629 btraceDisable(); 57630 createSJFT(); 57631 getsoSmallJsonT(); 57632 setsoSmallJsonT(); 57633 mirrorSmallJsonT(); 57634 setTopBoolSmallJsonT(); 57635 setTopDoubleSmallJsonT(); 57636 setTopIntSmallJsonT(); 57637 setTopStringSmallJsonT(); 57638 setTopCharSmallJsonT(); 57639 setTopDictSmallJsonT(); 57640 setTopArraySmallJsonT(); 57641 setTopArraycSmallJsonT(); 57642 setTopSmallBoolSmallJsonT(); 57643 setTopSmallDoubleSmallJsonT(); 57644 setTopSmallIntSmallJsonT(); 57645 setTopSmallJsonSmallJsonT(); 57646 setTopSmallStringSmallJsonT(); 57647 setTopNFreeSmallJsonT(); 57648 setTopNFreeBoolSmallJsonT(); 57649 setTopNFreeDoubleSmallJsonT(); 57650 setTopNFreeIntSmallJsonT(); 57651 setTopNFreeStringSmallJsonT(); 57652 setTopNFreeDictSmallJsonT(); 57653 setTopNFreeArraySmallJsonT(); 57654 setTopNFreeArraycSmallJsonT(); 57655 setTopNFreeSmallBoolSmallJsonT(); 57656 setTopNFreeSmallDoubleSmallJsonT(); 57657 setTopNFreeSmallIntSmallJsonT(); 57658 setTopNFreeSmallJsonSmallJsonT(); 57659 setTopNFreeSmallStringSmallJsonT(); 57660 fromArraySmallJsonT(); 57661 fromArrayNFreeSmallJsonT(); 57662 fromArrayDictSmallJsonT(); 57663 toArrayDictSmallJsonT(); 57664 getTopUndefinedSmallJsonT(); 57665 getTopBoolSmallJsonT(); 57666 getTopBoolPSmallJsonT(); 57667 getTopDoubleSmallJsonT(); 57668 getTopDoublePSmallJsonT(); 57669 getTopIntSmallJsonT(); 57670 getTopIntPSmallJsonT(); 57671 getTopInt32SmallJsonT(); 57672 getTopInt32PSmallJsonT(); 57673 getTopUintSmallJsonT(); 57674 getTopUintPSmallJsonT(); 57675 getTopUint32SmallJsonT(); 57676 getTopUint32PSmallJsonT(); 57677 getTopSSmallJsonT(); 57678 getTopDictSmallJsonT(); 57679 getTopArraySmallJsonT(); 57680 getTopSmallBoolSmallJsonT(); 57681 getTopSmallDoubleSmallJsonT(); 57682 getTopSmallIntSmallJsonT(); 57683 getTopSmallStringSmallJsonT(); 57684 keyIsSmallJsonT(); 57685 keyIsSSmallJsonT(); 57686 makeKeySmallJsonT(); 57687 iMakeKeySmallJsonT(); 57688 bMakeKeySmallJsonT(); 57689 bLMakeKeySmallJsonT(); 57690 makeKeyLenSmallJsonT(); 57691 setSmallJsonT(); 57692 setUndefinedSmallJsonT(); 57693 setBoolSmallJsonT(); 57694 setDoubleSmallJsonT(); 57695 setIntSmallJsonT(); 57696 setSSmallJsonT(); 57697 setCharSmallJsonT(); 57698 setDictSmallJsonT(); 57699 setArraySmallJsonT(); 57700 setArraycSmallJsonT(); 57701 setSmallBoolSmallJsonT(); 57702 setSmallBytesSmallJsonT(); 57703 setSmallDoubleSmallJsonT(); 57704 setSmallIntSmallJsonT(); 57705 setSmallJsonSmallJsonT(); 57706 setSmallStringSmallJsonT(); 57707 setSmallContainerSmallJsonT(); 57708 setNFreeSmallJsonT(); 57709 setNFreeUndefinedSmallJsonT(); 57710 setNFreeSSmallJsonT(); 57711 setNFreeDictSmallJsonT(); 57712 setNFreeArraySmallJsonT(); 57713 setNFreeArraycSmallJsonT(); 57714 setNFreeSmallBoolSmallJsonT(); 57715 setNFreeSmallBytesSmallJsonT(); 57716 setNFreeSmallDoubleSmallJsonT(); 57717 setNFreeSmallIntSmallJsonT(); 57718 setNFreeSmallJsonSmallJsonT(); 57719 setNFreeSmallStringSmallJsonT(); 57720 setNFreeSmallContainerSmallJsonT(); 57721 setPDictSmallJsonT(); 57722 setPArraySmallJsonT(); 57723 setPSmallJsonSmallJsonT(); 57724 setPSmallStringSmallJsonT(); 57725 setNFreePDictSmallJsonT(); 57726 setNFreePArraySmallJsonT(); 57727 setNFreePSmallJsonSmallJsonT(); 57728 setNFreePSmallStringSmallJsonT(); 57729 setAtSmallJsonT(); 57730 setAtUndefinedSmallJsonT(); 57731 setAtBoolSmallJsonT(); 57732 setAtDoubleSmallJsonT(); 57733 setAtIntSmallJsonT(); 57734 setAtSSmallJsonT(); 57735 setAtCharSmallJsonT(); 57736 setAtDictSmallJsonT(); 57737 setAtArraySmallJsonT(); 57738 setAtArraycSmallJsonT(); 57739 setAtSmallBoolSmallJsonT(); 57740 setAtSmallBytesSmallJsonT(); 57741 setAtSmallDoubleSmallJsonT(); 57742 setAtSmallIntSmallJsonT(); 57743 setAtSmallJsonSmallJsonT(); 57744 setAtSmallStringSmallJsonT(); 57745 setAtSmallContainerSmallJsonT(); 57746 setAtNFreeSmallJsonT(); 57747 setAtNFreeUndefinedSmallJsonT(); 57748 setAtNFreeSSmallJsonT(); 57749 setAtNFreeDictSmallJsonT(); 57750 setAtNFreeArraySmallJsonT(); 57751 setAtNFreeArraycSmallJsonT(); 57752 setAtNFreeSmallBoolSmallJsonT(); 57753 setAtNFreeSmallBytesSmallJsonT(); 57754 setAtNFreeSmallDoubleSmallJsonT(); 57755 setAtNFreeSmallIntSmallJsonT(); 57756 setAtNFreeSmallJsonSmallJsonT(); 57757 setAtNFreeSmallStringSmallJsonT(); 57758 setAtNFreeSmallContainerSmallJsonT(); 57759 setPAtDictSmallJsonT(); 57760 setPAtArraySmallJsonT(); 57761 setPAtSmallJsonSmallJsonT(); 57762 setPAtSmallStringSmallJsonT(); 57763 setPAtNFreeDictSmallJsonT(); 57764 setPAtNFreeArraySmallJsonT(); 57765 setPAtNFreeSmallJsonSmallJsonT(); 57766 setPAtNFreeSmallStringSmallJsonT(); 57767 pushUndefinedSmallJsonT(); 57768 pushBoolSmallJsonT(); 57769 pushDoubleSmallJsonT(); 57770 pushIntSmallJsonT(); 57771 pushSSmallJsonT(); 57772 pushCharSmallJsonT(); 57773 pushDictSmallJsonT(); 57774 pushArraySmallJsonT(); 57775 pushArraycSmallJsonT(); 57776 pushSmallBoolSmallJsonT(); 57777 pushSmallBytesSmallJsonT(); 57778 pushSmallDoubleSmallJsonT(); 57779 pushSmallIntSmallJsonT(); 57780 pushSmallJsonSmallJsonT(); 57781 pushSmallStringSmallJsonT(); 57782 pushSmallContainerSmallJsonT(); 57783 pushNFreeSmallJsonT(); 57784 pushNFreeUndefinedSmallJsonT(); 57785 pushNFreeSSmallJsonT(); 57786 pushNFreeDictSmallJsonT(); 57787 pushNFreeArraySmallJsonT(); 57788 pushNFreeArraycSmallJsonT(); 57789 pushNFreeSmallBoolSmallJsonT(); 57790 pushNFreeSmallBytesSmallJsonT(); 57791 pushNFreeSmallDoubleSmallJsonT(); 57792 pushNFreeSmallIntSmallJsonT(); 57793 pushNFreeSmallJsonSmallJsonT(); 57794 pushNFreeSmallStringSmallJsonT(); 57795 pushNFreeSmallContainerSmallJsonT(); 57796 pushManySmallJsonT(); 57797 pushManySSmallJsonT(); 57798 pushNFreeManySmallJsonT(); 57799 pushNFreeManySSmallJsonT(); 57800 popSmallJsonT(); 57801 popUndefinedSmallJsonT(); 57802 popBoolSmallJsonT(); 57803 popDoubleSmallJsonT(); 57804 popIntSmallJsonT(); 57805 popInt32SmallJsonT(); 57806 popUintSmallJsonT(); 57807 popUint32SmallJsonT(); 57808 popSSmallJsonT(); 57809 popDictSmallJsonT(); 57810 popArraySmallJsonT(); 57811 popSmallBoolSmallJsonT(); 57812 popSmallBytesSmallJsonT(); 57813 popSmallDoubleSmallJsonT(); 57814 popSmallIntSmallJsonT(); 57815 popSmallJsonSmallJsonT(); 57816 popSmallStringSmallJsonT(); 57817 popVoidSmallJsonT(); 57818 popSmallContainerSmallJsonT(); 57819 popNumSmallJsonT(); 57820 prependSmallJsonT(); 57821 prependUndefinedSmallJsonT(); 57822 prependBoolSmallJsonT(); 57823 prependDoubleSmallJsonT(); 57824 prependIntSmallJsonT(); 57825 prependSSmallJsonT(); 57826 prependCharSmallJsonT(); 57827 prependDictSmallJsonT(); 57828 prependArraySmallJsonT(); 57829 prependArraycSmallJsonT(); 57830 prependSmallBoolSmallJsonT(); 57831 prependSmallBytesSmallJsonT(); 57832 prependSmallDoubleSmallJsonT(); 57833 prependSmallIntSmallJsonT(); 57834 prependSmallJsonSmallJsonT(); 57835 prependSmallStringSmallJsonT(); 57836 prependSmallContainerSmallJsonT(); 57837 prependNFreeSmallJsonT(); 57838 prependNFreeUndefinedSmallJsonT(); 57839 prependNFreeSSmallJsonT(); 57840 prependNFreeDictSmallJsonT(); 57841 prependNFreeArraySmallJsonT(); 57842 prependNFreeArraycSmallJsonT(); 57843 prependNFreeSmallBoolSmallJsonT(); 57844 prependNFreeSmallBytesSmallJsonT(); 57845 prependNFreeSmallDoubleSmallJsonT(); 57846 prependNFreeSmallIntSmallJsonT(); 57847 prependNFreeSmallJsonSmallJsonT(); 57848 prependNFreeSmallStringSmallJsonT(); 57849 prependNFreeSmallContainerSmallJsonT(); 57850 dequeueSmallJsonT(); 57851 dequeueUndefinedSmallJsonT(); 57852 dequeueBoolSmallJsonT(); 57853 dequeueDoubleSmallJsonT(); 57854 dequeueIntSmallJsonT(); 57855 dequeueInt32SmallJsonT(); 57856 dequeueUintSmallJsonT(); 57857 dequeueUint32SmallJsonT(); 57858 dequeueSSmallJsonT(); 57859 dequeueDictSmallJsonT(); 57860 dequeueArraySmallJsonT(); 57861 dequeueSmallBoolSmallJsonT(); 57862 dequeueSmallBytesSmallJsonT(); 57863 dequeueSmallDoubleSmallJsonT(); 57864 dequeueSmallIntSmallJsonT(); 57865 dequeueSmallJsonSmallJsonT(); 57866 dequeueSmallStringSmallJsonT(); 57867 dequeueVoidSmallJsonT(); 57868 dequeueSmallContainerSmallJsonT(); 57869 dequeueNumSmallJsonT(); 57870 reverseSmallJsonT(); 57871 catSmallJsonT(); 57872 mergeDictSmallJsonT(); 57873 mergeDictNSmashSmallJsonT(); 57874 mergeSmallJsonT(); 57875 mergeNSmashSmallJsonT(); 57876 appendSmallJsonT(); 57877 appendNSmashSmallJsonT(); 57878 appendArraySmallJsonT(); 57879 appendNSmashArraySmallJsonT(); 57880 shiftSmallJsonT(); 57881 shiftNSmashSmallJsonT(); 57882 shiftSmallJsonSmallJsonT(); 57883 shiftNSmashSmallJsonSmallJsonT(); 57884 addSmallJsonT(); 57885 addJsonSmallJsonT(); 57886 sliceSmallJsonT(); 57887 cropSmallJsonT(); 57888 cropSSmallJsonT(); 57889 cropSmallStringSmallJsonT(); 57890 cropElemAtSmallJsonT(); 57891 cropElemAtUndefinedSmallJsonT(); 57892 cropElemAtBoolSmallJsonT(); 57893 cropElemAtDoubleSmallJsonT(); 57894 cropElemAtIntSmallJsonT(); 57895 cropElemAtInt32SmallJsonT(); 57896 cropElemAtUintSmallJsonT(); 57897 cropElemAtUint32SmallJsonT(); 57898 cropElemAtSSmallJsonT(); 57899 cropElemAtCharSmallJsonT(); 57900 cropElemAtDictSmallJsonT(); 57901 cropElemAtArraySmallJsonT(); 57902 cropElemAtSmallBoolSmallJsonT(); 57903 cropElemAtSmallBytesSmallJsonT(); 57904 cropElemAtSmallDoubleSmallJsonT(); 57905 cropElemAtSmallIntSmallJsonT(); 57906 cropElemAtSmallJsonSmallJsonT(); 57907 cropElemAtSmallStringSmallJsonT(); 57908 cropElemAtVoidSmallJsonT(); 57909 cropElemAtSmallContainerSmallJsonT(); 57910 cropElemKeySmallJsonT(); 57911 cropElemKeyUndefinedSmallJsonT(); 57912 cropElemKeyBoolSmallJsonT(); 57913 cropElemKeyDoubleSmallJsonT(); 57914 cropElemKeyIntSmallJsonT(); 57915 cropElemKeyInt32SmallJsonT(); 57916 cropElemKeyUintSmallJsonT(); 57917 cropElemKeyUint32SmallJsonT(); 57918 cropElemKeySSmallJsonT(); 57919 cropElemKeyDictSmallJsonT(); 57920 cropElemKeyArraySmallJsonT(); 57921 cropElemKeySmallBoolSmallJsonT(); 57922 cropElemKeySmallBytesSmallJsonT(); 57923 cropElemKeySmallDoubleSmallJsonT(); 57924 cropElemKeySmallIntSmallJsonT(); 57925 cropElemKeySmallJsonSmallJsonT(); 57926 cropElemKeySmallStringSmallJsonT(); 57927 cropElemKeyVoidSmallJsonT(); 57928 cropElemKeySmallContainerSmallJsonT(); 57929 copySmallJsonT(); 57930 insertSmallJsonT(); 57931 insertNSmashSmallJsonT(); 57932 insertSmallJsonSmallJsonT(); 57933 insertNSmashSmallJsonSmallJsonT(); 57934 insertStringSmallJsonT(); 57935 insertSSmallJsonT(); 57936 insertNFreeStringSmallJsonT(); 57937 insertSNFreeSmallJsonT(); 57938 injectSmallJsonT(); 57939 injectUndefinedSmallJsonT(); 57940 injectBoolSmallJsonT(); 57941 injectDoubleSmallJsonT(); 57942 injectIntSmallJsonT(); 57943 injectSSmallJsonT(); 57944 injectCharSmallJsonT(); 57945 injectDictSmallJsonT(); 57946 injectArraySmallJsonT(); 57947 injectArraycSmallJsonT(); 57948 injectSmallBoolSmallJsonT(); 57949 injectSmallBytesSmallJsonT(); 57950 injectSmallDoubleSmallJsonT(); 57951 injectSmallIntSmallJsonT(); 57952 injectSmallJsonSmallJsonT(); 57953 injectSmallStringSmallJsonT(); 57954 injectSmallContainerSmallJsonT(); 57955 injectNFreeSmallJsonT(); 57956 injectNFreeUndefinedSmallJsonT(); 57957 injectNFreeSSmallJsonT(); 57958 injectNFreeDictSmallJsonT(); 57959 injectNFreeArraySmallJsonT(); 57960 injectNFreeArraycSmallJsonT(); 57961 injectNFreeSmallBoolSmallJsonT(); 57962 injectNFreeSmallBytesSmallJsonT(); 57963 injectNFreeSmallDoubleSmallJsonT(); 57964 injectNFreeSmallIntSmallJsonT(); 57965 injectNFreeSmallJsonSmallJsonT(); 57966 injectNFreeSmallStringSmallJsonT(); 57967 injectNFreeSmallContainerSmallJsonT(); 57968 uniqSmallJsonT(); 57969 sortSmallJsonT(); 57970 icSortSmallJsonT(); 57971 sortFSmallJsonT(); 57972 icUniqSmallJsonT(); 57973 uniqCharSmallJsonT(); 57974 icUniqCharSmallJsonT(); 57975 hasSmallJsonT(); 57976 hasUndefinedSmallJsonT(); 57977 hasBoolSmallJsonT(); 57978 hasDoubleSmallJsonT(); 57979 hasIntSmallJsonT(); 57980 hasSSmallJsonT(); 57981 hasCharSmallJsonT(); 57982 hasDictSmallJsonT(); 57983 hasArraySmallJsonT(); 57984 hasArraycSmallJsonT(); 57985 hasSmallBoolSmallJsonT(); 57986 hasSmallBytesSmallJsonT(); 57987 hasSmallDoubleSmallJsonT(); 57988 hasSmallIntSmallJsonT(); 57989 hasSmallJsonSmallJsonT(); 57990 hasSmallStringSmallJsonT(); 57991 hasSmallContainerSmallJsonT(); 57992 findSmallJsonT(); 57993 findCharSmallJsonT(); 57994 findSmallStringSmallJsonT(); 57995 findJsonSmallJsonT(); 57996 indexOfSmallJsonT(); 57997 indexOfUndefinedSmallJsonT(); 57998 indexOfBoolSmallJsonT(); 57999 indexOfDoubleSmallJsonT(); 58000 indexOfIntSmallJsonT(); 58001 indexOfSSmallJsonT(); 58002 indexOfCharSmallJsonT(); 58003 indexOfDictSmallJsonT(); 58004 indexOfArraySmallJsonT(); 58005 indexOfArraycSmallJsonT(); 58006 indexOfSmallBoolSmallJsonT(); 58007 indexOfSmallBytesSmallJsonT(); 58008 indexOfSmallDoubleSmallJsonT(); 58009 indexOfSmallIntSmallJsonT(); 58010 indexOfSmallJsonSmallJsonT(); 58011 indexOfSmallStringSmallJsonT(); 58012 indexOfSmallContainerSmallJsonT(); 58013 binarySearchSmallJsonT(); 58014 binarySearchUndefinedSmallJsonT(); 58015 binarySearchBoolSmallJsonT(); 58016 binarySearchDoubleSmallJsonT(); 58017 binarySearchIntSmallJsonT(); 58018 binarySearchSSmallJsonT(); 58019 binarySearchCharSmallJsonT(); 58020 binarySearchDictSmallJsonT(); 58021 binarySearchArraySmallJsonT(); 58022 binarySearchArraycSmallJsonT(); 58023 binarySearchSmallBoolSmallJsonT(); 58024 binarySearchSmallBytesSmallJsonT(); 58025 binarySearchSmallDoubleSmallJsonT(); 58026 binarySearchSmallIntSmallJsonT(); 58027 binarySearchSmallJsonSmallJsonT(); 58028 binarySearchSmallStringSmallJsonT(); 58029 binarySearchSmallContainerSmallJsonT(); 58030 icHasSmallJsonT(); 58031 icHasSSmallJsonT(); 58032 icHasCharSmallJsonT(); 58033 icHasDictSmallJsonT(); 58034 icHasArraySmallJsonT(); 58035 icHasArraycSmallJsonT(); 58036 icHasSmallStringSmallJsonT(); 58037 icFindSmallJsonT(); 58038 icFindCharSmallJsonT(); 58039 icFindSmallStringSmallJsonT(); 58040 icFindJsonSmallJsonT(); 58041 icIndexOfSmallJsonT(); 58042 icIndexOfSSmallJsonT(); 58043 icIndexOfCharSmallJsonT(); 58044 icIndexOfDictSmallJsonT(); 58045 icIndexOfArraySmallJsonT(); 58046 icIndexOfArraycSmallJsonT(); 58047 icIndexOfSmallStringSmallJsonT(); 58048 icBinarySearchSmallJsonT(); 58049 icBinarySearchSSmallJsonT(); 58050 icBinarySearchCharSmallJsonT(); 58051 icBinarySearchDictSmallJsonT(); 58052 icBinarySearchArraySmallJsonT(); 58053 icBinarySearchArraycSmallJsonT(); 58054 icBinarySearchSmallStringSmallJsonT(); 58055 keyBySmallJsonT(); 58056 keyByUndefinedSmallJsonT(); 58057 keyByBoolSmallJsonT(); 58058 keyByDoubleSmallJsonT(); 58059 keyByIntSmallJsonT(); 58060 keyBySSmallJsonT(); 58061 keyByCharSmallJsonT(); 58062 keyByDictSmallJsonT(); 58063 keyByArraySmallJsonT(); 58064 keyByArraycSmallJsonT(); 58065 keyBySmallBoolSmallJsonT(); 58066 keyBySmallBytesSmallJsonT(); 58067 keyBySmallDoubleSmallJsonT(); 58068 keyBySmallIntSmallJsonT(); 58069 keyBySmallJsonSmallJsonT(); 58070 keyBySmallStringSmallJsonT(); 58071 keyBySmallContainerSmallJsonT(); 58072 icKeyBySmallJsonT(); 58073 icKeyBySSmallJsonT(); 58074 icKeyByCharSmallJsonT(); 58075 icKeyByDictSmallJsonT(); 58076 icKeyByArraySmallJsonT(); 58077 icKeyByArraycSmallJsonT(); 58078 icKeyBySmallStringSmallJsonT(); 58079 replaceSmallJsonT(); 58080 replaceCharSSmallJsonT(); 58081 replaceSCharSmallJsonT(); 58082 replaceCharCharSmallJsonT(); 58083 replaceSmallStringSmallStringSmallJsonT(); 58084 replaceSmallStringSSmallJsonT(); 58085 replaceSmallStringCharSmallJsonT(); 58086 replaceSSmallStringSmallJsonT(); 58087 replaceCharSmallStringSmallJsonT(); 58088 replaceJsonJsonSmallJsonT(); 58089 replaceJsonSmallStringSmallJsonT(); 58090 replaceJsonSSmallJsonT(); 58091 replaceJsonCharSmallJsonT(); 58092 replaceSmallStringJsonSmallJsonT(); 58093 replaceSJsonSmallJsonT(); 58094 replaceCharJsonSmallJsonT(); 58095 replaceManySmallJsonT(); 58096 icReplaceSmallJsonT(); 58097 icReplaceCharSSmallJsonT(); 58098 icReplaceSCharSmallJsonT(); 58099 icReplaceCharCharSmallJsonT(); 58100 icReplaceSmallStringSmallStringSmallJsonT(); 58101 icReplaceSmallStringSSmallJsonT(); 58102 icReplaceSmallStringCharSmallJsonT(); 58103 icReplaceSSmallStringSmallJsonT(); 58104 icReplaceCharSmallStringSmallJsonT(); 58105 icReplaceJsonJsonSmallJsonT(); 58106 icReplaceJsonSmallStringSmallJsonT(); 58107 icReplaceJsonSSmallJsonT(); 58108 icReplaceJsonCharSmallJsonT(); 58109 icReplaceSmallStringJsonSmallJsonT(); 58110 icReplaceSJsonSmallJsonT(); 58111 icReplaceCharJsonSmallJsonT(); 58112 icReplaceManySmallJsonT(); 58113 equalSmallJsonSmallArrayT(); 58114 equalSmallJsonArrayT(); 58115 equalSmallJsonBaseT(); 58116 equalSmallJsonChaT(); 58117 equalSmallJsonCharT(); 58118 equalSmallJsonBoolT(); 58119 equalSmallJsonDoubleT(); 58120 equalSmallJsonInt64T(); 58121 equalSmallJsonInt32T(); 58122 equalSmallJsonUint32T(); 58123 equalSmallJsonUint64T(); 58124 equalSmallJsonSmallBoolT(); 58125 equalSmallJsonSmallBytesT(); 58126 equalSmallJsonSmallDoubleT(); 58127 equalSmallJsonSmallIntT(); 58128 equalSmallJsonSmallJsonT(); 58129 equalSmallJsonSmallStringT(); 58130 equalSmallJsonSmallDictT(); 58131 icEqualSmallJsonSmallArrayT(); 58132 icEqualSmallJsonArrayT(); 58133 icEqualSmallJsonBaseT(); 58134 icEqualSmallJsonSmallDictT(); 58135 icEqualSmallJsonSmallJsonT(); 58136 icEqualSmallJsonSmallStringT(); 58137 icEqualSSmallJsonT(); 58138 icEqualCharSmallJsonT(); 58139 equalISSmallJsonT(); 58140 equalICharSmallJsonT(); 58141 equalIJsonSmallJsonT(); 58142 equalISmallStringSmallJsonT(); 58143 startsWithSSmallJsonT(); 58144 startsWithCharSmallJsonT(); 58145 startsWithSmallStringSmallJsonT(); 58146 startsWithJsonSmallJsonT(); 58147 endsWithSSmallJsonT(); 58148 endsWithCharSmallJsonT(); 58149 endsWithSmallStringSmallJsonT(); 58150 endsWithJsonSmallJsonT(); 58151 countSSmallJsonT(); 58152 countCharSmallJsonT(); 58153 countSmallStringSmallJsonT(); 58154 countJsonSmallJsonT(); 58155 icStartsWithSSmallJsonT(); 58156 icStartsWithCharSmallJsonT(); 58157 icStartsWithSmallStringSmallJsonT(); 58158 icStartsWithJsonSmallJsonT(); 58159 icEndsWithSSmallJsonT(); 58160 icEndsWithCharSmallJsonT(); 58161 icEndsWithSmallStringSmallJsonT(); 58162 icEndsWithJsonSmallJsonT(); 58163 icCountSSmallJsonT(); 58164 icCountCharSmallJsonT(); 58165 icCountSmallStringSmallJsonT(); 58166 icCountJsonSmallJsonT(); 58167 isNumberSmallJsonT(); 58168 isIntSmallJsonT(); 58169 parseIntSmallJsonT(); 58170 parseDoubleSmallJsonT(); 58171 intToSmallJsonT(); 58172 doubleToSmallJsonT(); 58173 upperSmallJsonT(); 58174 lowerSmallJsonT(); 58175 trimSmallJsonT(); 58176 lTrimSmallJsonT(); 58177 rTrimSmallJsonT(); 58178 keysSmallJsonT(); 58179 keysSmallStringSmallJsonT(); 58180 valuesSmallJsonT(); 58181 compactSmallJsonT(); 58182 isEmptySmallJsonT(); 58183 isBlankSmallJsonT(); 58184 forEachSmallJsonFT(); 58185 enumerateSmallJsonFT(); 58186 enumerateDictSmallJsonT(); 58187 joinSmallJsonT(); 58188 joinCharSmallJsonT(); 58189 joinSmallJsonSmallJsonT(); 58190 joinSmallStringSmallJsonT(); 58191 joinSSmallJsonT(); 58192 joinCharSSmallJsonT(); 58193 joinSmallJsonSSmallJsonT(); 58194 joinSmallStringSSmallJsonT(); 58195 splitSmallJsonT(); 58196 splitCharSmallJsonT(); 58197 splitSmallJsonSmallJsonT(); 58198 splitSmallStringSmallJsonT(); 58199 splitSSmallJsonT(); 58200 splitCharSSmallJsonT(); 58201 splitSmallJsonSSmallJsonT(); 58202 splitSmallStringSSmallJsonT(); 58203 extractSmallJsonT(); 58204 extractCharSSmallJsonT(); 58205 extractSCharSmallJsonT(); 58206 extractCharCharSmallJsonT(); 58207 extractSmallJsonSmallJsonSmallJsonT(); 58208 extractSmallJsonSmallStringSmallJsonT(); 58209 extractSmallJsonSSmallJsonT(); 58210 extractSmallJsonCharSmallJsonT(); 58211 extractSmallStringSmallJsonSmallJsonT(); 58212 extractSmallStringSmallStringSmallJsonT(); 58213 extractSmallStringSSmallJsonT(); 58214 extractSmallStringCharSmallJsonT(); 58215 extractSSmallJsonSmallJsonT(); 58216 extractSSmallStringSmallJsonT(); 58217 extractCharSmallJsonSmallJsonT(); 58218 extractCharSmallStringSmallJsonT(); 58219 icSplitSmallJsonT(); 58220 icSplitCharSmallJsonT(); 58221 icSplitSmallJsonSmallJsonT(); 58222 icSplitSmallStringSmallJsonT(); 58223 icSplitSSmallJsonT(); 58224 icSplitCharSSmallJsonT(); 58225 icSplitSmallJsonSSmallJsonT(); 58226 icSplitSmallStringSSmallJsonT(); 58227 icExtractSmallJsonT(); 58228 icExtractCharSSmallJsonT(); 58229 icExtractSCharSmallJsonT(); 58230 icExtractCharCharSmallJsonT(); 58231 icExtractSmallJsonSmallJsonSmallJsonT(); 58232 icExtractSmallJsonSmallStringSmallJsonT(); 58233 icExtractSmallJsonSSmallJsonT(); 58234 icExtractSmallJsonCharSmallJsonT(); 58235 icExtractSmallStringSmallJsonSmallJsonT(); 58236 icExtractSmallStringSmallStringSmallJsonT(); 58237 icExtractSmallStringSSmallJsonT(); 58238 icExtractSmallStringCharSmallJsonT(); 58239 icExtractSSmallJsonSmallJsonT(); 58240 icExtractSSmallStringSmallJsonT(); 58241 icExtractCharSmallJsonSmallJsonT(); 58242 icExtractCharSmallStringSmallJsonT(); 58243 colorSmallJsonT(); 58244 colordSmallJsonT(); 58245 zipSmallJsonT(); 58246 zipArraySmallJsonT(); 58247 zipCArraySmallJsonT(); 58248 zipCharSmallJsonT(); 58249 zipCCharSmallJsonT(); 58250 zipArrayCharSmallJsonT(); 58251 zipCArrayCharSmallJsonT(); 58252 zipArrayCCharSmallJsonT(); 58253 zipCArrayCCharSmallJsonT(); 58254 zipJsonSmallJsonT(); 58255 zipJsonSmallArraySmallJsonT(); 58256 zipJsonArraySmallJsonT(); 58257 zipJsonCArraySmallJsonT(); 58258 zipSmallArrayJsonSmallJsonT(); 58259 zipArrayJsonSmallJsonT(); 58260 zipCArrayJsonSmallJsonT(); 58261 iterStartSmallJsonT(); 58262 iterStartKeySmallJsonT(); 58263 iterStartLastSmallJsonT(); 58264 iterStartFromSmallJsonT(); 58265 iterStartFromStepSmallJsonT(); 58266 iterNextSmallJsonT(); 58267 iterNextKeySmallJsonT(); 58268 iterElementSmallJsonT(); 58269 iterKeySmallJsonT(); 58270 iterIndexSmallJsonT(); 58271 iterStepSmallJsonT(); 58272 getUndefinedSmallJsonT(); 58273 getBoolSmallJsonT(); 58274 getBoolPSmallJsonT(); 58275 getDoubleSmallJsonT(); 58276 getDoublePSmallJsonT(); 58277 getIntSmallJsonT(); 58278 getIntPSmallJsonT(); 58279 getInt32SmallJsonT(); 58280 getInt32PSmallJsonT(); 58281 getUintSmallJsonT(); 58282 getUintPSmallJsonT(); 58283 getUint32SmallJsonT(); 58284 getUint32PSmallJsonT(); 58285 getSSmallJsonT(); 58286 getDictSmallJsonT(); 58287 getArraySmallJsonT(); 58288 getSmallBoolSmallJsonT(); 58289 getSmallBytesSmallJsonT(); 58290 getSmallDoubleSmallJsonT(); 58291 getSmallIntSmallJsonT(); 58292 getSmallJsonSmallJsonT(); 58293 getSmallStringSmallJsonT(); 58294 getVoidSmallJsonT(); 58295 getSmallContainerSmallJsonT(); 58296 getNDupSmallJsonT(); 58297 getNDupUndefinedSmallJsonT(); 58298 getNDupBoolSmallJsonT(); 58299 getNDupDoubleSmallJsonT(); 58300 getNDupIntSmallJsonT(); 58301 getNDupInt32SmallJsonT(); 58302 getNDupUintSmallJsonT(); 58303 getNDupUint32SmallJsonT(); 58304 getNDupSSmallJsonT(); 58305 getNDupDictSmallJsonT(); 58306 getNDupArraySmallJsonT(); 58307 getNDupSmallBoolSmallJsonT(); 58308 getNDupSmallBytesSmallJsonT(); 58309 getNDupSmallDoubleSmallJsonT(); 58310 getNDupSmallIntSmallJsonT(); 58311 getNDupSmallJsonSmallJsonT(); 58312 getNDupSmallStringSmallJsonT(); 58313 getNDupVoidSmallJsonT(); 58314 getNDupSmallContainerSmallJsonT(); 58315 getAtSmallJsonT(); 58316 getAtUndefinedSmallJsonT(); 58317 getAtBoolSmallJsonT(); 58318 getAtBoolPSmallJsonT(); 58319 getAtDoubleSmallJsonT(); 58320 getAtDoublePSmallJsonT(); 58321 getAtIntSmallJsonT(); 58322 getAtIntPSmallJsonT(); 58323 getAtInt32SmallJsonT(); 58324 getAtInt32PSmallJsonT(); 58325 getAtUintSmallJsonT(); 58326 getAtUintPSmallJsonT(); 58327 getAtUint32SmallJsonT(); 58328 getAtUint32PSmallJsonT(); 58329 getAtSSmallJsonT(); 58330 getAtDictSmallJsonT(); 58331 getAtArraySmallJsonT(); 58332 getAtSmallBoolSmallJsonT(); 58333 getAtSmallBytesSmallJsonT(); 58334 getAtSmallDoubleSmallJsonT(); 58335 getAtSmallIntSmallJsonT(); 58336 getAtSmallJsonSmallJsonT(); 58337 getAtSmallStringSmallJsonT(); 58338 getAtVoidSmallJsonT(); 58339 getAtSmallContainerSmallJsonT(); 58340 getAtNDupSmallJsonT(); 58341 getAtNDupUndefinedSmallJsonT(); 58342 getAtNDupBoolSmallJsonT(); 58343 getAtNDupDoubleSmallJsonT(); 58344 getAtNDupIntSmallJsonT(); 58345 getAtNDupInt32SmallJsonT(); 58346 getAtNDupUintSmallJsonT(); 58347 getAtNDupUint32SmallJsonT(); 58348 getAtNDupSSmallJsonT(); 58349 getAtNDupDictSmallJsonT(); 58350 getAtNDupArraySmallJsonT(); 58351 getAtNDupSmallBoolSmallJsonT(); 58352 getAtNDupSmallBytesSmallJsonT(); 58353 getAtNDupSmallDoubleSmallJsonT(); 58354 getAtNDupSmallIntSmallJsonT(); 58355 getAtNDupSmallJsonSmallJsonT(); 58356 getAtNDupSmallStringSmallJsonT(); 58357 getAtNDupVoidSmallJsonT(); 58358 getAtNDupSmallContainerSmallJsonT(); 58359 getNumSmallJsonT(); 58360 getNumAtSmallJsonT(); 58361 delElemSmallJsonT(); 58362 delSmallJsonT(); 58363 delElemIndexSmallJsonT(); 58364 removeElemSmallJsonT(); 58365 removeSmallJsonT(); 58366 removeElemIndexSmallJsonT(); 58367 stringifySmallStringSmallJsonT(); 58368 toYMLSmallStringSmallJsonT(); 58369 parseSmallJsonSmallJsonT(); 58370 parseSmallStringSmallJsonT(); 58371 parseYMLSmallJsonSmallJsonT(); 58372 parseYMLSmallStringSmallJsonT(); 58373 logSmallJsonT(); 58374 readFileSmallJsonT(); 58375 readFileSmallStringSmallJsonT(); 58376 readFileJsonSmallJsonT(); 58377 readStreamSmallJsonT(); 58378 writeFileSmallJsonT(); 58379 writeFileSmallStringSmallJsonT(); 58380 writeFileJsonSmallJsonT(); 58381 writeStreamSmallJsonT(); 58382 appendFileSmallJsonT(); 58383 appendFileSmallStringSmallJsonT(); 58384 appendFileJsonSmallJsonT(); 58385 readTextSmallJsonT(); 58386 readTextSmallStringSmallJsonT(); 58387 readTextJsonSmallJsonT(); 58388 readTextStreamSmallJsonT(); 58389 writeTextSmallJsonT(); 58390 writeTextSmallStringSmallJsonT(); 58391 writeTextJsonSmallJsonT(); 58392 writeTextStreamSmallJsonT(); 58393 appendTextSmallJsonT(); 58394 appendTextSmallStringSmallJsonT(); 58395 appendTextJsonSmallJsonT(); 58396 typeStringSmallJsonT(); 58397 typeSmallStringSmallJsonT(); 58398 typeAtStringSmallJsonT(); 58399 typeAtSmallStringSmallJsonT(); 58400 typeStringKCharSmallJsonT(); 58401 typeSmallStringKCharSmallJsonT(); 58402 typeSmallJsonT(); 58403 typeKCharSmallJsonT(); 58404 typeAtSmallJsonT(); 58405 typeStringsSmallJsonT(); 58406 typesSmallJsonT(); 58407 isETypeAtSmallJsonT(); 58408 isEUndefinedAtSmallJsonT(); 58409 isEBoolAtSmallJsonT(); 58410 isEContainerAtSmallJsonT(); 58411 isEDictAtSmallJsonT(); 58412 isEDoubleAtSmallJsonT(); 58413 isEIntAtSmallJsonT(); 58414 isEStringAtSmallJsonT(); 58415 isEFaststringAtSmallJsonT(); 58416 isEArrayAtSmallJsonT(); 58417 isEBytesAtSmallJsonT(); 58418 isETypeSmallJsonT(); 58419 isEUndefinedSmallJsonT(); 58420 isEBoolSmallJsonT(); 58421 isEContainerSmallJsonT(); 58422 isEDictSmallJsonT(); 58423 isEDoubleSmallJsonT(); 58424 isEIntSmallJsonT(); 58425 isEStringSmallJsonT(); 58426 isEFaststringSmallJsonT(); 58427 isEArraySmallJsonT(); 58428 isEBytesSmallJsonT(); 58429 areAllETypeSmallJsonT(); 58430 areAllEUndefinedSmallJsonT(); 58431 areAllEBoolSmallJsonT(); 58432 areAllEContainerSmallJsonT(); 58433 areAllEDictSmallJsonT(); 58434 areAllEDoubleSmallJsonT(); 58435 areAllEIntSmallJsonT(); 58436 areAllEStringSmallJsonT(); 58437 areAllEFaststringSmallJsonT(); 58438 areAllEArraySmallJsonT(); 58439 areAllEBytesSmallJsonT(); 58440 duplicateSmallJsonGT(); 58441 freeSmallJsonGT(); 58442 setTopSmallJsonGT(); 58443 setTopBoolSmallJsonGT(); 58444 setTopDoubleSmallJsonGT(); 58445 setTopIntSmallJsonGT(); 58446 setTopStringSmallJsonGT(); 58447 setTopCharSmallJsonGT(); 58448 setTopDictSmallJsonGT(); 58449 setTopArraySmallJsonGT(); 58450 setTopArraycSmallJsonGT(); 58451 setTopCArraycSmallJsonGT(); 58452 setTopSmallBoolSmallJsonGT(); 58453 setTopSmallDoubleSmallJsonGT(); 58454 setTopSmallIntSmallJsonGT(); 58455 setTopSmallJsonSmallJsonGT(); 58456 setTopSmallStringSmallJsonGT(); 58457 setTopNFreeSmallJsonGT(); 58458 setTopNFreeBoolSmallJsonGT(); 58459 setTopNFreeDoubleSmallJsonGT(); 58460 setTopNFreeIntSmallJsonGT(); 58461 setTopNFreeStringSmallJsonGT(); 58462 setTopNFreeDictSmallJsonGT(); 58463 setTopNFreeArraySmallJsonGT(); 58464 setTopNFreeArraycSmallJsonGT(); 58465 setTopNFreeSmallBoolSmallJsonGT(); 58466 setTopNFreeSmallDoubleSmallJsonGT(); 58467 setTopNFreeSmallIntSmallJsonGT(); 58468 setTopNFreeSmallJsonSmallJsonGT(); 58469 setTopNFreeSmallStringSmallJsonGT(); 58470 fromArraySmallJsonGT(); 58471 fromCArraySmallJsonGT(); 58472 getTopSmallJsonGT(); 58473 getTopUndefinedSmallJsonGT(); 58474 getTopBoolSmallJsonGT(); 58475 getTopBoolPSmallJsonGT(); 58476 getTopDoubleSmallJsonGT(); 58477 getTopDoublePSmallJsonGT(); 58478 getTopIntSmallJsonGT(); 58479 getTopIntPSmallJsonGT(); 58480 getTopInt32SmallJsonGT(); 58481 getTopInt32PSmallJsonGT(); 58482 getTopUintSmallJsonGT(); 58483 getTopUintPSmallJsonGT(); 58484 getTopUint32SmallJsonGT(); 58485 getTopUint32PSmallJsonGT(); 58486 getTopSSmallJsonGT(); 58487 getTopDictSmallJsonGT(); 58488 getTopArraySmallJsonGT(); 58489 getTopSmallBoolSmallJsonGT(); 58490 getTopSmallDoubleSmallJsonGT(); 58491 getTopSmallIntSmallJsonGT(); 58492 getTopSmallStringSmallJsonGT(); 58493 pushSmallJsonGT(); 58494 pushUndefinedSmallJsonGT(); 58495 pushBoolSmallJsonGT(); 58496 pushDoubleSmallJsonGT(); 58497 pushIntSmallJsonGT(); 58498 pushSSmallJsonGT(); 58499 pushCharSmallJsonGT(); 58500 pushDictSmallJsonGT(); 58501 pushArraySmallJsonGT(); 58502 pushArraycSmallJsonGT(); 58503 pushCArraycSmallJsonGT(); 58504 pushVoidSmallJsonGT(); 58505 pushSmallBoolSmallJsonGT(); 58506 pushSmallBytesSmallJsonGT(); 58507 pushSmallDoubleSmallJsonGT(); 58508 pushSmallIntSmallJsonGT(); 58509 pushSmallJsonSmallJsonGT(); 58510 pushSmallStringSmallJsonGT(); 58511 pushSmallContainerSmallJsonGT(); 58512 pushNFreeSmallJsonGT(); 58513 pushNFreeUndefinedSmallJsonGT(); 58514 pushNFreeSSmallJsonGT(); 58515 pushNFreeDictSmallJsonGT(); 58516 pushNFreeArraySmallJsonGT(); 58517 pushNFreeArraycSmallJsonGT(); 58518 pushNFreeSmallBoolSmallJsonGT(); 58519 pushNFreeSmallBytesSmallJsonGT(); 58520 pushNFreeSmallDoubleSmallJsonGT(); 58521 pushNFreeSmallIntSmallJsonGT(); 58522 pushNFreeSmallJsonSmallJsonGT(); 58523 pushNFreeSmallStringSmallJsonGT(); 58524 pushNFreeSmallContainerSmallJsonGT(); 58525 popSmallJsonGT(); 58526 popUndefinedSmallJsonGT(); 58527 popBoolSmallJsonGT(); 58528 popDoubleSmallJsonGT(); 58529 popIntSmallJsonGT(); 58530 popInt32SmallJsonGT(); 58531 popUintSmallJsonGT(); 58532 popUint32SmallJsonGT(); 58533 popSSmallJsonGT(); 58534 popDictSmallJsonGT(); 58535 popArraySmallJsonGT(); 58536 popSmallBoolSmallJsonGT(); 58537 popSmallBytesSmallJsonGT(); 58538 popSmallDoubleSmallJsonGT(); 58539 popSmallIntSmallJsonGT(); 58540 popSmallJsonSmallJsonGT(); 58541 popSmallStringSmallJsonGT(); 58542 popVoidSmallJsonGT(); 58543 popSmallContainerSmallJsonGT(); 58544 setSmallJsonGT(); 58545 setUndefinedSmallJsonGT(); 58546 setBoolSmallJsonGT(); 58547 setDoubleSmallJsonGT(); 58548 setIntSmallJsonGT(); 58549 setSSmallJsonGT(); 58550 setCharSmallJsonGT(); 58551 setDictSmallJsonGT(); 58552 setArraySmallJsonGT(); 58553 setArraycSmallJsonGT(); 58554 setCArraycSmallJsonGT(); 58555 setVoidSmallJsonGT(); 58556 setSmallBoolSmallJsonGT(); 58557 setSmallBytesSmallJsonGT(); 58558 setSmallDoubleSmallJsonGT(); 58559 setSmallIntSmallJsonGT(); 58560 setSmallJsonSmallJsonGT(); 58561 setSmallStringSmallJsonGT(); 58562 setSmallContainerSmallJsonGT(); 58563 setNFreeSmallJsonGT(); 58564 setNFreeUndefinedSmallJsonGT(); 58565 setNFreeSSmallJsonGT(); 58566 setNFreeDictSmallJsonGT(); 58567 setNFreeArraySmallJsonGT(); 58568 setNFreeArraycSmallJsonGT(); 58569 setNFreeSmallBoolSmallJsonGT(); 58570 setNFreeSmallBytesSmallJsonGT(); 58571 setNFreeSmallDoubleSmallJsonGT(); 58572 setNFreeSmallIntSmallJsonGT(); 58573 setNFreeSmallJsonSmallJsonGT(); 58574 setNFreeSmallStringSmallJsonGT(); 58575 setNFreeSmallContainerSmallJsonGT(); 58576 setPDictSmallJsonGT(); 58577 setPArraySmallJsonGT(); 58578 setPSmallJsonSmallJsonGT(); 58579 setPSmallStringSmallJsonGT(); 58580 setNFreePDictSmallJsonGT(); 58581 setNFreePArraySmallJsonGT(); 58582 setNFreePSmallJsonSmallJsonGT(); 58583 setNFreePSmallStringSmallJsonGT(); 58584 setAtSmallJsonGT(); 58585 setAtUndefinedSmallJsonGT(); 58586 setAtBoolSmallJsonGT(); 58587 setAtDoubleSmallJsonGT(); 58588 setAtIntSmallJsonGT(); 58589 setAtSSmallJsonGT(); 58590 setAtCharSmallJsonGT(); 58591 setAtDictSmallJsonGT(); 58592 setAtArraySmallJsonGT(); 58593 setAtArraycSmallJsonGT(); 58594 setAtCArraycSmallJsonGT(); 58595 setAtVoidSmallJsonGT(); 58596 setAtSmallBoolSmallJsonGT(); 58597 setAtSmallBytesSmallJsonGT(); 58598 setAtSmallDoubleSmallJsonGT(); 58599 setAtSmallIntSmallJsonGT(); 58600 setAtSmallJsonSmallJsonGT(); 58601 setAtSmallStringSmallJsonGT(); 58602 setAtSmallContainerSmallJsonGT(); 58603 setAtNFreeSmallJsonGT(); 58604 setAtNFreeUndefinedSmallJsonGT(); 58605 setAtNFreeSSmallJsonGT(); 58606 setAtNFreeDictSmallJsonGT(); 58607 setAtNFreeArraySmallJsonGT(); 58608 setAtNFreeArraycSmallJsonGT(); 58609 setAtNFreeSmallBoolSmallJsonGT(); 58610 setAtNFreeSmallBytesSmallJsonGT(); 58611 setAtNFreeSmallDoubleSmallJsonGT(); 58612 setAtNFreeSmallIntSmallJsonGT(); 58613 setAtNFreeSmallJsonSmallJsonGT(); 58614 setAtNFreeSmallStringSmallJsonGT(); 58615 setAtNFreeSmallContainerSmallJsonGT(); 58616 setPAtDictSmallJsonGT(); 58617 setPAtArraySmallJsonGT(); 58618 setPAtSmallJsonSmallJsonGT(); 58619 setPAtSmallStringSmallJsonGT(); 58620 setPAtNFreeDictSmallJsonGT(); 58621 setPAtNFreeArraySmallJsonGT(); 58622 setPAtNFreeSmallJsonSmallJsonGT(); 58623 setPAtNFreeSmallStringSmallJsonGT(); 58624 getSmallJsonGT(); 58625 getUndefinedSmallJsonGT(); 58626 getBoolSmallJsonGT(); 58627 getBoolPSmallJsonGT(); 58628 getDoubleSmallJsonGT(); 58629 getDoublePSmallJsonGT(); 58630 getIntSmallJsonGT(); 58631 getIntPSmallJsonGT(); 58632 getInt32SmallJsonGT(); 58633 getInt32PSmallJsonGT(); 58634 getUintSmallJsonGT(); 58635 getUintPSmallJsonGT(); 58636 getUint32SmallJsonGT(); 58637 getUint32PSmallJsonGT(); 58638 getSSmallJsonGT(); 58639 getDictSmallJsonGT(); 58640 getArraySmallJsonGT(); 58641 getSmallBoolSmallJsonGT(); 58642 getSmallBytesSmallJsonGT(); 58643 getSmallDoubleSmallJsonGT(); 58644 getSmallIntSmallJsonGT(); 58645 getSmallJsonSmallJsonGT(); 58646 getSmallStringSmallJsonGT(); 58647 getVoidSmallJsonGT(); 58648 getSmallContainerSmallJsonGT(); 58649 getNDupSmallJsonGT(); 58650 getNDupUndefinedSmallJsonGT(); 58651 getNDupBoolSmallJsonGT(); 58652 getNDupDoubleSmallJsonGT(); 58653 getNDupIntSmallJsonGT(); 58654 getNDupInt32SmallJsonGT(); 58655 getNDupUintSmallJsonGT(); 58656 getNDupUint32SmallJsonGT(); 58657 getNDupSSmallJsonGT(); 58658 getNDupDictSmallJsonGT(); 58659 getNDupArraySmallJsonGT(); 58660 getNDupSmallBoolSmallJsonGT(); 58661 getNDupSmallBytesSmallJsonGT(); 58662 getNDupSmallDoubleSmallJsonGT(); 58663 getNDupSmallIntSmallJsonGT(); 58664 getNDupSmallJsonSmallJsonGT(); 58665 getNDupSmallStringSmallJsonGT(); 58666 getNDupVoidSmallJsonGT(); 58667 getNDupSmallContainerSmallJsonGT(); 58668 getAtSmallJsonGT(); 58669 getAtUndefinedSmallJsonGT(); 58670 getAtBoolSmallJsonGT(); 58671 getAtBoolPSmallJsonGT(); 58672 getAtDoubleSmallJsonGT(); 58673 getAtDoublePSmallJsonGT(); 58674 getAtIntSmallJsonGT(); 58675 getAtIntPSmallJsonGT(); 58676 getAtInt32SmallJsonGT(); 58677 getAtInt32PSmallJsonGT(); 58678 getAtUintSmallJsonGT(); 58679 getAtUintPSmallJsonGT(); 58680 getAtUint32SmallJsonGT(); 58681 getAtUint32PSmallJsonGT(); 58682 getAtSSmallJsonGT(); 58683 getAtDictSmallJsonGT(); 58684 getAtArraySmallJsonGT(); 58685 getAtSmallBoolSmallJsonGT(); 58686 getAtSmallBytesSmallJsonGT(); 58687 getAtSmallDoubleSmallJsonGT(); 58688 getAtSmallIntSmallJsonGT(); 58689 getAtSmallJsonSmallJsonGT(); 58690 getAtSmallStringSmallJsonGT(); 58691 getAtVoidSmallJsonGT(); 58692 getAtSmallContainerSmallJsonGT(); 58693 getAtNDupSmallJsonGT(); 58694 getAtNDupUndefinedSmallJsonGT(); 58695 getAtNDupBoolSmallJsonGT(); 58696 getAtNDupDoubleSmallJsonGT(); 58697 getAtNDupIntSmallJsonGT(); 58698 getAtNDupInt32SmallJsonGT(); 58699 getAtNDupUintSmallJsonGT(); 58700 getAtNDupUint32SmallJsonGT(); 58701 getAtNDupSSmallJsonGT(); 58702 getAtNDupDictSmallJsonGT(); 58703 getAtNDupArraySmallJsonGT(); 58704 getAtNDupSmallBoolSmallJsonGT(); 58705 getAtNDupSmallBytesSmallJsonGT(); 58706 getAtNDupSmallDoubleSmallJsonGT(); 58707 getAtNDupSmallIntSmallJsonGT(); 58708 getAtNDupSmallJsonSmallJsonGT(); 58709 getAtNDupSmallStringSmallJsonGT(); 58710 getAtNDupVoidSmallJsonGT(); 58711 getAtNDupSmallContainerSmallJsonGT(); 58712 getNumSmallJsonGT(); 58713 getNumAtSmallJsonGT(); 58714 delKeySmallJsonGT(); 58715 delSmallJsonGT(); 58716 delElemSmallJsonGT(); 58717 delElemIndexSmallJsonGT(); 58718 prependSmallJsonGT(); 58719 prependUndefinedSmallJsonGT(); 58720 prependBoolSmallJsonGT(); 58721 prependDoubleSmallJsonGT(); 58722 prependIntSmallJsonGT(); 58723 prependSSmallJsonGT(); 58724 prependCharSmallJsonGT(); 58725 prependDictSmallJsonGT(); 58726 prependArraySmallJsonGT(); 58727 prependArraycSmallJsonGT(); 58728 prependCArraycSmallJsonGT(); 58729 prependVoidSmallJsonGT(); 58730 prependSmallBoolSmallJsonGT(); 58731 prependSmallBytesSmallJsonGT(); 58732 prependSmallDoubleSmallJsonGT(); 58733 prependSmallIntSmallJsonGT(); 58734 prependSmallJsonSmallJsonGT(); 58735 prependSmallStringSmallJsonGT(); 58736 prependSmallContainerSmallJsonGT(); 58737 prependNFreeSmallJsonGT(); 58738 prependNFreeUndefinedSmallJsonGT(); 58739 prependNFreeSSmallJsonGT(); 58740 prependNFreeDictSmallJsonGT(); 58741 prependNFreeArraySmallJsonGT(); 58742 prependNFreeArraycSmallJsonGT(); 58743 prependNFreeSmallBoolSmallJsonGT(); 58744 prependNFreeSmallBytesSmallJsonGT(); 58745 prependNFreeSmallDoubleSmallJsonGT(); 58746 prependNFreeSmallIntSmallJsonGT(); 58747 prependNFreeSmallJsonSmallJsonGT(); 58748 prependNFreeSmallStringSmallJsonGT(); 58749 prependNFreeSmallContainerSmallJsonGT(); 58750 dequeueSmallJsonGT(); 58751 dequeueUndefinedSmallJsonGT(); 58752 dequeueBoolSmallJsonGT(); 58753 dequeueDoubleSmallJsonGT(); 58754 dequeueIntSmallJsonGT(); 58755 dequeueInt32SmallJsonGT(); 58756 dequeueUintSmallJsonGT(); 58757 dequeueUint32SmallJsonGT(); 58758 dequeueSSmallJsonGT(); 58759 dequeueDictSmallJsonGT(); 58760 dequeueArraySmallJsonGT(); 58761 dequeueSmallBoolSmallJsonGT(); 58762 dequeueSmallBytesSmallJsonGT(); 58763 dequeueSmallDoubleSmallJsonGT(); 58764 dequeueSmallIntSmallJsonGT(); 58765 dequeueSmallJsonSmallJsonGT(); 58766 dequeueSmallStringSmallJsonGT(); 58767 dequeueVoidSmallJsonGT(); 58768 dequeueSmallContainerSmallJsonGT(); 58769 reverseSmallJsonGT(); 58770 mergeDictSmallJsonGT(); 58771 mergeDictNSmashSmallJsonGT(); 58772 mergeSmallJsonGT(); 58773 mergeNSmashSmallJsonGT(); 58774 appendSmallJsonGT(); 58775 appendNSmashSmallJsonGT(); 58776 appendArraySmallJsonGT(); 58777 appendNSmashArraySmallJsonGT(); 58778 appendCArraySmallJsonGT(); 58779 shiftSmallJsonGT(); 58780 shiftNSmashSmallJsonGT(); 58781 shiftSmallJsonSmallJsonGT(); 58782 shiftNSmashSmallJsonSmallJsonGT(); 58783 addSmallJsonGT(); 58784 addJsonSmallJsonGT(); 58785 sliceSmallJsonGT(); 58786 cropSmallJsonGT(); 58787 cropSSmallJsonGT(); 58788 cropSmallStringSmallJsonGT(); 58789 cropElemAtSmallJsonGT(); 58790 cropElemAtUndefinedSmallJsonGT(); 58791 cropElemAtBoolSmallJsonGT(); 58792 cropElemAtDoubleSmallJsonGT(); 58793 cropElemAtIntSmallJsonGT(); 58794 cropElemAtInt32SmallJsonGT(); 58795 cropElemAtUintSmallJsonGT(); 58796 cropElemAtUint32SmallJsonGT(); 58797 cropElemAtSSmallJsonGT(); 58798 cropElemAtCharSmallJsonGT(); 58799 cropElemAtDictSmallJsonGT(); 58800 cropElemAtArraySmallJsonGT(); 58801 cropElemAtSmallBoolSmallJsonGT(); 58802 cropElemAtSmallBytesSmallJsonGT(); 58803 cropElemAtSmallDoubleSmallJsonGT(); 58804 cropElemAtSmallIntSmallJsonGT(); 58805 cropElemAtSmallJsonSmallJsonGT(); 58806 cropElemAtSmallStringSmallJsonGT(); 58807 cropElemAtVoidSmallJsonGT(); 58808 cropElemAtSmallContainerSmallJsonGT(); 58809 cropElemKeySmallJsonGT(); 58810 cropElemKeyUndefinedSmallJsonGT(); 58811 cropElemKeyBoolSmallJsonGT(); 58812 cropElemKeyDoubleSmallJsonGT(); 58813 cropElemKeyIntSmallJsonGT(); 58814 cropElemKeyInt32SmallJsonGT(); 58815 cropElemKeyUintSmallJsonGT(); 58816 cropElemKeyUint32SmallJsonGT(); 58817 cropElemKeySSmallJsonGT(); 58818 cropElemKeyDictSmallJsonGT(); 58819 cropElemKeyArraySmallJsonGT(); 58820 cropElemKeySmallBoolSmallJsonGT(); 58821 cropElemKeySmallBytesSmallJsonGT(); 58822 cropElemKeySmallDoubleSmallJsonGT(); 58823 cropElemKeySmallIntSmallJsonGT(); 58824 cropElemKeySmallJsonSmallJsonGT(); 58825 cropElemKeySmallStringSmallJsonGT(); 58826 cropElemKeyVoidSmallJsonGT(); 58827 cropElemKeySmallContainerSmallJsonGT(); 58828 copySmallJsonGT(); 58829 insertSmallJsonGT(); 58830 insertNSmashSmallJsonGT(); 58831 insertSmallJsonSmallJsonGT(); 58832 insertNSmashSmallJsonSmallJsonGT(); 58833 insertStringSmallJsonGT(); 58834 insertSSmallJsonGT(); 58835 insertNFreeSmallJsonGT(); 58836 insertSNFreeStringSmallJsonGT(); 58837 injectSmallJsonGT(); 58838 injectUndefinedSmallJsonGT(); 58839 injectBoolSmallJsonGT(); 58840 injectDoubleSmallJsonGT(); 58841 injectIntSmallJsonGT(); 58842 injectSSmallJsonGT(); 58843 injectCharSmallJsonGT(); 58844 injectDictSmallJsonGT(); 58845 injectArraySmallJsonGT(); 58846 injectArraycSmallJsonGT(); 58847 injectCArraycSmallJsonGT(); 58848 injectVoidSmallJsonGT(); 58849 injectSmallBoolSmallJsonGT(); 58850 injectSmallBytesSmallJsonGT(); 58851 injectSmallDoubleSmallJsonGT(); 58852 injectSmallIntSmallJsonGT(); 58853 injectSmallJsonSmallJsonGT(); 58854 injectSmallStringSmallJsonGT(); 58855 injectSmallContainerSmallJsonGT(); 58856 injectNFreeSmallJsonGT(); 58857 injectNFreeUndefinedSmallJsonGT(); 58858 injectNFreeSSmallJsonGT(); 58859 injectNFreeDictSmallJsonGT(); 58860 injectNFreeArraySmallJsonGT(); 58861 injectNFreeArraycSmallJsonGT(); 58862 injectNFreeSmallBoolSmallJsonGT(); 58863 injectNFreeSmallBytesSmallJsonGT(); 58864 injectNFreeSmallDoubleSmallJsonGT(); 58865 injectNFreeSmallIntSmallJsonGT(); 58866 injectNFreeSmallJsonSmallJsonGT(); 58867 injectNFreeSmallStringSmallJsonGT(); 58868 injectNFreeSmallContainerSmallJsonGT(); 58869 uniqSmallJsonGT(); 58870 sortSmallJsonGT(); 58871 sortFSmallJsonGT(); 58872 icSortSmallJsonGT(); 58873 icUniqSmallJsonGT(); 58874 hasSmallJsonGT(); 58875 hasUndefinedSmallJsonGT(); 58876 hasBoolSmallJsonGT(); 58877 hasDoubleSmallJsonGT(); 58878 hasIntSmallJsonGT(); 58879 hasSSmallJsonGT(); 58880 hasCharSmallJsonGT(); 58881 hasDictSmallJsonGT(); 58882 hasArraySmallJsonGT(); 58883 hasArraycSmallJsonGT(); 58884 hasCArraycSmallJsonGT(); 58885 hasSmallBoolSmallJsonGT(); 58886 hasSmallBytesSmallJsonGT(); 58887 hasSmallDoubleSmallJsonGT(); 58888 hasSmallIntSmallJsonGT(); 58889 hasSmallJsonSmallJsonGT(); 58890 hasSmallStringSmallJsonGT(); 58891 hasSmallContainerSmallJsonGT(); 58892 findSmallJsonGT(); 58893 findCharSmallJsonGT(); 58894 findSmallStringSmallJsonGT(); 58895 findJsonSmallJsonGT(); 58896 indexOfSmallJsonGT(); 58897 indexOfUndefinedSmallJsonGT(); 58898 indexOfBoolSmallJsonGT(); 58899 indexOfDoubleSmallJsonGT(); 58900 indexOfIntSmallJsonGT(); 58901 indexOfSSmallJsonGT(); 58902 indexOfCharSmallJsonGT(); 58903 indexOfDictSmallJsonGT(); 58904 indexOfArraySmallJsonGT(); 58905 indexOfArraycSmallJsonGT(); 58906 indexOfCArraycSmallJsonGT(); 58907 indexOfSmallBoolSmallJsonGT(); 58908 indexOfSmallBytesSmallJsonGT(); 58909 indexOfSmallDoubleSmallJsonGT(); 58910 indexOfSmallIntSmallJsonGT(); 58911 indexOfSmallJsonSmallJsonGT(); 58912 indexOfSmallStringSmallJsonGT(); 58913 indexOfSmallContainerSmallJsonGT(); 58914 binarySearchSmallJsonGT(); 58915 binarySearchUndefinedSmallJsonGT(); 58916 binarySearchBoolSmallJsonGT(); 58917 binarySearchDoubleSmallJsonGT(); 58918 binarySearchIntSmallJsonGT(); 58919 binarySearchSSmallJsonGT(); 58920 binarySearchCharSmallJsonGT(); 58921 binarySearchDictSmallJsonGT(); 58922 binarySearchArraySmallJsonGT(); 58923 binarySearchArraycSmallJsonGT(); 58924 binarySearchCArraycSmallJsonGT(); 58925 binarySearchSmallBoolSmallJsonGT(); 58926 binarySearchSmallBytesSmallJsonGT(); 58927 binarySearchSmallDoubleSmallJsonGT(); 58928 binarySearchSmallIntSmallJsonGT(); 58929 binarySearchSmallJsonSmallJsonGT(); 58930 binarySearchSmallStringSmallJsonGT(); 58931 binarySearchSmallContainerSmallJsonGT(); 58932 icHasSmallJsonGT(); 58933 icHasSSmallJsonGT(); 58934 icHasCharSmallJsonGT(); 58935 icHasDictSmallJsonGT(); 58936 icHasArraySmallJsonGT(); 58937 icHasArraycSmallJsonGT(); 58938 icHasCArraycSmallJsonGT(); 58939 icHasSmallStringSmallJsonGT(); 58940 icFindSmallJsonGT(); 58941 icFindCharSmallJsonGT(); 58942 icFindSmallStringSmallJsonGT(); 58943 icFindJsonSmallJsonGT(); 58944 icIndexOfSmallJsonGT(); 58945 icIndexOfSSmallJsonGT(); 58946 icIndexOfCharSmallJsonGT(); 58947 icIndexOfDictSmallJsonGT(); 58948 icIndexOfArraySmallJsonGT(); 58949 icIndexOfArraycSmallJsonGT(); 58950 icIndexOfCArraycSmallJsonGT(); 58951 icIndexOfSmallStringSmallJsonGT(); 58952 icBinarySearchSmallJsonGT(); 58953 icBinarySearchSSmallJsonGT(); 58954 icBinarySearchCharSmallJsonGT(); 58955 icBinarySearchDictSmallJsonGT(); 58956 icBinarySearchArraySmallJsonGT(); 58957 icBinarySearchArraycSmallJsonGT(); 58958 icBinarySearchCArraycSmallJsonGT(); 58959 icBinarySearchSmallStringSmallJsonGT(); 58960 keyBySmallJsonGT(); 58961 keyByUndefinedSmallJsonGT(); 58962 keyByBoolSmallJsonGT(); 58963 keyByDoubleSmallJsonGT(); 58964 keyByIntSmallJsonGT(); 58965 keyBySSmallJsonGT(); 58966 keyByCharSmallJsonGT(); 58967 keyByDictSmallJsonGT(); 58968 keyByArraySmallJsonGT(); 58969 keyByArraycSmallJsonGT(); 58970 keyByCArraycSmallJsonGT(); 58971 keyBySmallBoolSmallJsonGT(); 58972 keyBySmallBytesSmallJsonGT(); 58973 keyBySmallDoubleSmallJsonGT(); 58974 keyBySmallIntSmallJsonGT(); 58975 keyBySmallJsonSmallJsonGT(); 58976 keyBySmallStringSmallJsonGT(); 58977 keyBySmallContainerSmallJsonGT(); 58978 icKeyBySmallJsonGT(); 58979 icKeyBySSmallJsonGT(); 58980 icKeyByCharSmallJsonGT(); 58981 icKeyByDictSmallJsonGT(); 58982 icKeyByArraySmallJsonGT(); 58983 icKeyByArraycSmallJsonGT(); 58984 icKeyByCArraycSmallJsonGT(); 58985 icKeyBySmallStringSmallJsonGT(); 58986 replaceSmallJsonGT(); 58987 replaceCharSSmallJsonGT(); 58988 replaceSCharSmallJsonGT(); 58989 replaceCharCharSmallJsonGT(); 58990 replaceSmallStringSmallStringSmallJsonGT(); 58991 replaceSmallStringSSmallJsonGT(); 58992 replaceSmallStringCharSmallJsonGT(); 58993 replaceSSmallStringSmallJsonGT(); 58994 replaceCharSmallStringSmallJsonGT(); 58995 replaceJsonJsonSmallJsonGT(); 58996 replaceJsonSmallStringSmallJsonGT(); 58997 replaceJsonSSmallJsonGT(); 58998 replaceJsonCharSmallJsonGT(); 58999 replaceSmallStringJsonSmallJsonGT(); 59000 replaceSJsonSmallJsonGT(); 59001 replaceCharJsonSmallJsonGT(); 59002 icReplaceSmallJsonGT(); 59003 icReplaceCharSSmallJsonGT(); 59004 icReplaceSCharSmallJsonGT(); 59005 icReplaceCharCharSmallJsonGT(); 59006 icReplaceSmallStringSmallStringSmallJsonGT(); 59007 icReplaceSmallStringSSmallJsonGT(); 59008 icReplaceSmallStringCharSmallJsonGT(); 59009 icReplaceSSmallStringSmallJsonGT(); 59010 icReplaceCharSmallStringSmallJsonGT(); 59011 icReplaceJsonJsonSmallJsonGT(); 59012 icReplaceJsonSmallStringSmallJsonGT(); 59013 icReplaceJsonSSmallJsonGT(); 59014 icReplaceJsonCharSmallJsonGT(); 59015 icReplaceSmallStringJsonSmallJsonGT(); 59016 icReplaceSJsonSmallJsonGT(); 59017 icReplaceCharJsonSmallJsonGT(); 59018 equalSmallJsonSmallArrayGT(); 59019 equalSmallJsonArrayGT(); 59020 equalSmallJsonCArrayGT(); 59021 equalSmallJsonBaseGT(); 59022 equalSmallJsonChaGT(); 59023 equalSmallJsonCharGT(); 59024 equalSmallJsonBoolGT(); 59025 equalSmallJsonDoubleGT(); 59026 equalSmallJsonInt64GT(); 59027 equalSmallJsonInt32GT(); 59028 equalSmallJsonUint32GT(); 59029 equalSmallJsonUint64GT(); 59030 equalSmallJsonSmallBoolGT(); 59031 equalSmallJsonSmallBytesGT(); 59032 equalSmallJsonSmallDoubleGT(); 59033 equalSmallJsonSmallIntGT(); 59034 equalSmallJsonSmallJsonGT(); 59035 equalSmallJsonSmallStringGT(); 59036 equalSmallJsonSmallDictGT(); 59037 icEqualSmallJsonSmallArrayGT(); 59038 icEqualSmallJsonArrayGT(); 59039 icEqualSmallJsonCArrayGT(); 59040 icEqualSmallJsonBaseGT(); 59041 icEqualSmallJsonSmallDictGT(); 59042 icEqualSmallJsonSmallJsonGT(); 59043 icEqualSmallJsonSmallStringGT(); 59044 icEqualCharSmallJsonGT(); 59045 icEqualSSmallJsonGT(); 59046 equalISSmallJsonGT(); 59047 equalICharSmallJsonGT(); 59048 equalIJsonSmallJsonGT(); 59049 equalISmallStringSmallJsonGT(); 59050 startsWithSSmallJsonGT(); 59051 startsWithCharSmallJsonGT(); 59052 startsWithSmallStringSmallJsonGT(); 59053 startsWithJsonSmallJsonGT(); 59054 endsWithSSmallJsonGT(); 59055 endsWithCharSmallJsonGT(); 59056 endsWithSmallStringSmallJsonGT(); 59057 endsWithJsonSmallJsonGT(); 59058 countSSmallJsonGT(); 59059 countCharSmallJsonGT(); 59060 countSmallStringSmallJsonGT(); 59061 countJsonSmallJsonGT(); 59062 icStartsWithSSmallJsonGT(); 59063 icStartsWithCharSmallJsonGT(); 59064 icStartsWithSmallStringSmallJsonGT(); 59065 icStartsWithJsonSmallJsonGT(); 59066 icEndsWithSSmallJsonGT(); 59067 icEndsWithCharSmallJsonGT(); 59068 icEndsWithSmallStringSmallJsonGT(); 59069 icEndsWithJsonSmallJsonGT(); 59070 icCountSSmallJsonGT(); 59071 icCountCharSmallJsonGT(); 59072 icCountSmallStringSmallJsonGT(); 59073 icCountJsonSmallJsonGT(); 59074 isNumberSmallJsonGT(); 59075 isIntSmallJsonGT(); 59076 parseIntSmallJsonGT(); 59077 parseDoubleSmallJsonGT(); 59078 intToSmallJsonGT(); 59079 doubleToSmallJsonGT(); 59080 lenSmallJsonGT(); 59081 upperSmallJsonGT(); 59082 lowerSmallJsonGT(); 59083 trimSmallJsonGT(); 59084 lTrimSmallJsonGT(); 59085 rTrimSmallJsonGT(); 59086 compactSmallJsonGT(); 59087 emptySmallJsonGT(); 59088 isEmptySmallJsonGT(); 59089 isBlankSmallJsonGT(); 59090 joinSmallJsonGT(); 59091 joinCharSmallJsonGT(); 59092 joinSmallJsonSmallJsonGT(); 59093 joinSmallStringSmallJsonGT(); 59094 joinSSmallJsonGT(); 59095 joinCharSSmallJsonGT(); 59096 joinSmallJsonSSmallJsonGT(); 59097 joinSmallStringSSmallJsonGT(); 59098 splitSmallJsonGT(); 59099 splitCharSmallJsonGT(); 59100 splitSmallJsonSmallJsonGT(); 59101 splitSmallStringSmallJsonGT(); 59102 splitSSmallJsonGT(); 59103 splitCharSSmallJsonGT(); 59104 splitSmallJsonSSmallJsonGT(); 59105 splitSmallStringSSmallJsonGT(); 59106 extractSmallJsonGT(); 59107 extractCharSSmallJsonGT(); 59108 extractSCharSmallJsonGT(); 59109 extractCharCharSmallJsonGT(); 59110 extractSmallJsonSmallJsonSmallJsonGT(); 59111 extractSmallJsonSmallStringSmallJsonGT(); 59112 extractSmallJsonSSmallJsonGT(); 59113 extractSmallJsonCharSmallJsonGT(); 59114 extractSmallStringSmallJsonSmallJsonGT(); 59115 extractSmallStringSmallStringSmallJsonGT(); 59116 extractSmallStringSSmallJsonGT(); 59117 extractSmallStringCharSmallJsonGT(); 59118 extractSSmallJsonSmallJsonGT(); 59119 extractSSmallStringSmallJsonGT(); 59120 extractCharSmallJsonSmallJsonGT(); 59121 extractCharSmallStringSmallJsonGT(); 59122 icSplitSmallJsonGT(); 59123 icSplitCharSmallJsonGT(); 59124 icSplitSmallJsonSmallJsonGT(); 59125 icSplitSmallStringSmallJsonGT(); 59126 icSplitSSmallJsonGT(); 59127 icSplitCharSSmallJsonGT(); 59128 icSplitSmallJsonSSmallJsonGT(); 59129 icSplitSmallStringSSmallJsonGT(); 59130 icExtractSmallJsonGT(); 59131 icExtractCharSSmallJsonGT(); 59132 icExtractSCharSmallJsonGT(); 59133 icExtractCharCharSmallJsonGT(); 59134 icExtractSmallJsonSmallJsonSmallJsonGT(); 59135 icExtractSmallJsonSmallStringSmallJsonGT(); 59136 icExtractSmallJsonSSmallJsonGT(); 59137 icExtractSmallJsonCharSmallJsonGT(); 59138 icExtractSmallStringSmallJsonSmallJsonGT(); 59139 icExtractSmallStringSmallStringSmallJsonGT(); 59140 icExtractSmallStringSSmallJsonGT(); 59141 icExtractSmallStringCharSmallJsonGT(); 59142 icExtractSSmallJsonSmallJsonGT(); 59143 icExtractSSmallStringSmallJsonGT(); 59144 icExtractCharSmallJsonSmallJsonGT(); 59145 icExtractCharSmallStringSmallJsonGT(); 59146 zipSmallJsonGT(); 59147 zipArraySmallJsonGT(); 59148 zipCArraySmallJsonGT(); 59149 zipCharSmallJsonGT(); 59150 zipCCharSmallJsonGT(); 59151 zipArrayCharSmallJsonGT(); 59152 zipArrayCCharSmallJsonGT(); 59153 zipCArrayCharSmallJsonGT(); 59154 zipCArrayCCharSmallJsonGT(); 59155 zipJsonSmallJsonGT(); 59156 zipJsonSmallArraySmallJsonGT(); 59157 zipJsonArraySmallJsonGT(); 59158 zipJsonCArraySmallJsonGT(); 59159 zipSmallArrayJsonSmallJsonGT(); 59160 zipArrayJsonSmallJsonGT(); 59161 zipCArrayJsonSmallJsonGT(); 59162 stringifySmallStringSmallJsonGT(); 59163 toYMLSmallStringSmallJsonGT(); 59164 parseSmallJsonGT(); 59165 parseSmallJsonSmallJsonGT(); 59166 parseSmallStringSmallJsonGT(); 59167 parseYMLSmallJsonGT(); 59168 parseYMLSmallJsonSmallJsonGT(); 59169 parseYMLSmallStringSmallJsonGT(); 59170 logSmallJsonGT(); 59171 readFileSmallJsonGT(); 59172 readFileSmallStringSmallJsonGT(); 59173 readFileJsonSmallJsonGT(); 59174 readStreamSmallJsonGT(); 59175 writeFileSmallJsonGT(); 59176 writeFileSmallStringSmallJsonGT(); 59177 writeFileJsonSmallJsonGT(); 59178 writeStreamSmallJsonGT(); 59179 appendFileSmallJsonGT(); 59180 appendFileSmallStringSmallJsonGT(); 59181 appendFileJsonSmallJsonGT(); 59182 readTextSmallJsonGT(); 59183 readTextSmallStringSmallJsonGT(); 59184 readTextJsonSmallJsonGT(); 59185 readTextStreamSmallJsonGT(); 59186 writeTextSmallJsonGT(); 59187 writeTextSmallStringSmallJsonGT(); 59188 writeTextJsonSmallJsonGT(); 59189 writeTextStreamSmallJsonGT(); 59190 appendTextSmallStringSmallJsonGT(); 59191 appendTextJsonSmallJsonGT(); 59192 cSmallJsonT(); 59193 59194 finalizeSmallDict(); 59195 finalizeSmallArray(); 59196 finalizeSmallJson(); 59197 finalizeUndefined(); 59198 finalizeSmallBytes(); 59199 finalizeSmallBool(); 59200 finalizeSmallContainer(); 59201 finalizeSmallDouble(); 59202 finalizeSmallInt(); 59203 finalizeSmallString(); 59204 }