MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestSub

Function TestSub

libs/bits/bit_array_test.go:80–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestSub(t *testing.T) {
81 testCases := []struct {
82 initBA string
83 subtractingBA string
84 expectedBA string
85 }{
86 {`null`, `null`, `null`},
87 {`"x"`, `null`, `null`},
88 {`null`, `"x"`, `null`},
89 {`"x"`, `"x"`, `"_"`},
90 {`"xxxxxx"`, `"x_x_x_"`, `"_x_x_x"`},
91 {`"x_x_x_"`, `"xxxxxx"`, `"______"`},
92 {`"xxxxxx"`, `"x_x_x_xxxx"`, `"_x_x_x"`},
93 {`"x_x_x_xxxx"`, `"xxxxxx"`, `"______xxxx"`},
94 {`"xxxxxxxxxx"`, `"x_x_x_"`, `"_x_x_xxxxx"`},
95 {`"x_x_x_"`, `"xxxxxxxxxx"`, `"______"`},
96 }
97 for _, tc := range testCases {
98 var bA *BitArray
99 err := json.Unmarshal([]byte(tc.initBA), &bA)
100 require.Nil(t, err)
101
102 var o *BitArray
103 err = json.Unmarshal([]byte(tc.subtractingBA), &o)
104 require.Nil(t, err)
105
106 got, _ := json.Marshal(bA.Sub(o))
107 require.Equal(
108 t,
109 tc.expectedBA,
110 string(got),
111 "%s minus %s doesn't equal %s",
112 tc.initBA,
113 tc.subtractingBA,
114 tc.expectedBA,
115 )
116 }
117}
118
119func TestPickRandom(t *testing.T) {
120 empty16Bits := "________________"

Callers

nothing calls this directly

Calls 4

SubMethod · 0.95
EqualMethod · 0.65
UnmarshalMethod · 0.45
MarshalMethod · 0.45

Tested by

no test coverage detected