values_flex_test.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* // +build testing */
  2. // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
  3. // Use of this source code is governed by a MIT license found in the LICENSE file.
  4. package codec
  5. // This file contains values used by tests and benchmarks.
  6. type TestStrucFlex struct {
  7. _struct struct{} `codec:",omitempty"` //set omitempty for every field
  8. testStrucCommon
  9. Mis map[int]string
  10. Miwu64s map[int]wrapUint64Slice
  11. Mfwss map[float64]wrapStringSlice
  12. Mf32wss map[float32]wrapStringSlice
  13. Mui2wss map[uint64]wrapStringSlice
  14. Msu2wss map[stringUint64T]wrapStringSlice
  15. //M map[interface{}]interface{} `json:"-",bson:"-"`
  16. Mtsptr map[string]*TestStrucFlex
  17. Mts map[string]TestStrucFlex
  18. Its []*TestStrucFlex
  19. Nteststruc *TestStrucFlex
  20. }
  21. func newTestStrucFlex(depth, n int, bench, useInterface, useStringKeyOnly bool) (ts *TestStrucFlex) {
  22. ts = &TestStrucFlex{
  23. Miwu64s: map[int]wrapUint64Slice{
  24. 5: []wrapUint64{1, 2, 3, 4, 5},
  25. 3: []wrapUint64{1, 2, 3},
  26. },
  27. Mf32wss: map[float32]wrapStringSlice{
  28. 5.0: []wrapString{"1.0", "2.0", "3.0", "4.0", "5.0"},
  29. 3.0: []wrapString{"1.0", "2.0", "3.0"},
  30. },
  31. Mui2wss: map[uint64]wrapStringSlice{
  32. 5: []wrapString{"1.0", "2.0", "3.0", "4.0", "5.0"},
  33. 3: []wrapString{"1.0", "2.0", "3.0"},
  34. },
  35. Mfwss: map[float64]wrapStringSlice{
  36. 5.0: []wrapString{"1.0", "2.0", "3.0", "4.0", "5.0"},
  37. 3.0: []wrapString{"1.0", "2.0", "3.0"},
  38. },
  39. Mis: map[int]string{
  40. 1: "one",
  41. 22: "twenty two",
  42. -44: "minus forty four",
  43. },
  44. }
  45. populateTestStrucCommon(&ts.testStrucCommon, n, bench, useInterface, useStringKeyOnly)
  46. if depth > 0 {
  47. depth--
  48. if ts.Mtsptr == nil {
  49. ts.Mtsptr = make(map[string]*TestStrucFlex)
  50. }
  51. if ts.Mts == nil {
  52. ts.Mts = make(map[string]TestStrucFlex)
  53. }
  54. ts.Mtsptr["0"] = newTestStrucFlex(depth, n, bench, useInterface, useStringKeyOnly)
  55. ts.Mts["0"] = *(ts.Mtsptr["0"])
  56. ts.Its = append(ts.Its, ts.Mtsptr["0"])
  57. }
  58. return
  59. }