MCPcopy Create free account
hub / github.com/brimdata/super / TestNormalizeSet

Function TestNormalizeSet

complex_test.go:44–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestNormalizeSet(t *testing.T) {
45 t.Run("duplicate-element", func(t *testing.T) {
46 b := scode.NewBuilder()
47 b.BeginContainer()
48 b.Append([]byte("dup"))
49 b.Append([]byte("dup"))
50 b.TransformContainer(super.NormalizeSet)
51 b.EndContainer()
52 set := scode.Append(nil, []byte("dup"))
53 expected := scode.Append(nil, set)
54 require.Exactly(t, expected, b.Bytes())
55 })
56 t.Run("unsorted-elements", func(t *testing.T) {
57 b := scode.NewBuilder()
58 b.BeginContainer()
59 b.Append([]byte("z"))
60 b.Append([]byte("a"))
61 b.TransformContainer(super.NormalizeSet)
62 b.EndContainer()
63 set := scode.Append(nil, []byte("a"))
64 set = scode.Append(set, []byte("z"))
65 expected := scode.Append(nil, set)
66 require.Exactly(t, expected, b.Bytes())
67 })
68 t.Run("unsorted-and-duplicate-elements", func(t *testing.T) {
69 b := scode.NewBuilder()
70 big := bytes.Repeat([]byte("x"), 256)
71 small := []byte("small")
72 b.Append(big)
73 b.BeginContainer()
74 // Append duplicate elements in reverse of set-normal order.
75 for range 3 {
76 b.Append(big)
77 b.Append(big)
78 b.Append(small)
79 b.Append(small)
80 b.Append(nil)
81 b.Append(nil)
82 }
83 b.TransformContainer(super.NormalizeSet)
84 b.EndContainer()
85 set := scode.Append(nil, nil)
86 set = scode.Append(set, small)
87 set = scode.Append(set, big)
88 expected := scode.Append(nil, big)
89 expected = scode.Append(expected, set)
90 require.Exactly(t, expected, b.Bytes())
91 })
92}
93
94func TestDuplicates(t *testing.T) {
95 ctx := super.NewContext()

Callers

nothing calls this directly

Calls 8

BeginContainerMethod · 0.95
AppendMethod · 0.95
TransformContainerMethod · 0.95
EndContainerMethod · 0.95
BytesMethod · 0.95
NewBuilderFunction · 0.92
AppendFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected