git.gammaspectra.live/P2Pool/go-json@v0.99.0/test/cover/cover_array_test.go (about)

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