github.com/nsqio/nsq@v1.3.0/internal/stringy/slice_test.go (about)

     1  package stringy_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/nsqio/nsq/internal/stringy"
     7  )
     8  
     9  func BenchmarkUniq(b *testing.B) {
    10  	values := []string{"a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "b"}
    11  	for i := 0; i < b.N; i++ {
    12  		values = stringy.Uniq(values)
    13  		if len(values) != 2 {
    14  			b.Fatal("values len is incorrect")
    15  		}
    16  	}
    17  }
    18  
    19  func TestUniq(t *testing.T) {
    20  	values := []string{"a", "a", "a", "b", "b", "b", "c", "c", "c"}
    21  	values = stringy.Uniq(values)
    22  	if len(values) != 3 {
    23  		t.Fatal("values len is incorrect")
    24  	}
    25  }