github.com/goccy/go-json@v0.10.3-0.20240509105655-5e2ae3f23c1d/test/cover/cover_bool_test.go (about) 1 package json_test 2 3 import ( 4 "bytes" 5 stdjson "encoding/json" 6 "fmt" 7 "testing" 8 9 "github.com/goccy/go-json" 10 ) 11 12 type customBool bool 13 14 type customBoolWithMarshaler bool 15 16 func (b customBoolWithMarshaler) MarshalJSON() ([]byte, error) { 17 return stdjson.Marshal(bool(b)) 18 } 19 20 func TestCoverBool(t *testing.T) { 21 type structBool struct { 22 A bool `json:"a"` 23 } 24 type structBoolOmitEmpty struct { 25 A bool `json:"a,omitempty"` 26 } 27 type structBoolString struct { 28 A bool `json:"a,string"` 29 } 30 type structBoolStringOmitEmpty struct { 31 A bool `json:"a,string,omitempty"` 32 } 33 34 type structBoolPtr struct { 35 A *bool `json:"a"` 36 } 37 type structBoolPtrOmitEmpty struct { 38 A *bool `json:"a,omitempty"` 39 } 40 type structBoolPtrString struct { 41 A *bool `json:"a,string"` 42 } 43 type structBoolPtrStringOmitEmpty struct { 44 A *bool `json:"a,string,omitempty"` 45 } 46 47 type structCustomBoolOmitEmpty struct { 48 A customBool `json:"a,omitempty"` 49 } 50 51 type structSecondFieldCustomBoolOmitEmpty struct { 52 C bool `json:"c"` 53 A customBool `json:"a,omitempty"` 54 } 55 56 type structCustomBoolWithMarshalerOmitEmpty struct { 57 A customBoolWithMarshaler `json:"a,omitempty"` 58 } 59 60 type structSecondFieldCustomBoolWithMarshalerOmitEmpty struct { 61 C bool `json:"c"` 62 A customBoolWithMarshaler `json:"a,omitempty"` 63 } 64 65 tests := []struct { 66 name string 67 data interface{} 68 }{ 69 { 70 name: "Bool", 71 data: bool(true), 72 }, 73 { 74 name: "BoolPtr", 75 data: boolptr(true), 76 }, 77 { 78 name: "BoolPtr3", 79 data: boolptr3(true), 80 }, 81 { 82 name: "BoolPtrNil", 83 data: (*bool)(nil), 84 }, 85 { 86 name: "BoolPtr3Nil", 87 data: (***bool)(nil), 88 }, 89 90 // HeadBoolZero 91 { 92 name: "HeadBoolZero", 93 data: struct { 94 A bool `json:"a"` 95 }{}, 96 }, 97 { 98 name: "HeadBoolZeroOmitEmpty", 99 data: struct { 100 A bool `json:"a,omitempty"` 101 }{}, 102 }, 103 { 104 name: "HeadBoolZeroString", 105 data: struct { 106 A bool `json:"a,string"` 107 }{}, 108 }, 109 { 110 name: "HeadBoolZeroStringOmitEmpty", 111 data: struct { 112 A bool `json:"a,string,omitempty"` 113 }{}, 114 }, 115 116 // HeadBool 117 { 118 name: "HeadBool", 119 data: struct { 120 A bool `json:"a"` 121 }{A: true}, 122 }, 123 { 124 name: "HeadBoolOmitEmpty", 125 data: struct { 126 A bool `json:"a,omitempty"` 127 }{A: true}, 128 }, 129 { 130 name: "HeadBoolString", 131 data: struct { 132 A bool `json:"a,string"` 133 }{A: true}, 134 }, 135 { 136 name: "HeadBoolStringOmitEmpty", 137 data: struct { 138 A bool `json:"a,string,omitempty"` 139 }{A: true}, 140 }, 141 142 // HeadBoolPtr 143 { 144 name: "HeadBoolPtr", 145 data: struct { 146 A *bool `json:"a"` 147 }{A: boolptr(true)}, 148 }, 149 { 150 name: "HeadBoolPtrOmitEmpty", 151 data: struct { 152 A *bool `json:"a,omitempty"` 153 }{A: boolptr(true)}, 154 }, 155 { 156 name: "HeadBoolPtrString", 157 data: struct { 158 A *bool `json:"a,string"` 159 }{A: boolptr(true)}, 160 }, 161 { 162 name: "HeadBoolPtrStringOmitEmpty", 163 data: struct { 164 A *bool `json:"a,string,omitempty"` 165 }{A: boolptr(true)}, 166 }, 167 168 // HeadBoolPtrNil 169 { 170 name: "HeadBoolPtrNil", 171 data: struct { 172 A *bool `json:"a"` 173 }{A: nil}, 174 }, 175 { 176 name: "HeadBoolPtrNilOmitEmpty", 177 data: struct { 178 A *bool `json:"a,omitempty"` 179 }{A: nil}, 180 }, 181 { 182 name: "HeadBoolPtrNilString", 183 data: struct { 184 A *bool `json:"a,string"` 185 }{A: nil}, 186 }, 187 { 188 name: "HeadBoolPtrNilStringOmitEmpty", 189 data: struct { 190 A *bool `json:"a,string,omitempty"` 191 }{A: nil}, 192 }, 193 194 // PtrHeadBoolZero 195 { 196 name: "PtrHeadBoolZero", 197 data: &struct { 198 A bool `json:"a"` 199 }{}, 200 }, 201 { 202 name: "PtrHeadBoolZeroOmitEmpty", 203 data: &struct { 204 A bool `json:"a,omitempty"` 205 }{}, 206 }, 207 { 208 name: "PtrHeadBoolZeroString", 209 data: &struct { 210 A bool `json:"a,string"` 211 }{}, 212 }, 213 { 214 name: "PtrHeadBoolZeroStringOmitEmpty", 215 data: &struct { 216 A bool `json:"a,string,omitempty"` 217 }{}, 218 }, 219 220 // PtrHeadBool 221 { 222 name: "PtrHeadBool", 223 data: &struct { 224 A bool `json:"a"` 225 }{A: true}, 226 }, 227 { 228 name: "PtrHeadBoolOmitEmpty", 229 data: &struct { 230 A bool `json:"a,omitempty"` 231 }{A: true}, 232 }, 233 { 234 name: "PtrHeadBoolString", 235 data: &struct { 236 A bool `json:"a,string"` 237 }{A: true}, 238 }, 239 { 240 name: "PtrHeadBoolStringOmitEmpty", 241 data: &struct { 242 A bool `json:"a,string,omitempty"` 243 }{A: true}, 244 }, 245 246 // PtrHeadBoolPtr 247 { 248 name: "PtrHeadBoolPtr", 249 data: &struct { 250 A *bool `json:"a"` 251 }{A: boolptr(true)}, 252 }, 253 { 254 name: "PtrHeadBoolPtrOmitEmpty", 255 data: &struct { 256 A *bool `json:"a,omitempty"` 257 }{A: boolptr(true)}, 258 }, 259 { 260 name: "PtrHeadBoolPtrString", 261 data: &struct { 262 A *bool `json:"a,string"` 263 }{A: boolptr(true)}, 264 }, 265 { 266 name: "PtrHeadBoolPtrStringOmitEmpty", 267 data: &struct { 268 A *bool `json:"a,string,omitempty"` 269 }{A: boolptr(true)}, 270 }, 271 272 // PtrHeadBoolPtrNil 273 { 274 name: "PtrHeadBoolPtrNil", 275 data: &struct { 276 A *bool `json:"a"` 277 }{A: nil}, 278 }, 279 { 280 name: "PtrHeadBoolPtrNilOmitEmpty", 281 data: &struct { 282 A *bool `json:"a,omitempty"` 283 }{A: nil}, 284 }, 285 { 286 name: "PtrHeadBoolPtrNilString", 287 data: &struct { 288 A *bool `json:"a,string"` 289 }{A: nil}, 290 }, 291 { 292 name: "PtrHeadBoolPtrNilStringOmitEmpty", 293 data: &struct { 294 A *bool `json:"a,string,omitempty"` 295 }{A: nil}, 296 }, 297 298 // PtrHeadBoolNil 299 { 300 name: "PtrHeadBoolNil", 301 data: (*struct { 302 A *bool `json:"a"` 303 })(nil), 304 }, 305 { 306 name: "PtrHeadBoolNilOmitEmpty", 307 data: (*struct { 308 A *bool `json:"a,omitempty"` 309 })(nil), 310 }, 311 { 312 name: "PtrHeadBoolNilString", 313 data: (*struct { 314 A *bool `json:"a,string"` 315 })(nil), 316 }, 317 { 318 name: "PtrHeadBoolNilStringOmitEmpty", 319 data: (*struct { 320 A *bool `json:"a,string,omitempty"` 321 })(nil), 322 }, 323 324 // HeadBoolZeroMultiFields 325 { 326 name: "HeadBoolZeroMultiFields", 327 data: struct { 328 A bool `json:"a"` 329 B bool `json:"b"` 330 C bool `json:"c"` 331 }{}, 332 }, 333 { 334 name: "HeadBoolZeroMultiFieldsOmitEmpty", 335 data: struct { 336 A bool `json:"a,omitempty"` 337 B bool `json:"b,omitempty"` 338 C bool `json:"c,omitempty"` 339 }{}, 340 }, 341 { 342 name: "HeadBoolZeroMultiFieldsString", 343 data: struct { 344 A bool `json:"a,string"` 345 B bool `json:"b,string"` 346 C bool `json:"c,string"` 347 }{}, 348 }, 349 { 350 name: "HeadBoolZeroMultiFieldsStringOmitEmpty", 351 data: struct { 352 A bool `json:"a,string,omitempty"` 353 B bool `json:"b,string,omitempty"` 354 C bool `json:"c,string,omitempty"` 355 }{}, 356 }, 357 358 // HeadBoolMultiFields 359 { 360 name: "HeadBoolMultiFields", 361 data: struct { 362 A bool `json:"a"` 363 B bool `json:"b"` 364 C bool `json:"c"` 365 }{A: true, B: false, C: true}, 366 }, 367 { 368 name: "HeadBoolMultiFieldsOmitEmpty", 369 data: struct { 370 A bool `json:"a,omitempty"` 371 B bool `json:"b,omitempty"` 372 C bool `json:"c,omitempty"` 373 }{A: true, B: false, C: true}, 374 }, 375 { 376 name: "HeadBoolMultiFieldsString", 377 data: struct { 378 A bool `json:"a,string"` 379 B bool `json:"b,string"` 380 C bool `json:"c,string"` 381 }{A: true, B: false, C: true}, 382 }, 383 { 384 name: "HeadBoolMultiFieldsStringOmitEmpty", 385 data: struct { 386 A bool `json:"a,string,omitempty"` 387 B bool `json:"b,string,omitempty"` 388 C bool `json:"c,string,omitempty"` 389 }{A: true, B: false, C: true}, 390 }, 391 392 // HeadBoolPtrMultiFields 393 { 394 name: "HeadBoolPtrMultiFields", 395 data: struct { 396 A *bool `json:"a"` 397 B *bool `json:"b"` 398 C *bool `json:"c"` 399 }{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, 400 }, 401 { 402 name: "HeadBoolPtrMultiFieldsOmitEmpty", 403 data: struct { 404 A *bool `json:"a,omitempty"` 405 B *bool `json:"b,omitempty"` 406 C *bool `json:"c,omitempty"` 407 }{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, 408 }, 409 { 410 name: "HeadBoolPtrMultiFieldsString", 411 data: struct { 412 A *bool `json:"a,string"` 413 B *bool `json:"b,string"` 414 C *bool `json:"c,string"` 415 }{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, 416 }, 417 { 418 name: "HeadBoolPtrMultiFieldsStringOmitEmpty", 419 data: struct { 420 A *bool `json:"a,string,omitempty"` 421 B *bool `json:"b,string,omitempty"` 422 C *bool `json:"c,string,omitempty"` 423 }{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, 424 }, 425 426 // HeadBoolPtrNilMultiFields 427 { 428 name: "HeadBoolPtrNilMultiFields", 429 data: struct { 430 A *bool `json:"a"` 431 B *bool `json:"b"` 432 C *bool `json:"c"` 433 }{A: nil, B: nil, C: nil}, 434 }, 435 { 436 name: "HeadBoolPtrNilMultiFieldsOmitEmpty", 437 data: struct { 438 A *bool `json:"a,omitempty"` 439 B *bool `json:"b,omitempty"` 440 C *bool `json:"c,omitempty"` 441 }{A: nil, B: nil, C: nil}, 442 }, 443 { 444 name: "HeadBoolPtrNilMultiFieldsString", 445 data: struct { 446 A *bool `json:"a,string"` 447 B *bool `json:"b,string"` 448 C *bool `json:"c,string"` 449 }{A: nil, B: nil, C: nil}, 450 }, 451 { 452 name: "HeadBoolPtrNilMultiFieldsStringOmitEmpty", 453 data: struct { 454 A *bool `json:"a,string,omitempty"` 455 B *bool `json:"b,string,omitempty"` 456 C *bool `json:"c,string,omitempty"` 457 }{A: nil, B: nil, C: nil}, 458 }, 459 460 // PtrHeadBoolZeroMultiFields 461 { 462 name: "PtrHeadBoolZeroMultiFields", 463 data: &struct { 464 A bool `json:"a"` 465 B bool `json:"b"` 466 }{}, 467 }, 468 { 469 name: "PtrHeadBoolZeroMultiFieldsOmitEmpty", 470 data: &struct { 471 A bool `json:"a,omitempty"` 472 B bool `json:"b,omitempty"` 473 }{}, 474 }, 475 { 476 name: "PtrHeadBoolZeroMultiFieldsString", 477 data: &struct { 478 A bool `json:"a,string"` 479 B bool `json:"b,string"` 480 }{}, 481 }, 482 { 483 name: "PtrHeadBoolZeroMultiFieldsStringOmitEmpty", 484 data: &struct { 485 A bool `json:"a,string,omitempty"` 486 B bool `json:"b,string,omitempty"` 487 }{}, 488 }, 489 490 // PtrHeadBoolMultiFields 491 { 492 name: "PtrHeadBoolMultiFields", 493 data: &struct { 494 A bool `json:"a"` 495 B bool `json:"b"` 496 }{A: true, B: false}, 497 }, 498 { 499 name: "PtrHeadBoolMultiFieldsOmitEmpty", 500 data: &struct { 501 A bool `json:"a,omitempty"` 502 B bool `json:"b,omitempty"` 503 }{A: true, B: false}, 504 }, 505 { 506 name: "PtrHeadBoolMultiFieldsString", 507 data: &struct { 508 A bool `json:"a,string"` 509 B bool `json:"b,string"` 510 }{A: true, B: false}, 511 }, 512 { 513 name: "PtrHeadBoolMultiFieldsStringOmitEmpty", 514 data: &struct { 515 A bool `json:"a,string,omitempty"` 516 B bool `json:"b,string,omitempty"` 517 }{A: true, B: false}, 518 }, 519 520 // PtrHeadBoolPtrMultiFields 521 { 522 name: "PtrHeadBoolPtrMultiFields", 523 data: &struct { 524 A *bool `json:"a"` 525 B *bool `json:"b"` 526 }{A: boolptr(true), B: boolptr(false)}, 527 }, 528 { 529 name: "PtrHeadBoolPtrMultiFieldsOmitEmpty", 530 data: &struct { 531 A *bool `json:"a,omitempty"` 532 B *bool `json:"b,omitempty"` 533 }{A: boolptr(true), B: boolptr(false)}, 534 }, 535 { 536 name: "PtrHeadBoolPtrMultiFieldsString", 537 data: &struct { 538 A *bool `json:"a,string"` 539 B *bool `json:"b,string"` 540 }{A: boolptr(true), B: boolptr(false)}, 541 }, 542 { 543 name: "PtrHeadBoolPtrMultiFieldsStringOmitEmpty", 544 data: &struct { 545 A *bool `json:"a,string,omitempty"` 546 B *bool `json:"b,string,omitempty"` 547 }{A: boolptr(true), B: boolptr(false)}, 548 }, 549 550 // PtrHeadBoolPtrNilMultiFields 551 { 552 name: "PtrHeadBoolPtrNilMultiFields", 553 data: &struct { 554 A *bool `json:"a"` 555 B *bool `json:"b"` 556 }{A: nil, B: nil}, 557 }, 558 { 559 name: "PtrHeadBoolPtrNilMultiFieldsOmitEmpty", 560 data: &struct { 561 A *bool `json:"a,omitempty"` 562 B *bool `json:"b,omitempty"` 563 }{A: nil, B: nil}, 564 }, 565 { 566 name: "PtrHeadBoolPtrNilMultiFieldsString", 567 data: &struct { 568 A *bool `json:"a,string"` 569 B *bool `json:"b,string"` 570 }{A: nil, B: nil}, 571 }, 572 { 573 name: "PtrHeadBoolPtrNilMultiFieldsStringOmitEmpty", 574 data: &struct { 575 A *bool `json:"a,string,omitempty"` 576 B *bool `json:"b,string,omitempty"` 577 }{A: nil, B: nil}, 578 }, 579 580 // PtrHeadBoolNilMultiFields 581 { 582 name: "PtrHeadBoolNilMultiFields", 583 data: (*struct { 584 A *bool `json:"a"` 585 B *bool `json:"b"` 586 })(nil), 587 }, 588 { 589 name: "PtrHeadBoolNilMultiFieldsOmitEmpty", 590 data: (*struct { 591 A *bool `json:"a,omitempty"` 592 B *bool `json:"b,omitempty"` 593 })(nil), 594 }, 595 { 596 name: "PtrHeadBoolNilMultiFieldsString", 597 data: (*struct { 598 A *bool `json:"a,string"` 599 B *bool `json:"b,string"` 600 })(nil), 601 }, 602 { 603 name: "PtrHeadBoolNilMultiFieldsStringOmitEmpty", 604 data: (*struct { 605 A *bool `json:"a,string,omitempty"` 606 B *bool `json:"b,string,omitempty"` 607 })(nil), 608 }, 609 610 // HeadBoolZeroNotRoot 611 { 612 name: "HeadBoolZeroNotRoot", 613 data: struct { 614 A struct { 615 A bool `json:"a"` 616 } 617 }{}, 618 }, 619 { 620 name: "HeadBoolZeroNotRootOmitEmpty", 621 data: struct { 622 A struct { 623 A bool `json:"a,omitempty"` 624 } 625 }{}, 626 }, 627 { 628 name: "HeadBoolZeroNotRootString", 629 data: struct { 630 A struct { 631 A bool `json:"a,string"` 632 } 633 }{}, 634 }, 635 { 636 name: "HeadBoolZeroNotRootStringOmitEmpty", 637 data: struct { 638 A struct { 639 A bool `json:"a,string,omitempty"` 640 } 641 }{}, 642 }, 643 644 // HeadBoolNotRoot 645 { 646 name: "HeadBoolNotRoot", 647 data: struct { 648 A struct { 649 A bool `json:"a"` 650 } 651 }{A: struct { 652 A bool `json:"a"` 653 }{A: true}}, 654 }, 655 { 656 name: "HeadBoolNotRootOmitEmpty", 657 data: struct { 658 A struct { 659 A bool `json:"a,omitempty"` 660 } 661 }{A: struct { 662 A bool `json:"a,omitempty"` 663 }{A: true}}, 664 }, 665 { 666 name: "HeadBoolNotRootString", 667 data: struct { 668 A struct { 669 A bool `json:"a,string"` 670 } 671 }{A: struct { 672 A bool `json:"a,string"` 673 }{A: true}}, 674 }, 675 { 676 name: "HeadBoolNotRootStringOmitEmpty", 677 data: struct { 678 A struct { 679 A bool `json:"a,string,omitempty"` 680 } 681 }{A: struct { 682 A bool `json:"a,string,omitempty"` 683 }{A: true}}, 684 }, 685 686 // HeadBoolPtrNotRoot 687 { 688 name: "HeadBoolPtrNotRoot", 689 data: struct { 690 A struct { 691 A *bool `json:"a"` 692 } 693 }{A: struct { 694 A *bool `json:"a"` 695 }{boolptr(true)}}, 696 }, 697 { 698 name: "HeadBoolPtrNotRootOmitEmpty", 699 data: struct { 700 A struct { 701 A *bool `json:"a,omitempty"` 702 } 703 }{A: struct { 704 A *bool `json:"a,omitempty"` 705 }{boolptr(true)}}, 706 }, 707 { 708 name: "HeadBoolPtrNotRootString", 709 data: struct { 710 A struct { 711 A *bool `json:"a,string"` 712 } 713 }{A: struct { 714 A *bool `json:"a,string"` 715 }{boolptr(true)}}, 716 }, 717 { 718 name: "HeadBoolPtrNotRootStringOmitEmpty", 719 data: struct { 720 A struct { 721 A *bool `json:"a,string,omitempty"` 722 } 723 }{A: struct { 724 A *bool `json:"a,string,omitempty"` 725 }{boolptr(true)}}, 726 }, 727 728 // HeadBoolPtrNilNotRoot 729 { 730 name: "HeadBoolPtrNilNotRoot", 731 data: struct { 732 A struct { 733 A *bool `json:"a"` 734 } 735 }{}, 736 }, 737 { 738 name: "HeadBoolPtrNilNotRootOmitEmpty", 739 data: struct { 740 A struct { 741 A *bool `json:"a,omitempty"` 742 } 743 }{}, 744 }, 745 { 746 name: "HeadBoolPtrNilNotRootString", 747 data: struct { 748 A struct { 749 A *bool `json:"a,string"` 750 } 751 }{}, 752 }, 753 { 754 name: "HeadBoolPtrNilNotRootStringOmitEmpty", 755 data: struct { 756 A struct { 757 A *bool `json:"a,string,omitempty"` 758 } 759 }{}, 760 }, 761 762 // PtrHeadBoolZeroNotRoot 763 { 764 name: "PtrHeadBoolZeroNotRoot", 765 data: struct { 766 A *struct { 767 A bool `json:"a"` 768 } 769 }{A: new(struct { 770 A bool `json:"a"` 771 })}, 772 }, 773 { 774 name: "PtrHeadBoolZeroNotRootOmitEmpty", 775 data: struct { 776 A *struct { 777 A bool `json:"a,omitempty"` 778 } 779 }{A: new(struct { 780 A bool `json:"a,omitempty"` 781 })}, 782 }, 783 { 784 name: "PtrHeadBoolZeroNotRootString", 785 data: struct { 786 A *struct { 787 A bool `json:"a,string"` 788 } 789 }{A: new(struct { 790 A bool `json:"a,string"` 791 })}, 792 }, 793 { 794 name: "PtrHeadBoolZeroNotRootStringOmitEmpty", 795 data: struct { 796 A *struct { 797 A bool `json:"a,string,omitempty"` 798 } 799 }{A: new(struct { 800 A bool `json:"a,string,omitempty"` 801 })}, 802 }, 803 804 // PtrHeadBoolNotRoot 805 { 806 name: "PtrHeadBoolNotRoot", 807 data: struct { 808 A *struct { 809 A bool `json:"a"` 810 } 811 }{A: &(struct { 812 A bool `json:"a"` 813 }{A: true})}, 814 }, 815 { 816 name: "PtrHeadBoolNotRootOmitEmpty", 817 data: struct { 818 A *struct { 819 A bool `json:"a,omitempty"` 820 } 821 }{A: &(struct { 822 A bool `json:"a,omitempty"` 823 }{A: true})}, 824 }, 825 { 826 name: "PtrHeadBoolNotRootString", 827 data: struct { 828 A *struct { 829 A bool `json:"a,string"` 830 } 831 }{A: &(struct { 832 A bool `json:"a,string"` 833 }{A: true})}, 834 }, 835 { 836 name: "PtrHeadBoolNotRootStringOmitEmpty", 837 data: struct { 838 A *struct { 839 A bool `json:"a,string,omitempty"` 840 } 841 }{A: &(struct { 842 A bool `json:"a,string,omitempty"` 843 }{A: true})}, 844 }, 845 846 // PtrHeadBoolPtrNotRoot 847 { 848 name: "PtrHeadBoolPtrNotRoot", 849 data: struct { 850 A *struct { 851 A *bool `json:"a"` 852 } 853 }{A: &(struct { 854 A *bool `json:"a"` 855 }{A: boolptr(true)})}, 856 }, 857 { 858 name: "PtrHeadBoolPtrNotRootOmitEmpty", 859 data: struct { 860 A *struct { 861 A *bool `json:"a,omitempty"` 862 } 863 }{A: &(struct { 864 A *bool `json:"a,omitempty"` 865 }{A: boolptr(true)})}, 866 }, 867 { 868 name: "PtrHeadBoolPtrNotRootString", 869 data: struct { 870 A *struct { 871 A *bool `json:"a,string"` 872 } 873 }{A: &(struct { 874 A *bool `json:"a,string"` 875 }{A: boolptr(true)})}, 876 }, 877 { 878 name: "PtrHeadBoolPtrNotRootStringOmitEmpty", 879 data: struct { 880 A *struct { 881 A *bool `json:"a,string,omitempty"` 882 } 883 }{A: &(struct { 884 A *bool `json:"a,string,omitempty"` 885 }{A: boolptr(true)})}, 886 }, 887 888 // PtrHeadBoolPtrNilNotRoot 889 { 890 name: "PtrHeadBoolPtrNilNotRoot", 891 data: struct { 892 A *struct { 893 A *bool `json:"a"` 894 } 895 }{A: &(struct { 896 A *bool `json:"a"` 897 }{A: nil})}, 898 }, 899 { 900 name: "PtrHeadBoolPtrNilNotRootOmitEmpty", 901 data: struct { 902 A *struct { 903 A *bool `json:"a,omitempty"` 904 } 905 }{A: &(struct { 906 A *bool `json:"a,omitempty"` 907 }{A: nil})}, 908 }, 909 { 910 name: "PtrHeadBoolPtrNilNotRootString", 911 data: struct { 912 A *struct { 913 A *bool `json:"a,string"` 914 } 915 }{A: &(struct { 916 A *bool `json:"a,string"` 917 }{A: nil})}, 918 }, 919 { 920 name: "PtrHeadBoolPtrNilNotRootStringOmitEmpty", 921 data: struct { 922 A *struct { 923 A *bool `json:"a,string,omitempty"` 924 } 925 }{A: &(struct { 926 A *bool `json:"a,string,omitempty"` 927 }{A: nil})}, 928 }, 929 930 // PtrHeadBoolNilNotRoot 931 { 932 name: "PtrHeadBoolNilNotRoot", 933 data: struct { 934 A *struct { 935 A *bool `json:"a"` 936 } 937 }{A: nil}, 938 }, 939 { 940 name: "PtrHeadBoolNilNotRootOmitEmpty", 941 data: struct { 942 A *struct { 943 A *bool `json:"a,omitempty"` 944 } `json:",omitempty"` 945 }{A: nil}, 946 }, 947 { 948 name: "PtrHeadBoolNilNotRootString", 949 data: struct { 950 A *struct { 951 A *bool `json:"a,string"` 952 } `json:",string"` 953 }{A: nil}, 954 }, 955 { 956 name: "PtrHeadBoolNilNotRootStringOmitEmpty", 957 data: struct { 958 A *struct { 959 A *bool `json:"a,string,omitempty"` 960 } `json:",string,omitempty"` 961 }{A: nil}, 962 }, 963 964 // HeadBoolZeroMultiFieldsNotRoot 965 { 966 name: "HeadBoolZeroMultiFieldsNotRoot", 967 data: struct { 968 A struct { 969 A bool `json:"a"` 970 } 971 B struct { 972 B bool `json:"b"` 973 } 974 }{}, 975 }, 976 { 977 name: "HeadBoolZeroMultiFieldsNotRootOmitEmpty", 978 data: struct { 979 A struct { 980 A bool `json:"a,omitempty"` 981 } 982 B struct { 983 B bool `json:"b,omitempty"` 984 } 985 }{}, 986 }, 987 { 988 name: "HeadBoolZeroMultiFieldsNotRootString", 989 data: struct { 990 A struct { 991 A bool `json:"a,string"` 992 } 993 B struct { 994 B bool `json:"b,string"` 995 } 996 }{}, 997 }, 998 { 999 name: "HeadBoolZeroMultiFieldsNotRootStringOmitEmpty", 1000 data: struct { 1001 A struct { 1002 A bool `json:"a,string,omitempty"` 1003 } 1004 B struct { 1005 B bool `json:"b,string,omitempty"` 1006 } 1007 }{}, 1008 }, 1009 1010 // HeadBoolMultiFieldsNotRoot 1011 { 1012 name: "HeadBoolMultiFieldsNotRoot", 1013 data: struct { 1014 A struct { 1015 A bool `json:"a"` 1016 } 1017 B struct { 1018 B bool `json:"b"` 1019 } 1020 }{A: struct { 1021 A bool `json:"a"` 1022 }{A: true}, B: struct { 1023 B bool `json:"b"` 1024 }{B: false}}, 1025 }, 1026 { 1027 name: "HeadBoolMultiFieldsNotRootOmitEmpty", 1028 data: struct { 1029 A struct { 1030 A bool `json:"a,omitempty"` 1031 } 1032 B struct { 1033 B bool `json:"b,omitempty"` 1034 } 1035 }{A: struct { 1036 A bool `json:"a,omitempty"` 1037 }{A: true}, B: struct { 1038 B bool `json:"b,omitempty"` 1039 }{B: false}}, 1040 }, 1041 { 1042 name: "HeadBoolMultiFieldsNotRootString", 1043 data: struct { 1044 A struct { 1045 A bool `json:"a,string"` 1046 } 1047 B struct { 1048 B bool `json:"b,string"` 1049 } 1050 }{A: struct { 1051 A bool `json:"a,string"` 1052 }{A: true}, B: struct { 1053 B bool `json:"b,string"` 1054 }{B: false}}, 1055 }, 1056 { 1057 name: "HeadBoolMultiFieldsNotRootStringOmitEmpty", 1058 data: struct { 1059 A struct { 1060 A bool `json:"a,string,omitempty"` 1061 } 1062 B struct { 1063 B bool `json:"b,string,omitempty"` 1064 } 1065 }{A: struct { 1066 A bool `json:"a,string,omitempty"` 1067 }{A: true}, B: struct { 1068 B bool `json:"b,string,omitempty"` 1069 }{B: false}}, 1070 }, 1071 1072 // HeadBoolPtrMultiFieldsNotRoot 1073 { 1074 name: "HeadBoolPtrMultiFieldsNotRoot", 1075 data: struct { 1076 A struct { 1077 A *bool `json:"a"` 1078 } 1079 B struct { 1080 B *bool `json:"b"` 1081 } 1082 }{A: struct { 1083 A *bool `json:"a"` 1084 }{A: boolptr(true)}, B: struct { 1085 B *bool `json:"b"` 1086 }{B: boolptr(false)}}, 1087 }, 1088 { 1089 name: "HeadBoolPtrMultiFieldsNotRootOmitEmpty", 1090 data: struct { 1091 A struct { 1092 A *bool `json:"a,omitempty"` 1093 } 1094 B struct { 1095 B *bool `json:"b,omitempty"` 1096 } 1097 }{A: struct { 1098 A *bool `json:"a,omitempty"` 1099 }{A: boolptr(true)}, B: struct { 1100 B *bool `json:"b,omitempty"` 1101 }{B: boolptr(false)}}, 1102 }, 1103 { 1104 name: "HeadBoolPtrMultiFieldsNotRootString", 1105 data: struct { 1106 A struct { 1107 A *bool `json:"a,string"` 1108 } 1109 B struct { 1110 B *bool `json:"b,string"` 1111 } 1112 }{A: struct { 1113 A *bool `json:"a,string"` 1114 }{A: boolptr(true)}, B: struct { 1115 B *bool `json:"b,string"` 1116 }{B: boolptr(false)}}, 1117 }, 1118 { 1119 name: "HeadBoolPtrMultiFieldsNotRootStringOmitEmpty", 1120 data: struct { 1121 A struct { 1122 A *bool `json:"a,string,omitempty"` 1123 } 1124 B struct { 1125 B *bool `json:"b,string,omitempty"` 1126 } 1127 }{A: struct { 1128 A *bool `json:"a,string,omitempty"` 1129 }{A: boolptr(true)}, B: struct { 1130 B *bool `json:"b,string,omitempty"` 1131 }{B: boolptr(false)}}, 1132 }, 1133 1134 // HeadBoolPtrNilMultiFieldsNotRoot 1135 { 1136 name: "HeadBoolPtrNilMultiFieldsNotRoot", 1137 data: struct { 1138 A struct { 1139 A *bool `json:"a"` 1140 } 1141 B struct { 1142 B *bool `json:"b"` 1143 } 1144 }{A: struct { 1145 A *bool `json:"a"` 1146 }{A: nil}, B: struct { 1147 B *bool `json:"b"` 1148 }{B: nil}}, 1149 }, 1150 { 1151 name: "HeadBoolPtrNilMultiFieldsNotRootOmitEmpty", 1152 data: struct { 1153 A struct { 1154 A *bool `json:"a,omitempty"` 1155 } 1156 B struct { 1157 B *bool `json:"b,omitempty"` 1158 } 1159 }{A: struct { 1160 A *bool `json:"a,omitempty"` 1161 }{A: nil}, B: struct { 1162 B *bool `json:"b,omitempty"` 1163 }{B: nil}}, 1164 }, 1165 { 1166 name: "HeadBoolPtrNilMultiFieldsNotRootString", 1167 data: struct { 1168 A struct { 1169 A *bool `json:"a,string"` 1170 } 1171 B struct { 1172 B *bool `json:"b,string"` 1173 } 1174 }{A: struct { 1175 A *bool `json:"a,string"` 1176 }{A: nil}, B: struct { 1177 B *bool `json:"b,string"` 1178 }{B: nil}}, 1179 }, 1180 { 1181 name: "HeadBoolPtrNilMultiFieldsNotRootStringOmitEmpty", 1182 data: struct { 1183 A struct { 1184 A *bool `json:"a,string,omitempty"` 1185 } 1186 B struct { 1187 B *bool `json:"b,string,omitempty"` 1188 } 1189 }{A: struct { 1190 A *bool `json:"a,string,omitempty"` 1191 }{A: nil}, B: struct { 1192 B *bool `json:"b,string,omitempty"` 1193 }{B: nil}}, 1194 }, 1195 1196 // PtrHeadBoolZeroMultiFieldsNotRoot 1197 { 1198 name: "PtrHeadBoolZeroMultiFieldsNotRoot", 1199 data: &struct { 1200 A struct { 1201 A bool `json:"a"` 1202 } 1203 B struct { 1204 B bool `json:"b"` 1205 } 1206 }{}, 1207 }, 1208 { 1209 name: "PtrHeadBoolZeroMultiFieldsNotRootOmitEmpty", 1210 data: &struct { 1211 A struct { 1212 A bool `json:"a,omitempty"` 1213 } 1214 B struct { 1215 B bool `json:"b,omitempty"` 1216 } 1217 }{}, 1218 }, 1219 { 1220 name: "PtrHeadBoolZeroMultiFieldsNotRootString", 1221 data: &struct { 1222 A struct { 1223 A bool `json:"a,string"` 1224 } 1225 B struct { 1226 B bool `json:"b,string"` 1227 } 1228 }{}, 1229 }, 1230 { 1231 name: "PtrHeadBoolZeroMultiFieldsNotRootStringOmitEmpty", 1232 data: &struct { 1233 A struct { 1234 A bool `json:"a,string,omitempty"` 1235 } 1236 B struct { 1237 B bool `json:"b,string,omitempty"` 1238 } 1239 }{}, 1240 }, 1241 1242 // PtrHeadBoolMultiFieldsNotRoot 1243 { 1244 name: "PtrHeadBoolMultiFieldsNotRoot", 1245 data: &struct { 1246 A struct { 1247 A bool `json:"a"` 1248 } 1249 B struct { 1250 B bool `json:"b"` 1251 } 1252 }{A: struct { 1253 A bool `json:"a"` 1254 }{A: true}, B: struct { 1255 B bool `json:"b"` 1256 }{B: false}}, 1257 }, 1258 { 1259 name: "PtrHeadBoolMultiFieldsNotRootOmitEmpty", 1260 data: &struct { 1261 A struct { 1262 A bool `json:"a,omitempty"` 1263 } 1264 B struct { 1265 B bool `json:"b,omitempty"` 1266 } 1267 }{A: struct { 1268 A bool `json:"a,omitempty"` 1269 }{A: true}, B: struct { 1270 B bool `json:"b,omitempty"` 1271 }{B: false}}, 1272 }, 1273 { 1274 name: "PtrHeadBoolMultiFieldsNotRootString", 1275 data: &struct { 1276 A struct { 1277 A bool `json:"a,string"` 1278 } 1279 B struct { 1280 B bool `json:"b,string"` 1281 } 1282 }{A: struct { 1283 A bool `json:"a,string"` 1284 }{A: true}, B: struct { 1285 B bool `json:"b,string"` 1286 }{B: false}}, 1287 }, 1288 { 1289 name: "PtrHeadBoolMultiFieldsNotRootStringOmitEmpty", 1290 data: &struct { 1291 A struct { 1292 A bool `json:"a,string,omitempty"` 1293 } 1294 B struct { 1295 B bool `json:"b,string,omitempty"` 1296 } 1297 }{A: struct { 1298 A bool `json:"a,string,omitempty"` 1299 }{A: true}, B: struct { 1300 B bool `json:"b,string,omitempty"` 1301 }{B: false}}, 1302 }, 1303 1304 // PtrHeadBoolPtrMultiFieldsNotRoot 1305 { 1306 name: "PtrHeadBoolPtrMultiFieldsNotRoot", 1307 data: &struct { 1308 A *struct { 1309 A *bool `json:"a"` 1310 } 1311 B *struct { 1312 B *bool `json:"b"` 1313 } 1314 }{A: &(struct { 1315 A *bool `json:"a"` 1316 }{A: boolptr(true)}), B: &(struct { 1317 B *bool `json:"b"` 1318 }{B: boolptr(false)})}, 1319 }, 1320 { 1321 name: "PtrHeadBoolPtrMultiFieldsNotRootOmitEmpty", 1322 data: &struct { 1323 A *struct { 1324 A *bool `json:"a,omitempty"` 1325 } 1326 B *struct { 1327 B *bool `json:"b,omitempty"` 1328 } 1329 }{A: &(struct { 1330 A *bool `json:"a,omitempty"` 1331 }{A: boolptr(true)}), B: &(struct { 1332 B *bool `json:"b,omitempty"` 1333 }{B: boolptr(false)})}, 1334 }, 1335 { 1336 name: "PtrHeadBoolPtrMultiFieldsNotRootString", 1337 data: &struct { 1338 A *struct { 1339 A *bool `json:"a,string"` 1340 } 1341 B *struct { 1342 B *bool `json:"b,string"` 1343 } 1344 }{A: &(struct { 1345 A *bool `json:"a,string"` 1346 }{A: boolptr(true)}), B: &(struct { 1347 B *bool `json:"b,string"` 1348 }{B: boolptr(false)})}, 1349 }, 1350 { 1351 name: "PtrHeadBoolPtrMultiFieldsNotRootStringOmitEmpty", 1352 data: &struct { 1353 A *struct { 1354 A *bool `json:"a,string,omitempty"` 1355 } 1356 B *struct { 1357 B *bool `json:"b,string,omitempty"` 1358 } 1359 }{A: &(struct { 1360 A *bool `json:"a,string,omitempty"` 1361 }{A: boolptr(true)}), B: &(struct { 1362 B *bool `json:"b,string,omitempty"` 1363 }{B: boolptr(false)})}, 1364 }, 1365 1366 // PtrHeadBoolPtrNilMultiFieldsNotRoot 1367 { 1368 name: "PtrHeadBoolPtrNilMultiFieldsNotRoot", 1369 data: &struct { 1370 A *struct { 1371 A *bool `json:"a"` 1372 } 1373 B *struct { 1374 B *bool `json:"b"` 1375 } 1376 }{A: nil, B: nil}, 1377 }, 1378 { 1379 name: "PtrHeadBoolPtrNilMultiFieldsNotRootOmitEmpty", 1380 data: &struct { 1381 A *struct { 1382 A *bool `json:"a,omitempty"` 1383 } `json:",omitempty"` 1384 B *struct { 1385 B *bool `json:"b,omitempty"` 1386 } `json:",omitempty"` 1387 }{A: nil, B: nil}, 1388 }, 1389 { 1390 name: "PtrHeadBoolPtrNilMultiFieldsNotRootString", 1391 data: &struct { 1392 A *struct { 1393 A *bool `json:"a,string"` 1394 } `json:",string"` 1395 B *struct { 1396 B *bool `json:"b,string"` 1397 } `json:",string"` 1398 }{A: nil, B: nil}, 1399 }, 1400 { 1401 name: "PtrHeadBoolPtrNilMultiFieldsNotRootStringOmitEmpty", 1402 data: &struct { 1403 A *struct { 1404 A *bool `json:"a,string,omitempty"` 1405 } `json:",string"` 1406 B *struct { 1407 B *bool `json:"b,string,omitempty"` 1408 } `json:",string"` 1409 }{A: nil, B: nil}, 1410 }, 1411 1412 // PtrHeadBoolNilMultiFieldsNotRoot 1413 { 1414 name: "PtrHeadBoolNilMultiFieldsNotRoot", 1415 data: (*struct { 1416 A *struct { 1417 A *bool `json:"a"` 1418 } 1419 B *struct { 1420 B *bool `json:"b"` 1421 } 1422 })(nil), 1423 }, 1424 { 1425 name: "PtrHeadBoolNilMultiFieldsNotRootOmitEmpty", 1426 data: (*struct { 1427 A *struct { 1428 A *bool `json:"a,omitempty"` 1429 } 1430 B *struct { 1431 B *bool `json:"b,omitempty"` 1432 } 1433 })(nil), 1434 }, 1435 { 1436 name: "PtrHeadBoolNilMultiFieldsNotRootString", 1437 data: (*struct { 1438 A *struct { 1439 A *bool `json:"a,string"` 1440 } 1441 B *struct { 1442 B *bool `json:"b,string"` 1443 } 1444 })(nil), 1445 }, 1446 { 1447 name: "PtrHeadBoolNilMultiFieldsNotRootStringOmitEmpty", 1448 data: (*struct { 1449 A *struct { 1450 A *bool `json:"a,string,omitempty"` 1451 } 1452 B *struct { 1453 B *bool `json:"b,string,omitempty"` 1454 } 1455 })(nil), 1456 }, 1457 1458 // PtrHeadBoolDoubleMultiFieldsNotRoot 1459 { 1460 name: "PtrHeadBoolDoubleMultiFieldsNotRoot", 1461 data: &struct { 1462 A *struct { 1463 A bool `json:"a"` 1464 B bool `json:"b"` 1465 } 1466 B *struct { 1467 A bool `json:"a"` 1468 B bool `json:"b"` 1469 } 1470 }{A: &(struct { 1471 A bool `json:"a"` 1472 B bool `json:"b"` 1473 }{A: true, B: false}), B: &(struct { 1474 A bool `json:"a"` 1475 B bool `json:"b"` 1476 }{A: true, B: false})}, 1477 }, 1478 { 1479 name: "PtrHeadBoolDoubleMultiFieldsNotRootOmitEmpty", 1480 data: &struct { 1481 A *struct { 1482 A bool `json:"a,omitempty"` 1483 B bool `json:"b,omitempty"` 1484 } 1485 B *struct { 1486 A bool `json:"a,omitempty"` 1487 B bool `json:"b,omitempty"` 1488 } 1489 }{A: &(struct { 1490 A bool `json:"a,omitempty"` 1491 B bool `json:"b,omitempty"` 1492 }{A: true, B: false}), B: &(struct { 1493 A bool `json:"a,omitempty"` 1494 B bool `json:"b,omitempty"` 1495 }{A: true, B: false})}, 1496 }, 1497 { 1498 name: "PtrHeadBoolDoubleMultiFieldsNotRootString", 1499 data: &struct { 1500 A *struct { 1501 A bool `json:"a,string"` 1502 B bool `json:"b,string"` 1503 } 1504 B *struct { 1505 A bool `json:"a,string"` 1506 B bool `json:"b,string"` 1507 } 1508 }{A: &(struct { 1509 A bool `json:"a,string"` 1510 B bool `json:"b,string"` 1511 }{A: true, B: false}), B: &(struct { 1512 A bool `json:"a,string"` 1513 B bool `json:"b,string"` 1514 }{A: true, B: false})}, 1515 }, 1516 { 1517 name: "PtrHeadBoolDoubleMultiFieldsNotRootStringOmitEmpty", 1518 data: &struct { 1519 A *struct { 1520 A bool `json:"a,string,omitempty"` 1521 B bool `json:"b,string,omitempty"` 1522 } 1523 B *struct { 1524 A bool `json:"a,string,omitempty"` 1525 B bool `json:"b,string,omitempty"` 1526 } 1527 }{A: &(struct { 1528 A bool `json:"a,string,omitempty"` 1529 B bool `json:"b,string,omitempty"` 1530 }{A: true, B: false}), B: &(struct { 1531 A bool `json:"a,string,omitempty"` 1532 B bool `json:"b,string,omitempty"` 1533 }{A: true, B: false})}, 1534 }, 1535 1536 // PtrHeadBoolNilDoubleMultiFieldsNotRoot 1537 { 1538 name: "PtrHeadBoolNilDoubleMultiFieldsNotRoot", 1539 data: &struct { 1540 A *struct { 1541 A bool `json:"a"` 1542 B bool `json:"b"` 1543 } 1544 B *struct { 1545 A bool `json:"a"` 1546 B bool `json:"b"` 1547 } 1548 }{A: nil, B: nil}, 1549 }, 1550 { 1551 name: "PtrHeadBoolNilDoubleMultiFieldsNotRootOmitEmpty", 1552 data: &struct { 1553 A *struct { 1554 A bool `json:"a,omitempty"` 1555 B bool `json:"b,omitempty"` 1556 } `json:",omitempty"` 1557 B *struct { 1558 A bool `json:"a,omitempty"` 1559 B bool `json:"b,omitempty"` 1560 } `json:",omitempty"` 1561 }{A: nil, B: nil}, 1562 }, 1563 { 1564 name: "PtrHeadBoolNilDoubleMultiFieldsNotRootString", 1565 data: &struct { 1566 A *struct { 1567 A bool `json:"a,string"` 1568 B bool `json:"b,string"` 1569 } 1570 B *struct { 1571 A bool `json:"a,string"` 1572 B bool `json:"b,string"` 1573 } 1574 }{A: nil, B: nil}, 1575 }, 1576 { 1577 name: "PtrHeadBoolNilDoubleMultiFieldsNotRootStringOmitEmpty", 1578 data: &struct { 1579 A *struct { 1580 A bool `json:"a,string,omitempty"` 1581 B bool `json:"b,string,omitempty"` 1582 } 1583 B *struct { 1584 A bool `json:"a,string,omitempty"` 1585 B bool `json:"b,string,omitempty"` 1586 } 1587 }{A: nil, B: nil}, 1588 }, 1589 1590 // PtrHeadBoolNilDoubleMultiFieldsNotRoot 1591 { 1592 name: "PtrHeadBoolNilDoubleMultiFieldsNotRoot", 1593 data: (*struct { 1594 A *struct { 1595 A bool `json:"a"` 1596 B bool `json:"b"` 1597 } 1598 B *struct { 1599 A bool `json:"a"` 1600 B bool `json:"b"` 1601 } 1602 })(nil), 1603 }, 1604 { 1605 name: "PtrHeadBoolNilDoubleMultiFieldsNotRootOmitEmpty", 1606 data: (*struct { 1607 A *struct { 1608 A bool `json:"a,omitempty"` 1609 B bool `json:"b,omitempty"` 1610 } 1611 B *struct { 1612 A bool `json:"a,omitempty"` 1613 B bool `json:"b,omitempty"` 1614 } 1615 })(nil), 1616 }, 1617 { 1618 name: "PtrHeadBoolNilDoubleMultiFieldsNotRootString", 1619 data: (*struct { 1620 A *struct { 1621 A bool `json:"a,string"` 1622 B bool `json:"b,string"` 1623 } 1624 B *struct { 1625 A bool `json:"a,string"` 1626 B bool `json:"b,string"` 1627 } 1628 })(nil), 1629 }, 1630 { 1631 name: "PtrHeadBoolNilDoubleMultiFieldsNotRootStringOmitEmpty", 1632 data: (*struct { 1633 A *struct { 1634 A bool `json:"a,string,omitempty"` 1635 B bool `json:"b,string,omitempty"` 1636 } 1637 B *struct { 1638 A bool `json:"a,string,omitempty"` 1639 B bool `json:"b,string,omitempty"` 1640 } 1641 })(nil), 1642 }, 1643 1644 // PtrHeadBoolPtrDoubleMultiFieldsNotRoot 1645 { 1646 name: "PtrHeadBoolPtrDoubleMultiFieldsNotRoot", 1647 data: &struct { 1648 A *struct { 1649 A *bool `json:"a"` 1650 B *bool `json:"b"` 1651 } 1652 B *struct { 1653 A *bool `json:"a"` 1654 B *bool `json:"b"` 1655 } 1656 }{A: &(struct { 1657 A *bool `json:"a"` 1658 B *bool `json:"b"` 1659 }{A: boolptr(true), B: boolptr(false)}), B: &(struct { 1660 A *bool `json:"a"` 1661 B *bool `json:"b"` 1662 }{A: boolptr(true), B: boolptr(false)})}, 1663 }, 1664 { 1665 name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootOmitEmpty", 1666 data: &struct { 1667 A *struct { 1668 A *bool `json:"a,omitempty"` 1669 B *bool `json:"b,omitempty"` 1670 } 1671 B *struct { 1672 A *bool `json:"a,omitempty"` 1673 B *bool `json:"b,omitempty"` 1674 } 1675 }{A: &(struct { 1676 A *bool `json:"a,omitempty"` 1677 B *bool `json:"b,omitempty"` 1678 }{A: boolptr(true), B: boolptr(false)}), B: &(struct { 1679 A *bool `json:"a,omitempty"` 1680 B *bool `json:"b,omitempty"` 1681 }{A: boolptr(true), B: boolptr(false)})}, 1682 }, 1683 { 1684 name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootString", 1685 data: &struct { 1686 A *struct { 1687 A *bool `json:"a,string"` 1688 B *bool `json:"b,string"` 1689 } 1690 B *struct { 1691 A *bool `json:"a,string"` 1692 B *bool `json:"b,string"` 1693 } 1694 }{A: &(struct { 1695 A *bool `json:"a,string"` 1696 B *bool `json:"b,string"` 1697 }{A: boolptr(true), B: boolptr(false)}), B: &(struct { 1698 A *bool `json:"a,string"` 1699 B *bool `json:"b,string"` 1700 }{A: boolptr(true), B: boolptr(false)})}, 1701 }, 1702 { 1703 name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootStringOmitEmpty", 1704 data: &struct { 1705 A *struct { 1706 A *bool `json:"a,string,omitempty"` 1707 B *bool `json:"b,string,omitempty"` 1708 } 1709 B *struct { 1710 A *bool `json:"a,string,omitempty"` 1711 B *bool `json:"b,string,omitempty"` 1712 } 1713 }{A: &(struct { 1714 A *bool `json:"a,string,omitempty"` 1715 B *bool `json:"b,string,omitempty"` 1716 }{A: boolptr(true), B: boolptr(false)}), B: &(struct { 1717 A *bool `json:"a,string,omitempty"` 1718 B *bool `json:"b,string,omitempty"` 1719 }{A: boolptr(true), B: boolptr(false)})}, 1720 }, 1721 1722 // PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot 1723 { 1724 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot", 1725 data: &struct { 1726 A *struct { 1727 A *bool `json:"a"` 1728 B *bool `json:"b"` 1729 } 1730 B *struct { 1731 A *bool `json:"a"` 1732 B *bool `json:"b"` 1733 } 1734 }{A: nil, B: nil}, 1735 }, 1736 { 1737 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootOmitEmpty", 1738 data: &struct { 1739 A *struct { 1740 A *bool `json:"a,omitempty"` 1741 B *bool `json:"b,omitempty"` 1742 } `json:",omitempty"` 1743 B *struct { 1744 A *bool `json:"a,omitempty"` 1745 B *bool `json:"b,omitempty"` 1746 } `json:",omitempty"` 1747 }{A: nil, B: nil}, 1748 }, 1749 { 1750 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootString", 1751 data: &struct { 1752 A *struct { 1753 A *bool `json:"a,string"` 1754 B *bool `json:"b,string"` 1755 } 1756 B *struct { 1757 A *bool `json:"a,string"` 1758 B *bool `json:"b,string"` 1759 } 1760 }{A: nil, B: nil}, 1761 }, 1762 { 1763 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootStringOmitEmpty", 1764 data: &struct { 1765 A *struct { 1766 A *bool `json:"a,string,omitempty"` 1767 B *bool `json:"b,string,omitempty"` 1768 } 1769 B *struct { 1770 A *bool `json:"a,string,omitempty"` 1771 B *bool `json:"b,string,omitempty"` 1772 } 1773 }{A: nil, B: nil}, 1774 }, 1775 1776 // PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot 1777 { 1778 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot", 1779 data: (*struct { 1780 A *struct { 1781 A *bool `json:"a"` 1782 B *bool `json:"b"` 1783 } 1784 B *struct { 1785 A *bool `json:"a"` 1786 B *bool `json:"b"` 1787 } 1788 })(nil), 1789 }, 1790 { 1791 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootOmitEmpty", 1792 data: (*struct { 1793 A *struct { 1794 A *bool `json:"a,omitempty"` 1795 B *bool `json:"b,omitempty"` 1796 } 1797 B *struct { 1798 A *bool `json:"a,omitempty"` 1799 B *bool `json:"b,omitempty"` 1800 } 1801 })(nil), 1802 }, 1803 { 1804 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootString", 1805 data: (*struct { 1806 A *struct { 1807 A *bool `json:"a,string"` 1808 B *bool `json:"b,string"` 1809 } 1810 B *struct { 1811 A *bool `json:"a,string"` 1812 B *bool `json:"b,string"` 1813 } 1814 })(nil), 1815 }, 1816 { 1817 name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootStringOmitEmpty", 1818 data: (*struct { 1819 A *struct { 1820 A *bool `json:"a,string,omitempty"` 1821 B *bool `json:"b,string,omitempty"` 1822 } 1823 B *struct { 1824 A *bool `json:"a,string,omitempty"` 1825 B *bool `json:"b,string,omitempty"` 1826 } 1827 })(nil), 1828 }, 1829 1830 // AnonymousHeadBool 1831 { 1832 name: "AnonymousHeadBool", 1833 data: struct { 1834 structBool 1835 B bool `json:"b"` 1836 }{ 1837 structBool: structBool{A: true}, 1838 B: false, 1839 }, 1840 }, 1841 { 1842 name: "AnonymousHeadBoolOmitEmpty", 1843 data: struct { 1844 structBoolOmitEmpty 1845 B bool `json:"b,omitempty"` 1846 }{ 1847 structBoolOmitEmpty: structBoolOmitEmpty{A: true}, 1848 B: false, 1849 }, 1850 }, 1851 { 1852 name: "AnonymousHeadCustomBoolOmitEmpty", 1853 data: struct { 1854 structCustomBoolOmitEmpty 1855 B bool `json:"b,omitempty"` 1856 }{ 1857 structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{A: true}, 1858 B: false, 1859 }, 1860 }, 1861 { 1862 name: "AnonymousHeadCustomBoolOmitEmptyFalse", 1863 data: struct { 1864 structCustomBoolOmitEmpty 1865 B bool `json:"b,omitempty"` 1866 }{ 1867 structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{}, 1868 B: false, 1869 }, 1870 }, 1871 { 1872 name: "AnonymousHeadSecondFieldCustomBoolOmitEmpty", 1873 data: struct { 1874 structSecondFieldCustomBoolOmitEmpty 1875 B bool `json:"b,omitempty"` 1876 }{ 1877 structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{A: true}, 1878 B: false, 1879 }, 1880 }, 1881 { 1882 name: "AnonymousHeadSecondFieldCustomBoolOmitEmptyFalse", 1883 data: struct { 1884 structSecondFieldCustomBoolOmitEmpty 1885 B bool `json:"b,omitempty"` 1886 }{ 1887 structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{}, 1888 B: false, 1889 }, 1890 }, 1891 { 1892 name: "AnonymousHeadCustomBoolWithMarshalerOmitEmpty", 1893 data: struct { 1894 structCustomBoolWithMarshalerOmitEmpty 1895 B bool `json:"b,omitempty"` 1896 }{ 1897 structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{A: true}, 1898 B: false, 1899 }, 1900 }, 1901 { 1902 name: "AnonymousHeadCustomBoolWithMarshalerOmitEmptyFalse", 1903 data: struct { 1904 structCustomBoolWithMarshalerOmitEmpty 1905 B bool `json:"b,omitempty"` 1906 }{ 1907 structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{}, 1908 B: false, 1909 }, 1910 }, 1911 { 1912 name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmpty", 1913 data: struct { 1914 structSecondFieldCustomBoolWithMarshalerOmitEmpty 1915 B bool `json:"b,omitempty"` 1916 }{ 1917 structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true}, 1918 B: false, 1919 }, 1920 }, 1921 { 1922 name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmptyFalse", 1923 data: struct { 1924 structSecondFieldCustomBoolWithMarshalerOmitEmpty 1925 B bool `json:"b,omitempty"` 1926 }{ 1927 structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{}, 1928 B: false, 1929 }, 1930 }, 1931 { 1932 name: "AnonymousHeadBoolString", 1933 data: struct { 1934 structBoolString 1935 B bool `json:"b,string"` 1936 }{ 1937 structBoolString: structBoolString{A: true}, 1938 B: false, 1939 }, 1940 }, 1941 { 1942 name: "AnonymousHeadBoolStringOmitEmpty", 1943 data: struct { 1944 structBoolStringOmitEmpty 1945 B bool `json:"b,string,omitempty"` 1946 }{ 1947 structBoolStringOmitEmpty: structBoolStringOmitEmpty{A: true}, 1948 B: false, 1949 }, 1950 }, 1951 1952 // PtrAnonymousHeadBool 1953 { 1954 name: "PtrAnonymousHeadBool", 1955 data: struct { 1956 *structBool 1957 B bool `json:"b"` 1958 }{ 1959 structBool: &structBool{A: true}, 1960 B: false, 1961 }, 1962 }, 1963 { 1964 name: "PtrAnonymousHeadBoolOmitEmpty", 1965 data: struct { 1966 *structBoolOmitEmpty 1967 B bool `json:"b,omitempty"` 1968 }{ 1969 structBoolOmitEmpty: &structBoolOmitEmpty{A: true}, 1970 B: false, 1971 }, 1972 }, 1973 { 1974 name: "PtrAnonymousHeadCustomBoolOmitEmpty", 1975 data: struct { 1976 *structCustomBoolOmitEmpty 1977 B bool `json:"b,omitempty"` 1978 }{ 1979 structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{A: true}, 1980 B: false, 1981 }, 1982 }, 1983 { 1984 name: "PtrAnonymousHeadCustomBoolOmitEmptyFalse", 1985 data: struct { 1986 *structCustomBoolOmitEmpty 1987 B bool `json:"b,omitempty"` 1988 }{ 1989 structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{}, 1990 B: false, 1991 }, 1992 }, 1993 { 1994 name: "PtrAnonymousHeadSecondFieldCustomBoolOmitEmpty", 1995 data: struct { 1996 *structSecondFieldCustomBoolOmitEmpty 1997 B bool `json:"b,omitempty"` 1998 }{ 1999 structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{A: true}, 2000 B: false, 2001 }, 2002 }, 2003 { 2004 name: "PtrAnonymousHeadSecondFieldCustomBoolOmitEmptyFalse", 2005 data: struct { 2006 *structSecondFieldCustomBoolOmitEmpty 2007 B bool `json:"b,omitempty"` 2008 }{ 2009 structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{}, 2010 B: false, 2011 }, 2012 }, 2013 { 2014 name: "PtrAnonymousHeadCustomBoolWithMarshalerOmitEmpty", 2015 data: struct { 2016 *structCustomBoolWithMarshalerOmitEmpty 2017 B bool `json:"b,omitempty"` 2018 }{ 2019 structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{A: true}, 2020 B: false, 2021 }, 2022 }, 2023 { 2024 name: "PtrAnonymousHeadCustomBoolWithMarshalerOmitEmptyFalse", 2025 data: struct { 2026 *structCustomBoolWithMarshalerOmitEmpty 2027 B bool `json:"b,omitempty"` 2028 }{ 2029 structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{}, 2030 B: false, 2031 }, 2032 }, 2033 { 2034 name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmpty", 2035 data: struct { 2036 *structSecondFieldCustomBoolWithMarshalerOmitEmpty 2037 B bool `json:"b,omitempty"` 2038 }{ 2039 structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true}, 2040 B: false, 2041 }, 2042 }, 2043 { 2044 name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmptyFalse", 2045 data: struct { 2046 *structSecondFieldCustomBoolWithMarshalerOmitEmpty 2047 B bool `json:"b,omitempty"` 2048 }{ 2049 structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{}, 2050 B: false, 2051 }, 2052 }, 2053 { 2054 name: "PtrAnonymousHeadBoolString", 2055 data: struct { 2056 *structBoolString 2057 B bool `json:"b,string"` 2058 }{ 2059 structBoolString: &structBoolString{A: true}, 2060 B: false, 2061 }, 2062 }, 2063 { 2064 name: "PtrAnonymousHeadBoolStringOmitEmpty", 2065 data: struct { 2066 *structBoolStringOmitEmpty 2067 B bool `json:"b,string,omitempty"` 2068 }{ 2069 structBoolStringOmitEmpty: &structBoolStringOmitEmpty{A: true}, 2070 B: false, 2071 }, 2072 }, 2073 2074 // NilPtrAnonymousHeadBool 2075 { 2076 name: "NilPtrAnonymousHeadBool", 2077 data: struct { 2078 *structBool 2079 B bool `json:"b"` 2080 }{ 2081 structBool: nil, 2082 B: true, 2083 }, 2084 }, 2085 { 2086 name: "NilPtrAnonymousHeadBoolOmitEmpty", 2087 data: struct { 2088 *structBoolOmitEmpty 2089 B bool `json:"b,omitempty"` 2090 }{ 2091 structBoolOmitEmpty: nil, 2092 B: true, 2093 }, 2094 }, 2095 { 2096 name: "NilPtrAnonymousHeadCustomBoolOmitEmpty", 2097 data: struct { 2098 *structCustomBoolOmitEmpty 2099 B bool `json:"b,omitempty"` 2100 }{ 2101 structCustomBoolOmitEmpty: nil, 2102 B: true, 2103 }, 2104 }, 2105 { 2106 name: "NilPtrAnonymousHeadCustomBoolWithMarshalerOmitEmpty", 2107 data: struct { 2108 *structCustomBoolWithMarshalerOmitEmpty 2109 B bool `json:"b,omitempty"` 2110 }{ 2111 structCustomBoolWithMarshalerOmitEmpty: nil, 2112 B: true, 2113 }, 2114 }, 2115 { 2116 name: "NilPtrAnonymousHeadBoolString", 2117 data: struct { 2118 *structBoolString 2119 B bool `json:"b,string"` 2120 }{ 2121 structBoolString: nil, 2122 B: true, 2123 }, 2124 }, 2125 { 2126 name: "NilPtrAnonymousHeadBoolStringOmitEmpty", 2127 data: struct { 2128 *structBoolStringOmitEmpty 2129 B bool `json:"b,string,omitempty"` 2130 }{ 2131 structBoolStringOmitEmpty: nil, 2132 B: true, 2133 }, 2134 }, 2135 2136 // AnonymousHeadBoolPtr 2137 { 2138 name: "AnonymousHeadBoolPtr", 2139 data: struct { 2140 structBoolPtr 2141 B *bool `json:"b"` 2142 }{ 2143 structBoolPtr: structBoolPtr{A: boolptr(true)}, 2144 B: boolptr(false), 2145 }, 2146 }, 2147 { 2148 name: "AnonymousHeadBoolPtrOmitEmpty", 2149 data: struct { 2150 structBoolPtrOmitEmpty 2151 B *bool `json:"b,omitempty"` 2152 }{ 2153 structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: boolptr(true)}, 2154 B: boolptr(false), 2155 }, 2156 }, 2157 { 2158 name: "AnonymousHeadBoolPtrString", 2159 data: struct { 2160 structBoolPtrString 2161 B *bool `json:"b,string"` 2162 }{ 2163 structBoolPtrString: structBoolPtrString{A: boolptr(true)}, 2164 B: boolptr(false), 2165 }, 2166 }, 2167 { 2168 name: "AnonymousHeadBoolPtrStringOmitEmpty", 2169 data: struct { 2170 structBoolPtrStringOmitEmpty 2171 B *bool `json:"b,string,omitempty"` 2172 }{ 2173 structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: boolptr(true)}, 2174 B: boolptr(false), 2175 }, 2176 }, 2177 2178 // AnonymousHeadBoolPtrNil 2179 { 2180 name: "AnonymousHeadBoolPtrNil", 2181 data: struct { 2182 structBoolPtr 2183 B *bool `json:"b"` 2184 }{ 2185 structBoolPtr: structBoolPtr{A: nil}, 2186 B: boolptr(true), 2187 }, 2188 }, 2189 { 2190 name: "AnonymousHeadBoolPtrNilOmitEmpty", 2191 data: struct { 2192 structBoolPtrOmitEmpty 2193 B *bool `json:"b,omitempty"` 2194 }{ 2195 structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: nil}, 2196 B: boolptr(true), 2197 }, 2198 }, 2199 { 2200 name: "AnonymousHeadBoolPtrNilString", 2201 data: struct { 2202 structBoolPtrString 2203 B *bool `json:"b,string"` 2204 }{ 2205 structBoolPtrString: structBoolPtrString{A: nil}, 2206 B: boolptr(true), 2207 }, 2208 }, 2209 { 2210 name: "AnonymousHeadBoolPtrNilStringOmitEmpty", 2211 data: struct { 2212 structBoolPtrStringOmitEmpty 2213 B *bool `json:"b,string,omitempty"` 2214 }{ 2215 structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: nil}, 2216 B: boolptr(true), 2217 }, 2218 }, 2219 2220 // PtrAnonymousHeadBoolPtr 2221 { 2222 name: "PtrAnonymousHeadBoolPtr", 2223 data: struct { 2224 *structBoolPtr 2225 B *bool `json:"b"` 2226 }{ 2227 structBoolPtr: &structBoolPtr{A: boolptr(true)}, 2228 B: boolptr(false), 2229 }, 2230 }, 2231 { 2232 name: "PtrAnonymousHeadBoolPtrOmitEmpty", 2233 data: struct { 2234 *structBoolPtrOmitEmpty 2235 B *bool `json:"b,omitempty"` 2236 }{ 2237 structBoolPtrOmitEmpty: &structBoolPtrOmitEmpty{A: boolptr(true)}, 2238 B: boolptr(false), 2239 }, 2240 }, 2241 { 2242 name: "PtrAnonymousHeadBoolPtrString", 2243 data: struct { 2244 *structBoolPtrString 2245 B *bool `json:"b,string"` 2246 }{ 2247 structBoolPtrString: &structBoolPtrString{A: boolptr(true)}, 2248 B: boolptr(false), 2249 }, 2250 }, 2251 { 2252 name: "PtrAnonymousHeadBoolPtrStringOmitEmpty", 2253 data: struct { 2254 *structBoolPtrStringOmitEmpty 2255 B *bool `json:"b,string,omitempty"` 2256 }{ 2257 structBoolPtrStringOmitEmpty: &structBoolPtrStringOmitEmpty{A: boolptr(true)}, 2258 B: boolptr(false), 2259 }, 2260 }, 2261 2262 // NilPtrAnonymousHeadBoolPtr 2263 { 2264 name: "NilPtrAnonymousHeadBoolPtr", 2265 data: struct { 2266 *structBoolPtr 2267 B *bool `json:"b"` 2268 }{ 2269 structBoolPtr: nil, 2270 B: boolptr(true), 2271 }, 2272 }, 2273 { 2274 name: "NilPtrAnonymousHeadBoolPtrOmitEmpty", 2275 data: struct { 2276 *structBoolPtrOmitEmpty 2277 B *bool `json:"b,omitempty"` 2278 }{ 2279 structBoolPtrOmitEmpty: nil, 2280 B: boolptr(true), 2281 }, 2282 }, 2283 { 2284 name: "NilPtrAnonymousHeadBoolPtrString", 2285 data: struct { 2286 *structBoolPtrString 2287 B *bool `json:"b,string"` 2288 }{ 2289 structBoolPtrString: nil, 2290 B: boolptr(true), 2291 }, 2292 }, 2293 { 2294 name: "NilPtrAnonymousHeadBoolPtrStringOmitEmpty", 2295 data: struct { 2296 *structBoolPtrStringOmitEmpty 2297 B *bool `json:"b,string,omitempty"` 2298 }{ 2299 structBoolPtrStringOmitEmpty: nil, 2300 B: boolptr(true), 2301 }, 2302 }, 2303 2304 // AnonymousHeadBoolOnly 2305 { 2306 name: "AnonymousHeadBoolOnly", 2307 data: struct { 2308 structBool 2309 }{ 2310 structBool: structBool{A: true}, 2311 }, 2312 }, 2313 { 2314 name: "AnonymousHeadBoolOnlyOmitEmpty", 2315 data: struct { 2316 structBoolOmitEmpty 2317 }{ 2318 structBoolOmitEmpty: structBoolOmitEmpty{A: true}, 2319 }, 2320 }, 2321 { 2322 name: "AnonymousHeadCustomBoolOnlyOmitEmpty", 2323 data: struct { 2324 structCustomBoolOmitEmpty 2325 }{ 2326 structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{A: true}, 2327 }, 2328 }, 2329 { 2330 name: "AnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty", 2331 data: struct { 2332 structSecondFieldCustomBoolOmitEmpty 2333 }{ 2334 structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{A: true}, 2335 }, 2336 }, 2337 { 2338 name: "AnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty", 2339 data: struct { 2340 structCustomBoolWithMarshalerOmitEmpty 2341 }{ 2342 structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{A: true}, 2343 }, 2344 }, 2345 { 2346 name: "AnonymousHeadCustomBoolWithMarshalerOnlyOmitEmptyFalse", 2347 data: struct { 2348 structCustomBoolWithMarshalerOmitEmpty 2349 }{ 2350 structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{}, 2351 }, 2352 }, 2353 { 2354 name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty", 2355 data: struct { 2356 structSecondFieldCustomBoolWithMarshalerOmitEmpty 2357 }{ 2358 structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true}, 2359 }, 2360 }, 2361 { 2362 name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse", 2363 data: struct { 2364 structSecondFieldCustomBoolWithMarshalerOmitEmpty 2365 }{ 2366 structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{}, 2367 }, 2368 }, 2369 { 2370 name: "AnonymousHeadBoolOnlyString", 2371 data: struct { 2372 structBoolString 2373 }{ 2374 structBoolString: structBoolString{A: true}, 2375 }, 2376 }, 2377 { 2378 name: "AnonymousHeadBoolOnlyStringOmitEmpty", 2379 data: struct { 2380 structBoolStringOmitEmpty 2381 }{ 2382 structBoolStringOmitEmpty: structBoolStringOmitEmpty{A: true}, 2383 }, 2384 }, 2385 2386 // PtrAnonymousHeadBoolOnly 2387 { 2388 name: "PtrAnonymousHeadBoolOnly", 2389 data: struct { 2390 *structBool 2391 }{ 2392 structBool: &structBool{A: true}, 2393 }, 2394 }, 2395 { 2396 name: "PtrAnonymousHeadBoolOnlyOmitEmpty", 2397 data: struct { 2398 *structBoolOmitEmpty 2399 }{ 2400 structBoolOmitEmpty: &structBoolOmitEmpty{A: true}, 2401 }, 2402 }, 2403 { 2404 name: "PtrAnonymousHeadCustomBoolOnlyOmitEmpty", 2405 data: struct { 2406 *structCustomBoolOmitEmpty 2407 }{ 2408 structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{A: true}, 2409 }, 2410 }, 2411 { 2412 name: "PtrAnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty", 2413 data: struct { 2414 *structSecondFieldCustomBoolOmitEmpty 2415 }{ 2416 structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{A: true}, 2417 }, 2418 }, 2419 { 2420 name: "PtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty", 2421 data: struct { 2422 *structCustomBoolWithMarshalerOmitEmpty 2423 }{ 2424 structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{A: true}, 2425 }, 2426 }, 2427 { 2428 name: "PtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmptyFalse", 2429 data: struct { 2430 *structCustomBoolWithMarshalerOmitEmpty 2431 }{ 2432 structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{}, 2433 }, 2434 }, 2435 { 2436 name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty", 2437 data: struct { 2438 *structSecondFieldCustomBoolWithMarshalerOmitEmpty 2439 }{ 2440 structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true}, 2441 }, 2442 }, 2443 { 2444 name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse", 2445 data: struct { 2446 *structSecondFieldCustomBoolWithMarshalerOmitEmpty 2447 }{ 2448 structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{}, 2449 }, 2450 }, 2451 { 2452 name: "PtrAnonymousHeadBoolOnlyString", 2453 data: struct { 2454 *structBoolString 2455 }{ 2456 structBoolString: &structBoolString{A: true}, 2457 }, 2458 }, 2459 { 2460 name: "PtrAnonymousHeadBoolOnlyStringOmitEmpty", 2461 data: struct { 2462 *structBoolStringOmitEmpty 2463 }{ 2464 structBoolStringOmitEmpty: &structBoolStringOmitEmpty{A: true}, 2465 }, 2466 }, 2467 2468 // NilPtrAnonymousHeadBoolOnly 2469 { 2470 name: "NilPtrAnonymousHeadBoolOnly", 2471 data: struct { 2472 *structBool 2473 }{ 2474 structBool: nil, 2475 }, 2476 }, 2477 { 2478 name: "NilPtrAnonymousHeadBoolOnlyOmitEmpty", 2479 data: struct { 2480 *structBoolOmitEmpty 2481 }{ 2482 structBoolOmitEmpty: nil, 2483 }, 2484 }, 2485 { 2486 name: "NilPtrAnonymousHeadCustomBoolOnlyOmitEmpty", 2487 data: struct { 2488 *structCustomBoolOmitEmpty 2489 }{ 2490 structCustomBoolOmitEmpty: nil, 2491 }, 2492 }, 2493 { 2494 name: "NilPtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty", 2495 data: struct { 2496 *structCustomBoolWithMarshalerOmitEmpty 2497 }{ 2498 structCustomBoolWithMarshalerOmitEmpty: nil, 2499 }, 2500 }, 2501 { 2502 name: "NilPtrAnonymousHeadBoolOnlyString", 2503 data: struct { 2504 *structBoolString 2505 }{ 2506 structBoolString: nil, 2507 }, 2508 }, 2509 { 2510 name: "NilPtrAnonymousHeadBoolOnlyStringOmitEmpty", 2511 data: struct { 2512 *structBoolStringOmitEmpty 2513 }{ 2514 structBoolStringOmitEmpty: nil, 2515 }, 2516 }, 2517 2518 // AnonymousHeadBoolPtrOnly 2519 { 2520 name: "AnonymousHeadBoolPtrOnly", 2521 data: struct { 2522 structBoolPtr 2523 }{ 2524 structBoolPtr: structBoolPtr{A: boolptr(true)}, 2525 }, 2526 }, 2527 { 2528 name: "AnonymousHeadBoolPtrOnlyOmitEmpty", 2529 data: struct { 2530 structBoolPtrOmitEmpty 2531 }{ 2532 structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: boolptr(true)}, 2533 }, 2534 }, 2535 { 2536 name: "AnonymousHeadBoolPtrOnlyString", 2537 data: struct { 2538 structBoolPtrString 2539 }{ 2540 structBoolPtrString: structBoolPtrString{A: boolptr(true)}, 2541 }, 2542 }, 2543 { 2544 name: "AnonymousHeadBoolPtrOnlyStringOmitEmpty", 2545 data: struct { 2546 structBoolPtrStringOmitEmpty 2547 }{ 2548 structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: boolptr(true)}, 2549 }, 2550 }, 2551 2552 // AnonymousHeadBoolPtrNilOnly 2553 { 2554 name: "AnonymousHeadBoolPtrNilOnly", 2555 data: struct { 2556 structBoolPtr 2557 }{ 2558 structBoolPtr: structBoolPtr{A: nil}, 2559 }, 2560 }, 2561 { 2562 name: "AnonymousHeadBoolPtrNilOnlyOmitEmpty", 2563 data: struct { 2564 structBoolPtrOmitEmpty 2565 }{ 2566 structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: nil}, 2567 }, 2568 }, 2569 { 2570 name: "AnonymousHeadBoolPtrNilOnlyString", 2571 data: struct { 2572 structBoolPtrString 2573 }{ 2574 structBoolPtrString: structBoolPtrString{A: nil}, 2575 }, 2576 }, 2577 { 2578 name: "AnonymousHeadBoolPtrNilOnlyStringOmitEmpty", 2579 data: struct { 2580 structBoolPtrStringOmitEmpty 2581 }{ 2582 structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: nil}, 2583 }, 2584 }, 2585 2586 // PtrAnonymousHeadBoolPtrOnly 2587 { 2588 name: "PtrAnonymousHeadBoolPtrOnly", 2589 data: struct { 2590 *structBoolPtr 2591 }{ 2592 structBoolPtr: &structBoolPtr{A: boolptr(true)}, 2593 }, 2594 }, 2595 { 2596 name: "PtrAnonymousHeadBoolPtrOnlyOmitEmpty", 2597 data: struct { 2598 *structBoolPtrOmitEmpty 2599 }{ 2600 structBoolPtrOmitEmpty: &structBoolPtrOmitEmpty{A: boolptr(true)}, 2601 }, 2602 }, 2603 { 2604 name: "PtrAnonymousHeadBoolPtrOnlyString", 2605 data: struct { 2606 *structBoolPtrString 2607 }{ 2608 structBoolPtrString: &structBoolPtrString{A: boolptr(true)}, 2609 }, 2610 }, 2611 { 2612 name: "PtrAnonymousHeadBoolPtrOnlyStringOmitEmpty", 2613 data: struct { 2614 *structBoolPtrStringOmitEmpty 2615 }{ 2616 structBoolPtrStringOmitEmpty: &structBoolPtrStringOmitEmpty{A: boolptr(true)}, 2617 }, 2618 }, 2619 2620 // NilPtrAnonymousHeadBoolPtrOnly 2621 { 2622 name: "NilPtrAnonymousHeadBoolPtrOnly", 2623 data: struct { 2624 *structBoolPtr 2625 }{ 2626 structBoolPtr: nil, 2627 }, 2628 }, 2629 { 2630 name: "NilPtrAnonymousHeadBoolPtrOnlyOmitEmpty", 2631 data: struct { 2632 *structBoolPtrOmitEmpty 2633 }{ 2634 structBoolPtrOmitEmpty: nil, 2635 }, 2636 }, 2637 { 2638 name: "NilPtrAnonymousHeadBoolPtrOnlyString", 2639 data: struct { 2640 *structBoolPtrString 2641 }{ 2642 structBoolPtrString: nil, 2643 }, 2644 }, 2645 { 2646 name: "NilPtrAnonymousHeadBoolPtrOnlyStringOmitEmpty", 2647 data: struct { 2648 *structBoolPtrStringOmitEmpty 2649 }{ 2650 structBoolPtrStringOmitEmpty: nil, 2651 }, 2652 }, 2653 } 2654 for _, test := range tests { 2655 for _, indent := range []bool{true, false} { 2656 for _, htmlEscape := range []bool{true, false} { 2657 t.Run(fmt.Sprintf("%s_indent_%t_escape_%t", test.name, indent, htmlEscape), func(t *testing.T) { 2658 var buf bytes.Buffer 2659 enc := json.NewEncoder(&buf) 2660 enc.SetEscapeHTML(htmlEscape) 2661 if indent { 2662 enc.SetIndent("", " ") 2663 } 2664 if err := enc.Encode(test.data); err != nil { 2665 t.Fatalf("%s(htmlEscape:%v,indent:%v): %+v: %s", test.name, htmlEscape, indent, test.data, err) 2666 } 2667 stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape) 2668 if buf.String() != stdresult { 2669 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()) 2670 } 2671 }) 2672 } 2673 } 2674 } 2675 }