Added SortByKeys
* Fixed slice allocations in strmangle helpers * Removed duplicate commaList function
This commit is contained in:
parent
4ad069f64d
commit
37a333f6ff
7 changed files with 74 additions and 36 deletions
boil
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue