Skip to content

Commit

Permalink
[Add] test on checking exist with sub keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Koyushev authored and Sergey Koyushev committed Apr 12, 2018
1 parent 43c80b3 commit 0fd0047
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion exists_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mxj

import "testing"
import (
"testing"
)

func TestExists(t *testing.T) {
m := map[string]interface{}{
Expand All @@ -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")
}
}

0 comments on commit 0fd0047

Please sign in to comment.