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