Skip to content

Commit

Permalink
Regex filter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Jul 13, 2024
1 parent 03a137c commit ebfcc32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Bouncer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = SMSFilter/SMSFilter.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1007;
CURRENT_PROJECT_VERSION = 1031;
DEVELOPMENT_TEAM = JM9222EF99;
INFOPLIST_FILE = SMSFilter/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -714,7 +714,7 @@
CODE_SIGN_ENTITLEMENTS = SMSFilter/SMSFilter.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1007;
CURRENT_PROJECT_VERSION = 1031;
DEVELOPMENT_TEAM = JM9222EF99;
INFOPLIST_FILE = SMSFilter/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -860,7 +860,7 @@
CODE_SIGN_ENTITLEMENTS = Bouncer/Bouncer.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1007;
CURRENT_PROJECT_VERSION = 1031;
DEVELOPMENT_ASSET_PATHS = "\"Bouncer/Preview Content\"";
DEVELOPMENT_TEAM = JM9222EF99;
ENABLE_PREVIEWS = YES;
Expand All @@ -872,7 +872,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.4.0;
MARKETING_VERSION = 2.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.banshai.bouncer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -891,7 +891,7 @@
CODE_SIGN_ENTITLEMENTS = Bouncer/Bouncer.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1007;
CURRENT_PROJECT_VERSION = 1031;
DEVELOPMENT_ASSET_PATHS = "\"Bouncer/Preview Content\"";
DEVELOPMENT_TEAM = JM9222EF99;
ENABLE_PREVIEWS = YES;
Expand All @@ -903,7 +903,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.4.0;
MARKETING_VERSION = 2.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.banshai.bouncer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
18 changes: 18 additions & 0 deletions BouncerTests/Models/SMSOfflineFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ class SMSOfflineFilterTest: XCTestCase {
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "[E].*[l][o]cidAd", type: .message, action: .junk, useRegex: true, caseSensitive: true)])
filterResult = smsFilter.filterMessage(message: messages[0])
XCTAssertEqual(filterResult.action, .junk)

// Regex filter test (Case sensitive)
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "compra|algo|nuevo", type: .message, action: .junk, useRegex: true, caseSensitive: true)])
filterResult = smsFilter.filterMessage(message: messages[0])
XCTAssertEqual(filterResult.action, .junk)

smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "compra|extensor|nuevo", type: .message, action: .junk, useRegex: true, caseSensitive: true)])
filterResult = smsFilter.filterMessage(message: messages[0])
XCTAssertEqual(filterResult.action, .junk)

smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "(?=.*especial)(?=.*meses)(?=.*megas).*", type: .message, action: .junk, useRegex: true, caseSensitive: true)])
filterResult = smsFilter.filterMessage(message: messages[0])
XCTAssertEqual(filterResult.action, .junk)

smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "(?=.*compra)(?=.*casa)(?=.*megas).*", type: .message, action: .junk, useRegex: true, caseSensitive: false)])
filterResult = smsFilter.filterMessage(message: messages[0])
print(filterResult.action)
XCTAssertEqual(filterResult.action, .none)
}

func testSubactionFilters() {
Expand Down

0 comments on commit ebfcc32

Please sign in to comment.