github.com/hdt3213/godis@v1.2.9/datastruct/set/set_test.go (about)

     1  package set
     2  
     3  import (
     4  	"strconv"
     5  	"testing"
     6  )
     7  
     8  func TestSet(t *testing.T) {
     9  	size := 10
    10  	set := Make()
    11  	for i := 0; i < size; i++ {
    12  		set.Add(strconv.Itoa(i))
    13  	}
    14  	for i := 0; i < size; i++ {
    15  		ok := set.Has(strconv.Itoa(i))
    16  		if !ok {
    17  			t.Error("expected true actual false, key: " + strconv.Itoa(i))
    18  		}
    19  	}
    20  	for i := 0; i < size; i++ {
    21  		ok := set.Remove(strconv.Itoa(i))
    22  		if ok != 1 {
    23  			t.Error("expected true actual false, key: " + strconv.Itoa(i))
    24  		}
    25  	}
    26  	for i := 0; i < size; i++ {
    27  		ok := set.Has(strconv.Itoa(i))
    28  		if ok {
    29  			t.Error("expected false actual true, key: " + strconv.Itoa(i))
    30  		}
    31  	}
    32  }