github.com/goccy/go-json@v0.10.3-0.20240509105655-5e2ae3f23c1d/test/cover/cover_map_test.go (about)

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