diff --git a/Sources/Queries/StringQuery.swift b/Sources/Queries/StringQuery.swift index 51a6efe..28ec112 100644 --- a/Sources/Queries/StringQuery.swift +++ b/Sources/Queries/StringQuery.swift @@ -125,11 +125,11 @@ public final class StringQuery: NilComparable, Matchable { - file: Name of the file the function is being called from. Defaults to `#file` - line: Number of the line the function is being called from. Defaults to `#line` */ - @discardableResult public func equals(_ string: String) -> FinalizedIncluder { - builder.predicateString = "\(property) == \"\(string)\"" + @discardableResult public func equals(_ string: String, options: PredicateOptions = .None) -> FinalizedIncluder { + builder.predicateString = "\(property) ==\(optionsString(options)) \"\(string)\"" return FinalizedIncluder(builder: builder) } - + fileprivate func optionsString(_ options: PredicateOptions) -> String { if !options.isEmpty && !options.contains(.None) { var string = "[" diff --git a/Tests/PrediKitTests.swift b/Tests/PrediKitTests.swift index a270097..6a8a1e2 100644 --- a/Tests/PrediKitTests.swift +++ b/Tests/PrediKitTests.swift @@ -72,6 +72,8 @@ class PrediKitTests: XCTestCase { XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title CONTAINS[c] %@", theKrakensTitle).predicateFormat) includeIf.string(.krakenTitle).matches(theKrakensTitle, options: .CaseInsensitive) XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title MATCHES[c] %@", theKrakensTitle).predicateFormat) + includeIf.string(.krakenTitle).equals(theKrakensTitle, options: .CaseInsensitive) + XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title ==[c] %@", theKrakensTitle).predicateFormat) includeIf.string(.krakenTitle).beginsWith(theKrakensTitle, options: .DiacriticInsensitive) XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title BEGINSWITH[d] %@", theKrakensTitle).predicateFormat) @@ -81,6 +83,8 @@ class PrediKitTests: XCTestCase { XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title CONTAINS[d] %@", theKrakensTitle).predicateFormat) includeIf.string(.krakenTitle).matches(theKrakensTitle, options: .DiacriticInsensitive) XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title MATCHES[d] %@", theKrakensTitle).predicateFormat) + includeIf.string(.krakenTitle).equals(theKrakensTitle, options: .DiacriticInsensitive) + XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title ==[d] %@", theKrakensTitle).predicateFormat) includeIf.string(.krakenTitle).beginsWith(theKrakensTitle, options: [.CaseInsensitive, .DiacriticInsensitive]) XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title BEGINSWITH[cd] %@", theKrakensTitle).predicateFormat) @@ -90,6 +94,8 @@ class PrediKitTests: XCTestCase { XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title CONTAINS[cd] %@", theKrakensTitle).predicateFormat) includeIf.string(.krakenTitle).matches(theKrakensTitle, options: [.CaseInsensitive, .DiacriticInsensitive]) XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title MATCHES[cd] %@", theKrakensTitle).predicateFormat) + includeIf.string(.krakenTitle).equals(theKrakensTitle, options: [.CaseInsensitive, .DiacriticInsensitive]) + XCTAssertEqual(includeIf.predicateString, NSPredicate(format: "title ==[cd] %@", theKrakensTitle).predicateFormat) } }