mirror of https://bitbucket.org/ausocean/av.git
add TestDeleteOrder to check that the order of keys is correct after deletion
This commit is contained in:
parent
9a9dba0cd2
commit
7ae9f265e0
|
@ -251,3 +251,45 @@ func TestEncodeAsString(t *testing.T) {
|
||||||
t.Errorf("Did not get expected out. \nGot : %v, \nWant: %v or %v\n", got, want1, want2)
|
t.Errorf("Did not get expected out. \nGot : %v, \nWant: %v or %v\n", got, want1, want2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestDeleteOrder checks that the order of keys is correct after a deletion.
|
||||||
|
func TestDeleteOrder(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
delKey string
|
||||||
|
want []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"key1",
|
||||||
|
[]string{"key2", "key3", "key4"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key2",
|
||||||
|
[]string{"key1", "key3", "key4"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key3",
|
||||||
|
[]string{"key1", "key2", "key4"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key4",
|
||||||
|
[]string{"key1", "key2", "key3"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Logf("deleting %s", test.delKey)
|
||||||
|
meta := NewWith([][2]string{
|
||||||
|
{"key1", "val1"},
|
||||||
|
{"key2", "val2"},
|
||||||
|
{"key3", "val3"},
|
||||||
|
{"key4", "val4"},
|
||||||
|
})
|
||||||
|
meta.Delete(test.delKey)
|
||||||
|
|
||||||
|
got := meta.order
|
||||||
|
want := test.want
|
||||||
|
if !reflect.DeepEqual(got, want) {
|
||||||
|
t.Errorf("Did not get expected out. \nGot: %v, \nWant: %v\n", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue