-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
446 additions
and
387 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Change Log | ||
|
||
## 0.1.2 | ||
|
||
### Improvements | ||
|
||
* Add Makfile for easier installation of command line tool. | ||
* Switched to using a swift package based executable. | ||
* Add more tests. | ||
|
||
## 0.1.1 | ||
|
||
Initial release | ||
|
||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import XCTest | ||
|
||
class EmailAddressTests: XCTestCase { | ||
|
||
func testEmailAddress() throws { | ||
let result = runProcess(args: "email-address") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
// should have one email address | ||
let emails = output.components(separatedBy: .whitespaces) | ||
XCTAssertEqual(1, emails.count) | ||
|
||
emails.forEach { XCTAssertTrue($0.isEmailAddress) } | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testEmailAddress", testEmailAddress), | ||
] | ||
} |
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,90 @@ | ||
import XCTest | ||
|
||
class NameTests: XCTestCase { | ||
|
||
func testName() throws { | ||
let result = runProcess(args: "name") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
let words = output.words() | ||
XCTAssertEqual(1, words.count) | ||
|
||
words.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.isCapitalized) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testFirstName() throws { | ||
let result = runProcess(args: "name", "--portion", "first") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
let words = output.words() | ||
XCTAssertEqual(1, words.count) | ||
|
||
words.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.isCapitalized) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testLastName() throws { | ||
let result = runProcess(args: "name", "--portion", "last") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
let words = output.words() | ||
XCTAssertEqual(1, words.count) | ||
|
||
words.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.isCapitalized) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testFullName() throws { | ||
let result = runProcess(args: "name", "--portion", "full") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
let words = output.words() | ||
XCTAssertEqual(2, words.count) | ||
|
||
words.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.isCapitalized) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testFirstName", testFirstName), | ||
("testLastName", testLastName), | ||
("testFullName", testFullName), | ||
] | ||
} |
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,45 @@ | ||
import XCTest | ||
|
||
class ParagraphTests: XCTestCase { | ||
|
||
func testParagraph() throws { | ||
let result = runProcess(args: "paragraph") | ||
|
||
switch result { | ||
case .success(let output): | ||
let paragraphs = output.paragraphs() | ||
XCTAssertEqual(1, paragraphs.count) | ||
|
||
paragraphs.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.sentences().count > 1) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testParagraphCount() throws { | ||
let result = runProcess(args: "paragraph", "--count", "3") | ||
|
||
switch result { | ||
case .success(let output): | ||
let paragraphs = output.paragraphs() | ||
XCTAssertEqual(3, paragraphs.count) | ||
|
||
paragraphs.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.sentences().count > 1) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testParagraph", testParagraph), | ||
("testParagraphCount", testParagraphCount), | ||
] | ||
} |
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,45 @@ | ||
import XCTest | ||
|
||
class SentenceTests: XCTestCase { | ||
|
||
func testSentence() throws { | ||
let result = runProcess(args: "sentence") | ||
|
||
switch result { | ||
case .success(let output): | ||
let sentences = output.sentences() | ||
XCTAssertEqual(1, sentences.count) | ||
|
||
sentences.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.words().count > 1) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testSentenceCount() throws { | ||
let result = runProcess(args: "sentence", "--count", "3") | ||
|
||
switch result { | ||
case .success(let output): | ||
let sentences = output.sentences() | ||
XCTAssertEqual(3, sentences.count) | ||
|
||
sentences.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.words().count > 1) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testSentence", testSentence), | ||
("testSentenceCount", testSentenceCount), | ||
] | ||
} |
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,28 @@ | ||
import XCTest | ||
|
||
class TitleTests: XCTestCase { | ||
|
||
func testTitle() throws { | ||
let result = runProcess(args: "title") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
let words = output.words() | ||
XCTAssertTrue(words.count > 1) | ||
|
||
words.forEach { | ||
XCTAssertFalse($0.isEmpty) | ||
XCTAssertTrue($0.isCapitalized) | ||
} | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testTitle", testTitle), | ||
] | ||
} |
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,58 @@ | ||
import XCTest | ||
|
||
class TweetTests: XCTestCase { | ||
|
||
func testTweet() throws { | ||
let result = runProcess(args: "tweet") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
XCTAssertLessThan(output.count, 140) | ||
|
||
let words = output.words() | ||
XCTAssertTrue(words.count >= 1) | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testShortTweet() throws { | ||
let result = runProcess(args: "tweet", "--length", "short") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
XCTAssertLessThan(output.count, 140) | ||
|
||
let words = output.words() | ||
XCTAssertTrue(words.count >= 1) | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testLongTweet() throws { | ||
let result = runProcess(args: "tweet", "--length", "long") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
XCTAssertLessThan(output.count, 280) | ||
|
||
let words = output.words() | ||
XCTAssertTrue(words.count >= 1) | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testTweet", testTweet), | ||
("testShortTweet", testShortTweet), | ||
("testLongTweet", testLongTweet), | ||
] | ||
} |
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,25 @@ | ||
import XCTest | ||
|
||
class UrlTests: XCTestCase { | ||
|
||
func testUrl() throws { | ||
let result = runProcess(args: "url") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
let urls = output.components(separatedBy: .whitespaces) | ||
XCTAssertEqual(1, urls.count) | ||
|
||
urls.forEach { XCTAssertTrue($0.isWebUrl) } | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testUrl", testUrl), | ||
] | ||
} |
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,41 @@ | ||
import XCTest | ||
|
||
class WordTests: XCTestCase { | ||
|
||
func testWord() throws { | ||
let result = runProcess(args: "word") | ||
|
||
switch result { | ||
case .success(let output): | ||
XCTAssertFalse(output.isEmpty) | ||
|
||
let words = output.words() | ||
XCTAssertEqual(1, words.count) | ||
|
||
words.forEach { XCTAssertFalse($0.isEmpty) } | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func testWordCount() throws { | ||
let result = runProcess(args: "word", "--count", "3") | ||
|
||
switch result { | ||
case .success(let output): | ||
let words = output.words() | ||
XCTAssertEqual(3, words.count) | ||
|
||
words.forEach { XCTAssertFalse($0.isEmpty) } | ||
|
||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
static var allTests = [ | ||
("testWord", testWord), | ||
("testWordCount", testWordCount), | ||
] | ||
} |
Oops, something went wrong.