github.com/ugorji/go/codec@v1.2.13-0.20240307214044-07c54c229a5a/mammoth2_generated_test.go (about)

     1  //go:build !codec.notmammoth
     2  // +build !codec.notmammoth
     3  
     4  // Copyright (c) 2012-2020 Ugorji Nwoke. All rights reserved.
     5  // Use of this source code is governed by a MIT license found in the LICENSE file.
     6  
     7  // Code generated from mammoth2-test.go.tmpl - DO NOT EDIT.
     8  
     9  package codec
    10  
    11  // Increase codecoverage by covering all the codecgen paths, in fast-path and gen-helper.go....
    12  //
    13  // Note: even though this is built based on fast-path and gen-helper, we will run these tests
    14  // in all modes, including notfastpath, etc.
    15  //
    16  // Add test file for creating a mammoth generated file as _mammoth_generated.go
    17  //  - generate a second mammoth files in a different file: mammoth2_generated_test.go
    18  //    mammoth-test.go.tmpl will do this
    19  //  - run codecgen on it, into mammoth2_codecgen_generated_test.go (no build tags)
    20  //  - as part of TestMammoth, run it also
    21  //  - this will cover all the codecgen, gen-helper, etc in one full run
    22  //  - check in mammoth* files into github also
    23  //
    24  // Now, add some types:
    25  //  - some that implement BinaryMarshal, TextMarshal, JSONMarshal, and one that implements none of it
    26  //  - create a wrapper type that includes TestMammoth2, with it in slices, and maps, and the custom types
    27  //  - this wrapper object is what we work encode/decode (so that the codecgen methods are called)
    28  
    29  // import "encoding/binary"
    30  
    31  import "fmt"
    32  
    33  type TestMammoth2 struct {
    34  	FIntf       interface{}
    35  	FptrIntf    *interface{}
    36  	FString     string
    37  	FptrString  *string
    38  	FBytes      []byte
    39  	FptrBytes   *[]byte
    40  	FFloat32    float32
    41  	FptrFloat32 *float32
    42  	FFloat64    float64
    43  	FptrFloat64 *float64
    44  	FUint       uint
    45  	FptrUint    *uint
    46  	FUint8      uint8
    47  	FptrUint8   *uint8
    48  	FUint16     uint16
    49  	FptrUint16  *uint16
    50  	FUint32     uint32
    51  	FptrUint32  *uint32
    52  	FUint64     uint64
    53  	FptrUint64  *uint64
    54  	FUintptr    uintptr
    55  	FptrUintptr *uintptr
    56  	FInt        int
    57  	FptrInt     *int
    58  	FInt8       int8
    59  	FptrInt8    *int8
    60  	FInt16      int16
    61  	FptrInt16   *int16
    62  	FInt32      int32
    63  	FptrInt32   *int32
    64  	FInt64      int64
    65  	FptrInt64   *int64
    66  	FBool       bool
    67  	FptrBool    *bool
    68  
    69  	FSliceIntf       []interface{}
    70  	FptrSliceIntf    *[]interface{}
    71  	FSliceString     []string
    72  	FptrSliceString  *[]string
    73  	FSliceBytes      [][]byte
    74  	FptrSliceBytes   *[][]byte
    75  	FSliceFloat32    []float32
    76  	FptrSliceFloat32 *[]float32
    77  	FSliceFloat64    []float64
    78  	FptrSliceFloat64 *[]float64
    79  	FSliceUint8      []uint8
    80  	FptrSliceUint8   *[]uint8
    81  	FSliceUint64     []uint64
    82  	FptrSliceUint64  *[]uint64
    83  	FSliceInt        []int
    84  	FptrSliceInt     *[]int
    85  	FSliceInt32      []int32
    86  	FptrSliceInt32   *[]int32
    87  	FSliceInt64      []int64
    88  	FptrSliceInt64   *[]int64
    89  	FSliceBool       []bool
    90  	FptrSliceBool    *[]bool
    91  
    92  	FMapStringIntf       map[string]interface{}
    93  	FptrMapStringIntf    *map[string]interface{}
    94  	FMapStringString     map[string]string
    95  	FptrMapStringString  *map[string]string
    96  	FMapStringBytes      map[string][]byte
    97  	FptrMapStringBytes   *map[string][]byte
    98  	FMapStringUint8      map[string]uint8
    99  	FptrMapStringUint8   *map[string]uint8
   100  	FMapStringUint64     map[string]uint64
   101  	FptrMapStringUint64  *map[string]uint64
   102  	FMapStringInt        map[string]int
   103  	FptrMapStringInt     *map[string]int
   104  	FMapStringInt32      map[string]int32
   105  	FptrMapStringInt32   *map[string]int32
   106  	FMapStringFloat64    map[string]float64
   107  	FptrMapStringFloat64 *map[string]float64
   108  	FMapStringBool       map[string]bool
   109  	FptrMapStringBool    *map[string]bool
   110  	FMapUint8Intf        map[uint8]interface{}
   111  	FptrMapUint8Intf     *map[uint8]interface{}
   112  	FMapUint8String      map[uint8]string
   113  	FptrMapUint8String   *map[uint8]string
   114  	FMapUint8Bytes       map[uint8][]byte
   115  	FptrMapUint8Bytes    *map[uint8][]byte
   116  	FMapUint8Uint8       map[uint8]uint8
   117  	FptrMapUint8Uint8    *map[uint8]uint8
   118  	FMapUint8Uint64      map[uint8]uint64
   119  	FptrMapUint8Uint64   *map[uint8]uint64
   120  	FMapUint8Int         map[uint8]int
   121  	FptrMapUint8Int      *map[uint8]int
   122  	FMapUint8Int32       map[uint8]int32
   123  	FptrMapUint8Int32    *map[uint8]int32
   124  	FMapUint8Float64     map[uint8]float64
   125  	FptrMapUint8Float64  *map[uint8]float64
   126  	FMapUint8Bool        map[uint8]bool
   127  	FptrMapUint8Bool     *map[uint8]bool
   128  	FMapUint64Intf       map[uint64]interface{}
   129  	FptrMapUint64Intf    *map[uint64]interface{}
   130  	FMapUint64String     map[uint64]string
   131  	FptrMapUint64String  *map[uint64]string
   132  	FMapUint64Bytes      map[uint64][]byte
   133  	FptrMapUint64Bytes   *map[uint64][]byte
   134  	FMapUint64Uint8      map[uint64]uint8
   135  	FptrMapUint64Uint8   *map[uint64]uint8
   136  	FMapUint64Uint64     map[uint64]uint64
   137  	FptrMapUint64Uint64  *map[uint64]uint64
   138  	FMapUint64Int        map[uint64]int
   139  	FptrMapUint64Int     *map[uint64]int
   140  	FMapUint64Int32      map[uint64]int32
   141  	FptrMapUint64Int32   *map[uint64]int32
   142  	FMapUint64Float64    map[uint64]float64
   143  	FptrMapUint64Float64 *map[uint64]float64
   144  	FMapUint64Bool       map[uint64]bool
   145  	FptrMapUint64Bool    *map[uint64]bool
   146  	FMapIntIntf          map[int]interface{}
   147  	FptrMapIntIntf       *map[int]interface{}
   148  	FMapIntString        map[int]string
   149  	FptrMapIntString     *map[int]string
   150  	FMapIntBytes         map[int][]byte
   151  	FptrMapIntBytes      *map[int][]byte
   152  	FMapIntUint8         map[int]uint8
   153  	FptrMapIntUint8      *map[int]uint8
   154  	FMapIntUint64        map[int]uint64
   155  	FptrMapIntUint64     *map[int]uint64
   156  	FMapIntInt           map[int]int
   157  	FptrMapIntInt        *map[int]int
   158  	FMapIntInt32         map[int]int32
   159  	FptrMapIntInt32      *map[int]int32
   160  	FMapIntFloat64       map[int]float64
   161  	FptrMapIntFloat64    *map[int]float64
   162  	FMapIntBool          map[int]bool
   163  	FptrMapIntBool       *map[int]bool
   164  	FMapInt32Intf        map[int32]interface{}
   165  	FptrMapInt32Intf     *map[int32]interface{}
   166  	FMapInt32String      map[int32]string
   167  	FptrMapInt32String   *map[int32]string
   168  	FMapInt32Bytes       map[int32][]byte
   169  	FptrMapInt32Bytes    *map[int32][]byte
   170  	FMapInt32Uint8       map[int32]uint8
   171  	FptrMapInt32Uint8    *map[int32]uint8
   172  	FMapInt32Uint64      map[int32]uint64
   173  	FptrMapInt32Uint64   *map[int32]uint64
   174  	FMapInt32Int         map[int32]int
   175  	FptrMapInt32Int      *map[int32]int
   176  	FMapInt32Int32       map[int32]int32
   177  	FptrMapInt32Int32    *map[int32]int32
   178  	FMapInt32Float64     map[int32]float64
   179  	FptrMapInt32Float64  *map[int32]float64
   180  	FMapInt32Bool        map[int32]bool
   181  	FptrMapInt32Bool     *map[int32]bool
   182  }
   183  
   184  // -----------
   185  
   186  type testMammoth2Binary uint64
   187  
   188  func (x testMammoth2Binary) MarshalBinary() (data []byte, err error) {
   189  	data = make([]byte, 8)
   190  	bigenstd.PutUint64(data, uint64(x))
   191  	return
   192  }
   193  func (x *testMammoth2Binary) UnmarshalBinary(data []byte) (err error) {
   194  	*x = testMammoth2Binary(bigenstd.Uint64(data))
   195  	return
   196  }
   197  
   198  type testMammoth2Text uint64
   199  
   200  func (x testMammoth2Text) MarshalText() (data []byte, err error) {
   201  	data = []byte(fmt.Sprintf("%b", uint64(x)))
   202  	return
   203  }
   204  func (x *testMammoth2Text) UnmarshalText(data []byte) (err error) {
   205  	_, err = fmt.Sscanf(string(data), "%b", (*uint64)(x))
   206  	return
   207  }
   208  
   209  type testMammoth2Json uint64
   210  
   211  func (x testMammoth2Json) MarshalJSON() (data []byte, err error) {
   212  	data = []byte(fmt.Sprintf("%v", uint64(x)))
   213  	return
   214  }
   215  func (x *testMammoth2Json) UnmarshalJSON(data []byte) (err error) {
   216  	_, err = fmt.Sscanf(string(data), "%v", (*uint64)(x))
   217  	return
   218  }
   219  
   220  type testMammoth2Basic [4]uint64
   221  
   222  type TestMammoth2Wrapper struct {
   223  	V TestMammoth2
   224  	T testMammoth2Text
   225  	B testMammoth2Binary
   226  	J testMammoth2Json
   227  	C testMammoth2Basic
   228  	M map[testMammoth2Basic]TestMammoth2
   229  	L []TestMammoth2
   230  	A [4]int64
   231  
   232  	Tcomplex128 complex128
   233  	Tcomplex64  complex64
   234  	Tbytes      []uint8
   235  	Tpbytes     *[]uint8
   236  }