github.com/puellanivis/breton@v0.2.16/lib/metrics/internal/kv/keyval_test.go (about)

     1  package kv
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestKeyVal(t *testing.T) {
     9  	var kv KeyVal
    10  
    11  	kv.Append("alice", "1")
    12  	kv.Append("eve", "3")
    13  	kv.Append("bob", "2")
    14  
    15  	kv.Sort()
    16  
    17  	var (
    18  		keysExpected = []string{"alice", "bob", "eve"}
    19  		ValsExpected = []string{"1", "2", "3"}
    20  	)
    21  
    22  	if !reflect.DeepEqual(keysExpected, kv.Keys) {
    23  		t.Errorf("keys not sorted, expected %#v, got %#v", keysExpected, kv.Keys)
    24  	}
    25  
    26  	if !reflect.DeepEqual(ValsExpected, kv.Vals) {
    27  		t.Errorf("Vals not sorted, expected %#v, got %#v", ValsExpected, kv.Vals)
    28  	}
    29  }