#!/bin/bash # Test: XML parser tests # @see https://www.w3.org/TR/2008/REC-xml-20081126 # https://www.w3.org/TR/2009/REC-xml-names-20091208 #PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_xml" PROG=../util/clixon_util_xml # include err() and new() functions and creates $dir . ./lib.sh new "xml parse" expecteof "$PROG" 0 "" "^$" new "xml parse strange names" expecteof "$PROG" 0 "<_->" "^<_->$" new "xml parse name errors" expecteof "$PROG" 255 "<-a/>" "" new "xml parse name errors" expecteof "$PROG" 255 "<9/>" "" new "xml parse name errors" expecteof "$PROG" 255 "" "" XML=$(cat <An example of escaped CENDs y" so I guess that means that z > x ]]> ]]> ]]> EOF ) new "xml CDATA" expecteof "$PROG" 0 "$XML" "^An example of escaped CENDs y\" so I guess that means that z > x ]]> ]]>]]>$" XML=$(cat <Less than: < , greater than: > ampersand: & EOF ) new "xml encode <>&" expecteof "$PROG" 0 "$XML" "^$XML$" XML=$(cat <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 " EOF ) new "xml optional encode single and double quote" expecteof "$PROG" 0 "$XML" "^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 \"$" new "Double quotes for attributes" expecteof "$PROG" 0 '' '^$' new "Single quotes for attributes (returns double quotes but at least parses right)" expecteof "$PROG" 0 "" '^$' new "Mixed quotes" expecteof "$PROG" 0 "" '^$' new "XMLdecl version" expecteof "$PROG" 0 '' '' new "XMLdecl version, single quotes" expecteof "$PROG" 0 "" '' new "XMLdecl version no element" expecteof "$PROG" 255 '' '' new "XMLdecl no version" expecteof "$PROG" 255 '' '' new "XMLdecl misspelled version" expecteof "$PROG" 255 '' '' new "XMLdecl version + encoding" expecteof "$PROG" 0 '' '' new "XMLdecl version + misspelled encoding" expecteof "$PROG" 255 '' '' new "XMLdecl version + standalone" expecteof "$PROG" 0 '' '' new "PI - Processing instruction empty" expecteof "$PROG" 0 '' '' new "PI some content" expecteof "$PROG" 0 '' '' new "prolog element misc*" expecteof "$PROG" 0 '' '' # We allow it as an internal necessity for parsing of xml fragments #new "double element error" #expecteof "$PROG" 255 '' '' new "namespace: DefaultAttName" expecteof "$PROG" 0 'hello' '^hello$' new "namespace: PrefixedAttName" expecteof "$PROG" 0 'hello' '^hello$' new "First example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208" XML=$(cat < Frobnostication Moved to here. EOF ) expecteof "$PROG" 0 "$XML" "$XML" new "Second example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208" XML=$(cat < Cheaper by the Dozen 1568491379 EOF ) expecteof "$PROG" 0 "$XML" "$XML" rm -rf $dir