MCPcopy
hub / github.com/tinylib/msgp / TestStringSorted_AsSlice

Function TestStringSorted_AsSlice

msgp/setof/generated_test.go:263–286  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

261}
262
263func TestStringSorted_AsSlice(t *testing.T) {
264 set := make(StringSorted)
265 set["val0"] = struct{}{}
266 set["val1"] = struct{}{}
267 set["val2"] = struct{}{}
268 set["val3"] = struct{}{}
269 set["val4"] = struct{}{}
270
271 slice := set.AsSlice()
272 if len(slice) != len(set) {
273 t.Fatalf("length mismatch: expected %d, got %d", len(set), len(slice))
274 }
275
276 found := make(map[string]bool)
277 for _, v := range slice {
278 found[v] = true
279 }
280
281 for k := range set {
282 if !found[k] {
283 t.Fatalf("missing key in slice: %v", k)
284 }
285 }
286}
287
288func TestStringSorted_FromSlice(t *testing.T) {
289 slice := []string{"val0", "val1", "val2", "val3", "val4"}

Callers

nothing calls this directly

Calls 1

AsSliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…