Skip to content

Commit

Permalink
Merge pull request #820 from xml-project/add-tests
Browse files Browse the repository at this point in the history
Additional tests for c:data decoding
  • Loading branch information
xml-project authored Feb 2, 2025
2 parents 8ab46b5 + 68e245b commit f96229f
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test-suite/tests/ab-cast-content-type-029.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 029 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document is decoded if cast to Text. Charset UTF-8</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="text/plain">
<p:with-input>
<c:data content-type="text/plain"
encoding="base64"
charset="UTF-8"
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSDCqQ==</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron">
<s:pattern>
<s:rule context="/">
<s:assert test="result">The root element is not 'result'.</s:assert>
<s:assert test="result/text()='Copy ©'">The text is not correctly decoded.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
47 changes: 47 additions & 0 deletions test-suite/tests/ab-cast-content-type-030.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 030 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document is decoded if cast to Text. Implicit charset</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="text/plain">
<p:with-input>
<c:data content-type="text/plain"
encoding="base64"
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSDCqQ==</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron">
<s:pattern>
<s:rule context="/">
<s:assert test="result">The root element is not 'result'.</s:assert>
<s:assert test="result/text()='Copy ©'">The text is not correctly decoded.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
48 changes: 48 additions & 0 deletions test-suite/tests/ab-cast-content-type-031.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 031 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document is decoded if cast to Text. ISO charset</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="text/plain">
<p:with-input>
<c:data content-type="text/plain"
encoding="base64"
charset="ISO-8859-1"
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSCp</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron">
<s:pattern>
<s:rule context="/">
<s:assert test="result">The root element is not 'result'.</s:assert>
<s:assert test="result/text()='Copy ©'">The text is not correctly decoded.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
46 changes: 46 additions & 0 deletions test-suite/tests/ab-cast-content-type-032.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 032 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document is decoded if cast to Text, default encoding.</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="text/plain">
<p:with-input>
<c:data content-type="text/plain"
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSDCqQ==</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron">
<s:pattern>
<s:rule context="/">
<s:assert test="result">The root element is not 'result'.</s:assert>
<s:assert test="result/text()='Copy ©'">The text is not correctly decoded.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
36 changes: 36 additions & 0 deletions test-suite/tests/ab-cast-content-type-033.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="fail" code="err:XC0074"
xmlns:err="http://www.w3.org/ns/xproc-error"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 033 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document decoding raises error, if content-types are not equal.</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="application/xml">
<p:with-input>
<c:data content-type="text/plain"
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSDCqQ==</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
</t:test>
36 changes: 36 additions & 0 deletions test-suite/tests/ab-cast-content-type-034.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="fail" code="err:XC0052"
xmlns:err="http://www.w3.org/ns/xproc-error"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 034 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document decoding raises error, if encoding is unsupported.</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="text/plain">
<p:with-input>
<c:data content-type="text/plain" encoding="not-supported"
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSDCqQ==</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
</t:test>
36 changes: 36 additions & 0 deletions test-suite/tests/ab-cast-content-type-035.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="fail" code="err:XC0071"
xmlns:err="http://www.w3.org/ns/xproc-error"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 035 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document decoding raises error, if charset is unsupported.</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="text/plain">
<p:with-input>
<c:data content-type="text/plain" charset="not-supported"
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSDCqQ==</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
</t:test>
36 changes: 36 additions & 0 deletions test-suite/tests/ab-cast-content-type-036.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="fail" code="err:XC0073"
xmlns:err="http://www.w3.org/ns/xproc-error"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>cast-content-type 036 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-02</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Test casting from c:data to Text.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that a c:data document decoding raises error, no content-type on c:data.</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:cast-content-type content-type="text/plain">
<p:with-input>
<c:data
xmlns:c="http://www.w3.org/ns/xproc-step">Q29weSDCqQ==</c:data>
</p:with-input>
</p:cast-content-type>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
</t:test>

0 comments on commit f96229f

Please sign in to comment.