MCPcopy Create free account
hub / github.com/SamNet-dev/snix / TestTableAddGetRemove

Function TestTableAddGetRemove

core/conntrack/connection_test.go:17–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15}
16
17func TestTableAddGetRemove(t *testing.T) {
18 tab := NewTable()
19 c := New(tup(40000, 443), []byte("fake"))
20 if !tab.Add(c) {
21 t.Fatal("Add returned false on empty table")
22 }
23 if tab.Add(c) {
24 t.Fatal("duplicate Add should return false")
25 }
26 if tab.Len() != 1 {
27 t.Fatalf("Len: got %d want 1", tab.Len())
28 }
29 got, ok := tab.Get(c.Tuple)
30 if !ok || got != c {
31 t.Fatalf("Get: ok=%v same=%v", ok, got == c)
32 }
33 tab.Remove(c.Tuple)
34 if tab.Len() != 0 {
35 t.Fatalf("Len after Remove: got %d want 0", tab.Len())
36 }
37 tab.Remove(c.Tuple) // idempotent
38}
39
40func TestFinishIsIdempotentAndClosesDone(t *testing.T) {
41 c := New(tup(1, 443), nil)

Callers

nothing calls this directly

Calls 7

AddMethod · 0.95
LenMethod · 0.95
GetMethod · 0.95
RemoveMethod · 0.95
NewTableFunction · 0.85
tupFunction · 0.85
NewFunction · 0.70

Tested by

no test coverage detected