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