From 71dcf04e3033f00b4fb66ac4dd7bc9c488af235a Mon Sep 17 00:00:00 2001 From: Blazej SLEBODA <5544365+Adobels@users.noreply.github.com> Date: Mon, 22 Dec 2025 09:24:49 +0100 Subject: [PATCH 1/5] Update split method to keep empty substrings --- .../EnvironmentVariables/EnvironmentVariablesProvider.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Configuration/Providers/EnvironmentVariables/EnvironmentVariablesProvider.swift b/Sources/Configuration/Providers/EnvironmentVariables/EnvironmentVariablesProvider.swift index 38e1f47..60a261b 100644 --- a/Sources/Configuration/Providers/EnvironmentVariables/EnvironmentVariablesProvider.swift +++ b/Sources/Configuration/Providers/EnvironmentVariables/EnvironmentVariablesProvider.swift @@ -345,7 +345,7 @@ internal struct EnvironmentValueArrayDecoder { /// - Parameter string: The source string to parse. /// - Returns: The parsed array. func decode(_ string: String) -> [String] { - string.split(separator: separator).map { $0.trimmed() } + string.split(separator: separator, omittingEmptySubsequences: false).map { $0.trimmed() } } } From ce8c009ce53d85427deb81bcb6be8111a2821d36 Mon Sep 17 00:00:00 2001 From: Blazej SLEBODA <5544365+Adobels@users.noreply.github.com> Date: Mon, 22 Dec 2025 09:46:08 +0100 Subject: [PATCH 2/5] Update Tests for arrays with empty string and with space string --- .../EnvironmentVariablesProviderTests.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift b/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift index 030dd45..7f80aa0 100644 --- a/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift +++ b/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift @@ -99,11 +99,12 @@ struct EnvironmentVariablesProviderTests { "BOOL_NO": "NO", "BOOL_THROWS_ERROR_EMPTY": "", "BOOL_THROWS_ERROR_NOT_BOOL_STRING": "2", - "BOOLY_ARRAY_TRUE": "true,1,,YES", + "BOOLY_ARRAY_TRUE": "true,1,YES", "BOOLY_ARRAY_FALSE": "false,0,NO", "BOOLY_ARRAY_THROWS_1": "true,1,YESS", "BOOLY_ARRAY_THROWS_2": "false,00,no", - "BOOLY_ARRAY_THROWS_3": "false, ,no", + "BOOLY_ARRAY_THROWS_3": " ,", + "BOOLY_ARRAY_THROWS_4": ",", ]) #expect(try sut.value(forKey: "BOOL_TRUE", type: .bool).value == true) #expect(try sut.value(forKey: "BOOL_FALSE", type: .bool).value == false) @@ -124,6 +125,7 @@ struct EnvironmentVariablesProviderTests { #expect(throws: ConfigError.self) { try sut.value(forKey: "BOOLY_ARRAY_THROWS_1", type: .boolArray) } #expect(throws: ConfigError.self) { try sut.value(forKey: "BOOLY_ARRAY_THROWS_2", type: .boolArray) } #expect(throws: ConfigError.self) { try sut.value(forKey: "BOOLY_ARRAY_THROWS_3", type: .boolArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "BOOLY_ARRAY_THROWS_4", type: .boolArray) } } @available(Configuration 1.0, *) From 73337f86aec3e7a28d45f1b21e1d9b4970b4edaf Mon Sep 17 00:00:00 2001 From: Blazej SLEBODA <5544365+Adobels@users.noreply.github.com> Date: Mon, 22 Dec 2025 10:52:33 +0100 Subject: [PATCH 3/5] Add tests for int and double arrays values --- .../EnvironmentVariablesProviderTests.swift | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift b/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift index 7f80aa0..8a57cca 100644 --- a/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift +++ b/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift @@ -128,6 +128,44 @@ struct EnvironmentVariablesProviderTests { #expect(throws: ConfigError.self) { try sut.value(forKey: "BOOLY_ARRAY_THROWS_4", type: .boolArray) } } + @available(Configuration 1.0, *) + @Test func valueForKeyOfIntArrayTypes() throws { + let sut = EnvironmentVariablesProvider( + environmentVariables: [ + "INTLY_ARRAY_1": "", + "INTLY_ARRAY_2": " ", + "INTLY_ARRAY_3": ",", + "INTLY_ARRAY_4": " ,", + "INTLY_ARRAY_5": "1,,2", + "INTLY_ARRAY_6": "1, ,2", + ]) + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_1", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_2", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_3", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_4", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_5", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_6", type: .intArray) } + } + + @available(Configuration 1.0, *) + @Test func valueForKeyOfDoubleArrayTypes() throws { + let sut = EnvironmentVariablesProvider( + environmentVariables: [ + "DOUBLY_ARRAY_1": "", + "DOUBLY_ARRAY_2": " ", + "DOUBLY_ARRAY_3": ",", + "DOUBLY_ARRAY_4": " ,", + "DOUBLY_ARRAY_5": "1.1,,2.1", + "DOUBLY_ARRAY_6": "1.1, ,2.1", + ]) + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_1", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_2", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_3", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_4", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_5", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_6", type: .doubleArray) } + } + @available(Configuration 1.0, *) @Test func compat() async throws { try await ProviderCompatTest(provider: provider).runTest() From ae5cf01a1305502495a9e29510494e8fcd00144a Mon Sep 17 00:00:00 2001 From: Blazej SLEBODA <5544365+Adobels@users.noreply.github.com> Date: Mon, 22 Dec 2025 10:53:08 +0100 Subject: [PATCH 4/5] Move NSString components to String split API --- Sources/Configuration/Providers/CLI/CLIArgumentParser.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Configuration/Providers/CLI/CLIArgumentParser.swift b/Sources/Configuration/Providers/CLI/CLIArgumentParser.swift index 3a2a38c..fa781f8 100644 --- a/Sources/Configuration/Providers/CLI/CLIArgumentParser.swift +++ b/Sources/Configuration/Providers/CLI/CLIArgumentParser.swift @@ -122,7 +122,7 @@ internal struct CLIArgumentParser { if value.isEmpty { return [""] } - return value.components(separatedBy: ",") + return value.split(separator: ",", omittingEmptySubsequences: false).map(String.init) } } } From 43d66f1a114422de4f7b66de5b3bf9c998fe1510 Mon Sep 17 00:00:00 2001 From: Blazej SLEBODA <5544365+Adobels@users.noreply.github.com> Date: Tue, 23 Dec 2025 21:27:07 +0100 Subject: [PATCH 5/5] Add positive test cases in tests of int and double arrays values --- .../EnvironmentVariablesProviderTests.swift | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift b/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift index 8a57cca..af6228e 100644 --- a/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift +++ b/Tests/ConfigurationTests/EnvironmentVariablesProviderTests.swift @@ -132,38 +132,47 @@ struct EnvironmentVariablesProviderTests { @Test func valueForKeyOfIntArrayTypes() throws { let sut = EnvironmentVariablesProvider( environmentVariables: [ - "INTLY_ARRAY_1": "", - "INTLY_ARRAY_2": " ", - "INTLY_ARRAY_3": ",", - "INTLY_ARRAY_4": " ,", - "INTLY_ARRAY_5": "1,,2", - "INTLY_ARRAY_6": "1, ,2", + "INTLY_ARRAY_1": "-1,0,1", + "INTLY_ARRAY_2": " -1 , 0 ,1", + "INTLY_ARRAY_THROWS_1": "", + "INTLY_ARRAY_THROWS_2": " ", + "INTLY_ARRAY_THROWS_3": ",", + "INTLY_ARRAY_THROWS_4": " ,", + "INTLY_ARRAY_THROWS_5": "1,,2", + "INTLY_ARRAY_THROWS_6": "1, ,2", ]) - #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_1", type: .intArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_2", type: .intArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_3", type: .intArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_4", type: .intArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_5", type: .intArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_6", type: .intArray) } + #expect(try sut.value(forKey: "INTLY_ARRAY_1", type: .intArray).value == .init([-1, 0, 1], isSecret: false)) + #expect(try sut.value(forKey: "INTLY_ARRAY_2", type: .intArray).value == .init([-1, 0, 1], isSecret: false)) + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_THROWS_1", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_THROWS_2", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_THROWS_3", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_THROWS_4", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_THROWS_5", type: .intArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "INTLY_ARRAY_THROWS_6", type: .intArray) } } - + @available(Configuration 1.0, *) @Test func valueForKeyOfDoubleArrayTypes() throws { let sut = EnvironmentVariablesProvider( environmentVariables: [ - "DOUBLY_ARRAY_1": "", - "DOUBLY_ARRAY_2": " ", - "DOUBLY_ARRAY_3": ",", - "DOUBLY_ARRAY_4": " ,", - "DOUBLY_ARRAY_5": "1.1,,2.1", - "DOUBLY_ARRAY_6": "1.1, ,2.1", + "DOUBLY_ARRAY_1": "-1.1,0,1.1", + "DOUBLY_ARRAY_2": " -1.1 , 0 ,1.1", + "DOUBLY_ARRAY_THROWS_1": "", + "DOUBLY_ARRAY_THROWS_2": " ", + "DOUBLY_ARRAY_THROWS_3": ",", + "DOUBLY_ARRAY_THROWS_4": " ,", + "DOUBLY_ARRAY_THROWS_5": "1.1,,2.1", + "DOUBLY_ARRAY_THROWS_6": "1.1, ,2.1", ]) - #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_1", type: .doubleArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_2", type: .doubleArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_3", type: .doubleArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_4", type: .doubleArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_5", type: .doubleArray) } - #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_6", type: .doubleArray) } + #expect(try sut.value(forKey: "DOUBLY_ARRAY_1", type: .doubleArray).value == .init([-1.1, 0, 1.1], isSecret: false)) + #expect(try sut.value(forKey: "DOUBLY_ARRAY_2", type: .doubleArray).value == .init([-1.1, 0, 1.1], isSecret: false)) + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_THROWS_1", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_THROWS_1", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_THROWS_2", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_THROWS_3", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_THROWS_4", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_THROWS_5", type: .doubleArray) } + #expect(throws: ConfigError.self) { try sut.value(forKey: "DOUBLY_ARRAY_THROWS_6", type: .doubleArray) } } @available(Configuration 1.0, *)