MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / TestSet_SIsMember

Function TestSet_SIsMember

internal/data/set_test.go:338–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

336}
337
338func TestSet_SIsMember(t *testing.T) {
339 set := NewSet()
340
341 key := "key"
342
343 expectRecords := testutils.GenerateRecords(1)
344 values := [][]byte{expectRecords[0].Value}
345
346 require.NoError(t, set.SAdd(key, values, expectRecords))
347 tests := []struct {
348 key string
349 val []byte
350 ok bool
351 expectErr error
352 }{
353 {key, values[0], true, nil},
354 {key, testutils.GetRandomBytes(24), false, nil},
355 {"fake key", testutils.GetRandomBytes(24), false, ErrSetNotExist},
356 }
357 for _, tt := range tests {
358 ok, err := set.SIsMember(tt.key, tt.val)
359 if tt.expectErr != nil {
360 require.Equal(t, tt.expectErr, err)
361 } else {
362 require.Equal(t, tt.ok, ok)
363 }
364 }
365}
366
367func TestSet_SAreMembers(t *testing.T) {
368 set := NewSet()

Callers

nothing calls this directly

Calls 5

SAddMethod · 0.95
SIsMemberMethod · 0.95
GenerateRecordsFunction · 0.92
GetRandomBytesFunction · 0.92
NewSetFunction · 0.85

Tested by

no test coverage detected