Skip to content

Commit bff27f1

Browse files
committed
1 parent 41ffe9b commit bff27f1

File tree

4 files changed

+178
-0
lines changed

4 files changed

+178
-0
lines changed

src/Tests/CSVimportEdgeCasesTESTS.bas

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@ Function ImportTests(FullFileName As String, _
414414
WhitespaceAtEdgesOfUnquotedField ReadMode
415415
.IsEqual ActualResult, ExpectedResult, "Expected 1 record with 3 fields"
416416
End With
417+
'@--------------------------------------------------------------------------------
418+
'Complex CSV syntax
419+
With ImportTests.test("Complex CSV syntax")
420+
ComplexCSVsyntax ReadMode
421+
.IsEqual ActualResult, ExpectedResult, "Expected 2 record with 4 fields"
422+
End With
417423
Set ImportTests = Nothing
418424
End Function
419425
Sub GetActualAndExpectedResults(FileName As String, _
@@ -722,6 +728,12 @@ Sub QuotedFieldWithUnixEscapedQuotesAtBoundaries(Optional ReadMode As ImportMode
722728
confObj.unixEscapeMechanism = True 'Enable Unix escape mechanism
723729
GetActualAndExpectedResults "Quoted field with unix escaped quotes at boundaries.csv", "A,'B',C", ReadMode
724730
End Sub
731+
Sub ComplexCSVsyntax(Optional ReadMode As ImportMode = ImportMode.iStream)
732+
Set confObj = New parserConfig
733+
734+
GetActualAndExpectedResults "Complex CSV syntax.csv", "rec1? fld1,,rec1'?'fld3.1\r\n'?\r\nfld3.2,rec1\r\nfld4" _
735+
& "|rec2? fld1.1\r\n\r\nfld1.2,rec2 fld2.1'fld2.2'fld2.3,,rec2 fld4", ReadMode
736+
End Sub
725737
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
726738
'#
727739

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"rec1, fld1",,"rec1"",""fld3.1
2+
"",
3+
fld3.2","rec1
4+
fld4"
5+
"rec2, fld1.1
6+
7+
fld1.2","rec2 fld2.1""fld2.2""fld2.3","",rec2 fld4
1.04 KB
Binary file not shown.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
=== StreamCSVimport ===
2+
+ Bad comments value specified
3+
+ Comment with non-default character
4+
+ Commented line at beginning
5+
+ Commented line at end
6+
+ Commented line in middle
7+
+ Entire file is comment lines
8+
+ Input is just a string (a single field)
9+
+ Input is just empty fields
10+
+ Input is just the delimiter (2 empty fields)
11+
+ Input with only a commented line and blank line after
12+
+ Input with only a commented line, without comments enabled
13+
+ Input without comments with line starting with whitespace
14+
+ Line ends with quoted field
15+
+ Line starts with quoted field
16+
+ Misplaced quotes in data, not as opening quotes
17+
+ Multiple consecutive empty fields
18+
+ Multiple rows, one column (no delimiter found)
19+
+ One column input with empty fields
20+
+ One Row
21+
+ Pipe delimiter
22+
+ Quoted field at end of row (but not at EOF) has quotes
23+
+ Quoted field has no closing quote
24+
+ Quoted field with 5 quotes in a row and a delimiter
25+
+ Quoted field with delimiter
26+
+ Quoted field with escaped quotes at boundaries
27+
+ Quoted field with escaped quotes
28+
+ Quoted field with extra whitespace on edges
29+
+ Quoted field with line break
30+
+ Quoted field with quotes around delimiter
31+
+ Quoted field with quotes on left side of delimiter
32+
+ Quoted field with quotes on right side of delimiter
33+
+ Quoted field with Unix escaped quotes at boundaries
34+
+ Quoted field with whitespace around quotes
35+
+ Quoted field
36+
+ Quoted fields at end of row with delimiter and line break
37+
+ Quoted fields with line breaks
38+
+ Row with enough fields but blank field at end
39+
+ Row with too few fields
40+
+ Row with too many fields
41+
+ Skip empty lines, with empty input
42+
+ Skip empty lines, with first line only whitespace
43+
+ Skip empty lines, with newline at end of input
44+
+ Tab delimiter
45+
+ Three comment lines consecutively at beginning of file
46+
+ Two comment lines consecutively at end of file
47+
+ Two comment lines consecutively
48+
+ Two rows
49+
+ Unquoted field with quotes at end of field
50+
+ Whitespace at edges of unquoted field
51+
+ Complex CSV syntax
52+
= PASS (50 of 50 passed) = 4/7/2021 2:14:21 p.�m. =
53+
54+
=== StringCSVimport ===
55+
+ Bad comments value specified
56+
+ Comment with non-default character
57+
+ Commented line at beginning
58+
+ Commented line at end
59+
+ Commented line in middle
60+
+ Entire file is comment lines
61+
+ Input is just a string (a single field)
62+
+ Input is just empty fields
63+
+ Input is just the delimiter (2 empty fields)
64+
+ Input with only a commented line and blank line after
65+
+ Input with only a commented line, without comments enabled
66+
+ Input without comments with line starting with whitespace
67+
+ Line ends with quoted field
68+
+ Line starts with quoted field
69+
+ Misplaced quotes in data, not as opening quotes
70+
+ Multiple consecutive empty fields
71+
+ Multiple rows, one column (no delimiter found)
72+
+ One column input with empty fields
73+
+ One Row
74+
+ Pipe delimiter
75+
+ Quoted field at end of row (but not at EOF) has quotes
76+
+ Quoted field has no closing quote
77+
+ Quoted field with 5 quotes in a row and a delimiter
78+
+ Quoted field with delimiter
79+
+ Quoted field with escaped quotes at boundaries
80+
+ Quoted field with escaped quotes
81+
+ Quoted field with extra whitespace on edges
82+
+ Quoted field with line break
83+
+ Quoted field with quotes around delimiter
84+
+ Quoted field with quotes on left side of delimiter
85+
+ Quoted field with quotes on right side of delimiter
86+
+ Quoted field with Unix escaped quotes at boundaries
87+
+ Quoted field with whitespace around quotes
88+
+ Quoted field
89+
+ Quoted fields at end of row with delimiter and line break
90+
+ Quoted fields with line breaks
91+
+ Row with enough fields but blank field at end
92+
+ Row with too few fields
93+
+ Row with too many fields
94+
+ Skip empty lines, with empty input
95+
+ Skip empty lines, with first line only whitespace
96+
+ Skip empty lines, with newline at end of input
97+
+ Tab delimiter
98+
+ Three comment lines consecutively at beginning of file
99+
+ Two comment lines consecutively at end of file
100+
+ Two comment lines consecutively
101+
+ Two rows
102+
+ Unquoted field with quotes at end of field
103+
+ Whitespace at edges of unquoted field
104+
+ Complex CSV syntax
105+
= PASS (50 of 50 passed) = 4/7/2021 2:14:21 p.�m. =
106+
107+
=== SequentialCSVimport ===
108+
+ Bad comments value specified
109+
+ Comment with non-default character
110+
+ Commented line at beginning
111+
+ Commented line at end
112+
+ Commented line in middle
113+
+ Entire file is comment lines
114+
+ Input is just a string (a single field)
115+
+ Input is just empty fields
116+
+ Input is just the delimiter (2 empty fields)
117+
+ Input with only a commented line and blank line after
118+
+ Input with only a commented line, without comments enabled
119+
+ Input without comments with line starting with whitespace
120+
+ Line ends with quoted field
121+
+ Line starts with quoted field
122+
+ Misplaced quotes in data, not as opening quotes
123+
+ Multiple consecutive empty fields
124+
+ Multiple rows, one column (no delimiter found)
125+
+ One column input with empty fields
126+
+ One Row
127+
+ Pipe delimiter
128+
+ Quoted field at end of row (but not at EOF) has quotes
129+
+ Quoted field has no closing quote
130+
+ Quoted field with 5 quotes in a row and a delimiter
131+
+ Quoted field with delimiter
132+
+ Quoted field with escaped quotes at boundaries
133+
+ Quoted field with escaped quotes
134+
+ Quoted field with extra whitespace on edges
135+
+ Quoted field with line break
136+
+ Quoted field with quotes around delimiter
137+
+ Quoted field with quotes on left side of delimiter
138+
+ Quoted field with quotes on right side of delimiter
139+
+ Quoted field with Unix escaped quotes at boundaries
140+
+ Quoted field with whitespace around quotes
141+
+ Quoted field
142+
+ Quoted fields at end of row with delimiter and line break
143+
+ Quoted fields with line breaks
144+
+ Row with enough fields but blank field at end
145+
+ Row with too few fields
146+
+ Row with too many fields
147+
+ Skip empty lines, with empty input
148+
+ Skip empty lines, with first line only whitespace
149+
+ Skip empty lines, with newline at end of input
150+
+ Tab delimiter
151+
+ Three comment lines consecutively at beginning of file
152+
+ Two comment lines consecutively at end of file
153+
+ Two comment lines consecutively
154+
+ Two rows
155+
+ Unquoted field with quotes at end of field
156+
+ Whitespace at edges of unquoted field
157+
+ Complex CSV syntax
158+
= PASS (50 of 50 passed) = 4/7/2021 2:14:22 p.�m. =
159+

0 commit comments

Comments
 (0)