@@ -94,6 +94,24 @@ j, ,\x20
9494 },
9595 expectedDelimiter : ',' ,
9696 },
97+ // case 3 - every delimiter used, default to comma and handle differing number of fields per record
98+ {
99+ csv : `col1,col2
100+ a;b
101+ c@e
102+ f g
103+ h|i
104+ jkl` ,
105+ expectedRows : [][]string {
106+ {"col1" , "col2" },
107+ {"a;b" },
108+ {"c@e" },
109+ {"f g" },
110+ {"h|i" },
111+ {"jkl" },
112+ },
113+ expectedDelimiter : ',' ,
114+ },
97115 }
98116
99117 for n , c := range cases {
@@ -119,21 +137,6 @@ func TestDetermineDelimiterShortBufferError(t *testing.T) {
119137 assert .Nil (t , rd , "CSV reader should be mnil" )
120138}
121139
122- func TestDetermineDelimiterReadAllError (t * testing.T ) {
123- rd , err := CreateReaderAndDetermineDelimiter (nil , strings .NewReader (`col1,col2
124- a;b
125- c@e
126- f g
127- h|i
128- jkl` ))
129- assert .NoError (t , err , "CreateReaderAndDetermineDelimiter() shouldn't throw error" )
130- assert .NotNil (t , rd , "CSV reader should not be mnil" )
131- rows , err := rd .ReadAll ()
132- assert .Error (t , err , "RaadAll() should throw error" )
133- assert .ErrorIs (t , err , csv .ErrFieldCount )
134- assert .Empty (t , rows , "rows should be empty" )
135- }
136-
137140func TestDetermineDelimiter (t * testing.T ) {
138141 cases := []struct {
139142 csv string
0 commit comments