diff options
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | dummy/in.xml | 2 | ||||
-rw-r--r-- | dummy/transform.xsl | 83 | ||||
-rwxr-xr-x | test/check.sh | 24 | ||||
-rw-r--r-- | test/common/test.txt (renamed from dummy/test.txt) | 0 | ||||
-rw-r--r-- | test/read_directory/reference.xml | 9 | ||||
-rw-r--r-- | test/read_directory/transformation.xsl | 26 | ||||
-rw-r--r-- | test/read_file/reference.xml | 11 | ||||
-rw-r--r-- | test/read_file/transformation.xsl | 24 | ||||
-rw-r--r-- | test/read_xml_file/reference.xml | 9 | ||||
-rw-r--r-- | test/read_xml_file/transformation.xsl | 26 |
11 files changed, 136 insertions, 85 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b6229ca..2171d0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,3 +47,10 @@ target_link_libraries( test ${Libraries} ) + +add_custom_command( + TARGET + test + POST_BUILD COMMAND + cd ../test && ./check.sh +) diff --git a/dummy/in.xml b/dummy/in.xml deleted file mode 100644 index 6abcacd..0000000 --- a/dummy/in.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0"?> -<dummy /> diff --git a/dummy/transform.xsl b/dummy/transform.xsl deleted file mode 100644 index 5e172b6..0000000 --- a/dummy/transform.xsl +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xsl:stylesheet - version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:InputXSLT="function.inputxslt.application" - exclude-result-prefixes="InputXSLT" -> - -<xsl:output - method="xml" - doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" - doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" - omit-xml-declaration="yes" - encoding="UTF-8" - indent="yes" -/> - -<xsl:param name="test"/> - -<xsl:template match="/"> -<html> - <head> - </head> - <body> - <div id="parameter"> - Parameter "test" contains value "<xsl:value-of select="$test"/>" - </div> - - <div id="raw"> - <xsl:variable name="testFile" select="InputXSLT:read-file('test.txt')"/> - <xsl:choose> - <xsl:when test="$testFile/self::error"> - Could not read text file. - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$testFile[@name='test.txt']"/> - </xsl:otherwise> - </xsl:choose> - </div> - - <div id="xml"> - <xsl:variable name="testXml" select="InputXSLT:read-xml-file('test.txt')"/> - <xsl:choose> - <xsl:when test="$testXml/self::error"> - Could not read XML file. - </xsl:when> - <xsl:otherwise> - <ul id="xml"> - <xsl:for-each select="$testXml[@name='test.txt']/tester/eintrag"> - <li><xsl:value-of select="."/></li> - </xsl:for-each> - </ul> - </xsl:otherwise> - </xsl:choose> - </div> - - <div id="filelists"> - <xsl:variable name="fileList" select="InputXSLT:read-directory('../')"/> - <xsl:choose> - <xsl:when test="$fileList/self::error"> - Could not read directory. - </xsl:when> - <xsl:otherwise> - <ul id="filelist1"> - <xsl:for-each select="$fileList[@type='file']"> - <li><xsl:value-of select="."/></li> - </xsl:for-each> - </ul> - <ul id="filelist2"> - <xsl:for-each select="$fileList[@type='directory']"> - <li><xsl:value-of select="."/></li> - </xsl:for-each> - </ul> - </xsl:otherwise> - </xsl:choose> - </div> - </body> -</html> -</xsl:template> - -</xsl:stylesheet> - - diff --git a/test/check.sh b/test/check.sh new file mode 100755 index 0000000..fd537d7 --- /dev/null +++ b/test/check.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +for testcase in *; +do + if [ -d $testcase ] && [ "$testcase" != "common" ] + then + echo $testcase + + cd $testcase + rm -f actual.xml + + ./../../build/test --transformation transformation.xsl --target actual.xml + diff -u reference.xml actual.xml + + if [ $? = 0 ] + then + echo "passed." + else + echo "failed." + fi + + cd .. + fi +done diff --git a/dummy/test.txt b/test/common/test.txt index 046a6ef..046a6ef 100644 --- a/dummy/test.txt +++ b/test/common/test.txt diff --git a/test/read_directory/reference.xml b/test/read_directory/reference.xml new file mode 100644 index 0000000..7e83460 --- /dev/null +++ b/test/read_directory/reference.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<test_case> +<function_read_directory> +<item>read_directory</item> +<item>read_xml_file</item> +<item>common</item> +<item>read_file</item> +</function_read_directory> +</test_case> diff --git a/test/read_directory/transformation.xsl b/test/read_directory/transformation.xsl new file mode 100644 index 0000000..d3c21f1 --- /dev/null +++ b/test/read_directory/transformation.xsl @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet + version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:InputXSLT="function.inputxslt.application" + exclude-result-prefixes="InputXSLT" +> + +<xsl:output + method="xml" + omit-xml-declaration="no" + encoding="UTF-8" + indent="yes" +/> + +<xsl:template match="/"> +<test_case> + <function_read_directory> + <xsl:for-each select="InputXSLT:read-directory('../')[@type='directory']"> + <item><xsl:value-of select="."/></item> + </xsl:for-each> + </function_read_directory> +</test_case> +</xsl:template> + +</xsl:stylesheet> diff --git a/test/read_file/reference.xml b/test/read_file/reference.xml new file mode 100644 index 0000000..7cbcc95 --- /dev/null +++ b/test/read_file/reference.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<test_case> +<function_read_file><?xml version="1.0"?> +<tester> + <eintrag>Hello 1</eintrag> + <eintrag>Hello 2</eintrag> + <eintrag>Hello 3</eintrag> + <eintrag>Hello 4</eintrag> +</tester> +</function_read_file> +</test_case> diff --git a/test/read_file/transformation.xsl b/test/read_file/transformation.xsl new file mode 100644 index 0000000..96b8976 --- /dev/null +++ b/test/read_file/transformation.xsl @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet + version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:InputXSLT="function.inputxslt.application" + exclude-result-prefixes="InputXSLT" +> + +<xsl:output + method="xml" + omit-xml-declaration="no" + encoding="UTF-8" + indent="yes" +/> + +<xsl:template match="/"> +<test_case> + <function_read_file> + <xsl:value-of select="InputXSLT:read-file('../common/test.txt')"/> + </function_read_file> +</test_case> +</xsl:template> + +</xsl:stylesheet> diff --git a/test/read_xml_file/reference.xml b/test/read_xml_file/reference.xml new file mode 100644 index 0000000..d82dc9c --- /dev/null +++ b/test/read_xml_file/reference.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<test_case> +<function_read_xml_file> +<item>Hello 1</item> +<item>Hello 2</item> +<item>Hello 3</item> +<item>Hello 4</item> +</function_read_xml_file> +</test_case> diff --git a/test/read_xml_file/transformation.xsl b/test/read_xml_file/transformation.xsl new file mode 100644 index 0000000..ba6fed1 --- /dev/null +++ b/test/read_xml_file/transformation.xsl @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet + version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:InputXSLT="function.inputxslt.application" + exclude-result-prefixes="InputXSLT" +> + +<xsl:output + method="xml" + omit-xml-declaration="no" + encoding="UTF-8" + indent="yes" +/> + +<xsl:template match="/"> +<test_case> + <function_read_xml_file> + <xsl:for-each select="InputXSLT:read-xml-file('../common/test.txt')/tester/eintrag"> + <item><xsl:value-of select="."/></item> + </xsl:for-each> + </function_read_xml_file> +</test_case> +</xsl:template> + +</xsl:stylesheet> |