z_all_test.go 17 KB

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