2
0

Added Add and Replace commands

This commit is contained in:
Patrick Mylund Nielsen
2012-01-02 14:04:47 +01:00
parent 2a304e4c5c
commit a78bca69e4
2 changed files with 51 additions and 2 deletions
+25
View File
@@ -349,3 +349,28 @@ func TestDecrementInt64(t *testing.T) {
t.Error("int64 is not 3:", x)
}
}
func TestAdd(t *testing.T) {
tc := New(0, 0)
err := tc.Add("foo", "bar", 0)
if err != nil {
t.Error("Couldn't add foo even though it shouldn't exist")
}
err = tc.Add("foo", "baz", 0)
if err == nil {
t.Error("Successfully added another foo when it should have returned an error")
}
}
func TestReplace(t *testing.T) {
tc := New(0, 0)
err := tc.Replace("foo", "bar", 0)
if err == nil {
t.Error("Replaced foo when it shouldn't exist")
}
tc.Set("foo", "bar", 0)
err = tc.Replace("foo", "bar", 0)
if err != nil {
t.Error("Couldn't replace existing key foo")
}
}