summaryrefslogtreecommitdiff
path: root/tests/modules/xml/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-15 19:54:35 +0800
committerruki <[email protected]>2025-11-15 19:57:22 +0800
commit9c8f2febdddbe6e1ca4f6e04d4ba0d6f4f0f364f (patch)
tree2e05c85af37a48ed39d7cd3b38171f9dd70b6282 /tests/modules/xml/test.lua
parent48159a7a047aabcd77a4edb4cc98b6ecf3c51039 (diff)
use string apis
Diffstat (limited to 'tests/modules/xml/test.lua')
-rw-r--r--tests/modules/xml/test.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/modules/xml/test.lua b/tests/modules/xml/test.lua
index e7266c919..985600a9d 100644
--- a/tests/modules/xml/test.lua
+++ b/tests/modules/xml/test.lua
@@ -155,3 +155,16 @@ function test_find_update(t)
t:are_equal(encoded, '<root><item id="a" lang="en">bar</item><item id="b"/><item id="c">baz</item></root>')
end
+function test_decode_trim_text(t)
+ local doc = xml.decode("<root> foo </root>")
+ t:are_equal(xml.text_of(doc), " foo ")
+ local trimmed = xml.decode("<root> foo </root>", {trim_text = true})
+ t:are_equal(xml.text_of(trimmed), "foo")
+ local formatted = "<root>\n <item/>\n</root>"
+ local default = xml.decode(formatted)
+ t:are_equal(#default.children, 1)
+ local keep_ws = xml.decode(formatted, {keep_whitespace_nodes = true})
+ t:are_equal(#keep_ws.children, 3)
+ t:are_equal(keep_ws.children[1].kind, "text")
+end
+