MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestIPList_ContainsIPStrings

Function TestIPList_ContainsIPStrings

internal/iplibrary/ip_list_test.go:281–305  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

279}
280
281func TestIPList_ContainsIPStrings(t *testing.T) {
282 var a = assert.NewAssertion(t)
283
284 var list = iplibrary.NewIPList()
285 for i := 0; i < 255; i++ {
286 list.Add(&iplibrary.IPItem{
287 Id: uint64(i),
288 IPFrom: iputils.ToBytes(strconv.Itoa(i) + ".168.0.1"),
289 IPTo: iputils.ToBytes(strconv.Itoa(i) + ".168.255.1"),
290 ExpiredAt: 0,
291 })
292 }
293 t.Log(len(list.ItemsMap()), "ip")
294
295 {
296 item, ok := list.ContainsIPStrings([]string{"192.168.1.100"})
297 t.Log("item:", item)
298 a.IsTrue(ok)
299 }
300 {
301 item, ok := list.ContainsIPStrings([]string{"192.167.1.100"})
302 t.Log("item:", item)
303 a.IsFalse(ok)
304 }
305}
306
307func TestIPList_Delete(t *testing.T) {
308 var list = iplibrary.NewIPList()

Callers

nothing calls this directly

Calls 5

NewIPListFunction · 0.92
LogMethod · 0.80
ContainsIPStringsMethod · 0.80
AddMethod · 0.65
ItemsMapMethod · 0.45

Tested by

no test coverage detected