This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ArtSabintsev/improvement/regex
Regex Improvements
- Loading branch information
Showing
26 changed files
with
585 additions
and
636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// GuitarTests.swift | ||
// GuitarExample | ||
// | ||
// Created by Sabintsev, Arthur on 3/9/17. | ||
// Copyright © 2017 Arthur Ariel Sabintsev. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import Guitar | ||
|
||
class GuitarTests: XCTestCase { | ||
|
||
func testEmailMatching() { | ||
XCTAssertEqual(Guitar(chord: Guitar.Chord.email).evaluate(string: "This is one email address: [email protected]. This is another [[email protected]].").count, 2) | ||
} | ||
|
||
func testAlphanumericMatching() { | ||
let string = "Hello World, and Hello Guitar Users! ^_^" | ||
let newString = Guitar(chord: Guitar.Chord.nonAlphanumeric).replaceOccurences(in: string, with: "*") | ||
XCTAssertEqual(newString, "Hello World* and Hello Guitar Users* ***") | ||
} | ||
|
||
func testIsValidEmail() { | ||
XCTAssertTrue(Guitar.isValidEmail(email: "[email protected]")) | ||
XCTAssertTrue(Guitar.isValidEmail(email: "[email protected]")) | ||
XCTAssertFalse(Guitar.isValidEmail(email: "arthur.sabintsev@example")) | ||
XCTAssertFalse(Guitar.isValidEmail(email: "[email protected]")) | ||
} | ||
|
||
func testSanitize() { | ||
let string = "Hello, World! This is Arthur. My email is [email protected]! Who misses Obj-C []?" | ||
let newString = Guitar.sanitze(string: string) | ||
XCTAssertEqual(newString, "Hello World This is Arthur My email is arthur sabintsev com Who misses Obj C ") | ||
} | ||
|
||
} |
Oops, something went wrong.