Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Wordcount unit test for Xcode 6 beta 4 #5

Merged
merged 1 commit into from
Aug 8, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions word-count/WordCountTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,56 @@ import XCTest

class WordCountTest: XCTestCase {

func XCTAssertEqualDictionaries <S, T> (first: [S:T], _ second: [S:T]) {
XCTAssertEqual(first.bridgeToObjectiveC(), second.bridgeToObjectiveC())
}

func testCountOneWord() {
let words = WordCount(words: "word")
let expected = ["word": 1]
let result = words.count()
XCTAssertEqualObjects(expected, result)

XCTAssertEqualDictionaries(expected, result)
}

func testCountOneOfEeach() {
let words = WordCount(words: "one of each")
let expected = ["one" : 1, "of" : 1, "each" : 1 ]
let result = words.count();

XCTAssertEqualObjects(expected, result)
XCTAssertEqualDictionaries(expected, result)
}

func testCountMultipleOccurrences() {
let words = WordCount(words: "one fish two fish red fish blue fish")
let expected = ["one" : 1, "fish" : 4, "two" : 1, "red" : 1, "blue" : 1 ]
let result = words.count()
XCTAssertEqualObjects(expected, result)

XCTAssertEqualDictionaries(expected, result)
}

func testIgnorePunctation() {
let words = WordCount(words: "car : carpet as java : javascript!!&$%^&")
let expected = ["car" : 1, "carpet" : 1, "as" : 1, "java" : 1, "javascript" : 1 ]
let result = words.count()

XCTAssertEqualObjects(expected, result)
XCTAssertEqualDictionaries(expected, result)
}

func testIncludeNumbers() {
let words = WordCount(words: "testing, 1, 2 testing")
let expected = [ "testing" : 2, "1" : 1, "2" : 1 ]
let result = words.count()

XCTAssertEqualDictionaries(expected, result)
}

XCTAssertEqualObjects(expected, result)
}

func testNormalizeCase() {
let words = WordCount(words:"go Go GO")
let expected = [ "go" : 3]
let result = words.count()

XCTAssertEqualObjects(expected, result)
XCTAssertEqualDictionaries(expected, result)
}

}