From 9d93af61de715a199dfc71bb4cf4976f83a384d7 Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Mon, 18 Apr 2016 16:46:44 +0200 Subject: [PATCH] Add couple tests --- toml_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/toml_test.go b/toml_test.go index e7f8f16..c36a69c 100644 --- a/toml_test.go +++ b/toml_test.go @@ -15,6 +15,10 @@ func TestTomlHas(t *testing.T) { if !tree.Has("test.key") { t.Errorf("Has - expected test.key to exists") } + + if tree.Has("") { + t.Errorf("Should return false if the key is not provided") + } } func TestTomlHasPath(t *testing.T) { @@ -72,3 +76,11 @@ func TestTomlQuery(t *testing.T) { t.Errorf("Expected 'b' with a value 2: %v", tt.Get("b")) } } + +func TestTomlFromMap(t *testing.T) { + simpleMap := map[string]interface{}{"hello": 42} + tree := TreeFromMap(simpleMap) + if tree.Get("hello") != 42 { + t.Fatal("hello should be 42, not", tree.Get("hello")) + } +}