@@ -69,6 +69,76 @@ fn test_input_autoskip() {
6969 assert_eq ! ( got, expected) ;
7070}
7171
72+ #[ test]
73+ fn test_input_quotestyle_nonnumeric ( ) {
74+ let wrk = Workdir :: new ( "input_quotestyle_nonnumeric" ) ;
75+ wrk. create (
76+ "testdata.csv" ,
77+ vec ! [
78+ svec![ "column1" , "float column" , "int column" , "description" ] ,
79+ svec![ "a" , "1.0" , "1" , "this is a string" ] ,
80+ svec![ "c" , "3.5" , "3" , "this is another string" ] ,
81+ svec![ "e" , "3.14" , "42" , "this is a third string" ] ,
82+ ] ,
83+ ) ;
84+ let mut cmd = wrk. command ( "input" ) ;
85+ cmd. args ( [ "--quote-style" , "nonnumeric" ] )
86+ . arg ( "testdata.csv" ) ;
87+
88+ let got: String = wrk. stdout ( & mut cmd) ;
89+ let expected = r#""column1","float column","int column","description"
90+ "a",1.0,1,"this is a string"
91+ "c",3.5,3,"this is another string"
92+ "e",3.14,42,"this is a third string""# ;
93+ assert_eq ! ( got, expected) ;
94+ }
95+
96+ #[ test]
97+ fn test_input_quotestyle_necessary ( ) {
98+ let wrk = Workdir :: new ( "input_quotestyle_necessary" ) ;
99+ wrk. create (
100+ "testdata.csv" ,
101+ vec ! [
102+ svec![ "column1" , "float column" , "int column" , "description" ] ,
103+ svec![ "a" , "1.0" , "1" , "1,234,5678 - number with commas" ] ,
104+ svec![ "c" , "3.5" , "3" , "this is another string" ] ,
105+ svec![ "e" , "3.14" , "42" , "this is a third string" ] ,
106+ ] ,
107+ ) ;
108+ let mut cmd = wrk. command ( "input" ) ;
109+ cmd. args ( [ "--quote-style" , "necessary" ] ) . arg ( "testdata.csv" ) ;
110+
111+ let got: String = wrk. stdout ( & mut cmd) ;
112+ let expected = r#"column1,float column,int column,description
113+ a,1.0,1,"1,234,5678 - number with commas"
114+ c,3.5,3,this is another string
115+ e,3.14,42,this is a third string"# ;
116+ assert_eq ! ( got, expected) ;
117+ }
118+
119+ #[ test]
120+ fn test_input_quotestyle_all ( ) {
121+ let wrk = Workdir :: new ( "input_quotestyle_all" ) ;
122+ wrk. create (
123+ "testdata.csv" ,
124+ vec ! [
125+ svec![ "column1" , "float column" , "int column" , "description" ] ,
126+ svec![ "a" , "1.0" , "1" , "1,234,5678 - number with commas" ] ,
127+ svec![ "c" , "3.5" , "3" , "this is another string" ] ,
128+ svec![ "e" , "3.14" , "42" , "this is a third string" ] ,
129+ ] ,
130+ ) ;
131+ let mut cmd = wrk. command ( "input" ) ;
132+ cmd. args ( [ "--quote-style" , "all" ] ) . arg ( "testdata.csv" ) ;
133+
134+ let got: String = wrk. stdout ( & mut cmd) ;
135+ let expected = r#""column1","float column","int column","description"
136+ "a","1.0","1","1,234,5678 - number with commas"
137+ "c","3.5","3","this is another string"
138+ "e","3.14","42","this is a third string""# ;
139+ assert_eq ! ( got, expected) ;
140+ }
141+
72142#[ test]
73143fn test_input_skip_one_line ( ) {
74144 let wrk = Workdir :: new ( "input_skip_one_line" ) ;
0 commit comments