Dedicated xml,json,yang and xsl parser utility programs added
Sanity check of stdarg (...) added Cleanup of error messages.
This commit is contained in:
parent
1306174071
commit
85c4782e36
56 changed files with 1004 additions and 379 deletions
46
test/test_xml.sh
Executable file
46
test/test_xml.sh
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
# Test: XML parser tests
|
||||
PROG=../lib/src/clixon_util_xml
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
new "xml parse"
|
||||
expecteof $PROG 0 "<a><b/></a>" "^<a><b/></a>$"
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<a><description>An example of escaped CENDs</description>
|
||||
<sometext>
|
||||
<![CDATA[ They're saying "x < y" & that "z > y" so I guess that means that z > x ]]>
|
||||
</sometext>
|
||||
<!-- This text contains a CEND ]]> -->
|
||||
<!-- In this first case we put the ]] at the end of the first CDATA block
|
||||
and the > in the second CDATA block -->
|
||||
<data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data>
|
||||
<!-- In this second case we put a ] at the end of the first CDATA block
|
||||
and the ]> in the second CDATA block -->
|
||||
<alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative>
|
||||
</a>
|
||||
EOF
|
||||
)
|
||||
new "xml CDATA"
|
||||
expecteof $PROG 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
|
||||
<![CDATA[ They're saying \"x < y\" & that \"z > y\" so I guess that means that z > x ]]>
|
||||
</sometext><data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data><alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative></a>$"
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>Less than: < , greater than: > ampersand: & </message>
|
||||
EOF
|
||||
)
|
||||
new "xml encode <>&"
|
||||
expecteof $PROG 0 "$XML" "^$XML$"
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character ' may be represented as ' and the double-quote character as " </message>
|
||||
EOF
|
||||
)
|
||||
new "xml optional encode single and double quote"
|
||||
expecteof $PROG 0 "$XML" "^<message>To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character ' may be represented as ' and the double-quote character as \"</message>$"
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue