MCPcopy Create free account
hub / github.com/antchfx/xpath / Test_func_matches

Function Test_func_matches

xpath_function_test.go:169–184  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func Test_func_matches(t *testing.T) {
170 test_xpath_eval(t, empty_example, `matches("abracadabra", "bra")`, true)
171 test_xpath_eval(t, empty_example, `matches("abracadabra", "(?i)^A.*A$")`, true)
172 test_xpath_eval(t, empty_example, `matches("abracadabra", "^a.*a$")`, true)
173 test_xpath_eval(t, empty_example, `matches("abracadabra", "^bra")`, false)
174 assertPanic(t, func() { selectNode(html_example, `//*[matches()]`) }) // arg len check failure
175 assertPanic(t, func() { selectNode(html_example, "//*[matches(substring(), 0)]") }) // first arg processing failure
176 assertPanic(t, func() { selectNode(html_example, "//*[matches(@href, substring())]") }) // second arg processing failure
177 assertPanic(t, func() { selectNode(html_example, "//*[matches(@href, 0)]") }) // second arg not string
178 assertPanic(t, func() { selectNode(html_example, "//*[matches(@href, '[invalid')]") }) // second arg invalid regexp
179 // testing unexpected the regular expression.
180 _, err := Compile(`//*[matches(., '^[\u0621-\u064AA-Za-z\-]+')]`)
181 assertErr(t, err)
182 _, err = Compile(`//*[matches(., '//*[matches(., '\w+`)
183 assertErr(t, err)
184}
185
186func Test_func_number(t *testing.T) {
187 test_xpath_eval(t, empty_example, `number(10)`, float64(10))

Callers

nothing calls this directly

Calls 5

test_xpath_evalFunction · 0.85
assertPanicFunction · 0.85
selectNodeFunction · 0.85
CompileFunction · 0.85
assertErrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…