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