From 9c8f2febdddbe6e1ca4f6e04d4ba0d6f4f0f364f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 15 Nov 2025 19:54:35 +0800 Subject: use string apis --- tests/modules/xml/test.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/modules/xml/test.lua') 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, 'barbaz') end +function test_decode_trim_text(t) + local doc = xml.decode(" foo ") + t:are_equal(xml.text_of(doc), " foo ") + local trimmed = xml.decode(" foo ", {trim_text = true}) + t:are_equal(xml.text_of(trimmed), "foo") + local formatted = "\n \n" + 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 + -- cgit v1.3.1