Skip to content

Commit 15ff3ef

Browse files
committed
Fixed string comparison with options
1 parent 90d1bde commit 15ff3ef

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/SafeFetching/Predicate/Types/StringComparisonOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extension Optional where Wrapped == Builders.StringComparisonOptions {
4545
case .none:
4646
return operatorString
4747
case let .some(wrapped):
48-
return "\(wrapped)[\(wrapped.stringValue)]"
48+
return "\(operatorString)[\(wrapped.stringValue)]"
4949
}
5050
}
5151
}

Tests/SafeFetchingTests/BooleanPredicateBuilderTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ final class BooleanPredicateTests: XCTestCase {
3535
testNSFormat(\.property, .doesNotMatch(".*"), expecting: #"NOT property MATCHES ".*""#)
3636
}
3737

38+
func testString_comparisonOptions() {
39+
testNSFormat(\.property, .hasPrefix("Desp", options: .caseInsensitive), expecting: #"property BEGINSWITH[c] "Desp""#)
40+
testNSFormat(\.property, .hasPrefix("Desp", options: .diacriticInsensitive), expecting: #"property BEGINSWITH[d] "Desp""#)
41+
testNSFormat(\.property, .hasPrefix("Desp", options: .diacriticAndCaseInsensitive), expecting: #"property BEGINSWITH[cd] "Desp""#)
42+
testNSFormat(\.property, .hasPrefix("Desp", options: .normalized), expecting: #"property BEGINSWITH[n] "Desp""#)
43+
}
44+
3845
func testComparisonFormats_RawRepresentable() {
3946
testNSFormat(predicate: .stubRaw == .foo, expecting: #"stubRaw == 1"#)
4047
testNSFormat(predicate: .stubRaw != .bar, expecting: #"stubRaw != 2"#)

0 commit comments

Comments
 (0)