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