Skip to content

Commit 8b4ea21

Browse files
authored
Merge pull request #23 from ABridoux/develop
Fixed database test value string with double quotes
2 parents 8a9cf5d + 1872427 commit 8b4ea21

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Sources/SafeFetching/Predicate/DatabaseTestValue.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ public protocol DatabaseTestValue {
1818
// MARK: - Scalar
1919

2020
extension String: DatabaseTestValue {
21-
22-
public var testValue: String { #""\#(self)""# }
21+
public var testValue: String {
22+
let escapingQuoteString = replacingOccurrences(of: #"""#, with: #"\""#)
23+
return #""\#(escapingQuoteString)""#
24+
}
2325
}
2426

2527
extension Int: DatabaseTestValue {

Tests/SafeFetchingTests/BooleanPredicateBuilderTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ final class BooleanPredicateTests: XCTestCase {
3838
testNSFormat(\.property, .doesNotMatch(".*"), expecting: #"NOT property MATCHES ".*""#)
3939
}
4040

41+
func testStringWithQuotes() {
42+
testNSFormat(predicate: \.property == #"Quote ""#, expecting: #"property == "Quote \"""#)
43+
}
44+
4145
func testString_comparisonOptions() {
4246
testNSFormat(\.property, .hasPrefix("Desp", options: .caseInsensitive), expecting: #"property BEGINSWITH[c] "Desp""#)
4347
testNSFormat(\.property, .hasPrefix("Desp", options: .diacriticInsensitive), expecting: #"property BEGINSWITH[d] "Desp""#)

0 commit comments

Comments
 (0)