From a6242816afc292c1daececcf46ae8b5b98123805 Mon Sep 17 00:00:00 2001 From: Derek Clarkson Date: Tue, 18 Oct 2022 17:21:14 +1100 Subject: [PATCH] Adding missing string interpolation handling --- .gitignore | 1 + Sources/AnyCodable/AnyCodable.swift | 1 + Tests/AnyCodableTests/AnyCodableTests.swift | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1f88c2b..b59a4b7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ DeriveredData/ /*.gcno **/xcshareddata/WorkspaceSettings.xcsettings Carthage/Build/ +/.swiftpm diff --git a/Sources/AnyCodable/AnyCodable.swift b/Sources/AnyCodable/AnyCodable.swift index 7429525..5f9924d 100644 --- a/Sources/AnyCodable/AnyCodable.swift +++ b/Sources/AnyCodable/AnyCodable.swift @@ -100,6 +100,7 @@ extension AnyCodable: ExpressibleByBooleanLiteral {} extension AnyCodable: ExpressibleByIntegerLiteral {} extension AnyCodable: ExpressibleByFloatLiteral {} extension AnyCodable: ExpressibleByStringLiteral {} +extension AnyCodable: ExpressibleByStringInterpolation {} extension AnyCodable: ExpressibleByArrayLiteral {} extension AnyCodable: ExpressibleByDictionaryLiteral {} diff --git a/Tests/AnyCodableTests/AnyCodableTests.swift b/Tests/AnyCodableTests/AnyCodableTests.swift index df374f3..5e7770d 100644 --- a/Tests/AnyCodableTests/AnyCodableTests.swift +++ b/Tests/AnyCodableTests/AnyCodableTests.swift @@ -81,12 +81,14 @@ class AnyCodableTests: XCTestCase { func testJSONEncoding() throws { let someCodable = AnyCodable(SomeCodable(string: "String", int: 100, bool: true, hasUnderscore: "another string")) - + + let injectedValue = 1234 let dictionary: [String: AnyCodable] = [ "boolean": true, "integer": 42, "double": 3.141592653589793, "string": "string", + "stringInterpolation": "string \(injectedValue)", "array": [1, 2, 3], "nested": [ "a": "alpha", @@ -108,6 +110,7 @@ class AnyCodableTests: XCTestCase { "integer": 42, "double": 3.141592653589793, "string": "string", + "stringInterpolation": "string 1234", "array": [1, 2, 3], "nested": { "a": "alpha",