add to from string

This commit is contained in:
Bel LaPointe
2019-03-14 10:44:50 -06:00
parent b3a24aca42
commit 97b53aab90
4 changed files with 94 additions and 0 deletions

View File

@@ -135,3 +135,48 @@ func TestImplementations(t *testing.T) {
}
}
}
func TestToFromString(t *testing.T) {
cases := []struct {
key string
t Type
}{
{
key: "map",
t: MAP,
},
{
key: "bolt",
t: BOLT,
},
{
key: "cache",
t: CACHE,
},
{
key: "leveldb",
t: LEVELDB,
},
{
key: "memcache",
t: MEMCACHE,
},
{
key: "memcachecluster",
t: MEMCACHECLUSTER,
},
{
key: "mongo",
t: MONGO,
},
}
for _, c := range cases {
if TypeFromString(c.key) != c.t {
t.Errorf("wrong type for %v: got %v", c.key, TypeFromString(c.key))
}
if c.key != c.t.String() {
t.Errorf("wrong string for %v (%v): got %v", int(c.t), c.key, c.t.String())
}
}
}