github.com/grbit/go-json@v0.11.0/test/cover/cover_uint_test.go (about) 1 package json_test 2 3 import ( 4 "bytes" 5 "fmt" 6 "testing" 7 8 "github.com/grbit/go-json" 9 ) 10 11 func TestCoverUint(t *testing.T) { 12 type structUint struct { 13 A uint `json:"a"` 14 } 15 type structUintOmitEmpty struct { 16 A uint `json:"a,omitempty"` 17 } 18 type structUintString struct { 19 A uint `json:"a,string"` 20 } 21 type structUintStringOmitEmpty struct { 22 A uint `json:"a,string,omitempty"` 23 } 24 25 type structUintPtr struct { 26 A *uint `json:"a"` 27 } 28 type structUintPtrOmitEmpty struct { 29 A *uint `json:"a,omitempty"` 30 } 31 type structUintPtrString struct { 32 A *uint `json:"a,string"` 33 } 34 type structUintPtrStringOmitEmpty struct { 35 A *uint `json:"a,string,omitempty"` 36 } 37 38 tests := []struct { 39 name string 40 data interface{} 41 }{ 42 { 43 name: "Uint", 44 data: uint(10), 45 }, 46 { 47 name: "UintPtr", 48 data: uptr(10), 49 }, 50 { 51 name: "UintPtr3", 52 data: uintptr3(10), 53 }, 54 { 55 name: "UintPtrNil", 56 data: (*uint)(nil), 57 }, 58 { 59 name: "UintPtr3Nil", 60 data: (***uint)(nil), 61 }, 62 63 // HeadUintZero 64 { 65 name: "HeadUintZero", 66 data: struct { 67 A uint `json:"a"` 68 }{}, 69 }, 70 { 71 name: "HeadUintZeroOmitEmpty", 72 data: struct { 73 A uint `json:"a,omitempty"` 74 }{}, 75 }, 76 { 77 name: "HeadUintZeroString", 78 data: struct { 79 A uint `json:"a,string"` 80 }{}, 81 }, 82 { 83 name: "HeadUintZeroStringOmitEmpty", 84 data: struct { 85 A uint `json:"a,string,omitempty"` 86 }{}, 87 }, 88 89 // HeadUint 90 { 91 name: "HeadUint", 92 data: struct { 93 A uint `json:"a"` 94 }{A: 1}, 95 }, 96 { 97 name: "HeadUintOmitEmpty", 98 data: struct { 99 A uint `json:"a,omitempty"` 100 }{A: 1}, 101 }, 102 { 103 name: "HeadUintString", 104 data: struct { 105 A uint `json:"a,string"` 106 }{A: 1}, 107 }, 108 { 109 name: "HeadUintStringOmitEmpty", 110 data: struct { 111 A uint `json:"a,string,omitempty"` 112 }{A: 1}, 113 }, 114 115 // HeadUintPtr 116 { 117 name: "HeadUintPtr", 118 data: struct { 119 A *uint `json:"a"` 120 }{A: uptr(1)}, 121 }, 122 { 123 name: "HeadUintPtrOmitEmpty", 124 data: struct { 125 A *uint `json:"a,omitempty"` 126 }{A: uptr(1)}, 127 }, 128 { 129 name: "HeadUintPtrString", 130 data: struct { 131 A *uint `json:"a,string"` 132 }{A: uptr(1)}, 133 }, 134 { 135 name: "HeadUintPtrStringOmitEmpty", 136 data: struct { 137 A *uint `json:"a,string,omitempty"` 138 }{A: uptr(1)}, 139 }, 140 141 // HeadUintPtrNil 142 { 143 name: "HeadUintPtrNil", 144 data: struct { 145 A *uint `json:"a"` 146 }{A: nil}, 147 }, 148 { 149 name: "HeadUintPtrNilOmitEmpty", 150 data: struct { 151 A *uint `json:"a,omitempty"` 152 }{A: nil}, 153 }, 154 { 155 name: "HeadUintPtrNilString", 156 data: struct { 157 A *uint `json:"a,string"` 158 }{A: nil}, 159 }, 160 { 161 name: "HeadUintPtrNilStringOmitEmpty", 162 data: struct { 163 A *uint `json:"a,string,omitempty"` 164 }{A: nil}, 165 }, 166 167 // PtrHeadUintZero 168 { 169 name: "PtrHeadUintZero", 170 data: &struct { 171 A uint `json:"a"` 172 }{}, 173 }, 174 { 175 name: "PtrHeadUintZeroOmitEmpty", 176 data: &struct { 177 A uint `json:"a,omitempty"` 178 }{}, 179 }, 180 { 181 name: "PtrHeadUintZeroString", 182 data: &struct { 183 A uint `json:"a,string"` 184 }{}, 185 }, 186 { 187 name: "PtrHeadUintZeroStringOmitEmpty", 188 data: &struct { 189 A uint `json:"a,string,omitempty"` 190 }{}, 191 }, 192 193 // PtrHeadUint 194 { 195 name: "PtrHeadUint", 196 data: &struct { 197 A uint `json:"a"` 198 }{A: 1}, 199 }, 200 { 201 name: "PtrHeadUintOmitEmpty", 202 data: &struct { 203 A uint `json:"a,omitempty"` 204 }{A: 1}, 205 }, 206 { 207 name: "PtrHeadUintString", 208 data: &struct { 209 A uint `json:"a,string"` 210 }{A: 1}, 211 }, 212 { 213 name: "PtrHeadUintStringOmitEmpty", 214 data: &struct { 215 A uint `json:"a,string,omitempty"` 216 }{A: 1}, 217 }, 218 219 // PtrHeadUintPtr 220 { 221 name: "PtrHeadUintPtr", 222 data: &struct { 223 A *uint `json:"a"` 224 }{A: uptr(1)}, 225 }, 226 { 227 name: "PtrHeadUintPtrOmitEmpty", 228 data: &struct { 229 A *uint `json:"a,omitempty"` 230 }{A: uptr(1)}, 231 }, 232 { 233 name: "PtrHeadUintPtrString", 234 data: &struct { 235 A *uint `json:"a,string"` 236 }{A: uptr(1)}, 237 }, 238 { 239 name: "PtrHeadUintPtrStringOmitEmpty", 240 data: &struct { 241 A *uint `json:"a,string,omitempty"` 242 }{A: uptr(1)}, 243 }, 244 245 // PtrHeadUintPtrNil 246 { 247 name: "PtrHeadUintPtrNil", 248 data: &struct { 249 A *uint `json:"a"` 250 }{A: nil}, 251 }, 252 { 253 name: "PtrHeadUintPtrNilOmitEmpty", 254 data: &struct { 255 A *uint `json:"a,omitempty"` 256 }{A: nil}, 257 }, 258 { 259 name: "PtrHeadUintPtrNilString", 260 data: &struct { 261 A *uint `json:"a,string"` 262 }{A: nil}, 263 }, 264 { 265 name: "PtrHeadUintPtrNilStringOmitEmpty", 266 data: &struct { 267 A *uint `json:"a,string,omitempty"` 268 }{A: nil}, 269 }, 270 271 // PtrHeadUintNil 272 { 273 name: "PtrHeadUintNil", 274 data: (*struct { 275 A *uint `json:"a"` 276 })(nil), 277 }, 278 { 279 name: "PtrHeadUintNilOmitEmpty", 280 data: (*struct { 281 A *uint `json:"a,omitempty"` 282 })(nil), 283 }, 284 { 285 name: "PtrHeadUintNilString", 286 data: (*struct { 287 A *uint `json:"a,string"` 288 })(nil), 289 }, 290 { 291 name: "PtrHeadUintNilStringOmitEmpty", 292 data: (*struct { 293 A *uint `json:"a,string,omitempty"` 294 })(nil), 295 }, 296 297 // HeadUintZeroMultiFields 298 { 299 name: "HeadUintZeroMultiFields", 300 data: struct { 301 A uint `json:"a"` 302 B uint `json:"b"` 303 C uint `json:"c"` 304 }{}, 305 }, 306 { 307 name: "HeadUintZeroMultiFieldsOmitEmpty", 308 data: struct { 309 A uint `json:"a,omitempty"` 310 B uint `json:"b,omitempty"` 311 C uint `json:"c,omitempty"` 312 }{}, 313 }, 314 { 315 name: "HeadUintZeroMultiFieldsString", 316 data: struct { 317 A uint `json:"a,string"` 318 B uint `json:"b,string"` 319 C uint `json:"c,string"` 320 }{}, 321 }, 322 { 323 name: "HeadUintZeroMultiFieldsStringOmitEmpty", 324 data: struct { 325 A uint `json:"a,string,omitempty"` 326 B uint `json:"b,string,omitempty"` 327 C uint `json:"c,string,omitempty"` 328 }{}, 329 }, 330 331 // HeadUintMultiFields 332 { 333 name: "HeadUintMultiFields", 334 data: struct { 335 A uint `json:"a"` 336 B uint `json:"b"` 337 C uint `json:"c"` 338 }{A: 1, B: 2, C: 3}, 339 }, 340 { 341 name: "HeadUintMultiFieldsOmitEmpty", 342 data: struct { 343 A uint `json:"a,omitempty"` 344 B uint `json:"b,omitempty"` 345 C uint `json:"c,omitempty"` 346 }{A: 1, B: 2, C: 3}, 347 }, 348 { 349 name: "HeadUintMultiFieldsString", 350 data: struct { 351 A uint `json:"a,string"` 352 B uint `json:"b,string"` 353 C uint `json:"c,string"` 354 }{A: 1, B: 2, C: 3}, 355 }, 356 { 357 name: "HeadUintMultiFieldsStringOmitEmpty", 358 data: struct { 359 A uint `json:"a,string,omitempty"` 360 B uint `json:"b,string,omitempty"` 361 C uint `json:"c,string,omitempty"` 362 }{A: 1, B: 2, C: 3}, 363 }, 364 365 // HeadUintPtrMultiFields 366 { 367 name: "HeadUintPtrMultiFields", 368 data: struct { 369 A *uint `json:"a"` 370 B *uint `json:"b"` 371 C *uint `json:"c"` 372 }{A: uptr(1), B: uptr(2), C: uptr(3)}, 373 }, 374 { 375 name: "HeadUintPtrMultiFieldsOmitEmpty", 376 data: struct { 377 A *uint `json:"a,omitempty"` 378 B *uint `json:"b,omitempty"` 379 C *uint `json:"c,omitempty"` 380 }{A: uptr(1), B: uptr(2), C: uptr(3)}, 381 }, 382 { 383 name: "HeadUintPtrMultiFieldsString", 384 data: struct { 385 A *uint `json:"a,string"` 386 B *uint `json:"b,string"` 387 C *uint `json:"c,string"` 388 }{A: uptr(1), B: uptr(2), C: uptr(3)}, 389 }, 390 { 391 name: "HeadUintPtrMultiFieldsStringOmitEmpty", 392 data: struct { 393 A *uint `json:"a,string,omitempty"` 394 B *uint `json:"b,string,omitempty"` 395 C *uint `json:"c,string,omitempty"` 396 }{A: uptr(1), B: uptr(2), C: uptr(3)}, 397 }, 398 399 // HeadUintPtrNilMultiFields 400 { 401 name: "HeadUintPtrNilMultiFields", 402 data: struct { 403 A *uint `json:"a"` 404 B *uint `json:"b"` 405 C *uint `json:"c"` 406 }{A: nil, B: nil, C: nil}, 407 }, 408 { 409 name: "HeadUintPtrNilMultiFieldsOmitEmpty", 410 data: struct { 411 A *uint `json:"a,omitempty"` 412 B *uint `json:"b,omitempty"` 413 C *uint `json:"c,omitempty"` 414 }{A: nil, B: nil, C: nil}, 415 }, 416 { 417 name: "HeadUintPtrNilMultiFieldsString", 418 data: struct { 419 A *uint `json:"a,string"` 420 B *uint `json:"b,string"` 421 C *uint `json:"c,string"` 422 }{A: nil, B: nil, C: nil}, 423 }, 424 { 425 name: "HeadUintPtrNilMultiFieldsStringOmitEmpty", 426 data: struct { 427 A *uint `json:"a,string,omitempty"` 428 B *uint `json:"b,string,omitempty"` 429 C *uint `json:"c,string,omitempty"` 430 }{A: nil, B: nil, C: nil}, 431 }, 432 433 // PtrHeadUintZeroMultiFields 434 { 435 name: "PtrHeadUintZeroMultiFields", 436 data: &struct { 437 A uint `json:"a"` 438 B uint `json:"b"` 439 }{}, 440 }, 441 { 442 name: "PtrHeadUintZeroMultiFieldsOmitEmpty", 443 data: &struct { 444 A uint `json:"a,omitempty"` 445 B uint `json:"b,omitempty"` 446 }{}, 447 }, 448 { 449 name: "PtrHeadUintZeroMultiFieldsString", 450 data: &struct { 451 A uint `json:"a,string"` 452 B uint `json:"b,string"` 453 }{}, 454 }, 455 { 456 name: "PtrHeadUintZeroMultiFieldsStringOmitEmpty", 457 data: &struct { 458 A uint `json:"a,string,omitempty"` 459 B uint `json:"b,string,omitempty"` 460 }{}, 461 }, 462 463 // PtrHeadUintMultiFields 464 { 465 name: "PtrHeadUintMultiFields", 466 data: &struct { 467 A uint `json:"a"` 468 B uint `json:"b"` 469 }{A: 1, B: 2}, 470 }, 471 { 472 name: "PtrHeadUintMultiFieldsOmitEmpty", 473 data: &struct { 474 A uint `json:"a,omitempty"` 475 B uint `json:"b,omitempty"` 476 }{A: 1, B: 2}, 477 }, 478 { 479 name: "PtrHeadUintMultiFieldsString", 480 data: &struct { 481 A uint `json:"a,string"` 482 B uint `json:"b,string"` 483 }{A: 1, B: 2}, 484 }, 485 { 486 name: "PtrHeadUintMultiFieldsStringOmitEmpty", 487 data: &struct { 488 A uint `json:"a,string,omitempty"` 489 B uint `json:"b,string,omitempty"` 490 }{A: 1, B: 2}, 491 }, 492 493 // PtrHeadUintPtrMultiFields 494 { 495 name: "PtrHeadUintPtrMultiFields", 496 data: &struct { 497 A *uint `json:"a"` 498 B *uint `json:"b"` 499 }{A: uptr(1), B: uptr(2)}, 500 }, 501 { 502 name: "PtrHeadUintPtrMultiFieldsOmitEmpty", 503 data: &struct { 504 A *uint `json:"a,omitempty"` 505 B *uint `json:"b,omitempty"` 506 }{A: uptr(1), B: uptr(2)}, 507 }, 508 { 509 name: "PtrHeadUintPtrMultiFieldsString", 510 data: &struct { 511 A *uint `json:"a,string"` 512 B *uint `json:"b,string"` 513 }{A: uptr(1), B: uptr(2)}, 514 }, 515 { 516 name: "PtrHeadUintPtrMultiFieldsStringOmitEmpty", 517 data: &struct { 518 A *uint `json:"a,string,omitempty"` 519 B *uint `json:"b,string,omitempty"` 520 }{A: uptr(1), B: uptr(2)}, 521 }, 522 523 // PtrHeadUintPtrNilMultiFields 524 { 525 name: "PtrHeadUintPtrNilMultiFields", 526 data: &struct { 527 A *uint `json:"a"` 528 B *uint `json:"b"` 529 }{A: nil, B: nil}, 530 }, 531 { 532 name: "PtrHeadUintPtrNilMultiFieldsOmitEmpty", 533 data: &struct { 534 A *uint `json:"a,omitempty"` 535 B *uint `json:"b,omitempty"` 536 }{A: nil, B: nil}, 537 }, 538 { 539 name: "PtrHeadUintPtrNilMultiFieldsString", 540 data: &struct { 541 A *uint `json:"a,string"` 542 B *uint `json:"b,string"` 543 }{A: nil, B: nil}, 544 }, 545 { 546 name: "PtrHeadUintPtrNilMultiFieldsStringOmitEmpty", 547 data: &struct { 548 A *uint `json:"a,string,omitempty"` 549 B *uint `json:"b,string,omitempty"` 550 }{A: nil, B: nil}, 551 }, 552 553 // PtrHeadUintNilMultiFields 554 { 555 name: "PtrHeadUintNilMultiFields", 556 data: (*struct { 557 A *uint `json:"a"` 558 B *uint `json:"b"` 559 })(nil), 560 }, 561 { 562 name: "PtrHeadUintNilMultiFieldsOmitEmpty", 563 data: (*struct { 564 A *uint `json:"a,omitempty"` 565 B *uint `json:"b,omitempty"` 566 })(nil), 567 }, 568 { 569 name: "PtrHeadUintNilMultiFieldsString", 570 data: (*struct { 571 A *uint `json:"a,string"` 572 B *uint `json:"b,string"` 573 })(nil), 574 }, 575 { 576 name: "PtrHeadUintNilMultiFieldsStringOmitEmpty", 577 data: (*struct { 578 A *uint `json:"a,string,omitempty"` 579 B *uint `json:"b,string,omitempty"` 580 })(nil), 581 }, 582 583 // HeadUintZeroNotRoot 584 { 585 name: "HeadUintZeroNotRoot", 586 data: struct { 587 A struct { 588 A uint `json:"a"` 589 } 590 }{}, 591 }, 592 { 593 name: "HeadUintZeroNotRootOmitEmpty", 594 data: struct { 595 A struct { 596 A uint `json:"a,omitempty"` 597 } 598 }{}, 599 }, 600 { 601 name: "HeadUintZeroNotRootString", 602 data: struct { 603 A struct { 604 A uint `json:"a,string"` 605 } 606 }{}, 607 }, 608 { 609 name: "HeadUintZeroNotRootStringOmitEmpty", 610 data: struct { 611 A struct { 612 A uint `json:"a,string,omitempty"` 613 } 614 }{}, 615 }, 616 617 // HeadUintNotRoot 618 { 619 name: "HeadUintNotRoot", 620 data: struct { 621 A struct { 622 A uint `json:"a"` 623 } 624 }{A: struct { 625 A uint `json:"a"` 626 }{A: 1}}, 627 }, 628 { 629 name: "HeadUintNotRootOmitEmpty", 630 data: struct { 631 A struct { 632 A uint `json:"a,omitempty"` 633 } 634 }{A: struct { 635 A uint `json:"a,omitempty"` 636 }{A: 1}}, 637 }, 638 { 639 name: "HeadUintNotRootString", 640 data: struct { 641 A struct { 642 A uint `json:"a,string"` 643 } 644 }{A: struct { 645 A uint `json:"a,string"` 646 }{A: 1}}, 647 }, 648 { 649 name: "HeadUintNotRootStringOmitEmpty", 650 data: struct { 651 A struct { 652 A uint `json:"a,string,omitempty"` 653 } 654 }{A: struct { 655 A uint `json:"a,string,omitempty"` 656 }{A: 1}}, 657 }, 658 659 // HeadUintPtrNotRoot 660 { 661 name: "HeadUintPtrNotRoot", 662 data: struct { 663 A struct { 664 A *uint `json:"a"` 665 } 666 }{A: struct { 667 A *uint `json:"a"` 668 }{uptr(1)}}, 669 }, 670 { 671 name: "HeadUintPtrNotRootOmitEmpty", 672 data: struct { 673 A struct { 674 A *uint `json:"a,omitempty"` 675 } 676 }{A: struct { 677 A *uint `json:"a,omitempty"` 678 }{uptr(1)}}, 679 }, 680 { 681 name: "HeadUintPtrNotRootString", 682 data: struct { 683 A struct { 684 A *uint `json:"a,string"` 685 } 686 }{A: struct { 687 A *uint `json:"a,string"` 688 }{uptr(1)}}, 689 }, 690 { 691 name: "HeadUintPtrNotRootStringOmitEmpty", 692 data: struct { 693 A struct { 694 A *uint `json:"a,string,omitempty"` 695 } 696 }{A: struct { 697 A *uint `json:"a,string,omitempty"` 698 }{uptr(1)}}, 699 }, 700 701 // HeadUintPtrNilNotRoot 702 { 703 name: "HeadUintPtrNilNotRoot", 704 data: struct { 705 A struct { 706 A *uint `json:"a"` 707 } 708 }{}, 709 }, 710 { 711 name: "HeadUintPtrNilNotRootOmitEmpty", 712 data: struct { 713 A struct { 714 A *uint `json:"a,omitempty"` 715 } 716 }{}, 717 }, 718 { 719 name: "HeadUintPtrNilNotRootString", 720 data: struct { 721 A struct { 722 A *uint `json:"a,string"` 723 } 724 }{}, 725 }, 726 { 727 name: "HeadUintPtrNilNotRootStringOmitEmpty", 728 data: struct { 729 A struct { 730 A *uint `json:"a,string,omitempty"` 731 } 732 }{}, 733 }, 734 735 // PtrHeadUintZeroNotRoot 736 { 737 name: "PtrHeadUintZeroNotRoot", 738 data: struct { 739 A *struct { 740 A uint `json:"a"` 741 } 742 }{A: new(struct { 743 A uint `json:"a"` 744 })}, 745 }, 746 { 747 name: "PtrHeadUintZeroNotRootOmitEmpty", 748 data: struct { 749 A *struct { 750 A uint `json:"a,omitempty"` 751 } 752 }{A: new(struct { 753 A uint `json:"a,omitempty"` 754 })}, 755 }, 756 { 757 name: "PtrHeadUintZeroNotRootString", 758 data: struct { 759 A *struct { 760 A uint `json:"a,string"` 761 } 762 }{A: new(struct { 763 A uint `json:"a,string"` 764 })}, 765 }, 766 { 767 name: "PtrHeadUintZeroNotRootStringOmitEmpty", 768 data: struct { 769 A *struct { 770 A uint `json:"a,string,omitempty"` 771 } 772 }{A: new(struct { 773 A uint `json:"a,string,omitempty"` 774 })}, 775 }, 776 777 // PtrHeadUintNotRoot 778 { 779 name: "PtrHeadUintNotRoot", 780 data: struct { 781 A *struct { 782 A uint `json:"a"` 783 } 784 }{A: &(struct { 785 A uint `json:"a"` 786 }{A: 1})}, 787 }, 788 { 789 name: "PtrHeadUintNotRootOmitEmpty", 790 data: struct { 791 A *struct { 792 A uint `json:"a,omitempty"` 793 } 794 }{A: &(struct { 795 A uint `json:"a,omitempty"` 796 }{A: 1})}, 797 }, 798 { 799 name: "PtrHeadUintNotRootString", 800 data: struct { 801 A *struct { 802 A uint `json:"a,string"` 803 } 804 }{A: &(struct { 805 A uint `json:"a,string"` 806 }{A: 1})}, 807 }, 808 { 809 name: "PtrHeadUintNotRootStringOmitEmpty", 810 data: struct { 811 A *struct { 812 A uint `json:"a,string,omitempty"` 813 } 814 }{A: &(struct { 815 A uint `json:"a,string,omitempty"` 816 }{A: 1})}, 817 }, 818 819 // PtrHeadUintPtrNotRoot 820 { 821 name: "PtrHeadUintPtrNotRoot", 822 data: struct { 823 A *struct { 824 A *uint `json:"a"` 825 } 826 }{A: &(struct { 827 A *uint `json:"a"` 828 }{A: uptr(1)})}, 829 }, 830 { 831 name: "PtrHeadUintPtrNotRootOmitEmpty", 832 data: struct { 833 A *struct { 834 A *uint `json:"a,omitempty"` 835 } 836 }{A: &(struct { 837 A *uint `json:"a,omitempty"` 838 }{A: uptr(1)})}, 839 }, 840 { 841 name: "PtrHeadUintPtrNotRootString", 842 data: struct { 843 A *struct { 844 A *uint `json:"a,string"` 845 } 846 }{A: &(struct { 847 A *uint `json:"a,string"` 848 }{A: uptr(1)})}, 849 }, 850 { 851 name: "PtrHeadUintPtrNotRootStringOmitEmpty", 852 data: struct { 853 A *struct { 854 A *uint `json:"a,string,omitempty"` 855 } 856 }{A: &(struct { 857 A *uint `json:"a,string,omitempty"` 858 }{A: uptr(1)})}, 859 }, 860 861 // PtrHeadUintPtrNilNotRoot 862 { 863 name: "PtrHeadUintPtrNilNotRoot", 864 data: struct { 865 A *struct { 866 A *uint `json:"a"` 867 } 868 }{A: &(struct { 869 A *uint `json:"a"` 870 }{A: nil})}, 871 }, 872 { 873 name: "PtrHeadUintPtrNilNotRootOmitEmpty", 874 data: struct { 875 A *struct { 876 A *uint `json:"a,omitempty"` 877 } 878 }{A: &(struct { 879 A *uint `json:"a,omitempty"` 880 }{A: nil})}, 881 }, 882 { 883 name: "PtrHeadUintPtrNilNotRootString", 884 data: struct { 885 A *struct { 886 A *uint `json:"a,string"` 887 } 888 }{A: &(struct { 889 A *uint `json:"a,string"` 890 }{A: nil})}, 891 }, 892 { 893 name: "PtrHeadUintPtrNilNotRootStringOmitEmpty", 894 data: struct { 895 A *struct { 896 A *uint `json:"a,string,omitempty"` 897 } 898 }{A: &(struct { 899 A *uint `json:"a,string,omitempty"` 900 }{A: nil})}, 901 }, 902 903 // PtrHeadUintNilNotRoot 904 { 905 name: "PtrHeadUintNilNotRoot", 906 data: struct { 907 A *struct { 908 A *uint `json:"a"` 909 } 910 }{A: nil}, 911 }, 912 { 913 name: "PtrHeadUintNilNotRootOmitEmpty", 914 data: struct { 915 A *struct { 916 A *uint `json:"a,omitempty"` 917 } `json:",omitempty"` 918 }{A: nil}, 919 }, 920 { 921 name: "PtrHeadUintNilNotRootString", 922 data: struct { 923 A *struct { 924 A *uint `json:"a,string"` 925 } `json:",string"` 926 }{A: nil}, 927 }, 928 { 929 name: "PtrHeadUintNilNotRootStringOmitEmpty", 930 data: struct { 931 A *struct { 932 A *uint `json:"a,string,omitempty"` 933 } `json:",string,omitempty"` 934 }{A: nil}, 935 }, 936 937 // HeadUintZeroMultiFieldsNotRoot 938 { 939 name: "HeadUintZeroMultiFieldsNotRoot", 940 data: struct { 941 A struct { 942 A uint `json:"a"` 943 } 944 B struct { 945 B uint `json:"b"` 946 } 947 }{}, 948 }, 949 { 950 name: "HeadUintZeroMultiFieldsNotRootOmitEmpty", 951 data: struct { 952 A struct { 953 A uint `json:"a,omitempty"` 954 } 955 B struct { 956 B uint `json:"b,omitempty"` 957 } 958 }{}, 959 }, 960 { 961 name: "HeadUintZeroMultiFieldsNotRootString", 962 data: struct { 963 A struct { 964 A uint `json:"a,string"` 965 } 966 B struct { 967 B uint `json:"b,string"` 968 } 969 }{}, 970 }, 971 { 972 name: "HeadUintZeroMultiFieldsNotRootStringOmitEmpty", 973 data: struct { 974 A struct { 975 A uint `json:"a,string,omitempty"` 976 } 977 B struct { 978 B uint `json:"b,string,omitempty"` 979 } 980 }{}, 981 }, 982 983 // HeadUintMultiFieldsNotRoot 984 { 985 name: "HeadUintMultiFieldsNotRoot", 986 data: struct { 987 A struct { 988 A uint `json:"a"` 989 } 990 B struct { 991 B uint `json:"b"` 992 } 993 }{A: struct { 994 A uint `json:"a"` 995 }{A: 1}, B: struct { 996 B uint `json:"b"` 997 }{B: 2}}, 998 }, 999 { 1000 name: "HeadUintMultiFieldsNotRootOmitEmpty", 1001 data: struct { 1002 A struct { 1003 A uint `json:"a,omitempty"` 1004 } 1005 B struct { 1006 B uint `json:"b,omitempty"` 1007 } 1008 }{A: struct { 1009 A uint `json:"a,omitempty"` 1010 }{A: 1}, B: struct { 1011 B uint `json:"b,omitempty"` 1012 }{B: 2}}, 1013 }, 1014 { 1015 name: "HeadUintMultiFieldsNotRootString", 1016 data: struct { 1017 A struct { 1018 A uint `json:"a,string"` 1019 } 1020 B struct { 1021 B uint `json:"b,string"` 1022 } 1023 }{A: struct { 1024 A uint `json:"a,string"` 1025 }{A: 1}, B: struct { 1026 B uint `json:"b,string"` 1027 }{B: 2}}, 1028 }, 1029 { 1030 name: "HeadUintMultiFieldsNotRootStringOmitEmpty", 1031 data: struct { 1032 A struct { 1033 A uint `json:"a,string,omitempty"` 1034 } 1035 B struct { 1036 B uint `json:"b,string,omitempty"` 1037 } 1038 }{A: struct { 1039 A uint `json:"a,string,omitempty"` 1040 }{A: 1}, B: struct { 1041 B uint `json:"b,string,omitempty"` 1042 }{B: 2}}, 1043 }, 1044 1045 // HeadUintPtrMultiFieldsNotRoot 1046 { 1047 name: "HeadUintPtrMultiFieldsNotRoot", 1048 data: struct { 1049 A struct { 1050 A *uint `json:"a"` 1051 } 1052 B struct { 1053 B *uint `json:"b"` 1054 } 1055 }{A: struct { 1056 A *uint `json:"a"` 1057 }{A: uptr(1)}, B: struct { 1058 B *uint `json:"b"` 1059 }{B: uptr(2)}}, 1060 }, 1061 { 1062 name: "HeadUintPtrMultiFieldsNotRootOmitEmpty", 1063 data: struct { 1064 A struct { 1065 A *uint `json:"a,omitempty"` 1066 } 1067 B struct { 1068 B *uint `json:"b,omitempty"` 1069 } 1070 }{A: struct { 1071 A *uint `json:"a,omitempty"` 1072 }{A: uptr(1)}, B: struct { 1073 B *uint `json:"b,omitempty"` 1074 }{B: uptr(2)}}, 1075 }, 1076 { 1077 name: "HeadUintPtrMultiFieldsNotRootString", 1078 data: struct { 1079 A struct { 1080 A *uint `json:"a,string"` 1081 } 1082 B struct { 1083 B *uint `json:"b,string"` 1084 } 1085 }{A: struct { 1086 A *uint `json:"a,string"` 1087 }{A: uptr(1)}, B: struct { 1088 B *uint `json:"b,string"` 1089 }{B: uptr(2)}}, 1090 }, 1091 { 1092 name: "HeadUintPtrMultiFieldsNotRootStringOmitEmpty", 1093 data: struct { 1094 A struct { 1095 A *uint `json:"a,string,omitempty"` 1096 } 1097 B struct { 1098 B *uint `json:"b,string,omitempty"` 1099 } 1100 }{A: struct { 1101 A *uint `json:"a,string,omitempty"` 1102 }{A: uptr(1)}, B: struct { 1103 B *uint `json:"b,string,omitempty"` 1104 }{B: uptr(2)}}, 1105 }, 1106 1107 // HeadUintPtrNilMultiFieldsNotRoot 1108 { 1109 name: "HeadUintPtrNilMultiFieldsNotRoot", 1110 data: struct { 1111 A struct { 1112 A *uint `json:"a"` 1113 } 1114 B struct { 1115 B *uint `json:"b"` 1116 } 1117 }{A: struct { 1118 A *uint `json:"a"` 1119 }{A: nil}, B: struct { 1120 B *uint `json:"b"` 1121 }{B: nil}}, 1122 }, 1123 { 1124 name: "HeadUintPtrNilMultiFieldsNotRootOmitEmpty", 1125 data: struct { 1126 A struct { 1127 A *uint `json:"a,omitempty"` 1128 } 1129 B struct { 1130 B *uint `json:"b,omitempty"` 1131 } 1132 }{A: struct { 1133 A *uint `json:"a,omitempty"` 1134 }{A: nil}, B: struct { 1135 B *uint `json:"b,omitempty"` 1136 }{B: nil}}, 1137 }, 1138 { 1139 name: "HeadUintPtrNilMultiFieldsNotRootString", 1140 data: struct { 1141 A struct { 1142 A *uint `json:"a,string"` 1143 } 1144 B struct { 1145 B *uint `json:"b,string"` 1146 } 1147 }{A: struct { 1148 A *uint `json:"a,string"` 1149 }{A: nil}, B: struct { 1150 B *uint `json:"b,string"` 1151 }{B: nil}}, 1152 }, 1153 { 1154 name: "HeadUintPtrNilMultiFieldsNotRootStringOmitEmpty", 1155 data: struct { 1156 A struct { 1157 A *uint `json:"a,string,omitempty"` 1158 } 1159 B struct { 1160 B *uint `json:"b,string,omitempty"` 1161 } 1162 }{A: struct { 1163 A *uint `json:"a,string,omitempty"` 1164 }{A: nil}, B: struct { 1165 B *uint `json:"b,string,omitempty"` 1166 }{B: nil}}, 1167 }, 1168 1169 // PtrHeadUintZeroMultiFieldsNotRoot 1170 { 1171 name: "PtrHeadUintZeroMultiFieldsNotRoot", 1172 data: &struct { 1173 A struct { 1174 A uint `json:"a"` 1175 } 1176 B struct { 1177 B uint `json:"b"` 1178 } 1179 }{}, 1180 }, 1181 { 1182 name: "PtrHeadUintZeroMultiFieldsNotRootOmitEmpty", 1183 data: &struct { 1184 A struct { 1185 A uint `json:"a,omitempty"` 1186 } 1187 B struct { 1188 B uint `json:"b,omitempty"` 1189 } 1190 }{}, 1191 }, 1192 { 1193 name: "PtrHeadUintZeroMultiFieldsNotRootString", 1194 data: &struct { 1195 A struct { 1196 A uint `json:"a,string"` 1197 } 1198 B struct { 1199 B uint `json:"b,string"` 1200 } 1201 }{}, 1202 }, 1203 { 1204 name: "PtrHeadUintZeroMultiFieldsNotRootStringOmitEmpty", 1205 data: &struct { 1206 A struct { 1207 A uint `json:"a,string,omitempty"` 1208 } 1209 B struct { 1210 B uint `json:"b,string,omitempty"` 1211 } 1212 }{}, 1213 }, 1214 1215 // PtrHeadUintMultiFieldsNotRoot 1216 { 1217 name: "PtrHeadUintMultiFieldsNotRoot", 1218 data: &struct { 1219 A struct { 1220 A uint `json:"a"` 1221 } 1222 B struct { 1223 B uint `json:"b"` 1224 } 1225 }{A: struct { 1226 A uint `json:"a"` 1227 }{A: 1}, B: struct { 1228 B uint `json:"b"` 1229 }{B: 2}}, 1230 }, 1231 { 1232 name: "PtrHeadUintMultiFieldsNotRootOmitEmpty", 1233 data: &struct { 1234 A struct { 1235 A uint `json:"a,omitempty"` 1236 } 1237 B struct { 1238 B uint `json:"b,omitempty"` 1239 } 1240 }{A: struct { 1241 A uint `json:"a,omitempty"` 1242 }{A: 1}, B: struct { 1243 B uint `json:"b,omitempty"` 1244 }{B: 2}}, 1245 }, 1246 { 1247 name: "PtrHeadUintMultiFieldsNotRootString", 1248 data: &struct { 1249 A struct { 1250 A uint `json:"a,string"` 1251 } 1252 B struct { 1253 B uint `json:"b,string"` 1254 } 1255 }{A: struct { 1256 A uint `json:"a,string"` 1257 }{A: 1}, B: struct { 1258 B uint `json:"b,string"` 1259 }{B: 2}}, 1260 }, 1261 { 1262 name: "PtrHeadUintMultiFieldsNotRootStringOmitEmpty", 1263 data: &struct { 1264 A struct { 1265 A uint `json:"a,string,omitempty"` 1266 } 1267 B struct { 1268 B uint `json:"b,string,omitempty"` 1269 } 1270 }{A: struct { 1271 A uint `json:"a,string,omitempty"` 1272 }{A: 1}, B: struct { 1273 B uint `json:"b,string,omitempty"` 1274 }{B: 2}}, 1275 }, 1276 1277 // PtrHeadUintPtrMultiFieldsNotRoot 1278 { 1279 name: "PtrHeadUintPtrMultiFieldsNotRoot", 1280 data: &struct { 1281 A *struct { 1282 A *uint `json:"a"` 1283 } 1284 B *struct { 1285 B *uint `json:"b"` 1286 } 1287 }{A: &(struct { 1288 A *uint `json:"a"` 1289 }{A: uptr(1)}), B: &(struct { 1290 B *uint `json:"b"` 1291 }{B: uptr(2)})}, 1292 }, 1293 { 1294 name: "PtrHeadUintPtrMultiFieldsNotRootOmitEmpty", 1295 data: &struct { 1296 A *struct { 1297 A *uint `json:"a,omitempty"` 1298 } 1299 B *struct { 1300 B *uint `json:"b,omitempty"` 1301 } 1302 }{A: &(struct { 1303 A *uint `json:"a,omitempty"` 1304 }{A: uptr(1)}), B: &(struct { 1305 B *uint `json:"b,omitempty"` 1306 }{B: uptr(2)})}, 1307 }, 1308 { 1309 name: "PtrHeadUintPtrMultiFieldsNotRootString", 1310 data: &struct { 1311 A *struct { 1312 A *uint `json:"a,string"` 1313 } 1314 B *struct { 1315 B *uint `json:"b,string"` 1316 } 1317 }{A: &(struct { 1318 A *uint `json:"a,string"` 1319 }{A: uptr(1)}), B: &(struct { 1320 B *uint `json:"b,string"` 1321 }{B: uptr(2)})}, 1322 }, 1323 { 1324 name: "PtrHeadUintPtrMultiFieldsNotRootStringOmitEmpty", 1325 data: &struct { 1326 A *struct { 1327 A *uint `json:"a,string,omitempty"` 1328 } 1329 B *struct { 1330 B *uint `json:"b,string,omitempty"` 1331 } 1332 }{A: &(struct { 1333 A *uint `json:"a,string,omitempty"` 1334 }{A: uptr(1)}), B: &(struct { 1335 B *uint `json:"b,string,omitempty"` 1336 }{B: uptr(2)})}, 1337 }, 1338 1339 // PtrHeadUintPtrNilMultiFieldsNotRoot 1340 { 1341 name: "PtrHeadUintPtrNilMultiFieldsNotRoot", 1342 data: &struct { 1343 A *struct { 1344 A *uint `json:"a"` 1345 } 1346 B *struct { 1347 B *uint `json:"b"` 1348 } 1349 }{A: nil, B: nil}, 1350 }, 1351 { 1352 name: "PtrHeadUintPtrNilMultiFieldsNotRootOmitEmpty", 1353 data: &struct { 1354 A *struct { 1355 A *uint `json:"a,omitempty"` 1356 } `json:",omitempty"` 1357 B *struct { 1358 B *uint `json:"b,omitempty"` 1359 } `json:",omitempty"` 1360 }{A: nil, B: nil}, 1361 }, 1362 { 1363 name: "PtrHeadUintPtrNilMultiFieldsNotRootString", 1364 data: &struct { 1365 A *struct { 1366 A *uint `json:"a,string"` 1367 } `json:",string"` 1368 B *struct { 1369 B *uint `json:"b,string"` 1370 } `json:",string"` 1371 }{A: nil, B: nil}, 1372 }, 1373 { 1374 name: "PtrHeadUintPtrNilMultiFieldsNotRootStringOmitEmpty", 1375 data: &struct { 1376 A *struct { 1377 A *uint `json:"a,string,omitempty"` 1378 } `json:",string,omitempty"` 1379 B *struct { 1380 B *uint `json:"b,string,omitempty"` 1381 } `json:",string,omitempty"` 1382 }{A: nil, B: nil}, 1383 }, 1384 1385 // PtrHeadUintNilMultiFieldsNotRoot 1386 { 1387 name: "PtrHeadUintNilMultiFieldsNotRoot", 1388 data: (*struct { 1389 A *struct { 1390 A *uint `json:"a"` 1391 } 1392 B *struct { 1393 B *uint `json:"b"` 1394 } 1395 })(nil), 1396 }, 1397 { 1398 name: "PtrHeadUintNilMultiFieldsNotRootOmitEmpty", 1399 data: (*struct { 1400 A *struct { 1401 A *uint `json:"a,omitempty"` 1402 } 1403 B *struct { 1404 B *uint `json:"b,omitempty"` 1405 } 1406 })(nil), 1407 }, 1408 { 1409 name: "PtrHeadUintNilMultiFieldsNotRootString", 1410 data: (*struct { 1411 A *struct { 1412 A *uint `json:"a,string"` 1413 } 1414 B *struct { 1415 B *uint `json:"b,string"` 1416 } 1417 })(nil), 1418 }, 1419 { 1420 name: "PtrHeadUintNilMultiFieldsNotRootStringOmitEmpty", 1421 data: (*struct { 1422 A *struct { 1423 A *uint `json:"a,string,omitempty"` 1424 } 1425 B *struct { 1426 B *uint `json:"b,string,omitempty"` 1427 } 1428 })(nil), 1429 }, 1430 1431 // PtrHeadUintDoubleMultiFieldsNotRoot 1432 { 1433 name: "PtrHeadUintDoubleMultiFieldsNotRoot", 1434 data: &struct { 1435 A *struct { 1436 A uint `json:"a"` 1437 B uint `json:"b"` 1438 } 1439 B *struct { 1440 A uint `json:"a"` 1441 B uint `json:"b"` 1442 } 1443 }{A: &(struct { 1444 A uint `json:"a"` 1445 B uint `json:"b"` 1446 }{A: 1, B: 2}), B: &(struct { 1447 A uint `json:"a"` 1448 B uint `json:"b"` 1449 }{A: 3, B: 4})}, 1450 }, 1451 { 1452 name: "PtrHeadUintDoubleMultiFieldsNotRootOmitEmpty", 1453 data: &struct { 1454 A *struct { 1455 A uint `json:"a,omitempty"` 1456 B uint `json:"b,omitempty"` 1457 } 1458 B *struct { 1459 A uint `json:"a,omitempty"` 1460 B uint `json:"b,omitempty"` 1461 } 1462 }{A: &(struct { 1463 A uint `json:"a,omitempty"` 1464 B uint `json:"b,omitempty"` 1465 }{A: 1, B: 2}), B: &(struct { 1466 A uint `json:"a,omitempty"` 1467 B uint `json:"b,omitempty"` 1468 }{A: 3, B: 4})}, 1469 }, 1470 { 1471 name: "PtrHeadUintDoubleMultiFieldsNotRootString", 1472 data: &struct { 1473 A *struct { 1474 A uint `json:"a,string"` 1475 B uint `json:"b,string"` 1476 } 1477 B *struct { 1478 A uint `json:"a,string"` 1479 B uint `json:"b,string"` 1480 } 1481 }{A: &(struct { 1482 A uint `json:"a,string"` 1483 B uint `json:"b,string"` 1484 }{A: 1, B: 2}), B: &(struct { 1485 A uint `json:"a,string"` 1486 B uint `json:"b,string"` 1487 }{A: 3, B: 4})}, 1488 }, 1489 { 1490 name: "PtrHeadUintDoubleMultiFieldsNotRootStringOmitEmpty", 1491 data: &struct { 1492 A *struct { 1493 A uint `json:"a,string,omitempty"` 1494 B uint `json:"b,string,omitempty"` 1495 } 1496 B *struct { 1497 A uint `json:"a,string,omitempty"` 1498 B uint `json:"b,string,omitempty"` 1499 } 1500 }{A: &(struct { 1501 A uint `json:"a,string,omitempty"` 1502 B uint `json:"b,string,omitempty"` 1503 }{A: 1, B: 2}), B: &(struct { 1504 A uint `json:"a,string,omitempty"` 1505 B uint `json:"b,string,omitempty"` 1506 }{A: 3, B: 4})}, 1507 }, 1508 1509 // PtrHeadUintNilDoubleMultiFieldsNotRoot 1510 { 1511 name: "PtrHeadUintNilDoubleMultiFieldsNotRoot", 1512 data: &struct { 1513 A *struct { 1514 A uint `json:"a"` 1515 B uint `json:"b"` 1516 } 1517 B *struct { 1518 A uint `json:"a"` 1519 B uint `json:"b"` 1520 } 1521 }{A: nil, B: nil}, 1522 }, 1523 { 1524 name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty", 1525 data: &struct { 1526 A *struct { 1527 A uint `json:"a,omitempty"` 1528 B uint `json:"b,omitempty"` 1529 } `json:",omitempty"` 1530 B *struct { 1531 A uint `json:"a,omitempty"` 1532 B uint `json:"b,omitempty"` 1533 } `json:",omitempty"` 1534 }{A: nil, B: nil}, 1535 }, 1536 { 1537 name: "PtrHeadUintNilDoubleMultiFieldsNotRootString", 1538 data: &struct { 1539 A *struct { 1540 A uint `json:"a,string"` 1541 B uint `json:"b,string"` 1542 } 1543 B *struct { 1544 A uint `json:"a,string"` 1545 B uint `json:"b,string"` 1546 } 1547 }{A: nil, B: nil}, 1548 }, 1549 { 1550 name: "PtrHeadUintNilDoubleMultiFieldsNotRootStringOmitEmpty", 1551 data: &struct { 1552 A *struct { 1553 A uint `json:"a,string,omitempty"` 1554 B uint `json:"b,string,omitempty"` 1555 } 1556 B *struct { 1557 A uint `json:"a,string,omitempty"` 1558 B uint `json:"b,string,omitempty"` 1559 } 1560 }{A: nil, B: nil}, 1561 }, 1562 1563 // PtrHeadUintNilDoubleMultiFieldsNotRoot 1564 { 1565 name: "PtrHeadUintNilDoubleMultiFieldsNotRoot", 1566 data: (*struct { 1567 A *struct { 1568 A uint `json:"a"` 1569 B uint `json:"b"` 1570 } 1571 B *struct { 1572 A uint `json:"a"` 1573 B uint `json:"b"` 1574 } 1575 })(nil), 1576 }, 1577 { 1578 name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty", 1579 data: (*struct { 1580 A *struct { 1581 A uint `json:"a,omitempty"` 1582 B uint `json:"b,omitempty"` 1583 } 1584 B *struct { 1585 A uint `json:"a,omitempty"` 1586 B uint `json:"b,omitempty"` 1587 } 1588 })(nil), 1589 }, 1590 { 1591 name: "PtrHeadUintNilDoubleMultiFieldsNotRootString", 1592 data: (*struct { 1593 A *struct { 1594 A uint `json:"a,string"` 1595 B uint `json:"b,string"` 1596 } 1597 B *struct { 1598 A uint `json:"a,string"` 1599 B uint `json:"b,string"` 1600 } 1601 })(nil), 1602 }, 1603 { 1604 name: "PtrHeadUintNilDoubleMultiFieldsNotRootStringOmitEmpty", 1605 data: (*struct { 1606 A *struct { 1607 A uint `json:"a,string,omitempty"` 1608 B uint `json:"b,string,omitempty"` 1609 } 1610 B *struct { 1611 A uint `json:"a,string,omitempty"` 1612 B uint `json:"b,string,omitempty"` 1613 } 1614 })(nil), 1615 }, 1616 1617 // PtrHeadUintPtrDoubleMultiFieldsNotRoot 1618 { 1619 name: "PtrHeadUintPtrDoubleMultiFieldsNotRoot", 1620 data: &struct { 1621 A *struct { 1622 A *uint `json:"a"` 1623 B *uint `json:"b"` 1624 } 1625 B *struct { 1626 A *uint `json:"a"` 1627 B *uint `json:"b"` 1628 } 1629 }{A: &(struct { 1630 A *uint `json:"a"` 1631 B *uint `json:"b"` 1632 }{A: uptr(1), B: uptr(2)}), B: &(struct { 1633 A *uint `json:"a"` 1634 B *uint `json:"b"` 1635 }{A: uptr(3), B: uptr(4)})}, 1636 }, 1637 { 1638 name: "PtrHeadUintPtrDoubleMultiFieldsNotRootOmitEmpty", 1639 data: &struct { 1640 A *struct { 1641 A *uint `json:"a,omitempty"` 1642 B *uint `json:"b,omitempty"` 1643 } 1644 B *struct { 1645 A *uint `json:"a,omitempty"` 1646 B *uint `json:"b,omitempty"` 1647 } 1648 }{A: &(struct { 1649 A *uint `json:"a,omitempty"` 1650 B *uint `json:"b,omitempty"` 1651 }{A: uptr(1), B: uptr(2)}), B: &(struct { 1652 A *uint `json:"a,omitempty"` 1653 B *uint `json:"b,omitempty"` 1654 }{A: uptr(3), B: uptr(4)})}, 1655 }, 1656 { 1657 name: "PtrHeadUintPtrDoubleMultiFieldsNotRootString", 1658 data: &struct { 1659 A *struct { 1660 A *uint `json:"a,string"` 1661 B *uint `json:"b,string"` 1662 } 1663 B *struct { 1664 A *uint `json:"a,string"` 1665 B *uint `json:"b,string"` 1666 } 1667 }{A: &(struct { 1668 A *uint `json:"a,string"` 1669 B *uint `json:"b,string"` 1670 }{A: uptr(1), B: uptr(2)}), B: &(struct { 1671 A *uint `json:"a,string"` 1672 B *uint `json:"b,string"` 1673 }{A: uptr(3), B: uptr(4)})}, 1674 }, 1675 { 1676 name: "PtrHeadUintPtrDoubleMultiFieldsNotRootStringOmitEmpty", 1677 data: &struct { 1678 A *struct { 1679 A *uint `json:"a,string,omitempty"` 1680 B *uint `json:"b,string,omitempty"` 1681 } 1682 B *struct { 1683 A *uint `json:"a,string,omitempty"` 1684 B *uint `json:"b,string,omitempty"` 1685 } 1686 }{A: &(struct { 1687 A *uint `json:"a,string,omitempty"` 1688 B *uint `json:"b,string,omitempty"` 1689 }{A: uptr(1), B: uptr(2)}), B: &(struct { 1690 A *uint `json:"a,string,omitempty"` 1691 B *uint `json:"b,string,omitempty"` 1692 }{A: uptr(3), B: uptr(4)})}, 1693 }, 1694 1695 // PtrHeadUintPtrNilDoubleMultiFieldsNotRoot 1696 { 1697 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot", 1698 data: &struct { 1699 A *struct { 1700 A *uint `json:"a"` 1701 B *uint `json:"b"` 1702 } 1703 B *struct { 1704 A *uint `json:"a"` 1705 B *uint `json:"b"` 1706 } 1707 }{A: nil, B: nil}, 1708 }, 1709 { 1710 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty", 1711 data: &struct { 1712 A *struct { 1713 A *uint `json:"a,omitempty"` 1714 B *uint `json:"b,omitempty"` 1715 } `json:",omitempty"` 1716 B *struct { 1717 A *uint `json:"a,omitempty"` 1718 B *uint `json:"b,omitempty"` 1719 } `json:",omitempty"` 1720 }{A: nil, B: nil}, 1721 }, 1722 { 1723 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString", 1724 data: &struct { 1725 A *struct { 1726 A *uint `json:"a,string"` 1727 B *uint `json:"b,string"` 1728 } 1729 B *struct { 1730 A *uint `json:"a,string"` 1731 B *uint `json:"b,string"` 1732 } 1733 }{A: nil, B: nil}, 1734 }, 1735 { 1736 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootStringOmitEmpty", 1737 data: &struct { 1738 A *struct { 1739 A *uint `json:"a,string,omitempty"` 1740 B *uint `json:"b,string,omitempty"` 1741 } 1742 B *struct { 1743 A *uint `json:"a,string,omitempty"` 1744 B *uint `json:"b,string,omitempty"` 1745 } 1746 }{A: nil, B: nil}, 1747 }, 1748 1749 // PtrHeadUintPtrNilDoubleMultiFieldsNotRoot 1750 { 1751 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot", 1752 data: (*struct { 1753 A *struct { 1754 A *uint `json:"a"` 1755 B *uint `json:"b"` 1756 } 1757 B *struct { 1758 A *uint `json:"a"` 1759 B *uint `json:"b"` 1760 } 1761 })(nil), 1762 }, 1763 { 1764 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty", 1765 data: (*struct { 1766 A *struct { 1767 A *uint `json:"a,omitempty"` 1768 B *uint `json:"b,omitempty"` 1769 } 1770 B *struct { 1771 A *uint `json:"a,omitempty"` 1772 B *uint `json:"b,omitempty"` 1773 } 1774 })(nil), 1775 }, 1776 { 1777 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString", 1778 data: (*struct { 1779 A *struct { 1780 A *uint `json:"a,string"` 1781 B *uint `json:"b,string"` 1782 } 1783 B *struct { 1784 A *uint `json:"a,string"` 1785 B *uint `json:"b,string"` 1786 } 1787 })(nil), 1788 }, 1789 { 1790 name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootStringOmitEmpty", 1791 data: (*struct { 1792 A *struct { 1793 A *uint `json:"a,string,omitempty"` 1794 B *uint `json:"b,string,omitempty"` 1795 } 1796 B *struct { 1797 A *uint `json:"a,string,omitempty"` 1798 B *uint `json:"b,string,omitempty"` 1799 } 1800 })(nil), 1801 }, 1802 1803 // AnonymousHeadUint 1804 { 1805 name: "AnonymousHeadUint", 1806 data: struct { 1807 structUint 1808 B uint `json:"b"` 1809 }{ 1810 structUint: structUint{A: 1}, 1811 B: 2, 1812 }, 1813 }, 1814 { 1815 name: "AnonymousHeadUintOmitEmpty", 1816 data: struct { 1817 structUintOmitEmpty 1818 B uint `json:"b,omitempty"` 1819 }{ 1820 structUintOmitEmpty: structUintOmitEmpty{A: 1}, 1821 B: 2, 1822 }, 1823 }, 1824 { 1825 name: "AnonymousHeadUintString", 1826 data: struct { 1827 structUintString 1828 B uint `json:"b,string"` 1829 }{ 1830 structUintString: structUintString{A: 1}, 1831 B: 2, 1832 }, 1833 }, 1834 { 1835 name: "AnonymousHeadUintStringOmitEmpty", 1836 data: struct { 1837 structUintStringOmitEmpty 1838 B uint `json:"b,string,omitempty"` 1839 }{ 1840 structUintStringOmitEmpty: structUintStringOmitEmpty{A: 1}, 1841 B: 2, 1842 }, 1843 }, 1844 1845 // PtrAnonymousHeadUint 1846 { 1847 name: "PtrAnonymousHeadUint", 1848 data: struct { 1849 *structUint 1850 B uint `json:"b"` 1851 }{ 1852 structUint: &structUint{A: 1}, 1853 B: 2, 1854 }, 1855 }, 1856 { 1857 name: "PtrAnonymousHeadUintOmitEmpty", 1858 data: struct { 1859 *structUintOmitEmpty 1860 B uint `json:"b,omitempty"` 1861 }{ 1862 structUintOmitEmpty: &structUintOmitEmpty{A: 1}, 1863 B: 2, 1864 }, 1865 }, 1866 { 1867 name: "PtrAnonymousHeadUintString", 1868 data: struct { 1869 *structUintString 1870 B uint `json:"b,string"` 1871 }{ 1872 structUintString: &structUintString{A: 1}, 1873 B: 2, 1874 }, 1875 }, 1876 { 1877 name: "PtrAnonymousHeadUintStringOmitEmpty", 1878 data: struct { 1879 *structUintStringOmitEmpty 1880 B uint `json:"b,string,omitempty"` 1881 }{ 1882 structUintStringOmitEmpty: &structUintStringOmitEmpty{A: 1}, 1883 B: 2, 1884 }, 1885 }, 1886 1887 // NilPtrAnonymousHeadUint 1888 { 1889 name: "NilPtrAnonymousHeadUint", 1890 data: struct { 1891 *structUint 1892 B uint `json:"b"` 1893 }{ 1894 structUint: nil, 1895 B: 2, 1896 }, 1897 }, 1898 { 1899 name: "NilPtrAnonymousHeadUintOmitEmpty", 1900 data: struct { 1901 *structUintOmitEmpty 1902 B uint `json:"b,omitempty"` 1903 }{ 1904 structUintOmitEmpty: nil, 1905 B: 2, 1906 }, 1907 }, 1908 { 1909 name: "NilPtrAnonymousHeadUintString", 1910 data: struct { 1911 *structUintString 1912 B uint `json:"b,string"` 1913 }{ 1914 structUintString: nil, 1915 B: 2, 1916 }, 1917 }, 1918 { 1919 name: "NilPtrAnonymousHeadUintStringOmitEmpty", 1920 data: struct { 1921 *structUintStringOmitEmpty 1922 B uint `json:"b,string,omitempty"` 1923 }{ 1924 structUintStringOmitEmpty: nil, 1925 B: 2, 1926 }, 1927 }, 1928 1929 // AnonymousHeadUintPtr 1930 { 1931 name: "AnonymousHeadUintPtr", 1932 data: struct { 1933 structUintPtr 1934 B *uint `json:"b"` 1935 }{ 1936 structUintPtr: structUintPtr{A: uptr(1)}, 1937 B: uptr(2), 1938 }, 1939 }, 1940 { 1941 name: "AnonymousHeadUintPtrOmitEmpty", 1942 data: struct { 1943 structUintPtrOmitEmpty 1944 B *uint `json:"b,omitempty"` 1945 }{ 1946 structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: uptr(1)}, 1947 B: uptr(2), 1948 }, 1949 }, 1950 { 1951 name: "AnonymousHeadUintPtrString", 1952 data: struct { 1953 structUintPtrString 1954 B *uint `json:"b,string"` 1955 }{ 1956 structUintPtrString: structUintPtrString{A: uptr(1)}, 1957 B: uptr(2), 1958 }, 1959 }, 1960 { 1961 name: "AnonymousHeadUintPtrStringOmitEmpty", 1962 data: struct { 1963 structUintPtrStringOmitEmpty 1964 B *uint `json:"b,string,omitempty"` 1965 }{ 1966 structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: uptr(1)}, 1967 B: uptr(2), 1968 }, 1969 }, 1970 1971 // AnonymousHeadUintPtrNil 1972 { 1973 name: "AnonymousHeadUintPtrNil", 1974 data: struct { 1975 structUintPtr 1976 B *uint `json:"b"` 1977 }{ 1978 structUintPtr: structUintPtr{A: nil}, 1979 B: uptr(2), 1980 }, 1981 }, 1982 { 1983 name: "AnonymousHeadUintPtrNilOmitEmpty", 1984 data: struct { 1985 structUintPtrOmitEmpty 1986 B *uint `json:"b,omitempty"` 1987 }{ 1988 structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: nil}, 1989 B: uptr(2), 1990 }, 1991 }, 1992 { 1993 name: "AnonymousHeadUintPtrNilString", 1994 data: struct { 1995 structUintPtrString 1996 B *uint `json:"b,string"` 1997 }{ 1998 structUintPtrString: structUintPtrString{A: nil}, 1999 B: uptr(2), 2000 }, 2001 }, 2002 { 2003 name: "AnonymousHeadUintPtrNilStringOmitEmpty", 2004 data: struct { 2005 structUintPtrStringOmitEmpty 2006 B *uint `json:"b,string,omitempty"` 2007 }{ 2008 structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: nil}, 2009 B: uptr(2), 2010 }, 2011 }, 2012 2013 // PtrAnonymousHeadUintPtr 2014 { 2015 name: "PtrAnonymousHeadUintPtr", 2016 data: struct { 2017 *structUintPtr 2018 B *uint `json:"b"` 2019 }{ 2020 structUintPtr: &structUintPtr{A: uptr(1)}, 2021 B: uptr(2), 2022 }, 2023 }, 2024 { 2025 name: "PtrAnonymousHeadUintPtrOmitEmpty", 2026 data: struct { 2027 *structUintPtrOmitEmpty 2028 B *uint `json:"b,omitempty"` 2029 }{ 2030 structUintPtrOmitEmpty: &structUintPtrOmitEmpty{A: uptr(1)}, 2031 B: uptr(2), 2032 }, 2033 }, 2034 { 2035 name: "PtrAnonymousHeadUintPtrString", 2036 data: struct { 2037 *structUintPtrString 2038 B *uint `json:"b,string"` 2039 }{ 2040 structUintPtrString: &structUintPtrString{A: uptr(1)}, 2041 B: uptr(2), 2042 }, 2043 }, 2044 { 2045 name: "PtrAnonymousHeadUintPtrStringOmitEmpty", 2046 data: struct { 2047 *structUintPtrStringOmitEmpty 2048 B *uint `json:"b,string,omitempty"` 2049 }{ 2050 structUintPtrStringOmitEmpty: &structUintPtrStringOmitEmpty{A: uptr(1)}, 2051 B: uptr(2), 2052 }, 2053 }, 2054 2055 // NilPtrAnonymousHeadUintPtr 2056 { 2057 name: "NilPtrAnonymousHeadUintPtr", 2058 data: struct { 2059 *structUintPtr 2060 B *uint `json:"b"` 2061 }{ 2062 structUintPtr: nil, 2063 B: uptr(2), 2064 }, 2065 }, 2066 { 2067 name: "NilPtrAnonymousHeadUintPtrOmitEmpty", 2068 data: struct { 2069 *structUintPtrOmitEmpty 2070 B *uint `json:"b,omitempty"` 2071 }{ 2072 structUintPtrOmitEmpty: nil, 2073 B: uptr(2), 2074 }, 2075 }, 2076 { 2077 name: "NilPtrAnonymousHeadUintPtrString", 2078 data: struct { 2079 *structUintPtrString 2080 B *uint `json:"b,string"` 2081 }{ 2082 structUintPtrString: nil, 2083 B: uptr(2), 2084 }, 2085 }, 2086 { 2087 name: "NilPtrAnonymousHeadUintPtrStringOmitEmpty", 2088 data: struct { 2089 *structUintPtrStringOmitEmpty 2090 B *uint `json:"b,string,omitempty"` 2091 }{ 2092 structUintPtrStringOmitEmpty: nil, 2093 B: uptr(2), 2094 }, 2095 }, 2096 2097 // AnonymousHeadUintOnly 2098 { 2099 name: "AnonymousHeadUintOnly", 2100 data: struct { 2101 structUint 2102 }{ 2103 structUint: structUint{A: 1}, 2104 }, 2105 }, 2106 { 2107 name: "AnonymousHeadUintOnlyOmitEmpty", 2108 data: struct { 2109 structUintOmitEmpty 2110 }{ 2111 structUintOmitEmpty: structUintOmitEmpty{A: 1}, 2112 }, 2113 }, 2114 { 2115 name: "AnonymousHeadUintOnlyString", 2116 data: struct { 2117 structUintString 2118 }{ 2119 structUintString: structUintString{A: 1}, 2120 }, 2121 }, 2122 { 2123 name: "AnonymousHeadUintOnlyStringOmitEmpty", 2124 data: struct { 2125 structUintStringOmitEmpty 2126 }{ 2127 structUintStringOmitEmpty: structUintStringOmitEmpty{A: 1}, 2128 }, 2129 }, 2130 2131 // PtrAnonymousHeadUintOnly 2132 { 2133 name: "PtrAnonymousHeadUintOnly", 2134 data: struct { 2135 *structUint 2136 }{ 2137 structUint: &structUint{A: 1}, 2138 }, 2139 }, 2140 { 2141 name: "PtrAnonymousHeadUintOnlyOmitEmpty", 2142 data: struct { 2143 *structUintOmitEmpty 2144 }{ 2145 structUintOmitEmpty: &structUintOmitEmpty{A: 1}, 2146 }, 2147 }, 2148 { 2149 name: "PtrAnonymousHeadUintOnlyString", 2150 data: struct { 2151 *structUintString 2152 }{ 2153 structUintString: &structUintString{A: 1}, 2154 }, 2155 }, 2156 { 2157 name: "PtrAnonymousHeadUintOnlyStringOmitEmpty", 2158 data: struct { 2159 *structUintStringOmitEmpty 2160 }{ 2161 structUintStringOmitEmpty: &structUintStringOmitEmpty{A: 1}, 2162 }, 2163 }, 2164 2165 // NilPtrAnonymousHeadUintOnly 2166 { 2167 name: "NilPtrAnonymousHeadUintOnly", 2168 data: struct { 2169 *structUint 2170 }{ 2171 structUint: nil, 2172 }, 2173 }, 2174 { 2175 name: "NilPtrAnonymousHeadUintOnlyOmitEmpty", 2176 data: struct { 2177 *structUintOmitEmpty 2178 }{ 2179 structUintOmitEmpty: nil, 2180 }, 2181 }, 2182 { 2183 name: "NilPtrAnonymousHeadUintOnlyString", 2184 data: struct { 2185 *structUintString 2186 }{ 2187 structUintString: nil, 2188 }, 2189 }, 2190 { 2191 name: "NilPtrAnonymousHeadUintOnlyStringOmitEmpty", 2192 data: struct { 2193 *structUintStringOmitEmpty 2194 }{ 2195 structUintStringOmitEmpty: nil, 2196 }, 2197 }, 2198 2199 // AnonymousHeadUintPtrOnly 2200 { 2201 name: "AnonymousHeadUintPtrOnly", 2202 data: struct { 2203 structUintPtr 2204 }{ 2205 structUintPtr: structUintPtr{A: uptr(1)}, 2206 }, 2207 }, 2208 { 2209 name: "AnonymousHeadUintPtrOnlyOmitEmpty", 2210 data: struct { 2211 structUintPtrOmitEmpty 2212 }{ 2213 structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: uptr(1)}, 2214 }, 2215 }, 2216 { 2217 name: "AnonymousHeadUintPtrOnlyString", 2218 data: struct { 2219 structUintPtrString 2220 }{ 2221 structUintPtrString: structUintPtrString{A: uptr(1)}, 2222 }, 2223 }, 2224 { 2225 name: "AnonymousHeadUintPtrOnlyStringOmitEmpty", 2226 data: struct { 2227 structUintPtrStringOmitEmpty 2228 }{ 2229 structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: uptr(1)}, 2230 }, 2231 }, 2232 2233 // AnonymousHeadUintPtrNilOnly 2234 { 2235 name: "AnonymousHeadUintPtrNilOnly", 2236 data: struct { 2237 structUintPtr 2238 }{ 2239 structUintPtr: structUintPtr{A: nil}, 2240 }, 2241 }, 2242 { 2243 name: "AnonymousHeadUintPtrNilOnlyOmitEmpty", 2244 data: struct { 2245 structUintPtrOmitEmpty 2246 }{ 2247 structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: nil}, 2248 }, 2249 }, 2250 { 2251 name: "AnonymousHeadUintPtrNilOnlyString", 2252 data: struct { 2253 structUintPtrString 2254 }{ 2255 structUintPtrString: structUintPtrString{A: nil}, 2256 }, 2257 }, 2258 { 2259 name: "AnonymousHeadUintPtrNilOnlyStringOmitEmpty", 2260 data: struct { 2261 structUintPtrStringOmitEmpty 2262 }{ 2263 structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: nil}, 2264 }, 2265 }, 2266 2267 // PtrAnonymousHeadUintPtrOnly 2268 { 2269 name: "PtrAnonymousHeadUintPtrOnly", 2270 data: struct { 2271 *structUintPtr 2272 }{ 2273 structUintPtr: &structUintPtr{A: uptr(1)}, 2274 }, 2275 }, 2276 { 2277 name: "PtrAnonymousHeadUintPtrOnlyOmitEmpty", 2278 data: struct { 2279 *structUintPtrOmitEmpty 2280 }{ 2281 structUintPtrOmitEmpty: &structUintPtrOmitEmpty{A: uptr(1)}, 2282 }, 2283 }, 2284 { 2285 name: "PtrAnonymousHeadUintPtrOnlyString", 2286 data: struct { 2287 *structUintPtrString 2288 }{ 2289 structUintPtrString: &structUintPtrString{A: uptr(1)}, 2290 }, 2291 }, 2292 { 2293 name: "PtrAnonymousHeadUintPtrOnlyStringOmitEmpty", 2294 data: struct { 2295 *structUintPtrStringOmitEmpty 2296 }{ 2297 structUintPtrStringOmitEmpty: &structUintPtrStringOmitEmpty{A: uptr(1)}, 2298 }, 2299 }, 2300 2301 // NilPtrAnonymousHeadUintPtrOnly 2302 { 2303 name: "NilPtrAnonymousHeadUintPtrOnly", 2304 data: struct { 2305 *structUintPtr 2306 }{ 2307 structUintPtr: nil, 2308 }, 2309 }, 2310 { 2311 name: "NilPtrAnonymousHeadUintPtrOnlyOmitEmpty", 2312 data: struct { 2313 *structUintPtrOmitEmpty 2314 }{ 2315 structUintPtrOmitEmpty: nil, 2316 }, 2317 }, 2318 { 2319 name: "NilPtrAnonymousHeadUintPtrOnlyString", 2320 data: struct { 2321 *structUintPtrString 2322 }{ 2323 structUintPtrString: nil, 2324 }, 2325 }, 2326 { 2327 name: "NilPtrAnonymousHeadUintPtrOnlyStringOmitEmpty", 2328 data: struct { 2329 *structUintPtrStringOmitEmpty 2330 }{ 2331 structUintPtrStringOmitEmpty: nil, 2332 }, 2333 }, 2334 } 2335 for _, test := range tests { 2336 for _, indent := range []bool{true, false} { 2337 for _, htmlEscape := range []bool{true, false} { 2338 t.Run(fmt.Sprintf("%s_indent_%t_escape_%t", test.name, indent, htmlEscape), func(t *testing.T) { 2339 var buf bytes.Buffer 2340 enc := json.NewEncoder(&buf) 2341 enc.SetEscapeHTML(htmlEscape) 2342 if indent { 2343 enc.SetIndent("", " ") 2344 } 2345 if err := enc.Encode(test.data); err != nil { 2346 t.Fatalf("%s(htmlEscape:%T): %+v: %s", test.name, htmlEscape, test.data, err) 2347 } 2348 stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape) 2349 if buf.String() != stdresult { 2350 t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String()) 2351 } 2352 }) 2353 } 2354 } 2355 } 2356 }