summaryrefslogtreecommitdiff
path: root/tests/modules/xml/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-15 00:19:32 +0800
committerruki <[email protected]>2025-11-15 00:19:32 +0800
commite8aa6bd86dcfc67fb2fd5d9bb4319a956097f9c1 (patch)
tree7c3cca41a8342c3b7560070fedf1e09140127ac9 /tests/modules/xml/test.lua
parent3d6be9e48846d619bf389ee9a16157281bafa87b (diff)
add more tests
Diffstat (limited to 'tests/modules/xml/test.lua')
-rw-r--r--tests/modules/xml/test.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/modules/xml/test.lua b/tests/modules/xml/test.lua
index 271865338..841a1c797 100644
--- a/tests/modules/xml/test.lua
+++ b/tests/modules/xml/test.lua
@@ -68,3 +68,36 @@ function test_load_save(t)
os.tryrm(filepath)
end
+function test_plist_sample(t)
+ local plist = [[<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2020 tboox. All rights reserved.</string>
+ <key>NSSupportsAutomaticTermination</key>
+ <true/>
+</dict>
+</plist>]]
+ local doc = xml.decode(plist)
+ t:are_equal(doc.name, "plist")
+ t:are_equal(doc.attrs.version, "1.0")
+ t:are_equal(doc.prolog[1].kind, "doctype")
+ local dict = xml.find(doc, "plist/dict")
+ t:are_equal(dict.kind, "element")
+ local first_key = dict.children[1]
+ t:are_equal(first_key.name, "key")
+ t:are_equal(xml.text_of(first_key), "CFBundleDevelopmentRegion")
+ local first_value = dict.children[2]
+ t:are_equal(first_value.name, "string")
+ t:are_equal(xml.text_of(first_value), "$(DEVELOPMENT_LANGUAGE)")
+ local last_flag = dict.children[#dict.children]
+ t:are_equal(last_flag.name, "true")
+end
+