Skip to content

Commit 1b39e2f

Browse files
authored
Merge pull request #19 from ABridoux/develop
Fixed missing quotes for enum string value
2 parents fa9fe81 + 1a0dc69 commit 1b39e2f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Sources/SafeFetching/Predicate/DatabaseTestValue.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ extension Array: DatabaseTestValue where Element: DatabaseTestValue {
8787

8888
extension DatabaseTestValue where Self: RawRepresentable, RawValue: DatabaseValue {
8989

90-
public var testValue: String { String(describing: rawValue) }
90+
public var testValue: String {
91+
if RawValue.self == String.self {
92+
return #""\#(rawValue)""#
93+
} else {
94+
return String(describing: rawValue)
95+
}
96+
}
9197
}
9298

9399
// MARK: - Range

Sources/SafeFetching/Predicate/Declarations/PredicateRightValue+ValuesSet.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ public extension Builders.KeyPathPredicateRightValue where Value: Equatable & Da
2323
.init { .init(keyPath: $0, operatorString: "IN", value: values, isInverted: true) }
2424
}
2525
}
26-

Tests/SafeFetchingTests/BooleanPredicateBuilderTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ final class BooleanPredicateTests: XCTestCase {
4242
testNSFormat(predicate: .stubForcedRaw > .foo, expecting: #"stubForcedRaw > 1"#)
4343
testNSFormat(predicate: .stubForcedRaw <= .foo, expecting: #"stubForcedRaw <= 1"#)
4444
testNSFormat(predicate: .stubForcedRaw < .foo, expecting: #"stubForcedRaw < 1"#)
45+
testNSFormat(predicate: .stubStringRawValue == .foo, expecting: #"stubStringRawValue == "foo""#)
4546
}
4647

4748
func testRawRepresentable() {
@@ -119,6 +120,7 @@ extension BooleanPredicateTests {
119120
@objc var score = 0.0
120121
@objc var property: String? = ""
121122
@objc var stubRawValue: Int = 0
123+
@objc var stubStringRawValue = ""
122124
@objc var stubRawOption: Int = 0
123125

124126
@objc var stubRelationship: StubEntity?
@@ -143,6 +145,11 @@ extension BooleanPredicateTests {
143145
lhs.rawValue < rhs.rawValue
144146
}
145147
}
148+
149+
enum StubStringEnum: String, DatabaseTestValue {
150+
case foo
151+
case bar
152+
}
146153
}
147154

148155
extension StringKeyPath where Entity == BooleanPredicateTests.StubEntity, Value == BooleanPredicateTests.StubEnum {
@@ -159,6 +166,13 @@ extension StringKeyPath where Entity == BooleanPredicateTests.StubEntity, Value
159166
}
160167
}
161168

169+
extension StringKeyPath where Entity == BooleanPredicateTests.StubEntity, Value == BooleanPredicateTests.StubStringEnum {
170+
171+
static var stubStringRawValue: Self {
172+
Self(key: "stubStringRawValue")
173+
}
174+
}
175+
162176
// MARK: - Stub option set
163177

164178
extension BooleanPredicateTests {

0 commit comments

Comments
 (0)