package pcap

import (
	"fmt"
	"github.com/google/gopacket/layers"
	"testing"
)

func TestChanKey(t *testing.T) {

	ch := make([]chan struct{}, 10)

	for i := 0; i < 10; i++ {
		ch[i] = make(chan struct{})
	}

	c := ch[5]

	for n, v := range ch {
		if c == v {
			fmt.Println(n)
		}
	}

	for i := 0; i < 10; i++ {
		close(ch[i])
	}
}

func TestDeleteSlice(t *testing.T) {

	a := make([]int, 0)

	for i := 0; i < 10; i++ {
		a = append(a, i)
	}

	t.Log(a)

	i := 4

	a = append(a[:i], a[i+1:]...)
	t.Log(a)

	a = a[:0]
	t.Log(len(a))

}

func TestMapForRange(t *testing.T) {
	a := make(map[int]int, 0)

	for i := 0; i < 10; i++ {
		a[i] = i + 1000
	}

	for v, vv := range a {
		t.Log(v)
		t.Log(vv)
	}
}

const arptest = 0

func closechan(s interface{}, t int) {
	if t == arptest {
		close(s.(chan *layers.ARP))
	}

}

func TestCloseChannels(t *testing.T) {
	a := make(chan *layers.ARP, 0)
	closechan(a, arptest)

}
