in FBAEMKit/FBAEMKitTests/AEMAdvertiserSingleEntryRuleTests.swift [173:275]
func testIsMatchedWithStringComparision() {
let rule = _AEMAdvertiserSingleEntryRule(
with: .contains,
paramKey: "fb_content.title",
linguisticCondition: "hello",
numericalCondition: nil,
arrayCondition: nil
)
XCTAssertTrue(
rule.isMatched(withStringValue: "worldhelloworld", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
XCTAssertFalse(
rule.isMatched(withStringValue: "worldhellworld", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
rule.setOperator(.notContains)
XCTAssertFalse(
rule.isMatched(withStringValue: "worldhelloworld", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
XCTAssertFalse(
rule.isMatched(withStringValue: "WorldHelloWorld", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
XCTAssertTrue(
rule.isMatched(withStringValue: "worldhellworld", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
rule.setOperator(.startsWith)
XCTAssertTrue(
rule.isMatched(withStringValue: "helloworld", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
XCTAssertTrue(
rule.isMatched(withStringValue: "HelloWorld", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
XCTAssertFalse(
rule.isMatched(withStringValue: "worldhelloworld", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
rule.setOperator(.caseInsensitiveContains)
XCTAssertTrue(
rule.isMatched(withStringValue: "worldHELLOworld", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
XCTAssertFalse(
rule.isMatched(withStringValue: "worldhellworld", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
rule.setOperator(.caseInsensitiveNotContains)
XCTAssertFalse(
rule.isMatched(withStringValue: "worldHELLOworld", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
XCTAssertTrue(
rule.isMatched(withStringValue: "worldHELLworld", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
rule.setOperator(.caseInsensitiveStartsWith)
XCTAssertTrue(
rule.isMatched(withStringValue: "HELLOworld", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
XCTAssertFalse(
rule.isMatched(withStringValue: "worldHELLOworld", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
rule.setOperator(.equal)
XCTAssertTrue(
rule.isMatched(withStringValue: "hello", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
XCTAssertTrue(
rule.isMatched(withStringValue: "Hello", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
XCTAssertFalse(
rule.isMatched(withStringValue: "hellw", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
rule.setOperator(.notEqual)
XCTAssertFalse(
rule.isMatched(withStringValue: "hello", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
XCTAssertFalse(
rule.isMatched(withStringValue: "Hello", numericalValue: nil),
"Shoule not expect parameter matched with the value"
)
XCTAssertTrue(
rule.isMatched(withStringValue: "hellw", numericalValue: nil),
"Shoule expect parameter matched with the value"
)
}