File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub struct Line {
21
21
#[ serde( with = "colors_serde" ) ]
22
22
pub colors : Vec < String > ,
23
23
24
+ #[ serde( default ) ]
24
25
pub tokens : Vec < Token > ,
25
26
}
26
27
@@ -206,6 +207,12 @@ mod tests {
206
207
tokens = []
207
208
"# ;
208
209
210
+ pub static TEST_CONFIG3 : & ' static str = r#"
211
+ [[lines]]
212
+ pat = "A(.*) (.*) (.*) .*"
213
+ colors = ["xxx", "Blue", "Cyan", "Default"]
214
+ "# ;
215
+
209
216
#[ test]
210
217
fn test_colorize ( ) {
211
218
let config: Config = toml:: from_str ( TEST_CONFIG ) . unwrap ( ) ;
@@ -235,8 +242,14 @@ mod tests {
235
242
let config: Config = toml:: from_str ( TEST_CONFIG2 ) . unwrap ( ) ;
236
243
let ret = colorize ( String :: from ( "A123 456 789 xyz" ) , & config) ;
237
244
assert_eq ! (
238
- & format!( "{:?}" , ret) [ 0 ..50 ] ,
239
- "Err(Error(Msg( \" failed to parse color name \' xxx\' \" ), "
245
+ & format!( "{:?}" , ret) [ 0 ..37 ] ,
246
+ "Err(failed to parse color name \' xxx\' ) "
240
247
) ;
241
248
}
249
+
250
+ #[ test]
251
+ fn test_omit_token ( ) {
252
+ let config = toml:: from_str :: < Config > ( TEST_CONFIG3 ) ;
253
+ assert ! ( config. is_ok( ) ) ;
254
+ }
242
255
}
You can’t perform that action at this time.
0 commit comments