Skip to content

Commit

Permalink
Merge pull request #47 from serjk/exist-add-ut
Browse files Browse the repository at this point in the history
[Add] test on checking exist with sub keys
  • Loading branch information
clbanning authored Apr 12, 2018
2 parents 400a87d + 0fd0047 commit 4e06f4e
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 4e06f4e

Please sign in to comment.