@@ -71,6 +71,7 @@ struct EnvironmentVariablesProviderTests {
7171 @Test ( )
7272 @available ( Configuration 1 . 0 , * )
7373 func decodeBoolFromString( ) throws {
74+ let sut = EnvironmentVariablesProvider . Snapshot. decodeBool
7475 let cases : [ ( expected: Bool ? , input: [ String ] ) ] = [
7576 ( true , [ " 1 " ] ) ,
7677 ( false , [ " 0 " ] ) ,
@@ -80,17 +81,16 @@ struct EnvironmentVariablesProviderTests {
8081 ( false , [ " false " , " FALSE " , " faLse " ] ) ,
8182 ( nil , [ " " , " _true_ " , " _false_ " , " _yes_ " , " _no_ " , " _1_ " , " _0_ " , " 11 " , " 00 " ] )
8283 ]
83-
8484 for (expected, inputs) in cases {
8585 for input in inputs {
86- #expect( EnvironmentVariablesProvider . Snapshot . decodeBool ( from : input) == expected, " input: \( input) " )
86+ #expect( sut ( input) == expected, " input: \( input) " )
8787 }
8888 }
8989 }
9090
9191 @available ( Configuration 1 . 0 , * )
9292 @Test func valueForKeyOfBoolAndBoolArrayTypes( ) throws {
93- let ep = EnvironmentVariablesProvider (
93+ let sut = EnvironmentVariablesProvider (
9494 environmentVariables: [
9595 " BOOL_TRUE " : " true " ,
9696 " BOOL_FALSE " : " false " ,
@@ -105,18 +105,18 @@ struct EnvironmentVariablesProviderTests {
105105 " BOOLY_ARRAY_THROWS_1 " : " true,1,YESS " ,
106106 " BOOLY_ARRAY_THROWS_2 " : " false,00,no " ,
107107 ] )
108- #expect( try ep . value ( forKey: " BOOL_TRUE " , type: . bool) . value == true )
109- #expect( try ep . value ( forKey: " BOOL_FALSE " , type: . bool) . value == false )
110- #expect( try ep . value ( forKey: " BOOL_1 " , type: . bool) . value == true )
111- #expect( try ep . value ( forKey: " BOOL_0 " , type: . bool) . value == false )
112- #expect( try ep . value ( forKey: " BOOL_YES " , type: . bool) . value == true )
113- #expect( try ep . value ( forKey: " BOOL_NO " , type: . bool) . value == false )
114- #expect( throws: ConfigError . self) { try ep . value ( forKey: " BOOL_THROWS_ERROR_EMPTY " , type: . bool) }
115- #expect( throws: ConfigError . self) { try ep . value ( forKey: " BOOL_THROWS_ERROR_NOT_BOOL_STRING " , type: . bool) }
116- #expect( try ep . value ( forKey: " BOOLY_ARRAY_TRUE " , type: . boolArray) . value == . init( [ true , true , true ] , isSecret: false ) )
117- #expect( try ep . value ( forKey: " BOOLY_ARRAY_FALSE " , type: . boolArray) . value == . init( [ false , false , false ] , isSecret: false ) )
118- #expect( throws: ConfigError . self) { try ep . value ( forKey: " BOOLY_ARRAY_THROWS_1 " , type: . boolArray) }
119- #expect( throws: ConfigError . self) { try ep . value ( forKey: " BOOLY_ARRAY_THROWS_2 " , type: . boolArray) }
108+ #expect( try sut . value ( forKey: " BOOL_TRUE " , type: . bool) . value == true )
109+ #expect( try sut . value ( forKey: " BOOL_FALSE " , type: . bool) . value == false )
110+ #expect( try sut . value ( forKey: " BOOL_1 " , type: . bool) . value == true )
111+ #expect( try sut . value ( forKey: " BOOL_0 " , type: . bool) . value == false )
112+ #expect( try sut . value ( forKey: " BOOL_YES " , type: . bool) . value == true )
113+ #expect( try sut . value ( forKey: " BOOL_NO " , type: . bool) . value == false )
114+ #expect( throws: ConfigError . self) { try sut . value ( forKey: " BOOL_THROWS_ERROR_EMPTY " , type: . bool) }
115+ #expect( throws: ConfigError . self) { try sut . value ( forKey: " BOOL_THROWS_ERROR_NOT_BOOL_STRING " , type: . bool) }
116+ #expect( try sut . value ( forKey: " BOOLY_ARRAY_TRUE " , type: . boolArray) . value == . init( [ true , true , true ] , isSecret: false ) )
117+ #expect( try sut . value ( forKey: " BOOLY_ARRAY_FALSE " , type: . boolArray) . value == . init( [ false , false , false ] , isSecret: false ) )
118+ #expect( throws: ConfigError . self) { try sut . value ( forKey: " BOOLY_ARRAY_THROWS_1 " , type: . boolArray) }
119+ #expect( throws: ConfigError . self) { try sut . value ( forKey: " BOOLY_ARRAY_THROWS_2 " , type: . boolArray) }
120120 }
121121
122122 @available ( Configuration 1 . 0 , * )
0 commit comments