Skip to content

Commit

Permalink
Add a few more CSV tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Mar 14, 2024
1 parent be7530a commit 6ecfd95
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fn/csv-to-arrays.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<test-set xmlns="http://www.w3.org/2010/09/qt-fots-catalog" name="fn-csv-to-arrays" covers-40="fn-csv-to-arrays">
<test-set xmlns="http://www.w3.org/2010/09/qt-fots-catalog" name="fn-csv-to-arrays" covers-40="PR1052">
<description>Tests for the fn:csv-to-arrays function</description>
<link type="spec" document="http://www.w3.org/TR/xpath-functions-30/" idref="func-csv-to-arrays"/>
<dependency type="spec" value="XP40+ XQ40+"/>
Expand Down
43 changes: 41 additions & 2 deletions fn/csv-to-xml.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<test-set xmlns="http://www.w3.org/2010/09/qt-fots-catalog" name="fn-csv-to-xml" covers-40="fn-csv-to-xml">
<test-set xmlns="http://www.w3.org/2010/09/qt-fots-catalog" name="fn-csv-to-xml" covers-40="PR1052">
<description>Tests for the fn:csv-to-xml function</description>
<link type="spec" document="http://www.w3.org/TR/xpath-functions-30/" idref="func-csv-to-xml"/>
<dependency type="spec" value="XP40+ XQ40+"/>
Expand Down Expand Up @@ -547,14 +547,53 @@
<test>fn:csv-to-xml("1,2,3,4|11,12,13,14,15,16",
map{'row-delimiter':'|', 'trim-rows':false(), 'header':false()})</test>
<result>
<!-- TBA?? -->
<assert-xml><![CDATA[<csv xmlns="http://www.w3.org/2005/xpath-functions"
><rows><row><field>1</field><field>2</field><field>3</field><field>4</field></row
><row><field>11</field><field>12</field><field>13</field><field>14</field><field>15</field><field>16</field></row
></rows></csv>]]></assert-xml>
</result>
</test-case>

<test-case name="csv-to-xml-065">
<description>number-of-columns option causes row padding</description>
<created by="Michael Kay" on="2024-03-14"/>
<test>fn:csv-to-xml("1,2,3,4,5,6|14,15,16",
map{'row-delimiter':'|', 'select-columns':1 to 4})</test>
<result>
<assert-xml><![CDATA[<csv xmlns="http://www.w3.org/2005/xpath-functions"
><rows><row><field>1</field><field>2</field><field>3</field><field>4</field></row
><row><field>14</field><field>15</field><field>16</field><field/></row
></rows></csv>]]></assert-xml>
</result>
</test-case>

<test-case name="csv-to-xml-066">
<description>trim-rows option causes row padding</description>
<created by="Michael Kay" on="2024-03-14"/>
<test>fn:csv-to-xml("1,2,3,4,5,6|14,15,16",
map{'row-delimiter':'|', 'trim-rows':true()})</test>
<result>
<assert-xml><![CDATA[<csv xmlns="http://www.w3.org/2005/xpath-functions"
><rows><row><field>1</field><field>2</field><field>3</field><field>4</field><field>5</field><field>6</field></row
><row><field>14</field><field>15</field><field>16</field><field/><field/><field/></row
></rows></csv>]]></assert-xml>
</result>
</test-case>

<test-case name="csv-to-xml-067">
<description>trim-rows option with header causes row padding</description>
<created by="Michael Kay" on="2024-03-14"/>
<test>fn:csv-to-xml("a,b,c,d,e|1,2,3,4,5|14,15,16",
map{'row-delimiter':'|', 'trim-rows':true(), 'header':true()})</test>
<result>
<assert-xml><![CDATA[<csv xmlns="http://www.w3.org/2005/xpath-functions"
><columns><column>a</column><column>b</column><column>c</column><column>d</column><column>e</column></columns
><rows><row><field column="a">1</field><field column="b">2</field><field column="c">3</field><field column="d">4</field><field column="e">5</field></row
><row><field column="a">14</field><field column="b">15</field><field column="c">16</field><field column="d"/><field column="e"/></row
></rows></csv>]]></assert-xml>
</result>
</test-case>

<test-case name="csv-to-xml-080">
<description>select-columns</description>
<created by="Michael Kay" on="2024-02-26"/>
Expand Down
41 changes: 40 additions & 1 deletion fn/parse-csv.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<test-set xmlns="http://www.w3.org/2010/09/qt-fots-catalog" name="fn-parse-csv" covers-40="fn-parse-csv">
<test-set xmlns="http://www.w3.org/2010/09/qt-fots-catalog" name="fn-parse-csv" covers-40="PR1052">
<description>Tests for the fn:parse-csv function</description>
<link type="spec" document="http://www.w3.org/TR/xpath-functions-30/" idref="func-parse-csv"/>
<dependency type="spec" value="XP40+ XQ40+"/>
Expand Down Expand Up @@ -652,6 +652,45 @@
"rows":(["1","2","3","4"],["11","12","13","14","15","16"])})</assert>
</result>
</test-case>

<test-case name="parse-csv-065">
<description>number-of-columns option causes row padding</description>
<created by="Michael Kay" on="2024-03-14"/>
<test>fn:parse-csv("1,2,3,4,5,6|14,15,16",
map{'row-delimiter':'|', 'select-columns':1 to 4})</test>
<result>
<assert>deep-equal($result => map:remove("get"),
map{"columns":(),
"column-index": map{},
"rows":(["1","2","3","4"],["14","15","16",""])})</assert>
</result>
</test-case>

<test-case name="parse-csv-066">
<description>trim-rows option causes row padding</description>
<created by="Michael Kay" on="2024-03-14"/>
<test>fn:parse-csv("1,2,3,4,5,6|14,15,16",
map{'row-delimiter':'|', 'trim-rows':true()})</test>
<result>
<assert>deep-equal($result => map:remove("get"),
map{"columns":(),
"column-index": map{},
"rows":(["1","2","3","4","5","6"],["14","15","16","","",""])})</assert>
</result>
</test-case>

<test-case name="parse-csv-067">
<description>trim-rows option with header causes row padding</description>
<created by="Michael Kay" on="2024-03-14"/>
<test>fn:parse-csv("a,b,c,d,e|1,2,3|14,15,16",
map{'row-delimiter':'|', 'trim-rows':true(), 'header':true()})</test>
<result>
<assert>deep-equal($result => map:remove("get"),
map{"columns":("a","b","c","d","e"),
"column-index": map{"a":1,"b":2,"c":3,"d":4,"e":5},
"rows":(["1","2","3","",""],["14","15","16","",""])})</assert>
</result>
</test-case>

<test-case name="parse-csv-080">
<description>select-columns</description>
Expand Down

0 comments on commit 6ecfd95

Please sign in to comment.