mammoth2_generated_test.go 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // +build !notfastpath
  2. // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
  3. // Use of this source code is governed by a MIT license found in the LICENSE file.
  4. // Code generated from mammoth2-test.go.tmpl - DO NOT EDIT.
  5. package codec
  6. // Increase codecoverage by covering all the codecgen paths, in fast-path and gen-helper.go....
  7. //
  8. // Add:
  9. // - test file for creating a mammoth generated file as _mammoth_generated.go
  10. // - generate a second mammoth files in a different file: mammoth2_generated_test.go
  11. // - mammoth-test.go.tmpl will do this
  12. // - run codecgen on it, into mammoth2_codecgen_generated_test.go (no build tags)
  13. // - as part of TestMammoth, run it also
  14. // - this will cover all the codecgen, gen-helper, etc in one full run
  15. // - check in mammoth* files into github also
  16. // - then
  17. //
  18. // Now, add some types:
  19. // - some that implement BinaryMarshal, TextMarshal, JSONMarshal, and one that implements none of it
  20. // - create a wrapper type that includes TestMammoth2, with it in slices, and maps, and the custom types
  21. // - this wrapper object is what we work encode/decode (so that the codecgen methods are called)
  22. // import "encoding/binary"
  23. import "fmt"
  24. type TestMammoth2 struct {
  25. FIntf interface{}
  26. FptrIntf *interface{}
  27. FString string
  28. FptrString *string
  29. FBytes []byte
  30. FptrBytes *[]byte
  31. FFloat32 float32
  32. FptrFloat32 *float32
  33. FFloat64 float64
  34. FptrFloat64 *float64
  35. FUint uint
  36. FptrUint *uint
  37. FUint8 uint8
  38. FptrUint8 *uint8
  39. FUint16 uint16
  40. FptrUint16 *uint16
  41. FUint32 uint32
  42. FptrUint32 *uint32
  43. FUint64 uint64
  44. FptrUint64 *uint64
  45. FUintptr uintptr
  46. FptrUintptr *uintptr
  47. FInt int
  48. FptrInt *int
  49. FInt8 int8
  50. FptrInt8 *int8
  51. FInt16 int16
  52. FptrInt16 *int16
  53. FInt32 int32
  54. FptrInt32 *int32
  55. FInt64 int64
  56. FptrInt64 *int64
  57. FBool bool
  58. FptrBool *bool
  59. FSliceIntf []interface{}
  60. FptrSliceIntf *[]interface{}
  61. FSliceString []string
  62. FptrSliceString *[]string
  63. FSliceBytes [][]byte
  64. FptrSliceBytes *[][]byte
  65. FSliceFloat32 []float32
  66. FptrSliceFloat32 *[]float32
  67. FSliceFloat64 []float64
  68. FptrSliceFloat64 *[]float64
  69. FSliceUint []uint
  70. FptrSliceUint *[]uint
  71. FSliceUint8 []uint8
  72. FptrSliceUint8 *[]uint8
  73. FSliceUint16 []uint16
  74. FptrSliceUint16 *[]uint16
  75. FSliceUint32 []uint32
  76. FptrSliceUint32 *[]uint32
  77. FSliceUint64 []uint64
  78. FptrSliceUint64 *[]uint64
  79. FSliceUintptr []uintptr
  80. FptrSliceUintptr *[]uintptr
  81. FSliceInt []int
  82. FptrSliceInt *[]int
  83. FSliceInt8 []int8
  84. FptrSliceInt8 *[]int8
  85. FSliceInt16 []int16
  86. FptrSliceInt16 *[]int16
  87. FSliceInt32 []int32
  88. FptrSliceInt32 *[]int32
  89. FSliceInt64 []int64
  90. FptrSliceInt64 *[]int64
  91. FSliceBool []bool
  92. FptrSliceBool *[]bool
  93. FMapStringIntf map[string]interface{}
  94. FptrMapStringIntf *map[string]interface{}
  95. FMapStringString map[string]string
  96. FptrMapStringString *map[string]string
  97. FMapStringBytes map[string][]byte
  98. FptrMapStringBytes *map[string][]byte
  99. FMapStringUint map[string]uint
  100. FptrMapStringUint *map[string]uint
  101. FMapStringUint8 map[string]uint8
  102. FptrMapStringUint8 *map[string]uint8
  103. FMapStringUint64 map[string]uint64
  104. FptrMapStringUint64 *map[string]uint64
  105. FMapStringUintptr map[string]uintptr
  106. FptrMapStringUintptr *map[string]uintptr
  107. FMapStringInt map[string]int
  108. FptrMapStringInt *map[string]int
  109. FMapStringInt64 map[string]int64
  110. FptrMapStringInt64 *map[string]int64
  111. FMapStringFloat32 map[string]float32
  112. FptrMapStringFloat32 *map[string]float32
  113. FMapStringFloat64 map[string]float64
  114. FptrMapStringFloat64 *map[string]float64
  115. FMapStringBool map[string]bool
  116. FptrMapStringBool *map[string]bool
  117. FMapUintIntf map[uint]interface{}
  118. FptrMapUintIntf *map[uint]interface{}
  119. FMapUintString map[uint]string
  120. FptrMapUintString *map[uint]string
  121. FMapUintBytes map[uint][]byte
  122. FptrMapUintBytes *map[uint][]byte
  123. FMapUintUint map[uint]uint
  124. FptrMapUintUint *map[uint]uint
  125. FMapUintUint8 map[uint]uint8
  126. FptrMapUintUint8 *map[uint]uint8
  127. FMapUintUint64 map[uint]uint64
  128. FptrMapUintUint64 *map[uint]uint64
  129. FMapUintUintptr map[uint]uintptr
  130. FptrMapUintUintptr *map[uint]uintptr
  131. FMapUintInt map[uint]int
  132. FptrMapUintInt *map[uint]int
  133. FMapUintInt64 map[uint]int64
  134. FptrMapUintInt64 *map[uint]int64
  135. FMapUintFloat32 map[uint]float32
  136. FptrMapUintFloat32 *map[uint]float32
  137. FMapUintFloat64 map[uint]float64
  138. FptrMapUintFloat64 *map[uint]float64
  139. FMapUintBool map[uint]bool
  140. FptrMapUintBool *map[uint]bool
  141. FMapUint8Intf map[uint8]interface{}
  142. FptrMapUint8Intf *map[uint8]interface{}
  143. FMapUint8String map[uint8]string
  144. FptrMapUint8String *map[uint8]string
  145. FMapUint8Bytes map[uint8][]byte
  146. FptrMapUint8Bytes *map[uint8][]byte
  147. FMapUint8Uint map[uint8]uint
  148. FptrMapUint8Uint *map[uint8]uint
  149. FMapUint8Uint8 map[uint8]uint8
  150. FptrMapUint8Uint8 *map[uint8]uint8
  151. FMapUint8Uint64 map[uint8]uint64
  152. FptrMapUint8Uint64 *map[uint8]uint64
  153. FMapUint8Uintptr map[uint8]uintptr
  154. FptrMapUint8Uintptr *map[uint8]uintptr
  155. FMapUint8Int map[uint8]int
  156. FptrMapUint8Int *map[uint8]int
  157. FMapUint8Int64 map[uint8]int64
  158. FptrMapUint8Int64 *map[uint8]int64
  159. FMapUint8Float32 map[uint8]float32
  160. FptrMapUint8Float32 *map[uint8]float32
  161. FMapUint8Float64 map[uint8]float64
  162. FptrMapUint8Float64 *map[uint8]float64
  163. FMapUint8Bool map[uint8]bool
  164. FptrMapUint8Bool *map[uint8]bool
  165. FMapUint64Intf map[uint64]interface{}
  166. FptrMapUint64Intf *map[uint64]interface{}
  167. FMapUint64String map[uint64]string
  168. FptrMapUint64String *map[uint64]string
  169. FMapUint64Bytes map[uint64][]byte
  170. FptrMapUint64Bytes *map[uint64][]byte
  171. FMapUint64Uint map[uint64]uint
  172. FptrMapUint64Uint *map[uint64]uint
  173. FMapUint64Uint8 map[uint64]uint8
  174. FptrMapUint64Uint8 *map[uint64]uint8
  175. FMapUint64Uint64 map[uint64]uint64
  176. FptrMapUint64Uint64 *map[uint64]uint64
  177. FMapUint64Uintptr map[uint64]uintptr
  178. FptrMapUint64Uintptr *map[uint64]uintptr
  179. FMapUint64Int map[uint64]int
  180. FptrMapUint64Int *map[uint64]int
  181. FMapUint64Int64 map[uint64]int64
  182. FptrMapUint64Int64 *map[uint64]int64
  183. FMapUint64Float32 map[uint64]float32
  184. FptrMapUint64Float32 *map[uint64]float32
  185. FMapUint64Float64 map[uint64]float64
  186. FptrMapUint64Float64 *map[uint64]float64
  187. FMapUint64Bool map[uint64]bool
  188. FptrMapUint64Bool *map[uint64]bool
  189. FMapIntIntf map[int]interface{}
  190. FptrMapIntIntf *map[int]interface{}
  191. FMapIntString map[int]string
  192. FptrMapIntString *map[int]string
  193. FMapIntBytes map[int][]byte
  194. FptrMapIntBytes *map[int][]byte
  195. FMapIntUint map[int]uint
  196. FptrMapIntUint *map[int]uint
  197. FMapIntUint8 map[int]uint8
  198. FptrMapIntUint8 *map[int]uint8
  199. FMapIntUint64 map[int]uint64
  200. FptrMapIntUint64 *map[int]uint64
  201. FMapIntUintptr map[int]uintptr
  202. FptrMapIntUintptr *map[int]uintptr
  203. FMapIntInt map[int]int
  204. FptrMapIntInt *map[int]int
  205. FMapIntInt64 map[int]int64
  206. FptrMapIntInt64 *map[int]int64
  207. FMapIntFloat32 map[int]float32
  208. FptrMapIntFloat32 *map[int]float32
  209. FMapIntFloat64 map[int]float64
  210. FptrMapIntFloat64 *map[int]float64
  211. FMapIntBool map[int]bool
  212. FptrMapIntBool *map[int]bool
  213. FMapInt64Intf map[int64]interface{}
  214. FptrMapInt64Intf *map[int64]interface{}
  215. FMapInt64String map[int64]string
  216. FptrMapInt64String *map[int64]string
  217. FMapInt64Bytes map[int64][]byte
  218. FptrMapInt64Bytes *map[int64][]byte
  219. FMapInt64Uint map[int64]uint
  220. FptrMapInt64Uint *map[int64]uint
  221. FMapInt64Uint8 map[int64]uint8
  222. FptrMapInt64Uint8 *map[int64]uint8
  223. FMapInt64Uint64 map[int64]uint64
  224. FptrMapInt64Uint64 *map[int64]uint64
  225. FMapInt64Uintptr map[int64]uintptr
  226. FptrMapInt64Uintptr *map[int64]uintptr
  227. FMapInt64Int map[int64]int
  228. FptrMapInt64Int *map[int64]int
  229. FMapInt64Int64 map[int64]int64
  230. FptrMapInt64Int64 *map[int64]int64
  231. FMapInt64Float32 map[int64]float32
  232. FptrMapInt64Float32 *map[int64]float32
  233. FMapInt64Float64 map[int64]float64
  234. FptrMapInt64Float64 *map[int64]float64
  235. FMapInt64Bool map[int64]bool
  236. FptrMapInt64Bool *map[int64]bool
  237. }
  238. // -----------
  239. type testMammoth2Binary uint64
  240. func (x testMammoth2Binary) MarshalBinary() (data []byte, err error) {
  241. data = make([]byte, 8)
  242. bigen.PutUint64(data, uint64(x))
  243. return
  244. }
  245. func (x *testMammoth2Binary) UnmarshalBinary(data []byte) (err error) {
  246. *x = testMammoth2Binary(bigen.Uint64(data))
  247. return
  248. }
  249. type testMammoth2Text uint64
  250. func (x testMammoth2Text) MarshalText() (data []byte, err error) {
  251. data = []byte(fmt.Sprintf("%b", uint64(x)))
  252. return
  253. }
  254. func (x *testMammoth2Text) UnmarshalText(data []byte) (err error) {
  255. _, err = fmt.Sscanf(string(data), "%b", (*uint64)(x))
  256. return
  257. }
  258. type testMammoth2Json uint64
  259. func (x testMammoth2Json) MarshalJSON() (data []byte, err error) {
  260. data = []byte(fmt.Sprintf("%v", uint64(x)))
  261. return
  262. }
  263. func (x *testMammoth2Json) UnmarshalJSON(data []byte) (err error) {
  264. _, err = fmt.Sscanf(string(data), "%v", (*uint64)(x))
  265. return
  266. }
  267. type testMammoth2Basic [4]uint64
  268. type TestMammoth2Wrapper struct {
  269. V TestMammoth2
  270. T testMammoth2Text
  271. B testMammoth2Binary
  272. J testMammoth2Json
  273. C testMammoth2Basic
  274. M map[testMammoth2Basic]TestMammoth2
  275. L []TestMammoth2
  276. A [4]int64
  277. }