1
1
extern crate config;
2
2
extern crate serde_derive;
3
3
4
- use std:: env;
5
4
use config:: * ;
6
5
use serde_derive:: Deserialize ;
6
+ use std:: env;
7
7
8
8
/// Reminder that tests using env variables need to use different env variable names, since
9
9
/// tests can be run in parallel
@@ -88,6 +88,7 @@ fn test_custom_separator_behavior() {
88
88
env:: remove_var ( "C.B.A" ) ;
89
89
}
90
90
91
+ #[ test]
91
92
fn test_parse_int ( ) {
92
93
// using a struct in an enum here to make serde use `deserialize_any`
93
94
#[ derive( Deserialize , Debug ) ]
@@ -104,7 +105,7 @@ fn test_parse_int() {
104
105
env:: set_var ( "INT_VAL" , "42" ) ;
105
106
106
107
let environment = Environment :: new ( ) . try_parsing ( true ) ;
107
- let mut config = Config :: new ( ) ;
108
+ let mut config = Config :: default ( ) ;
108
109
109
110
config. set ( "tag" , "Int" ) . unwrap ( ) ;
110
111
@@ -134,7 +135,7 @@ fn test_parse_float() {
134
135
env:: set_var ( "FLOAT_VAL" , "42.3" ) ;
135
136
136
137
let environment = Environment :: new ( ) . try_parsing ( true ) ;
137
- let mut config = Config :: new ( ) ;
138
+ let mut config = Config :: default ( ) ;
138
139
139
140
config. set ( "tag" , "Float" ) . unwrap ( ) ;
140
141
@@ -167,7 +168,7 @@ fn test_parse_bool() {
167
168
env:: set_var ( "BOOL_VAL" , "true" ) ;
168
169
169
170
let environment = Environment :: new ( ) . try_parsing ( true ) ;
170
- let mut config = Config :: new ( ) ;
171
+ let mut config = Config :: default ( ) ;
171
172
172
173
config. set ( "tag" , "Bool" ) . unwrap ( ) ;
173
174
@@ -201,7 +202,7 @@ fn test_parse_off_int() {
201
202
env:: set_var ( "INT_VAL_1" , "42" ) ;
202
203
203
204
let environment = Environment :: new ( ) . try_parsing ( false ) ;
204
- let mut config = Config :: new ( ) ;
205
+ let mut config = Config :: default ( ) ;
205
206
206
207
config. set ( "tag" , "Int" ) . unwrap ( ) ;
207
208
@@ -230,7 +231,7 @@ fn test_parse_off_float() {
230
231
env:: set_var ( "FLOAT_VAL_1" , "42.3" ) ;
231
232
232
233
let environment = Environment :: new ( ) . try_parsing ( false ) ;
233
- let mut config = Config :: new ( ) ;
234
+ let mut config = Config :: default ( ) ;
234
235
235
236
config. set ( "tag" , "Float" ) . unwrap ( ) ;
236
237
@@ -259,7 +260,7 @@ fn test_parse_off_bool() {
259
260
env:: set_var ( "BOOL_VAL_1" , "true" ) ;
260
261
261
262
let environment = Environment :: new ( ) . try_parsing ( false ) ;
262
- let mut config = Config :: new ( ) ;
263
+ let mut config = Config :: default ( ) ;
263
264
264
265
config. set ( "tag" , "Bool" ) . unwrap ( ) ;
265
266
@@ -288,7 +289,7 @@ fn test_parse_int_fail() {
288
289
env:: set_var ( "INT_VAL_2" , "not an int" ) ;
289
290
290
291
let environment = Environment :: new ( ) . try_parsing ( true ) ;
291
- let mut config = Config :: new ( ) ;
292
+ let mut config = Config :: default ( ) ;
292
293
293
294
config. set ( "tag" , "Int" ) . unwrap ( ) ;
294
295
@@ -317,7 +318,7 @@ fn test_parse_float_fail() {
317
318
env:: set_var ( "FLOAT_VAL_2" , "not a float" ) ;
318
319
319
320
let environment = Environment :: new ( ) . try_parsing ( true ) ;
320
- let mut config = Config :: new ( ) ;
321
+ let mut config = Config :: default ( ) ;
321
322
322
323
config. set ( "tag" , "Float" ) . unwrap ( ) ;
323
324
@@ -346,7 +347,7 @@ fn test_parse_bool_fail() {
346
347
env:: set_var ( "BOOL_VAL_2" , "not a bool" ) ;
347
348
348
349
let environment = Environment :: new ( ) . try_parsing ( true ) ;
349
- let mut config = Config :: new ( ) ;
350
+ let mut config = Config :: default ( ) ;
350
351
351
352
config. set ( "tag" , "Bool" ) . unwrap ( ) ;
352
353
@@ -374,7 +375,7 @@ fn test_parse_string() {
374
375
env:: set_var ( "STRING_VAL" , "test string" ) ;
375
376
376
377
let environment = Environment :: new ( ) . try_parsing ( true ) ;
377
- let mut config = Config :: new ( ) ;
378
+ let mut config = Config :: default ( ) ;
378
379
379
380
config. set ( "tag" , "String" ) . unwrap ( ) ;
380
381
@@ -408,7 +409,7 @@ fn test_parse_off_string() {
408
409
env:: set_var ( "STRING_VAL_1" , "test string" ) ;
409
410
410
411
let environment = Environment :: new ( ) . try_parsing ( false ) ;
411
- let mut config = Config :: new ( ) ;
412
+ let mut config = Config :: default ( ) ;
412
413
413
414
config. set ( "tag" , "String" ) . unwrap ( ) ;
414
415
0 commit comments