Added SortByKeys

* Fixed slice allocations in strmangle helpers
* Removed duplicate commaList function
This commit is contained in:
Patrick O'brien 2016-06-07 16:21:00 +10:00
parent 4ad069f64d
commit 37a333f6ff
7 changed files with 74 additions and 36 deletions

View file

@ -142,6 +142,39 @@ func TestNonZeroDefaultSet(t *testing.T) {
}
}
func TestSortByKeys(t *testing.T) {
t.Parallel()
tests := []struct {
Keys []string
Strs []string
Ret []string
}{
{
[]string{"id", "name", "thing", "stuff"},
[]string{"thing", "stuff", "name", "id"},
[]string{"id", "name", "thing", "stuff"},
},
{
[]string{"id", "name", "thing", "stuff"},
[]string{"id", "name", "thing", "stuff"},
[]string{"id", "name", "thing", "stuff"},
},
{
[]string{"id", "name", "thing", "stuff"},
[]string{"stuff", "thing"},
[]string{"thing", "stuff"},
},
}
for i, test := range tests {
z := SortByKeys(test.Keys, test.Strs)
if !reflect.DeepEqual(test.Ret, z) {
t.Errorf("[%d] mismatch:\nWant: %#v\nGot: %#v", i, test.Ret, z)
}
}
}
func TestWherePrimaryKeyIn(t *testing.T) {
t.Parallel()