github.com/seeker-insurance/kit@v0.0.13/maputil/stringmap/stringmap_test.go (about)

     1  package stringmap
     2  
     3  import (
     4  	"sort"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  var m = map[string]string{"a": "a", "b": "b", "c": "c"}
    11  
    12  func TestSortedKeys(t *testing.T) {
    13  	want := []string{"a", "b", "c"}
    14  	got := SortedKeys(m)
    15  	assert.Equal(t, want, got)
    16  }
    17  func TestVals(t *testing.T) {
    18  	want := []string{"a", "b", "c"}
    19  	got := Vals(m)
    20  	sort.Strings(got)
    21  	assert.Equal(t, want, got)
    22  }
    23  func TestSortedVals(t *testing.T) {
    24  	want := []string{"a", "b", "c"}
    25  	got := SortedVals(m)
    26  	assert.Equal(t, want, got)
    27  }
    28  func TestCopy(t *testing.T) {
    29  	want := Copy(m)
    30  	got := Copy(want)
    31  	assert.Equal(t, want, got)
    32  	got["d"] = "d"
    33  	assert.NotEqual(t, want, got) //no leak
    34  }