Skip to content

Commit

Permalink
Fix Wordcount unit test for Xcode 6 beta 4
Browse files Browse the repository at this point in the history
Fix for issue #4
  • Loading branch information
Erik Dasque authored and Erik Dasque committed Jul 27, 2014
1 parent bbdea45 commit 53891e6
Showing 1 changed file with 17 additions and 11 deletions.
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)
}

}

0 comments on commit 53891e6

Please sign in to comment.