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