z_all_test.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
  2. // Use of this source code is governed by a MIT license found in the LICENSE file.
  3. // +build alltests
  4. // +build go1.7
  5. package codec
  6. // Run this using:
  7. // go test -tags=alltests -run=Suite -coverprofile=cov.out
  8. // go tool cover -html=cov.out
  9. //
  10. // Because build tags are a build time parameter, we will have to test out the
  11. // different tags separately.
  12. // Tags: x codecgen safe appengine notfastpath
  13. //
  14. // These tags should be added to alltests, e.g.
  15. // go test '-tags=alltests x codecgen' -run=Suite -coverprofile=cov.out
  16. //
  17. // To run all tests before submitting code, run:
  18. // a=( "" "safe" "codecgen" "notfastpath" "codecgen notfastpath" "codecgen safe" "safe notfastpath" )
  19. // for i in "${a[@]}"; do echo ">>>> TAGS: $i"; go test "-tags=alltests $i" -run=Suite; done
  20. //
  21. // This only works on go1.7 and above. This is when subtests and suites were supported.
  22. import "testing"
  23. // func TestMain(m *testing.M) {
  24. // println("calling TestMain")
  25. // // set some parameters
  26. // exitcode := m.Run()
  27. // os.Exit(exitcode)
  28. // }
  29. func testGroupResetFlags() {
  30. testUseMust = false
  31. testUseIoEncDec = -1
  32. testUseReset = false
  33. testMaxInitLen = 0
  34. testUseIoWrapper = false
  35. testNumRepeatString = 8
  36. testDepth = 0
  37. testDecodeOptions = DecodeOptions{}
  38. testEncodeOptions = EncodeOptions{}
  39. }
  40. func testSuite(t *testing.T, f func(t *testing.T)) {
  41. // find . -name "*_test.go" | xargs grep -e 'flag.' | cut -d '&' -f 2 | cut -d ',' -f 1 | grep -e '^test'
  42. // Disregard the following: testInitDebug, testSkipIntf, testJsonIndent (Need a test for it)
  43. testReinit() // so flag.Parse() is called first, and never called again
  44. testGroupResetFlags()
  45. testReinit()
  46. t.Run("optionsFalse", f)
  47. testUseMust = true
  48. testUseIoEncDec = 0
  49. testUseReset = true
  50. // xdebugf("with StructToArray=true")
  51. testDecodeOptions.InternString = true
  52. testDecodeOptions.MapValueReset = true
  53. // testDecodeOptions.SignedInteger = true
  54. // testDecodeOptions.SliceElementReset = true
  55. // testDecodeOptions.InterfaceReset = true
  56. // testDecodeOptions.PreferArrayOverSlice = true
  57. // testDecodeOptions.DeleteOnNilMapValue = true
  58. // testDecodeOptions.RawToString = true
  59. testEncodeOptions.StructToArray = true
  60. testEncodeOptions.Canonical = true
  61. testEncodeOptions.CheckCircularRef = true
  62. testEncodeOptions.RecursiveEmptyCheck = true
  63. // testEncodeOptions.Raw = true
  64. // testEncodeOptions.StringToRaw = true
  65. testReinit()
  66. t.Run("optionsTrue", f)
  67. // xdebugf("setting StructToArray=false")
  68. testEncodeOptions.StructToArray = false
  69. testDepth = 6
  70. testReinit()
  71. t.Run("optionsTrue-deepstruct", f)
  72. testDepth = 0
  73. // testEncodeOptions.AsSymbols = AsSymbolAll
  74. testUseIoWrapper = true
  75. testReinit()
  76. t.Run("optionsTrue-ioWrapper", f)
  77. // testUseIoEncDec = -1
  78. // make buffer small enough so that we have to re-fill multiple times.
  79. testSkipRPCTests = true
  80. testUseIoEncDec = 128
  81. // testDecodeOptions.ReaderBufferSize = 128
  82. // testEncodeOptions.WriterBufferSize = 128
  83. testReinit()
  84. t.Run("optionsTrue-bufio", f)
  85. // testDecodeOptions.ReaderBufferSize = 0
  86. // testEncodeOptions.WriterBufferSize = 0
  87. testUseIoEncDec = -1
  88. testSkipRPCTests = false
  89. testNumRepeatString = 32
  90. testReinit()
  91. t.Run("optionsTrue-largestrings", f)
  92. // The following here MUST be tested individually, as they create
  93. // side effects i.e. the decoded value is different.
  94. // testDecodeOptions.MapValueReset = true // ok - no side effects
  95. // testDecodeOptions.InterfaceReset = true // error??? because we do deepEquals to verify
  96. // testDecodeOptions.ErrorIfNoField = true // error, as expected, as fields not there
  97. // testDecodeOptions.ErrorIfNoArrayExpand = true // no error, but no error case either
  98. // testDecodeOptions.PreferArrayOverSlice = true // error??? because slice != array.
  99. // .... however, update deepEqual to take this option
  100. // testReinit()
  101. // t.Run("optionsTrue-resetOptions", f)
  102. testGroupResetFlags()
  103. }
  104. /*
  105. find . -name "codec_test.go" | xargs grep -e '^func Test' | \
  106. cut -d '(' -f 1 | cut -d ' ' -f 2 | \
  107. while read f; do echo "t.Run(\"$f\", $f)"; done
  108. */
  109. func testCodecGroup(t *testing.T) {
  110. // println("running testcodecsuite")
  111. // <setup code>
  112. testJsonGroup(t)
  113. testBincGroup(t)
  114. testCborGroup(t)
  115. testMsgpackGroup(t)
  116. testSimpleGroup(t)
  117. // testSimpleMammothGroup(t)
  118. // testRpcGroup(t)
  119. testNonHandlesGroup(t)
  120. // <tear-down code>
  121. }
  122. func testJsonGroup(t *testing.T) {
  123. t.Run("TestJsonCodecsTable", TestJsonCodecsTable)
  124. t.Run("TestJsonCodecsMisc", TestJsonCodecsMisc)
  125. t.Run("TestJsonCodecsEmbeddedPointer", TestJsonCodecsEmbeddedPointer)
  126. t.Run("TestJsonCodecChan", TestJsonCodecChan)
  127. t.Run("TestJsonStdEncIntf", TestJsonStdEncIntf)
  128. t.Run("TestJsonMammothA", TestJsonMammothA)
  129. t.Run("TestJsonRaw", TestJsonRaw)
  130. t.Run("TestJsonRpcGo", TestJsonRpcGo)
  131. t.Run("TestJsonLargeInteger", TestJsonLargeInteger)
  132. t.Run("TestJsonDecodeNonStringScalarInStringContext", TestJsonDecodeNonStringScalarInStringContext)
  133. t.Run("TestJsonEncodeIndent", TestJsonEncodeIndent)
  134. t.Run("TestJsonSwallowAndZero", TestJsonSwallowAndZero)
  135. t.Run("TestJsonRawExt", TestJsonRawExt)
  136. t.Run("TestJsonMapStructKey", TestJsonMapStructKey)
  137. t.Run("TestJsonDecodeNilMapValue", TestJsonDecodeNilMapValue)
  138. t.Run("TestJsonEmbeddedFieldPrecedence", TestJsonEmbeddedFieldPrecedence)
  139. t.Run("TestJsonLargeContainerLen", TestJsonLargeContainerLen)
  140. t.Run("TestJsonMammothMapsAndSlices", TestJsonMammothMapsAndSlices)
  141. t.Run("TestJsonTime", TestJsonTime)
  142. t.Run("TestJsonUintToInt", TestJsonUintToInt)
  143. t.Run("TestJsonDifferentMapOrSliceType", TestJsonDifferentMapOrSliceType)
  144. t.Run("TestJsonScalars", TestJsonScalars)
  145. t.Run("TestJsonOmitempty", TestJsonOmitempty)
  146. t.Run("TestJsonIntfMapping", TestJsonIntfMapping)
  147. t.Run("TestJsonMissingFields", TestJsonMissingFields)
  148. t.Run("TestJsonMaxDepth", TestJsonMaxDepth)
  149. t.Run("TestJsonSelfExt", TestJsonSelfExt)
  150. t.Run("TestJsonBytesEncodedAsArray", TestJsonBytesEncodedAsArray)
  151. t.Run("TestJsonStrucEncDec", TestJsonStrucEncDec)
  152. t.Run("TestJsonMapEncodeForCanonical", TestJsonMapEncodeForCanonical)
  153. t.Run("TestJsonRawToStringToRawEtc", TestJsonRawToStringToRawEtc)
  154. t.Run("TestJsonStructKeyType", TestJsonStructKeyType)
  155. t.Run("TestJsonPreferArrayOverSlice", TestJsonPreferArrayOverSlice)
  156. t.Run("TestJsonInvalidUnicode", TestJsonInvalidUnicode)
  157. }
  158. func testBincGroup(t *testing.T) {
  159. t.Run("TestBincCodecsTable", TestBincCodecsTable)
  160. t.Run("TestBincCodecsMisc", TestBincCodecsMisc)
  161. t.Run("TestBincCodecsEmbeddedPointer", TestBincCodecsEmbeddedPointer)
  162. t.Run("TestBincStdEncIntf", TestBincStdEncIntf)
  163. t.Run("TestBincMammoth", TestBincMammoth)
  164. t.Run("TestBincRaw", TestBincRaw)
  165. t.Run("TestBincRpcGo", TestBincRpcGo)
  166. t.Run("TestBincUnderlyingType", TestBincUnderlyingType)
  167. t.Run("TestBincSwallowAndZero", TestBincSwallowAndZero)
  168. t.Run("TestBincRawExt", TestBincRawExt)
  169. t.Run("TestBincMapStructKey", TestBincMapStructKey)
  170. t.Run("TestBincDecodeNilMapValue", TestBincDecodeNilMapValue)
  171. t.Run("TestBincEmbeddedFieldPrecedence", TestBincEmbeddedFieldPrecedence)
  172. t.Run("TestBincLargeContainerLen", TestBincLargeContainerLen)
  173. t.Run("TestBincMammothMapsAndSlices", TestBincMammothMapsAndSlices)
  174. t.Run("TestBincTime", TestBincTime)
  175. t.Run("TestBincUintToInt", TestBincUintToInt)
  176. t.Run("TestBincDifferentMapOrSliceType", TestBincDifferentMapOrSliceType)
  177. t.Run("TestBincScalars", TestBincScalars)
  178. t.Run("TestBincOmitempty", TestBincOmitempty)
  179. t.Run("TestBincIntfMapping", TestBincIntfMapping)
  180. t.Run("TestBincMissingFields", TestBincMissingFields)
  181. t.Run("TestBincMaxDepth", TestBincMaxDepth)
  182. t.Run("TestBincSelfExt", TestBincSelfExt)
  183. t.Run("TestBincBytesEncodedAsArray", TestBincBytesEncodedAsArray)
  184. t.Run("TestBincStrucEncDec", TestBincStrucEncDec)
  185. t.Run("TestBincMapEncodeForCanonical", TestBincMapEncodeForCanonical)
  186. t.Run("TestBincRawToStringToRawEtc", TestBincRawToStringToRawEtc)
  187. t.Run("TestBincStructKeyType", TestBincStructKeyType)
  188. t.Run("TestBincPreferArrayOverSlice", TestBincPreferArrayOverSlice)
  189. }
  190. func testCborGroup(t *testing.T) {
  191. t.Run("TestCborCodecsTable", TestCborCodecsTable)
  192. t.Run("TestCborCodecsMisc", TestCborCodecsMisc)
  193. t.Run("TestCborCodecsEmbeddedPointer", TestCborCodecsEmbeddedPointer)
  194. t.Run("TestCborCodecChan", TestCborCodecChan)
  195. t.Run("TestCborStdEncIntf", TestCborStdEncIntf)
  196. t.Run("TestCborMammoth", TestCborMammoth)
  197. t.Run("TestCborRaw", TestCborRaw)
  198. t.Run("TestCborRpcGo", TestCborRpcGo)
  199. t.Run("TestCborSwallowAndZero", TestCborSwallowAndZero)
  200. t.Run("TestCborRawExt", TestCborRawExt)
  201. t.Run("TestCborMapStructKey", TestCborMapStructKey)
  202. t.Run("TestCborDecodeNilMapValue", TestCborDecodeNilMapValue)
  203. t.Run("TestCborEmbeddedFieldPrecedence", TestCborEmbeddedFieldPrecedence)
  204. t.Run("TestCborLargeContainerLen", TestCborLargeContainerLen)
  205. t.Run("TestCborMammothMapsAndSlices", TestCborMammothMapsAndSlices)
  206. t.Run("TestCborTime", TestCborTime)
  207. t.Run("TestCborUintToInt", TestCborUintToInt)
  208. t.Run("TestCborDifferentMapOrSliceType", TestCborDifferentMapOrSliceType)
  209. t.Run("TestCborScalars", TestCborScalars)
  210. t.Run("TestCborOmitempty", TestCborOmitempty)
  211. t.Run("TestCborIntfMapping", TestCborIntfMapping)
  212. t.Run("TestCborMissingFields", TestCborMissingFields)
  213. t.Run("TestCborMaxDepth", TestCborMaxDepth)
  214. t.Run("TestCborSelfExt", TestCborSelfExt)
  215. t.Run("TestCborBytesEncodedAsArray", TestCborBytesEncodedAsArray)
  216. t.Run("TestCborStrucEncDec", TestCborStrucEncDec)
  217. t.Run("TestCborMapEncodeForCanonical", TestCborMapEncodeForCanonical)
  218. t.Run("TestCborRawToStringToRawEtc", TestCborRawToStringToRawEtc)
  219. t.Run("TestCborStructKeyType", TestCborStructKeyType)
  220. t.Run("TestCborPreferArrayOverSlice", TestCborPreferArrayOverSlice)
  221. t.Run("TestCborHalfFloat", TestCborHalfFloat)
  222. t.Run("TestCborSkipTags", TestCborSkipTags)
  223. }
  224. func testMsgpackGroup(t *testing.T) {
  225. t.Run("TestMsgpackCodecsTable", TestMsgpackCodecsTable)
  226. t.Run("TestMsgpackCodecsMisc", TestMsgpackCodecsMisc)
  227. t.Run("TestMsgpackCodecsEmbeddedPointer", TestMsgpackCodecsEmbeddedPointer)
  228. t.Run("TestMsgpackStdEncIntf", TestMsgpackStdEncIntf)
  229. t.Run("TestMsgpackMammoth", TestMsgpackMammoth)
  230. t.Run("TestMsgpackRaw", TestMsgpackRaw)
  231. t.Run("TestMsgpackRpcGo", TestMsgpackRpcGo)
  232. t.Run("TestMsgpackRpcSpec", TestMsgpackRpcSpec)
  233. t.Run("TestMsgpackSwallowAndZero", TestMsgpackSwallowAndZero)
  234. t.Run("TestMsgpackRawExt", TestMsgpackRawExt)
  235. t.Run("TestMsgpackMapStructKey", TestMsgpackMapStructKey)
  236. t.Run("TestMsgpackDecodeNilMapValue", TestMsgpackDecodeNilMapValue)
  237. t.Run("TestMsgpackEmbeddedFieldPrecedence", TestMsgpackEmbeddedFieldPrecedence)
  238. t.Run("TestMsgpackLargeContainerLen", TestMsgpackLargeContainerLen)
  239. t.Run("TestMsgpackMammothMapsAndSlices", TestMsgpackMammothMapsAndSlices)
  240. t.Run("TestMsgpackTime", TestMsgpackTime)
  241. t.Run("TestMsgpackUintToInt", TestMsgpackUintToInt)
  242. t.Run("TestMsgpackDifferentMapOrSliceType", TestMsgpackDifferentMapOrSliceType)
  243. t.Run("TestMsgpackScalars", TestMsgpackScalars)
  244. t.Run("TestMsgpackOmitempty", TestMsgpackOmitempty)
  245. t.Run("TestMsgpackIntfMapping", TestMsgpackIntfMapping)
  246. t.Run("TestMsgpackMissingFields", TestMsgpackMissingFields)
  247. t.Run("TestMsgpackMaxDepth", TestMsgpackMaxDepth)
  248. t.Run("TestMsgpackSelfExt", TestMsgpackSelfExt)
  249. t.Run("TestMsgpackBytesEncodedAsArray", TestMsgpackBytesEncodedAsArray)
  250. t.Run("TestMsgpackStrucEncDec", TestMsgpackStrucEncDec)
  251. t.Run("TestMsgpackMapEncodeForCanonical", TestMsgpackMapEncodeForCanonical)
  252. t.Run("TestMsgpackRawToStringToRawEtc", TestMsgpackRawToStringToRawEtc)
  253. t.Run("TestMsgpackStructKeyType", TestMsgpackStructKeyType)
  254. t.Run("TestMsgpackPreferArrayOverSlice", TestMsgpackPreferArrayOverSlice)
  255. t.Run("TestMsgpackDecodeMapAndExtSizeMismatch", TestMsgpackDecodeMapAndExtSizeMismatch)
  256. }
  257. func testSimpleGroup(t *testing.T) {
  258. t.Run("TestSimpleCodecsTable", TestSimpleCodecsTable)
  259. t.Run("TestSimpleCodecsMisc", TestSimpleCodecsMisc)
  260. t.Run("TestSimpleCodecsEmbeddedPointer", TestSimpleCodecsEmbeddedPointer)
  261. t.Run("TestSimpleStdEncIntf", TestSimpleStdEncIntf)
  262. t.Run("TestSimpleMammoth", TestSimpleMammoth)
  263. t.Run("TestSimpleRaw", TestSimpleRaw)
  264. t.Run("TestSimpleRpcGo", TestSimpleRpcGo)
  265. t.Run("TestSimpleSwallowAndZero", TestSimpleSwallowAndZero)
  266. t.Run("TestSimpleRawExt", TestSimpleRawExt)
  267. t.Run("TestSimpleMapStructKey", TestSimpleMapStructKey)
  268. t.Run("TestSimpleDecodeNilMapValue", TestSimpleDecodeNilMapValue)
  269. t.Run("TestSimpleEmbeddedFieldPrecedence", TestSimpleEmbeddedFieldPrecedence)
  270. t.Run("TestSimpleLargeContainerLen", TestSimpleLargeContainerLen)
  271. t.Run("TestSimpleMammothMapsAndSlices", TestSimpleMammothMapsAndSlices)
  272. t.Run("TestSimpleTime", TestSimpleTime)
  273. t.Run("TestSimpleUintToInt", TestSimpleUintToInt)
  274. t.Run("TestSimpleDifferentMapOrSliceType", TestSimpleDifferentMapOrSliceType)
  275. t.Run("TestSimpleScalars", TestSimpleScalars)
  276. t.Run("TestSimpleOmitempty", TestSimpleOmitempty)
  277. t.Run("TestSimpleIntfMapping", TestSimpleIntfMapping)
  278. t.Run("TestSimpleMissingFields", TestSimpleMissingFields)
  279. t.Run("TestSimpleMaxDepth", TestSimpleMaxDepth)
  280. t.Run("TestSimpleSelfExt", TestSimpleSelfExt)
  281. t.Run("TestSimpleBytesEncodedAsArray", TestSimpleBytesEncodedAsArray)
  282. t.Run("TestSimpleStrucEncDec", TestSimpleStrucEncDec)
  283. t.Run("TestSimpleMapEncodeForCanonical", TestSimpleMapEncodeForCanonical)
  284. t.Run("TestSimpleRawToStringToRawEtc", TestSimpleRawToStringToRawEtc)
  285. t.Run("TestSimpleStructKeyType", TestSimpleStructKeyType)
  286. t.Run("TestSimplePreferArrayOverSlice", TestSimplePreferArrayOverSlice)
  287. }
  288. func testSimpleMammothGroup(t *testing.T) {
  289. t.Run("TestSimpleMammothMapsAndSlices", TestSimpleMammothMapsAndSlices)
  290. }
  291. func testRpcGroup(t *testing.T) {
  292. t.Run("TestBincRpcGo", TestBincRpcGo)
  293. t.Run("TestSimpleRpcGo", TestSimpleRpcGo)
  294. t.Run("TestMsgpackRpcGo", TestMsgpackRpcGo)
  295. t.Run("TestCborRpcGo", TestCborRpcGo)
  296. t.Run("TestJsonRpcGo", TestJsonRpcGo)
  297. t.Run("TestMsgpackRpcSpec", TestMsgpackRpcSpec)
  298. }
  299. func testNonHandlesGroup(t *testing.T) {
  300. // grep "func Test" codec_test.go | grep -v -E '(Cbor|Json|Simple|Msgpack|Binc)'
  301. t.Run("TestBufioDecReader", TestBufioDecReader)
  302. t.Run("TestAtomic", TestAtomic)
  303. t.Run("TestAllEncCircularRef", TestAllEncCircularRef)
  304. t.Run("TestAllAnonCycle", TestAllAnonCycle)
  305. t.Run("TestMultipleEncDec", TestMultipleEncDec)
  306. t.Run("TestAllErrWriter", TestAllErrWriter)
  307. t.Run("TestMapRangeIndex", TestMapRangeIndex)
  308. }
  309. func TestCodecSuite(t *testing.T) {
  310. testSuite(t, testCodecGroup)
  311. testGroupResetFlags()
  312. oldIndent, oldCharsAsis, oldPreferFloat, oldMapKeyAsString :=
  313. testJsonH.Indent, testJsonH.HTMLCharsAsIs, testJsonH.PreferFloat, testJsonH.MapKeyAsString
  314. testMaxInitLen = 10
  315. testJsonH.Indent = 8
  316. testJsonH.HTMLCharsAsIs = true
  317. testJsonH.MapKeyAsString = true
  318. // testJsonH.PreferFloat = true
  319. testReinit()
  320. t.Run("json-spaces-htmlcharsasis-initLen10", testJsonGroup)
  321. testMaxInitLen = 10
  322. testJsonH.Indent = -1
  323. testJsonH.HTMLCharsAsIs = false
  324. testJsonH.MapKeyAsString = true
  325. // testJsonH.PreferFloat = false
  326. testReinit()
  327. t.Run("json-tabs-initLen10", testJsonGroup)
  328. testJsonH.Indent, testJsonH.HTMLCharsAsIs, testJsonH.PreferFloat, testJsonH.MapKeyAsString =
  329. oldIndent, oldCharsAsis, oldPreferFloat, oldMapKeyAsString
  330. oldIndefLen := testCborH.IndefiniteLength
  331. testCborH.IndefiniteLength = true
  332. testReinit()
  333. t.Run("cbor-indefinitelength", testCborGroup)
  334. testCborH.IndefiniteLength = oldIndefLen
  335. oldTimeRFC3339 := testCborH.TimeRFC3339
  336. testCborH.TimeRFC3339 = !testCborH.TimeRFC3339
  337. testReinit()
  338. t.Run("cbor-rfc3339", testCborGroup)
  339. testCborH.TimeRFC3339 = oldTimeRFC3339
  340. oldSkipUnexpectedTags := testCborH.SkipUnexpectedTags
  341. testCborH.SkipUnexpectedTags = !testCborH.SkipUnexpectedTags
  342. testReinit()
  343. t.Run("cbor-skip-tags", testCborGroup)
  344. testCborH.SkipUnexpectedTags = oldSkipUnexpectedTags
  345. oldSymbols := testBincH.AsSymbols
  346. testBincH.AsSymbols = 2 // AsSymbolNone
  347. testReinit()
  348. t.Run("binc-no-symbols", testBincGroup)
  349. testBincH.AsSymbols = 1 // AsSymbolAll
  350. testReinit()
  351. t.Run("binc-all-symbols", testBincGroup)
  352. testBincH.AsSymbols = oldSymbols
  353. oldWriteExt := testMsgpackH.WriteExt
  354. oldNoFixedNum := testMsgpackH.NoFixedNum
  355. testMsgpackH.WriteExt = !testMsgpackH.WriteExt
  356. testReinit()
  357. t.Run("msgpack-inverse-writeext", testMsgpackGroup)
  358. testMsgpackH.WriteExt = oldWriteExt
  359. testMsgpackH.NoFixedNum = !testMsgpackH.NoFixedNum
  360. testReinit()
  361. t.Run("msgpack-fixednum", testMsgpackGroup)
  362. testMsgpackH.NoFixedNum = oldNoFixedNum
  363. oldEncZeroValuesAsNil := testSimpleH.EncZeroValuesAsNil
  364. testSimpleH.EncZeroValuesAsNil = !testSimpleH.EncZeroValuesAsNil
  365. testUseMust = true
  366. testReinit()
  367. t.Run("simple-enczeroasnil", testSimpleMammothGroup) // testSimpleGroup
  368. testSimpleH.EncZeroValuesAsNil = oldEncZeroValuesAsNil
  369. oldRpcBufsize := testRpcBufsize
  370. testRpcBufsize = 0
  371. t.Run("rpc-buf-0", testRpcGroup)
  372. testRpcBufsize = 0
  373. t.Run("rpc-buf-00", testRpcGroup)
  374. testRpcBufsize = 0
  375. t.Run("rpc-buf-000", testRpcGroup)
  376. testRpcBufsize = 16
  377. t.Run("rpc-buf-16", testRpcGroup)
  378. testRpcBufsize = 2048
  379. t.Run("rpc-buf-2048", testRpcGroup)
  380. testRpcBufsize = oldRpcBufsize
  381. testGroupResetFlags()
  382. }
  383. // func TestCodecSuite(t *testing.T) {
  384. // testReinit() // so flag.Parse() is called first, and never called again
  385. // testDecodeOptions, testEncodeOptions = DecodeOptions{}, EncodeOptions{}
  386. // testGroupResetFlags()
  387. // testReinit()
  388. // t.Run("optionsFalse", func(t *testing.T) {
  389. // t.Run("TestJsonMammothMapsAndSlices", TestJsonMammothMapsAndSlices)
  390. // })
  391. // }