Skip to content

Commit

Permalink
Added Test
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Oct 1, 2024
1 parent 96fba10 commit 906bb1b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Bouncer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = SMSFilter/SMSFilter.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1137;
CURRENT_PROJECT_VERSION = 1150;
DEVELOPMENT_TEAM = J9F8F3PWTV;
INFOPLIST_FILE = SMSFilter/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
Expand Down Expand Up @@ -715,7 +715,7 @@
CODE_SIGN_ENTITLEMENTS = SMSFilter/SMSFilter.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1137;
CURRENT_PROJECT_VERSION = 1150;
DEVELOPMENT_TEAM = J9F8F3PWTV;
INFOPLIST_FILE = SMSFilter/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
Expand Down Expand Up @@ -866,7 +866,7 @@
CODE_SIGN_ENTITLEMENTS = Bouncer/Bouncer.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1137;
CURRENT_PROJECT_VERSION = 1150;
DEVELOPMENT_ASSET_PATHS = "\"Bouncer/Preview Content\"";
DEVELOPMENT_TEAM = J9F8F3PWTV;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -901,7 +901,7 @@
CODE_SIGN_ENTITLEMENTS = Bouncer/Bouncer.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1137;
CURRENT_PROJECT_VERSION = 1150;
DEVELOPMENT_ASSET_PATHS = "\"Bouncer/Preview Content\"";
DEVELOPMENT_TEAM = J9F8F3PWTV;
ENABLE_PREVIEWS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,21 @@
landmarkType = "14">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "72B75075-2E63-4698-A299-416FE4014806"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Bouncer/Models/SMSFilter/SMSOfflineFilter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "56"
endingLineNumber = "56"
landmarkName = "matchRegex(text:filter:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file modified Bouncer/.DS_Store
Binary file not shown.
26 changes: 23 additions & 3 deletions BouncerTests/Models/SMSOfflineFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class SMSOfflineFilterTest: XCTestCase {
func testRegexFilter() {
var smsFilter: SMSOfflineFilter
var filterResult: SMSOfflineFilterResponse

let message = SMSMessage(sender: "ETB Comunicaciones", text: "ETB compra 100 megas y recibe 200 por 6 meses. Incluye extensor de velocidAd mas promocion especial. Llama ya sin costo al 018000413807. Ver TyC. Hasta 31 ago 2020")
var message = SMSMessage(sender: "ETB Comunicaciones", text: "ETB compra 100 megas y recibe 200 por 6 meses. Incluye extensor de velocidAd mas promocion especial. Llama ya sin costo al 018000413807. Ver TyC. Hasta 31 ago 2020")

// Regex filter test
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "[E].*[l][o]cidad", type: .message, action: .junk, useRegex: true)])
filterResult = smsFilter.filterMessage(message: message)
XCTAssertEqual(filterResult.action, .junk)

// Regex filter test (Case sensitive)
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "[E].*[l][o]CidAd", type: .message, action: .junk, useRegex: true, caseSensitive: true)])
filterResult = smsFilter.filterMessage(message: message)
Expand All @@ -71,23 +71,43 @@ class SMSOfflineFilterTest: XCTestCase {
XCTAssertEqual(filterResult.action, .junk)

// Regex filter test (Case sensitive)
// Match any string that contains any words “compra,” “extensor,” and “nuevo” in any order and at any position
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "compra|algo|nuevo", type: .message, action: .junk, useRegex: true, caseSensitive: true)])
filterResult = smsFilter.filterMessage(message: message)
XCTAssertEqual(filterResult.action, .junk)

// Match any string that contains any words “compra,” “extensor,” and “nuevo” in any order and at any position
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "compra|extensor|nuevo", type: .message, action: .junk, useRegex: true)])
filterResult = smsFilter.filterMessage(message: message)
XCTAssertEqual(filterResult.action, .junk)

// Match any string that contains all words “compra,” “meses,” and “megas” in any order and at any position
// All Are included
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "(?=.*especial)(?=.*meses)(?=.*megas).*", type: .message, action: .junk, useRegex: true)])
filterResult = smsFilter.filterMessage(message: message)
XCTAssertEqual(filterResult.action, .junk)

// Match any string that contains all words “compra,” “casa,” and “megas” in any order and at any position
// Word casa is not included
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "(?=.*compra)(?=.*casa)(?=.*megas).*", type: .message, action: .junk, useRegex: true)])
filterResult = smsFilter.filterMessage(message: message)
print(filterResult.action)
XCTAssertEqual(filterResult.action, .none)

message = SMSMessage(sender: "Trump", text: """
Shocked you didn't sign..will you PLEASE sign to STRIP Trump of immunity by passing the No Kings Act! SIGN: go.freedom-dems.org/0930a3
Freedom Dems
Stop2End
""")

// Match any word starting with 'dem' or 'Dem' in the message
smsFilter = SMSOfflineFilter(filterList: [Filter(id: UUID(), phrase: "\\bdem\\w+", type: .message, action: .junk, useRegex: true)])
filterResult = smsFilter.filterMessage(message: message)
print(filterResult.action)
XCTAssertEqual(filterResult.action, .junk)

}

func testSubactionFilters() {
Expand Down

0 comments on commit 906bb1b

Please sign in to comment.