diff options
author | Adrian Kummerländer | 2014-05-08 21:16:31 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-08 21:16:31 +0200 |
commit | 947603b5d7f05053a93a3cfe257fa7ab11304a90 (patch) | |
tree | 58ed6c641ac0e9f36b0ca6e8d347ab0308e81a51 /test | |
parent | 209f0b2fd9310f503d4599b12483fddc04d1f7dd (diff) | |
download | InputXSLT-947603b5d7f05053a93a3cfe257fa7ab11304a90.tar InputXSLT-947603b5d7f05053a93a3cfe257fa7ab11304a90.tar.gz InputXSLT-947603b5d7f05053a93a3cfe257fa7ab11304a90.tar.bz2 InputXSLT-947603b5d7f05053a93a3cfe257fa7ab11304a90.tar.lz InputXSLT-947603b5d7f05053a93a3cfe257fa7ab11304a90.tar.xz InputXSLT-947603b5d7f05053a93a3cfe257fa7ab11304a90.tar.zst InputXSLT-947603b5d7f05053a93a3cfe257fa7ab11304a90.zip |
Implemented black-box test cases
* the directories below "./test" contain test cases
** "transformation.xsl" and the expected result as "reference.xml"
** tests are performed by "check.sh"
*** returns diff on error
* this system enables simple verification of external function results
** way simpler than C++ unit tests would be in this scenario
* expanded cmake instructions to automatically execute the test cases
* old example transformation was removed
Diffstat (limited to 'test')
-rwxr-xr-x | test/check.sh | 24 | ||||
-rw-r--r-- | test/common/test.txt | 7 | ||||
-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 |
8 files changed, 136 insertions, 0 deletions
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/test/common/test.txt b/test/common/test.txt new file mode 100644 index 0000000..046a6ef --- /dev/null +++ b/test/common/test.txt @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<tester> + <eintrag>Hello 1</eintrag> + <eintrag>Hello 2</eintrag> + <eintrag>Hello 3</eintrag> + <eintrag>Hello 4</eintrag> +</tester> 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> |