(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func TestNormalizeJSONLimit(t *testing.T) { |
| 56 | // Set default normalize limit. |
| 57 | x.Config.Limit = z.NewSuperFlag("normalize-node=10000;").MergeAndCheckDefault(worker.LimitDefaults) |
| 58 | |
| 59 | if testing.Short() { |
| 60 | t.Skip("Skipping TestNormalizeJSONLimit") |
| 61 | } |
| 62 | |
| 63 | enc := newEncoder() |
| 64 | n := enc.newNode(enc.idForAttr("root")) |
| 65 | require.NotNil(t, n) |
| 66 | for i := range 1000 { |
| 67 | require.NoError(t, enc.AddValue(n, enc.idForAttr(fmt.Sprintf("very long attr name %06d", i)), |
| 68 | types.ValueForType(types.StringID))) |
| 69 | child1 := enc.newNode(enc.idForAttr("child1")) |
| 70 | enc.AddListChild(n, child1) |
| 71 | for j := range 100 { |
| 72 | require.NoError(t, enc.AddValue(child1, enc.idForAttr(fmt.Sprintf("long child1 attr %06d", j)), |
| 73 | types.ValueForType(types.StringID))) |
| 74 | } |
| 75 | child2 := enc.newNode(enc.idForAttr("child2")) |
| 76 | enc.AddListChild(n, child2) |
| 77 | for j := range 100 { |
| 78 | require.NoError(t, enc.AddValue(child2, enc.idForAttr(fmt.Sprintf("long child2 attr %06d", j)), |
| 79 | types.ValueForType(types.StringID))) |
| 80 | } |
| 81 | child3 := enc.newNode(enc.idForAttr("child3")) |
| 82 | enc.AddListChild(n, child3) |
| 83 | for j := range 100 { |
| 84 | require.NoError(t, enc.AddValue(child3, enc.idForAttr(fmt.Sprintf("long child3 attr %06d", j)), |
| 85 | types.ValueForType(types.StringID))) |
| 86 | } |
| 87 | } |
| 88 | _, err := enc.normalize(n) |
| 89 | require.Error(t, err, "Couldn't evaluate @normalize directive - too many results") |
| 90 | } |
| 91 | |
| 92 | func BenchmarkJsonMarshal(b *testing.B) { |
| 93 | inputStrings := [][]string{ |
nothing calls this directly
no test coverage detected