From 0fd004793caab4edd166a1815fafc103c4d697cf Mon Sep 17 00:00:00 2001 From: Sergey Koyushev Date: Thu, 12 Apr 2018 13:20:15 +0300 Subject: [PATCH] [Add] test on checking exist with sub keys --- exists_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/exists_test.go b/exists_test.go index f5ae7c4..8eb9105 100644 --- a/exists_test.go +++ b/exists_test.go @@ -1,6 +1,8 @@ package mxj -import "testing" +import ( + "testing" +) func TestExists(t *testing.T) { m := map[string]interface{}{ @@ -18,3 +20,18 @@ func TestExists(t *testing.T) { t.Fatal("Have found a non existing element") } } + +func TestExistsWithSubKeys(t *testing.T) { + mv, err := NewMapXml(doc2) + if err != nil { + t.Fatal("err:", err.Error()) + } + + if !mv.Exists("doc.books.book", "-seq:1") { + t.Fatal("Haven't found an existing element") + } + + if mv.Exists("doc.books.book", "-seq:2") { + t.Fatal("Have found a non existing element") + } +} \ No newline at end of file