@@ -102,21 +102,23 @@ func TestXPathQuery(t *testing.T) {
102102 type test struct {
103103 input string
104104 node bool
105+ single bool
105106 query string
106107 result string
107108 }
108109
109110 tests := []test {
110- {input : "formatted.xml" , node : false , query : "//first_name" , result : "John" },
111- {input : "unformatted8.xml" , node : false , query : "//title" , result : "Some Title" },
112- {input : "unformatted8.xml" , node : true , query : "//title" , result : "<title>Some Title</title>" },
111+ {input : "formatted.xml" , node : false , single : true , query : "//first_name" , result : "John" },
112+ {input : "unformatted8.xml" , node : false , single : true , query : "//title" , result : "Some Title" },
113+ {input : "unformatted8.xml" , node : true , single : true , query : "//title" , result : "<title>Some Title</title>" },
114+ {input : "unformatted8.xml" , node : false , single : false , query : "count(//link)" , result : "2" },
113115 }
114116
115117 for _ , testCase := range tests {
116118 fileReader := getFileReader (path .Join (".." , ".." , "test" , "data" , "xml" , testCase .input ))
117119 output := new (strings.Builder )
118120 options := QueryOptions {WithTags : testCase .node , Indent : " " }
119- err := XPathQuery (fileReader , output , testCase .query , true , options )
121+ err := XPathQuery (fileReader , output , testCase .query , testCase . single , options )
120122 assert .Nil (t , err )
121123 assert .Equal (t , testCase .result , strings .Trim (output .String (), "\n " ))
122124 }
0 commit comments