github.com/grbit/go-json@v0.11.0/test/cover/cover_uint16_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 TestCoverUint16(t *testing.T) { 12 type structUint16 struct { 13 A uint16 `json:"a"` 14 } 15 type structUint16OmitEmpty struct { 16 A uint16 `json:"a,omitempty"` 17 } 18 type structUint16String struct { 19 A uint16 `json:"a,string"` 20 } 21 22 type structUint16Ptr struct { 23 A *uint16 `json:"a"` 24 } 25 type structUint16PtrOmitEmpty struct { 26 A *uint16 `json:"a,omitempty"` 27 } 28 type structUint16PtrString struct { 29 A *uint16 `json:"a,string"` 30 } 31 32 tests := []struct { 33 name string 34 data interface{} 35 }{ 36 { 37 name: "Uint16", 38 data: uint16(10), 39 }, 40 { 41 name: "Uint16Ptr", 42 data: uint16ptr(10), 43 }, 44 { 45 name: "Uint16Ptr3", 46 data: uint16ptr3(10), 47 }, 48 { 49 name: "Uint16PtrNil", 50 data: (*uint16)(nil), 51 }, 52 { 53 name: "Uint16Ptr3Nil", 54 data: (***uint16)(nil), 55 }, 56 57 // HeadUint16Zero 58 { 59 name: "HeadUint16Zero", 60 data: struct { 61 A uint16 `json:"a"` 62 }{}, 63 }, 64 { 65 name: "HeadUint16ZeroOmitEmpty", 66 data: struct { 67 A uint16 `json:"a,omitempty"` 68 }{}, 69 }, 70 { 71 name: "HeadUint16ZeroString", 72 data: struct { 73 A uint16 `json:"a,string"` 74 }{}, 75 }, 76 77 // HeadUint16 78 { 79 name: "HeadUint16", 80 data: struct { 81 A uint16 `json:"a"` 82 }{A: 1}, 83 }, 84 { 85 name: "HeadUint16OmitEmpty", 86 data: struct { 87 A uint16 `json:"a,omitempty"` 88 }{A: 1}, 89 }, 90 { 91 name: "HeadUint16String", 92 data: struct { 93 A uint16 `json:"a,string"` 94 }{A: 1}, 95 }, 96 97 // HeadUint16Ptr 98 { 99 name: "HeadUint16Ptr", 100 data: struct { 101 A *uint16 `json:"a"` 102 }{A: uint16ptr(1)}, 103 }, 104 { 105 name: "HeadUint16PtrOmitEmpty", 106 data: struct { 107 A *uint16 `json:"a,omitempty"` 108 }{A: uint16ptr(1)}, 109 }, 110 { 111 name: "HeadUint16PtrString", 112 data: struct { 113 A *uint16 `json:"a,string"` 114 }{A: uint16ptr(1)}, 115 }, 116 117 // HeadUint16PtrNil 118 { 119 name: "HeadUint16PtrNil", 120 data: struct { 121 A *uint16 `json:"a"` 122 }{A: nil}, 123 }, 124 { 125 name: "HeadUint16PtrNilOmitEmpty", 126 data: struct { 127 A *uint16 `json:"a,omitempty"` 128 }{A: nil}, 129 }, 130 { 131 name: "HeadUint16PtrNilString", 132 data: struct { 133 A *uint16 `json:"a,string"` 134 }{A: nil}, 135 }, 136 137 // PtrHeadUint16Zero 138 { 139 name: "PtrHeadUint16Zero", 140 data: &struct { 141 A uint16 `json:"a"` 142 }{}, 143 }, 144 { 145 name: "PtrHeadUint16ZeroOmitEmpty", 146 data: &struct { 147 A uint16 `json:"a,omitempty"` 148 }{}, 149 }, 150 { 151 name: "PtrHeadUint16ZeroString", 152 data: &struct { 153 A uint16 `json:"a,string"` 154 }{}, 155 }, 156 157 // PtrHeadUint16 158 { 159 name: "PtrHeadUint16", 160 data: &struct { 161 A uint16 `json:"a"` 162 }{A: 1}, 163 }, 164 { 165 name: "PtrHeadUint16OmitEmpty", 166 data: &struct { 167 A uint16 `json:"a,omitempty"` 168 }{A: 1}, 169 }, 170 { 171 name: "PtrHeadUint16String", 172 data: &struct { 173 A uint16 `json:"a,string"` 174 }{A: 1}, 175 }, 176 177 // PtrHeadUint16Ptr 178 { 179 name: "PtrHeadUint16Ptr", 180 data: &struct { 181 A *uint16 `json:"a"` 182 }{A: uint16ptr(1)}, 183 }, 184 { 185 name: "PtrHeadUint16PtrOmitEmpty", 186 data: &struct { 187 A *uint16 `json:"a,omitempty"` 188 }{A: uint16ptr(1)}, 189 }, 190 { 191 name: "PtrHeadUint16PtrString", 192 data: &struct { 193 A *uint16 `json:"a,string"` 194 }{A: uint16ptr(1)}, 195 }, 196 197 // PtrHeadUint16PtrNil 198 { 199 name: "PtrHeadUint16PtrNil", 200 data: &struct { 201 A *uint16 `json:"a"` 202 }{A: nil}, 203 }, 204 { 205 name: "PtrHeadUint16PtrNilOmitEmpty", 206 data: &struct { 207 A *uint16 `json:"a,omitempty"` 208 }{A: nil}, 209 }, 210 { 211 name: "PtrHeadUint16PtrNilString", 212 data: &struct { 213 A *uint16 `json:"a,string"` 214 }{A: nil}, 215 }, 216 217 // PtrHeadUint16Nil 218 { 219 name: "PtrHeadUint16Nil", 220 data: (*struct { 221 A *uint16 `json:"a"` 222 })(nil), 223 }, 224 { 225 name: "PtrHeadUint16NilOmitEmpty", 226 data: (*struct { 227 A *uint16 `json:"a,omitempty"` 228 })(nil), 229 }, 230 { 231 name: "PtrHeadUint16NilString", 232 data: (*struct { 233 A *uint16 `json:"a,string"` 234 })(nil), 235 }, 236 237 // HeadUint16ZeroMultiFields 238 { 239 name: "HeadUint16ZeroMultiFields", 240 data: struct { 241 A uint16 `json:"a"` 242 B uint16 `json:"b"` 243 C uint16 `json:"c"` 244 }{}, 245 }, 246 { 247 name: "HeadUint16ZeroMultiFieldsOmitEmpty", 248 data: struct { 249 A uint16 `json:"a,omitempty"` 250 B uint16 `json:"b,omitempty"` 251 C uint16 `json:"c,omitempty"` 252 }{}, 253 }, 254 { 255 name: "HeadUint16ZeroMultiFields", 256 data: struct { 257 A uint16 `json:"a,string"` 258 B uint16 `json:"b,string"` 259 C uint16 `json:"c,string"` 260 }{}, 261 }, 262 263 // HeadUint16MultiFields 264 { 265 name: "HeadUint16MultiFields", 266 data: struct { 267 A uint16 `json:"a"` 268 B uint16 `json:"b"` 269 C uint16 `json:"c"` 270 }{A: 1, B: 2, C: 3}, 271 }, 272 { 273 name: "HeadUint16MultiFieldsOmitEmpty", 274 data: struct { 275 A uint16 `json:"a,omitempty"` 276 B uint16 `json:"b,omitempty"` 277 C uint16 `json:"c,omitempty"` 278 }{A: 1, B: 2, C: 3}, 279 }, 280 { 281 name: "HeadUint16MultiFieldsString", 282 data: struct { 283 A uint16 `json:"a,string"` 284 B uint16 `json:"b,string"` 285 C uint16 `json:"c,string"` 286 }{A: 1, B: 2, C: 3}, 287 }, 288 289 // HeadUint16PtrMultiFields 290 { 291 name: "HeadUint16PtrMultiFields", 292 data: struct { 293 A *uint16 `json:"a"` 294 B *uint16 `json:"b"` 295 C *uint16 `json:"c"` 296 }{A: uint16ptr(1), B: uint16ptr(2), C: uint16ptr(3)}, 297 }, 298 { 299 name: "HeadUint16PtrMultiFieldsOmitEmpty", 300 data: struct { 301 A *uint16 `json:"a,omitempty"` 302 B *uint16 `json:"b,omitempty"` 303 C *uint16 `json:"c,omitempty"` 304 }{A: uint16ptr(1), B: uint16ptr(2), C: uint16ptr(3)}, 305 }, 306 { 307 name: "HeadUint16PtrMultiFieldsString", 308 data: struct { 309 A *uint16 `json:"a,string"` 310 B *uint16 `json:"b,string"` 311 C *uint16 `json:"c,string"` 312 }{A: uint16ptr(1), B: uint16ptr(2), C: uint16ptr(3)}, 313 }, 314 315 // HeadUint16PtrNilMultiFields 316 { 317 name: "HeadUint16PtrNilMultiFields", 318 data: struct { 319 A *uint16 `json:"a"` 320 B *uint16 `json:"b"` 321 C *uint16 `json:"c"` 322 }{A: nil, B: nil, C: nil}, 323 }, 324 { 325 name: "HeadUint16PtrNilMultiFieldsOmitEmpty", 326 data: struct { 327 A *uint16 `json:"a,omitempty"` 328 B *uint16 `json:"b,omitempty"` 329 C *uint16 `json:"c,omitempty"` 330 }{A: nil, B: nil, C: nil}, 331 }, 332 { 333 name: "HeadUint16PtrNilMultiFieldsString", 334 data: struct { 335 A *uint16 `json:"a,string"` 336 B *uint16 `json:"b,string"` 337 C *uint16 `json:"c,string"` 338 }{A: nil, B: nil, C: nil}, 339 }, 340 341 // PtrHeadUint16ZeroMultiFields 342 { 343 name: "PtrHeadUint16ZeroMultiFields", 344 data: &struct { 345 A uint16 `json:"a"` 346 B uint16 `json:"b"` 347 }{}, 348 }, 349 { 350 name: "PtrHeadUint16ZeroMultiFieldsOmitEmpty", 351 data: &struct { 352 A uint16 `json:"a,omitempty"` 353 B uint16 `json:"b,omitempty"` 354 }{}, 355 }, 356 { 357 name: "PtrHeadUint16ZeroMultiFieldsString", 358 data: &struct { 359 A uint16 `json:"a,string"` 360 B uint16 `json:"b,string"` 361 }{}, 362 }, 363 364 // PtrHeadUint16MultiFields 365 { 366 name: "PtrHeadUint16MultiFields", 367 data: &struct { 368 A uint16 `json:"a"` 369 B uint16 `json:"b"` 370 }{A: 1, B: 2}, 371 }, 372 { 373 name: "PtrHeadUint16MultiFieldsOmitEmpty", 374 data: &struct { 375 A uint16 `json:"a,omitempty"` 376 B uint16 `json:"b,omitempty"` 377 }{A: 1, B: 2}, 378 }, 379 { 380 name: "PtrHeadUint16MultiFieldsString", 381 data: &struct { 382 A uint16 `json:"a,string"` 383 B uint16 `json:"b,string"` 384 }{A: 1, B: 2}, 385 }, 386 387 // PtrHeadUint16PtrMultiFields 388 { 389 name: "PtrHeadUint16PtrMultiFields", 390 data: &struct { 391 A *uint16 `json:"a"` 392 B *uint16 `json:"b"` 393 }{A: uint16ptr(1), B: uint16ptr(2)}, 394 }, 395 { 396 name: "PtrHeadUint16PtrMultiFieldsOmitEmpty", 397 data: &struct { 398 A *uint16 `json:"a,omitempty"` 399 B *uint16 `json:"b,omitempty"` 400 }{A: uint16ptr(1), B: uint16ptr(2)}, 401 }, 402 { 403 name: "PtrHeadUint16PtrMultiFieldsString", 404 data: &struct { 405 A *uint16 `json:"a,string"` 406 B *uint16 `json:"b,string"` 407 }{A: uint16ptr(1), B: uint16ptr(2)}, 408 }, 409 410 // PtrHeadUint16PtrNilMultiFields 411 { 412 name: "PtrHeadUint16PtrNilMultiFields", 413 data: &struct { 414 A *uint16 `json:"a"` 415 B *uint16 `json:"b"` 416 }{A: nil, B: nil}, 417 }, 418 { 419 name: "PtrHeadUint16PtrNilMultiFieldsOmitEmpty", 420 data: &struct { 421 A *uint16 `json:"a,omitempty"` 422 B *uint16 `json:"b,omitempty"` 423 }{A: nil, B: nil}, 424 }, 425 { 426 name: "PtrHeadUint16PtrNilMultiFieldsString", 427 data: &struct { 428 A *uint16 `json:"a,string"` 429 B *uint16 `json:"b,string"` 430 }{A: nil, B: nil}, 431 }, 432 433 // PtrHeadUint16NilMultiFields 434 { 435 name: "PtrHeadUint16NilMultiFields", 436 data: (*struct { 437 A *uint16 `json:"a"` 438 B *uint16 `json:"b"` 439 })(nil), 440 }, 441 { 442 name: "PtrHeadUint16NilMultiFieldsOmitEmpty", 443 data: (*struct { 444 A *uint16 `json:"a,omitempty"` 445 B *uint16 `json:"b,omitempty"` 446 })(nil), 447 }, 448 { 449 name: "PtrHeadUint16NilMultiFieldsString", 450 data: (*struct { 451 A *uint16 `json:"a,string"` 452 B *uint16 `json:"b,string"` 453 })(nil), 454 }, 455 456 // HeadUint16ZeroNotRoot 457 { 458 name: "HeadUint16ZeroNotRoot", 459 data: struct { 460 A struct { 461 A uint16 `json:"a"` 462 } 463 }{}, 464 }, 465 { 466 name: "HeadUint16ZeroNotRootOmitEmpty", 467 data: struct { 468 A struct { 469 A uint16 `json:"a,omitempty"` 470 } 471 }{}, 472 }, 473 { 474 name: "HeadUint16ZeroNotRootString", 475 data: struct { 476 A struct { 477 A uint16 `json:"a,string"` 478 } 479 }{}, 480 }, 481 482 // HeadUint16NotRoot 483 { 484 name: "HeadUint16NotRoot", 485 data: struct { 486 A struct { 487 A uint16 `json:"a"` 488 } 489 }{A: struct { 490 A uint16 `json:"a"` 491 }{A: 1}}, 492 }, 493 { 494 name: "HeadUint16NotRootOmitEmpty", 495 data: struct { 496 A struct { 497 A uint16 `json:"a,omitempty"` 498 } 499 }{A: struct { 500 A uint16 `json:"a,omitempty"` 501 }{A: 1}}, 502 }, 503 { 504 name: "HeadUint16NotRootString", 505 data: struct { 506 A struct { 507 A uint16 `json:"a,string"` 508 } 509 }{A: struct { 510 A uint16 `json:"a,string"` 511 }{A: 1}}, 512 }, 513 514 // HeadUint16PtrNotRoot 515 { 516 name: "HeadUint16PtrNotRoot", 517 data: struct { 518 A struct { 519 A *uint16 `json:"a"` 520 } 521 }{A: struct { 522 A *uint16 `json:"a"` 523 }{uint16ptr(1)}}, 524 }, 525 { 526 name: "HeadUint16PtrNotRootOmitEmpty", 527 data: struct { 528 A struct { 529 A *uint16 `json:"a,omitempty"` 530 } 531 }{A: struct { 532 A *uint16 `json:"a,omitempty"` 533 }{uint16ptr(1)}}, 534 }, 535 { 536 name: "HeadUint16PtrNotRootString", 537 data: struct { 538 A struct { 539 A *uint16 `json:"a,string"` 540 } 541 }{A: struct { 542 A *uint16 `json:"a,string"` 543 }{uint16ptr(1)}}, 544 }, 545 546 // HeadUint16PtrNilNotRoot 547 { 548 name: "HeadUint16PtrNilNotRoot", 549 data: struct { 550 A struct { 551 A *uint16 `json:"a"` 552 } 553 }{}, 554 }, 555 { 556 name: "HeadUint16PtrNilNotRootOmitEmpty", 557 data: struct { 558 A struct { 559 A *uint16 `json:"a,omitempty"` 560 } 561 }{}, 562 }, 563 { 564 name: "HeadUint16PtrNilNotRootString", 565 data: struct { 566 A struct { 567 A *uint16 `json:"a,string"` 568 } 569 }{}, 570 }, 571 572 // PtrHeadUint16ZeroNotRoot 573 { 574 name: "PtrHeadUint16ZeroNotRoot", 575 data: struct { 576 A *struct { 577 A uint16 `json:"a"` 578 } 579 }{A: new(struct { 580 A uint16 `json:"a"` 581 })}, 582 }, 583 { 584 name: "PtrHeadUint16ZeroNotRootOmitEmpty", 585 data: struct { 586 A *struct { 587 A uint16 `json:"a,omitempty"` 588 } 589 }{A: new(struct { 590 A uint16 `json:"a,omitempty"` 591 })}, 592 }, 593 { 594 name: "PtrHeadUint16ZeroNotRootString", 595 data: struct { 596 A *struct { 597 A uint16 `json:"a,string"` 598 } 599 }{A: new(struct { 600 A uint16 `json:"a,string"` 601 })}, 602 }, 603 604 // PtrHeadUint16NotRoot 605 { 606 name: "PtrHeadUint16NotRoot", 607 data: struct { 608 A *struct { 609 A uint16 `json:"a"` 610 } 611 }{A: &(struct { 612 A uint16 `json:"a"` 613 }{A: 1})}, 614 }, 615 { 616 name: "PtrHeadUint16NotRootOmitEmpty", 617 data: struct { 618 A *struct { 619 A uint16 `json:"a,omitempty"` 620 } 621 }{A: &(struct { 622 A uint16 `json:"a,omitempty"` 623 }{A: 1})}, 624 }, 625 { 626 name: "PtrHeadUint16NotRootString", 627 data: struct { 628 A *struct { 629 A uint16 `json:"a,string"` 630 } 631 }{A: &(struct { 632 A uint16 `json:"a,string"` 633 }{A: 1})}, 634 }, 635 636 // PtrHeadUint16PtrNotRoot 637 { 638 name: "PtrHeadUint16PtrNotRoot", 639 data: struct { 640 A *struct { 641 A *uint16 `json:"a"` 642 } 643 }{A: &(struct { 644 A *uint16 `json:"a"` 645 }{A: uint16ptr(1)})}, 646 }, 647 { 648 name: "PtrHeadUint16PtrNotRootOmitEmpty", 649 data: struct { 650 A *struct { 651 A *uint16 `json:"a,omitempty"` 652 } 653 }{A: &(struct { 654 A *uint16 `json:"a,omitempty"` 655 }{A: uint16ptr(1)})}, 656 }, 657 { 658 name: "PtrHeadUint16PtrNotRootString", 659 data: struct { 660 A *struct { 661 A *uint16 `json:"a,string"` 662 } 663 }{A: &(struct { 664 A *uint16 `json:"a,string"` 665 }{A: uint16ptr(1)})}, 666 }, 667 668 // PtrHeadUint16PtrNilNotRoot 669 { 670 name: "PtrHeadUint16PtrNilNotRoot", 671 data: struct { 672 A *struct { 673 A *uint16 `json:"a"` 674 } 675 }{A: &(struct { 676 A *uint16 `json:"a"` 677 }{A: nil})}, 678 }, 679 { 680 name: "PtrHeadUint16PtrNilNotRootOmitEmpty", 681 data: struct { 682 A *struct { 683 A *uint16 `json:"a,omitempty"` 684 } 685 }{A: &(struct { 686 A *uint16 `json:"a,omitempty"` 687 }{A: nil})}, 688 }, 689 { 690 name: "PtrHeadUint16PtrNilNotRootString", 691 data: struct { 692 A *struct { 693 A *uint16 `json:"a,string"` 694 } 695 }{A: &(struct { 696 A *uint16 `json:"a,string"` 697 }{A: nil})}, 698 }, 699 700 // PtrHeadUint16NilNotRoot 701 { 702 name: "PtrHeadUint16NilNotRoot", 703 data: struct { 704 A *struct { 705 A *uint16 `json:"a"` 706 } 707 }{A: nil}, 708 }, 709 { 710 name: "PtrHeadUint16NilNotRootOmitEmpty", 711 data: struct { 712 A *struct { 713 A *uint16 `json:"a,omitempty"` 714 } `json:",omitempty"` 715 }{A: nil}, 716 }, 717 { 718 name: "PtrHeadUint16NilNotRootString", 719 data: struct { 720 A *struct { 721 A *uint16 `json:"a,string"` 722 } `json:",string"` 723 }{A: nil}, 724 }, 725 726 // HeadUint16ZeroMultiFieldsNotRoot 727 { 728 name: "HeadUint16ZeroMultiFieldsNotRoot", 729 data: struct { 730 A struct { 731 A uint16 `json:"a"` 732 } 733 B struct { 734 B uint16 `json:"b"` 735 } 736 }{}, 737 }, 738 { 739 name: "HeadUint16ZeroMultiFieldsNotRootOmitEmpty", 740 data: struct { 741 A struct { 742 A uint16 `json:"a,omitempty"` 743 } 744 B struct { 745 B uint16 `json:"b,omitempty"` 746 } 747 }{}, 748 }, 749 { 750 name: "HeadUint16ZeroMultiFieldsNotRootString", 751 data: struct { 752 A struct { 753 A uint16 `json:"a,string"` 754 } 755 B struct { 756 B uint16 `json:"b,string"` 757 } 758 }{}, 759 }, 760 761 // HeadUint16MultiFieldsNotRoot 762 { 763 name: "HeadUint16MultiFieldsNotRoot", 764 data: struct { 765 A struct { 766 A uint16 `json:"a"` 767 } 768 B struct { 769 B uint16 `json:"b"` 770 } 771 }{A: struct { 772 A uint16 `json:"a"` 773 }{A: 1}, B: struct { 774 B uint16 `json:"b"` 775 }{B: 2}}, 776 }, 777 { 778 name: "HeadUint16MultiFieldsNotRootOmitEmpty", 779 data: struct { 780 A struct { 781 A uint16 `json:"a,omitempty"` 782 } 783 B struct { 784 B uint16 `json:"b,omitempty"` 785 } 786 }{A: struct { 787 A uint16 `json:"a,omitempty"` 788 }{A: 1}, B: struct { 789 B uint16 `json:"b,omitempty"` 790 }{B: 2}}, 791 }, 792 { 793 name: "HeadUint16MultiFieldsNotRootString", 794 data: struct { 795 A struct { 796 A uint16 `json:"a,string"` 797 } 798 B struct { 799 B uint16 `json:"b,string"` 800 } 801 }{A: struct { 802 A uint16 `json:"a,string"` 803 }{A: 1}, B: struct { 804 B uint16 `json:"b,string"` 805 }{B: 2}}, 806 }, 807 808 // HeadUint16PtrMultiFieldsNotRoot 809 { 810 name: "HeadUint16PtrMultiFieldsNotRoot", 811 data: struct { 812 A struct { 813 A *uint16 `json:"a"` 814 } 815 B struct { 816 B *uint16 `json:"b"` 817 } 818 }{A: struct { 819 A *uint16 `json:"a"` 820 }{A: uint16ptr(1)}, B: struct { 821 B *uint16 `json:"b"` 822 }{B: uint16ptr(2)}}, 823 }, 824 { 825 name: "HeadUint16PtrMultiFieldsNotRootOmitEmpty", 826 data: struct { 827 A struct { 828 A *uint16 `json:"a,omitempty"` 829 } 830 B struct { 831 B *uint16 `json:"b,omitempty"` 832 } 833 }{A: struct { 834 A *uint16 `json:"a,omitempty"` 835 }{A: uint16ptr(1)}, B: struct { 836 B *uint16 `json:"b,omitempty"` 837 }{B: uint16ptr(2)}}, 838 }, 839 { 840 name: "HeadUint16PtrMultiFieldsNotRootString", 841 data: struct { 842 A struct { 843 A *uint16 `json:"a,string"` 844 } 845 B struct { 846 B *uint16 `json:"b,string"` 847 } 848 }{A: struct { 849 A *uint16 `json:"a,string"` 850 }{A: uint16ptr(1)}, B: struct { 851 B *uint16 `json:"b,string"` 852 }{B: uint16ptr(2)}}, 853 }, 854 855 // HeadUint16PtrNilMultiFieldsNotRoot 856 { 857 name: "HeadUint16PtrNilMultiFieldsNotRoot", 858 data: struct { 859 A struct { 860 A *uint16 `json:"a"` 861 } 862 B struct { 863 B *uint16 `json:"b"` 864 } 865 }{A: struct { 866 A *uint16 `json:"a"` 867 }{A: nil}, B: struct { 868 B *uint16 `json:"b"` 869 }{B: nil}}, 870 }, 871 { 872 name: "HeadUint16PtrNilMultiFieldsNotRootOmitEmpty", 873 data: struct { 874 A struct { 875 A *uint16 `json:"a,omitempty"` 876 } 877 B struct { 878 B *uint16 `json:"b,omitempty"` 879 } 880 }{A: struct { 881 A *uint16 `json:"a,omitempty"` 882 }{A: nil}, B: struct { 883 B *uint16 `json:"b,omitempty"` 884 }{B: nil}}, 885 }, 886 { 887 name: "HeadUint16PtrNilMultiFieldsNotRootString", 888 data: struct { 889 A struct { 890 A *uint16 `json:"a,string"` 891 } 892 B struct { 893 B *uint16 `json:"b,string"` 894 } 895 }{A: struct { 896 A *uint16 `json:"a,string"` 897 }{A: nil}, B: struct { 898 B *uint16 `json:"b,string"` 899 }{B: nil}}, 900 }, 901 902 // PtrHeadUint16ZeroMultiFieldsNotRoot 903 { 904 name: "PtrHeadUint16ZeroMultiFieldsNotRoot", 905 data: &struct { 906 A struct { 907 A uint16 `json:"a"` 908 } 909 B struct { 910 B uint16 `json:"b"` 911 } 912 }{}, 913 }, 914 { 915 name: "PtrHeadUint16ZeroMultiFieldsNotRootOmitEmpty", 916 data: &struct { 917 A struct { 918 A uint16 `json:"a,omitempty"` 919 } 920 B struct { 921 B uint16 `json:"b,omitempty"` 922 } 923 }{}, 924 }, 925 { 926 name: "PtrHeadUint16ZeroMultiFieldsNotRootString", 927 data: &struct { 928 A struct { 929 A uint16 `json:"a,string"` 930 } 931 B struct { 932 B uint16 `json:"b,string"` 933 } 934 }{}, 935 }, 936 937 // PtrHeadUint16MultiFieldsNotRoot 938 { 939 name: "PtrHeadUint16MultiFieldsNotRoot", 940 data: &struct { 941 A struct { 942 A uint16 `json:"a"` 943 } 944 B struct { 945 B uint16 `json:"b"` 946 } 947 }{A: struct { 948 A uint16 `json:"a"` 949 }{A: 1}, B: struct { 950 B uint16 `json:"b"` 951 }{B: 2}}, 952 }, 953 { 954 name: "PtrHeadUint16MultiFieldsNotRootOmitEmpty", 955 data: &struct { 956 A struct { 957 A uint16 `json:"a,omitempty"` 958 } 959 B struct { 960 B uint16 `json:"b,omitempty"` 961 } 962 }{A: struct { 963 A uint16 `json:"a,omitempty"` 964 }{A: 1}, B: struct { 965 B uint16 `json:"b,omitempty"` 966 }{B: 2}}, 967 }, 968 { 969 name: "PtrHeadUint16MultiFieldsNotRootString", 970 data: &struct { 971 A struct { 972 A uint16 `json:"a,string"` 973 } 974 B struct { 975 B uint16 `json:"b,string"` 976 } 977 }{A: struct { 978 A uint16 `json:"a,string"` 979 }{A: 1}, B: struct { 980 B uint16 `json:"b,string"` 981 }{B: 2}}, 982 }, 983 984 // PtrHeadUint16PtrMultiFieldsNotRoot 985 { 986 name: "PtrHeadUint16PtrMultiFieldsNotRoot", 987 data: &struct { 988 A *struct { 989 A *uint16 `json:"a"` 990 } 991 B *struct { 992 B *uint16 `json:"b"` 993 } 994 }{A: &(struct { 995 A *uint16 `json:"a"` 996 }{A: uint16ptr(1)}), B: &(struct { 997 B *uint16 `json:"b"` 998 }{B: uint16ptr(2)})}, 999 }, 1000 { 1001 name: "PtrHeadUint16PtrMultiFieldsNotRootOmitEmpty", 1002 data: &struct { 1003 A *struct { 1004 A *uint16 `json:"a,omitempty"` 1005 } 1006 B *struct { 1007 B *uint16 `json:"b,omitempty"` 1008 } 1009 }{A: &(struct { 1010 A *uint16 `json:"a,omitempty"` 1011 }{A: uint16ptr(1)}), B: &(struct { 1012 B *uint16 `json:"b,omitempty"` 1013 }{B: uint16ptr(2)})}, 1014 }, 1015 { 1016 name: "PtrHeadUint16PtrMultiFieldsNotRootString", 1017 data: &struct { 1018 A *struct { 1019 A *uint16 `json:"a,string"` 1020 } 1021 B *struct { 1022 B *uint16 `json:"b,string"` 1023 } 1024 }{A: &(struct { 1025 A *uint16 `json:"a,string"` 1026 }{A: uint16ptr(1)}), B: &(struct { 1027 B *uint16 `json:"b,string"` 1028 }{B: uint16ptr(2)})}, 1029 }, 1030 1031 // PtrHeadUint16PtrNilMultiFieldsNotRoot 1032 { 1033 name: "PtrHeadUint16PtrNilMultiFieldsNotRoot", 1034 data: &struct { 1035 A *struct { 1036 A *uint16 `json:"a"` 1037 } 1038 B *struct { 1039 B *uint16 `json:"b"` 1040 } 1041 }{A: nil, B: nil}, 1042 }, 1043 { 1044 name: "PtrHeadUint16PtrNilMultiFieldsNotRootOmitEmpty", 1045 data: &struct { 1046 A *struct { 1047 A *uint16 `json:"a,omitempty"` 1048 } `json:",omitempty"` 1049 B *struct { 1050 B *uint16 `json:"b,omitempty"` 1051 } `json:",omitempty"` 1052 }{A: nil, B: nil}, 1053 }, 1054 { 1055 name: "PtrHeadUint16PtrNilMultiFieldsNotRootString", 1056 data: &struct { 1057 A *struct { 1058 A *uint16 `json:"a,string"` 1059 } `json:",string"` 1060 B *struct { 1061 B *uint16 `json:"b,string"` 1062 } `json:",string"` 1063 }{A: nil, B: nil}, 1064 }, 1065 1066 // PtrHeadUint16NilMultiFieldsNotRoot 1067 { 1068 name: "PtrHeadUint16NilMultiFieldsNotRoot", 1069 data: (*struct { 1070 A *struct { 1071 A *uint16 `json:"a"` 1072 } 1073 B *struct { 1074 B *uint16 `json:"b"` 1075 } 1076 })(nil), 1077 }, 1078 { 1079 name: "PtrHeadUint16NilMultiFieldsNotRootOmitEmpty", 1080 data: (*struct { 1081 A *struct { 1082 A *uint16 `json:"a,omitempty"` 1083 } 1084 B *struct { 1085 B *uint16 `json:"b,omitempty"` 1086 } 1087 })(nil), 1088 }, 1089 { 1090 name: "PtrHeadUint16NilMultiFieldsNotRootString", 1091 data: (*struct { 1092 A *struct { 1093 A *uint16 `json:"a,string"` 1094 } 1095 B *struct { 1096 B *uint16 `json:"b,string"` 1097 } 1098 })(nil), 1099 }, 1100 1101 // PtrHeadUint16DoubleMultiFieldsNotRoot 1102 { 1103 name: "PtrHeadUint16DoubleMultiFieldsNotRoot", 1104 data: &struct { 1105 A *struct { 1106 A uint16 `json:"a"` 1107 B uint16 `json:"b"` 1108 } 1109 B *struct { 1110 A uint16 `json:"a"` 1111 B uint16 `json:"b"` 1112 } 1113 }{A: &(struct { 1114 A uint16 `json:"a"` 1115 B uint16 `json:"b"` 1116 }{A: 1, B: 2}), B: &(struct { 1117 A uint16 `json:"a"` 1118 B uint16 `json:"b"` 1119 }{A: 3, B: 4})}, 1120 }, 1121 { 1122 name: "PtrHeadUint16DoubleMultiFieldsNotRootOmitEmpty", 1123 data: &struct { 1124 A *struct { 1125 A uint16 `json:"a,omitempty"` 1126 B uint16 `json:"b,omitempty"` 1127 } 1128 B *struct { 1129 A uint16 `json:"a,omitempty"` 1130 B uint16 `json:"b,omitempty"` 1131 } 1132 }{A: &(struct { 1133 A uint16 `json:"a,omitempty"` 1134 B uint16 `json:"b,omitempty"` 1135 }{A: 1, B: 2}), B: &(struct { 1136 A uint16 `json:"a,omitempty"` 1137 B uint16 `json:"b,omitempty"` 1138 }{A: 3, B: 4})}, 1139 }, 1140 { 1141 name: "PtrHeadUint16DoubleMultiFieldsNotRootString", 1142 data: &struct { 1143 A *struct { 1144 A uint16 `json:"a,string"` 1145 B uint16 `json:"b,string"` 1146 } 1147 B *struct { 1148 A uint16 `json:"a,string"` 1149 B uint16 `json:"b,string"` 1150 } 1151 }{A: &(struct { 1152 A uint16 `json:"a,string"` 1153 B uint16 `json:"b,string"` 1154 }{A: 1, B: 2}), B: &(struct { 1155 A uint16 `json:"a,string"` 1156 B uint16 `json:"b,string"` 1157 }{A: 3, B: 4})}, 1158 }, 1159 1160 // PtrHeadUint16NilDoubleMultiFieldsNotRoot 1161 { 1162 name: "PtrHeadUint16NilDoubleMultiFieldsNotRoot", 1163 data: &struct { 1164 A *struct { 1165 A uint16 `json:"a"` 1166 B uint16 `json:"b"` 1167 } 1168 B *struct { 1169 A uint16 `json:"a"` 1170 B uint16 `json:"b"` 1171 } 1172 }{A: nil, B: nil}, 1173 }, 1174 { 1175 name: "PtrHeadUint16NilDoubleMultiFieldsNotRootOmitEmpty", 1176 data: &struct { 1177 A *struct { 1178 A uint16 `json:"a,omitempty"` 1179 B uint16 `json:"b,omitempty"` 1180 } `json:",omitempty"` 1181 B *struct { 1182 A uint16 `json:"a,omitempty"` 1183 B uint16 `json:"b,omitempty"` 1184 } `json:",omitempty"` 1185 }{A: nil, B: nil}, 1186 }, 1187 { 1188 name: "PtrHeadUint16NilDoubleMultiFieldsNotRootString", 1189 data: &struct { 1190 A *struct { 1191 A uint16 `json:"a,string"` 1192 B uint16 `json:"b,string"` 1193 } 1194 B *struct { 1195 A uint16 `json:"a,string"` 1196 B uint16 `json:"b,string"` 1197 } 1198 }{A: nil, B: nil}, 1199 }, 1200 1201 // PtrHeadUint16NilDoubleMultiFieldsNotRoot 1202 { 1203 name: "PtrHeadUint16NilDoubleMultiFieldsNotRoot", 1204 data: (*struct { 1205 A *struct { 1206 A uint16 `json:"a"` 1207 B uint16 `json:"b"` 1208 } 1209 B *struct { 1210 A uint16 `json:"a"` 1211 B uint16 `json:"b"` 1212 } 1213 })(nil), 1214 }, 1215 { 1216 name: "PtrHeadUint16NilDoubleMultiFieldsNotRootOmitEmpty", 1217 data: (*struct { 1218 A *struct { 1219 A uint16 `json:"a,omitempty"` 1220 B uint16 `json:"b,omitempty"` 1221 } 1222 B *struct { 1223 A uint16 `json:"a,omitempty"` 1224 B uint16 `json:"b,omitempty"` 1225 } 1226 })(nil), 1227 }, 1228 { 1229 name: "PtrHeadUint16NilDoubleMultiFieldsNotRootString", 1230 data: (*struct { 1231 A *struct { 1232 A uint16 `json:"a,string"` 1233 B uint16 `json:"b,string"` 1234 } 1235 B *struct { 1236 A uint16 `json:"a,string"` 1237 B uint16 `json:"b,string"` 1238 } 1239 })(nil), 1240 }, 1241 1242 // PtrHeadUint16PtrDoubleMultiFieldsNotRoot 1243 { 1244 name: "PtrHeadUint16PtrDoubleMultiFieldsNotRoot", 1245 data: &struct { 1246 A *struct { 1247 A *uint16 `json:"a"` 1248 B *uint16 `json:"b"` 1249 } 1250 B *struct { 1251 A *uint16 `json:"a"` 1252 B *uint16 `json:"b"` 1253 } 1254 }{A: &(struct { 1255 A *uint16 `json:"a"` 1256 B *uint16 `json:"b"` 1257 }{A: uint16ptr(1), B: uint16ptr(2)}), B: &(struct { 1258 A *uint16 `json:"a"` 1259 B *uint16 `json:"b"` 1260 }{A: uint16ptr(3), B: uint16ptr(4)})}, 1261 }, 1262 { 1263 name: "PtrHeadUint16PtrDoubleMultiFieldsNotRootOmitEmpty", 1264 data: &struct { 1265 A *struct { 1266 A *uint16 `json:"a,omitempty"` 1267 B *uint16 `json:"b,omitempty"` 1268 } 1269 B *struct { 1270 A *uint16 `json:"a,omitempty"` 1271 B *uint16 `json:"b,omitempty"` 1272 } 1273 }{A: &(struct { 1274 A *uint16 `json:"a,omitempty"` 1275 B *uint16 `json:"b,omitempty"` 1276 }{A: uint16ptr(1), B: uint16ptr(2)}), B: &(struct { 1277 A *uint16 `json:"a,omitempty"` 1278 B *uint16 `json:"b,omitempty"` 1279 }{A: uint16ptr(3), B: uint16ptr(4)})}, 1280 }, 1281 { 1282 name: "PtrHeadUint16PtrDoubleMultiFieldsNotRootString", 1283 data: &struct { 1284 A *struct { 1285 A *uint16 `json:"a,string"` 1286 B *uint16 `json:"b,string"` 1287 } 1288 B *struct { 1289 A *uint16 `json:"a,string"` 1290 B *uint16 `json:"b,string"` 1291 } 1292 }{A: &(struct { 1293 A *uint16 `json:"a,string"` 1294 B *uint16 `json:"b,string"` 1295 }{A: uint16ptr(1), B: uint16ptr(2)}), B: &(struct { 1296 A *uint16 `json:"a,string"` 1297 B *uint16 `json:"b,string"` 1298 }{A: uint16ptr(3), B: uint16ptr(4)})}, 1299 }, 1300 1301 // PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot 1302 { 1303 name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot", 1304 data: &struct { 1305 A *struct { 1306 A *uint16 `json:"a"` 1307 B *uint16 `json:"b"` 1308 } 1309 B *struct { 1310 A *uint16 `json:"a"` 1311 B *uint16 `json:"b"` 1312 } 1313 }{A: nil, B: nil}, 1314 }, 1315 { 1316 name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootOmitEmpty", 1317 data: &struct { 1318 A *struct { 1319 A *uint16 `json:"a,omitempty"` 1320 B *uint16 `json:"b,omitempty"` 1321 } `json:",omitempty"` 1322 B *struct { 1323 A *uint16 `json:"a,omitempty"` 1324 B *uint16 `json:"b,omitempty"` 1325 } `json:",omitempty"` 1326 }{A: nil, B: nil}, 1327 }, 1328 { 1329 name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootString", 1330 data: &struct { 1331 A *struct { 1332 A *uint16 `json:"a,string"` 1333 B *uint16 `json:"b,string"` 1334 } 1335 B *struct { 1336 A *uint16 `json:"a,string"` 1337 B *uint16 `json:"b,string"` 1338 } 1339 }{A: nil, B: nil}, 1340 }, 1341 1342 // PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot 1343 { 1344 name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot", 1345 data: (*struct { 1346 A *struct { 1347 A *uint16 `json:"a"` 1348 B *uint16 `json:"b"` 1349 } 1350 B *struct { 1351 A *uint16 `json:"a"` 1352 B *uint16 `json:"b"` 1353 } 1354 })(nil), 1355 }, 1356 { 1357 name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootOmitEmpty", 1358 data: (*struct { 1359 A *struct { 1360 A *uint16 `json:"a,omitempty"` 1361 B *uint16 `json:"b,omitempty"` 1362 } 1363 B *struct { 1364 A *uint16 `json:"a,omitempty"` 1365 B *uint16 `json:"b,omitempty"` 1366 } 1367 })(nil), 1368 }, 1369 { 1370 name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootString", 1371 data: (*struct { 1372 A *struct { 1373 A *uint16 `json:"a,string"` 1374 B *uint16 `json:"b,string"` 1375 } 1376 B *struct { 1377 A *uint16 `json:"a,string"` 1378 B *uint16 `json:"b,string"` 1379 } 1380 })(nil), 1381 }, 1382 1383 // AnonymousHeadUint16 1384 { 1385 name: "AnonymousHeadUint16", 1386 data: struct { 1387 structUint16 1388 B uint16 `json:"b"` 1389 }{ 1390 structUint16: structUint16{A: 1}, 1391 B: 2, 1392 }, 1393 }, 1394 { 1395 name: "AnonymousHeadUint16OmitEmpty", 1396 data: struct { 1397 structUint16OmitEmpty 1398 B uint16 `json:"b,omitempty"` 1399 }{ 1400 structUint16OmitEmpty: structUint16OmitEmpty{A: 1}, 1401 B: 2, 1402 }, 1403 }, 1404 { 1405 name: "AnonymousHeadUint16String", 1406 data: struct { 1407 structUint16String 1408 B uint16 `json:"b,string"` 1409 }{ 1410 structUint16String: structUint16String{A: 1}, 1411 B: 2, 1412 }, 1413 }, 1414 1415 // PtrAnonymousHeadUint16 1416 { 1417 name: "PtrAnonymousHeadUint16", 1418 data: struct { 1419 *structUint16 1420 B uint16 `json:"b"` 1421 }{ 1422 structUint16: &structUint16{A: 1}, 1423 B: 2, 1424 }, 1425 }, 1426 { 1427 name: "PtrAnonymousHeadUint16OmitEmpty", 1428 data: struct { 1429 *structUint16OmitEmpty 1430 B uint16 `json:"b,omitempty"` 1431 }{ 1432 structUint16OmitEmpty: &structUint16OmitEmpty{A: 1}, 1433 B: 2, 1434 }, 1435 }, 1436 { 1437 name: "PtrAnonymousHeadUint16String", 1438 data: struct { 1439 *structUint16String 1440 B uint16 `json:"b,string"` 1441 }{ 1442 structUint16String: &structUint16String{A: 1}, 1443 B: 2, 1444 }, 1445 }, 1446 1447 // NilPtrAnonymousHeadUint16 1448 { 1449 name: "NilPtrAnonymousHeadUint16", 1450 data: struct { 1451 *structUint16 1452 B uint16 `json:"b"` 1453 }{ 1454 structUint16: nil, 1455 B: 2, 1456 }, 1457 }, 1458 { 1459 name: "NilPtrAnonymousHeadUint16OmitEmpty", 1460 data: struct { 1461 *structUint16OmitEmpty 1462 B uint16 `json:"b,omitempty"` 1463 }{ 1464 structUint16OmitEmpty: nil, 1465 B: 2, 1466 }, 1467 }, 1468 { 1469 name: "NilPtrAnonymousHeadUint16String", 1470 data: struct { 1471 *structUint16String 1472 B uint16 `json:"b,string"` 1473 }{ 1474 structUint16String: nil, 1475 B: 2, 1476 }, 1477 }, 1478 1479 // AnonymousHeadUint16Ptr 1480 { 1481 name: "AnonymousHeadUint16Ptr", 1482 data: struct { 1483 structUint16Ptr 1484 B *uint16 `json:"b"` 1485 }{ 1486 structUint16Ptr: structUint16Ptr{A: uint16ptr(1)}, 1487 B: uint16ptr(2), 1488 }, 1489 }, 1490 { 1491 name: "AnonymousHeadUint16PtrOmitEmpty", 1492 data: struct { 1493 structUint16PtrOmitEmpty 1494 B *uint16 `json:"b,omitempty"` 1495 }{ 1496 structUint16PtrOmitEmpty: structUint16PtrOmitEmpty{A: uint16ptr(1)}, 1497 B: uint16ptr(2), 1498 }, 1499 }, 1500 { 1501 name: "AnonymousHeadUint16PtrString", 1502 data: struct { 1503 structUint16PtrString 1504 B *uint16 `json:"b,string"` 1505 }{ 1506 structUint16PtrString: structUint16PtrString{A: uint16ptr(1)}, 1507 B: uint16ptr(2), 1508 }, 1509 }, 1510 1511 // AnonymousHeadUint16PtrNil 1512 { 1513 name: "AnonymousHeadUint16PtrNil", 1514 data: struct { 1515 structUint16Ptr 1516 B *uint16 `json:"b"` 1517 }{ 1518 structUint16Ptr: structUint16Ptr{A: nil}, 1519 B: uint16ptr(2), 1520 }, 1521 }, 1522 { 1523 name: "AnonymousHeadUint16PtrNilOmitEmpty", 1524 data: struct { 1525 structUint16PtrOmitEmpty 1526 B *uint16 `json:"b,omitempty"` 1527 }{ 1528 structUint16PtrOmitEmpty: structUint16PtrOmitEmpty{A: nil}, 1529 B: uint16ptr(2), 1530 }, 1531 }, 1532 { 1533 name: "AnonymousHeadUint16PtrNilString", 1534 data: struct { 1535 structUint16PtrString 1536 B *uint16 `json:"b,string"` 1537 }{ 1538 structUint16PtrString: structUint16PtrString{A: nil}, 1539 B: uint16ptr(2), 1540 }, 1541 }, 1542 1543 // PtrAnonymousHeadUint16Ptr 1544 { 1545 name: "PtrAnonymousHeadUint16Ptr", 1546 data: struct { 1547 *structUint16Ptr 1548 B *uint16 `json:"b"` 1549 }{ 1550 structUint16Ptr: &structUint16Ptr{A: uint16ptr(1)}, 1551 B: uint16ptr(2), 1552 }, 1553 }, 1554 { 1555 name: "PtrAnonymousHeadUint16PtrOmitEmpty", 1556 data: struct { 1557 *structUint16PtrOmitEmpty 1558 B *uint16 `json:"b,omitempty"` 1559 }{ 1560 structUint16PtrOmitEmpty: &structUint16PtrOmitEmpty{A: uint16ptr(1)}, 1561 B: uint16ptr(2), 1562 }, 1563 }, 1564 { 1565 name: "PtrAnonymousHeadUint16PtrString", 1566 data: struct { 1567 *structUint16PtrString 1568 B *uint16 `json:"b,string"` 1569 }{ 1570 structUint16PtrString: &structUint16PtrString{A: uint16ptr(1)}, 1571 B: uint16ptr(2), 1572 }, 1573 }, 1574 1575 // NilPtrAnonymousHeadUint16Ptr 1576 { 1577 name: "NilPtrAnonymousHeadUint16Ptr", 1578 data: struct { 1579 *structUint16Ptr 1580 B *uint16 `json:"b"` 1581 }{ 1582 structUint16Ptr: nil, 1583 B: uint16ptr(2), 1584 }, 1585 }, 1586 { 1587 name: "NilPtrAnonymousHeadUint16PtrOmitEmpty", 1588 data: struct { 1589 *structUint16PtrOmitEmpty 1590 B *uint16 `json:"b,omitempty"` 1591 }{ 1592 structUint16PtrOmitEmpty: nil, 1593 B: uint16ptr(2), 1594 }, 1595 }, 1596 { 1597 name: "NilPtrAnonymousHeadUint16PtrString", 1598 data: struct { 1599 *structUint16PtrString 1600 B *uint16 `json:"b,string"` 1601 }{ 1602 structUint16PtrString: nil, 1603 B: uint16ptr(2), 1604 }, 1605 }, 1606 1607 // AnonymousHeadUint16Only 1608 { 1609 name: "AnonymousHeadUint16Only", 1610 data: struct { 1611 structUint16 1612 }{ 1613 structUint16: structUint16{A: 1}, 1614 }, 1615 }, 1616 { 1617 name: "AnonymousHeadUint16OnlyOmitEmpty", 1618 data: struct { 1619 structUint16OmitEmpty 1620 }{ 1621 structUint16OmitEmpty: structUint16OmitEmpty{A: 1}, 1622 }, 1623 }, 1624 { 1625 name: "AnonymousHeadUint16OnlyString", 1626 data: struct { 1627 structUint16String 1628 }{ 1629 structUint16String: structUint16String{A: 1}, 1630 }, 1631 }, 1632 1633 // PtrAnonymousHeadUint16Only 1634 { 1635 name: "PtrAnonymousHeadUint16Only", 1636 data: struct { 1637 *structUint16 1638 }{ 1639 structUint16: &structUint16{A: 1}, 1640 }, 1641 }, 1642 { 1643 name: "PtrAnonymousHeadUint16OnlyOmitEmpty", 1644 data: struct { 1645 *structUint16OmitEmpty 1646 }{ 1647 structUint16OmitEmpty: &structUint16OmitEmpty{A: 1}, 1648 }, 1649 }, 1650 { 1651 name: "PtrAnonymousHeadUint16OnlyString", 1652 data: struct { 1653 *structUint16String 1654 }{ 1655 structUint16String: &structUint16String{A: 1}, 1656 }, 1657 }, 1658 1659 // NilPtrAnonymousHeadUint16Only 1660 { 1661 name: "NilPtrAnonymousHeadUint16Only", 1662 data: struct { 1663 *structUint16 1664 }{ 1665 structUint16: nil, 1666 }, 1667 }, 1668 { 1669 name: "NilPtrAnonymousHeadUint16OnlyOmitEmpty", 1670 data: struct { 1671 *structUint16OmitEmpty 1672 }{ 1673 structUint16OmitEmpty: nil, 1674 }, 1675 }, 1676 { 1677 name: "NilPtrAnonymousHeadUint16OnlyString", 1678 data: struct { 1679 *structUint16String 1680 }{ 1681 structUint16String: nil, 1682 }, 1683 }, 1684 1685 // AnonymousHeadUint16PtrOnly 1686 { 1687 name: "AnonymousHeadUint16PtrOnly", 1688 data: struct { 1689 structUint16Ptr 1690 }{ 1691 structUint16Ptr: structUint16Ptr{A: uint16ptr(1)}, 1692 }, 1693 }, 1694 { 1695 name: "AnonymousHeadUint16PtrOnlyOmitEmpty", 1696 data: struct { 1697 structUint16PtrOmitEmpty 1698 }{ 1699 structUint16PtrOmitEmpty: structUint16PtrOmitEmpty{A: uint16ptr(1)}, 1700 }, 1701 }, 1702 { 1703 name: "AnonymousHeadUint16PtrOnlyString", 1704 data: struct { 1705 structUint16PtrString 1706 }{ 1707 structUint16PtrString: structUint16PtrString{A: uint16ptr(1)}, 1708 }, 1709 }, 1710 1711 // AnonymousHeadUint16PtrNilOnly 1712 { 1713 name: "AnonymousHeadUint16PtrNilOnly", 1714 data: struct { 1715 structUint16Ptr 1716 }{ 1717 structUint16Ptr: structUint16Ptr{A: nil}, 1718 }, 1719 }, 1720 { 1721 name: "AnonymousHeadUint16PtrNilOnlyOmitEmpty", 1722 data: struct { 1723 structUint16PtrOmitEmpty 1724 }{ 1725 structUint16PtrOmitEmpty: structUint16PtrOmitEmpty{A: nil}, 1726 }, 1727 }, 1728 { 1729 name: "AnonymousHeadUint16PtrNilOnlyString", 1730 data: struct { 1731 structUint16PtrString 1732 }{ 1733 structUint16PtrString: structUint16PtrString{A: nil}, 1734 }, 1735 }, 1736 1737 // PtrAnonymousHeadUint16PtrOnly 1738 { 1739 name: "PtrAnonymousHeadUint16PtrOnly", 1740 data: struct { 1741 *structUint16Ptr 1742 }{ 1743 structUint16Ptr: &structUint16Ptr{A: uint16ptr(1)}, 1744 }, 1745 }, 1746 { 1747 name: "PtrAnonymousHeadUint16PtrOnlyOmitEmpty", 1748 data: struct { 1749 *structUint16PtrOmitEmpty 1750 }{ 1751 structUint16PtrOmitEmpty: &structUint16PtrOmitEmpty{A: uint16ptr(1)}, 1752 }, 1753 }, 1754 { 1755 name: "PtrAnonymousHeadUint16PtrOnlyString", 1756 data: struct { 1757 *structUint16PtrString 1758 }{ 1759 structUint16PtrString: &structUint16PtrString{A: uint16ptr(1)}, 1760 }, 1761 }, 1762 1763 // NilPtrAnonymousHeadUint16PtrOnly 1764 { 1765 name: "NilPtrAnonymousHeadUint16PtrOnly", 1766 data: struct { 1767 *structUint16Ptr 1768 }{ 1769 structUint16Ptr: nil, 1770 }, 1771 }, 1772 { 1773 name: "NilPtrAnonymousHeadUint16PtrOnlyOmitEmpty", 1774 data: struct { 1775 *structUint16PtrOmitEmpty 1776 }{ 1777 structUint16PtrOmitEmpty: nil, 1778 }, 1779 }, 1780 { 1781 name: "NilPtrAnonymousHeadUint16PtrOnlyString", 1782 data: struct { 1783 *structUint16PtrString 1784 }{ 1785 structUint16PtrString: nil, 1786 }, 1787 }, 1788 } 1789 for _, test := range tests { 1790 for _, indent := range []bool{true, false} { 1791 for _, htmlEscape := range []bool{true, false} { 1792 t.Run(fmt.Sprintf("%s_indent_%t_escape_%t", test.name, indent, htmlEscape), func(t *testing.T) { 1793 var buf bytes.Buffer 1794 enc := json.NewEncoder(&buf) 1795 enc.SetEscapeHTML(htmlEscape) 1796 if indent { 1797 enc.SetIndent("", " ") 1798 } 1799 if err := enc.Encode(test.data); err != nil { 1800 t.Fatalf("%s(htmlEscape:%v,indent:%v): %+v: %s", test.name, htmlEscape, indent, test.data, err) 1801 } 1802 stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape) 1803 if buf.String() != stdresult { 1804 t.Errorf("%s(htmlEscape:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String()) 1805 } 1806 }) 1807 } 1808 } 1809 } 1810 }