-
Notifications
You must be signed in to change notification settings - Fork 2
/
SignsDictionaryTest.swift
95 lines (79 loc) · 3.29 KB
/
SignsDictionaryTest.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// SignsDictionaryTest.swift
// NZSLDict
//
// Created by Josh McArthur on 7/06/17.
//
//
import XCTest
@testable import NZSLDict
class SignsDictionaryTest: XCTestCase {
var signsDictionary: SignsDictionary!;
override func setUp() {
super.setUp()
signsDictionary = SignsDictionary.init(file: "");
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
signsDictionary = nil;
}
func test_searchForExactMainGlossMatch() {
let results = signsDictionary.search(for: "Book");
let firstResult: DictEntry = results![0] as! DictEntry;
assert(firstResult.gloss == "book");
}
func test_searchForExactMaoriGlossMatch() {
let results = signsDictionary.search(for: "ora");
let firstResult: DictEntry = results![0] as! DictEntry;
assert(firstResult.gloss == "alive, live, survive");
}
func test_searchForContainsMainGloss() {
let results = signsDictionary.search(for: "classif");
let firstResult: DictEntry = results![0] as! DictEntry;
assert(firstResult.gloss == "classifier");
}
func test_searchForContainsMaoriGloss() {
let results = signsDictionary.search(for: "akorang");
let firstResult: DictEntry = results![0] as! DictEntry;
assert(firstResult.gloss == "course");
}
func test_searchForExactSecondaryGloss() {
let results = signsDictionary.search(for: "nought");
let firstResult: DictEntry = results![0] as! DictEntry;
assert(firstResult.gloss == "zero");
}
func test_searchForContainsSecondaryGloss() {
let results = signsDictionary.search(for: "not get involved, nothing to do with");
let firstResult: DictEntry = results![0] as! DictEntry;
assert(firstResult.gloss == "neutral");
}
func test_duplicateResultsAreRemoved() {
// There are 5 unique results for Auckland. This search term is used
// because it was known to break and show duplicates, but also includes
// more than 1 unique result for the term
let results = signsDictionary.search(for: "Auckland");
let resultsMatchingAuckland = results?.filter { ($0 as AnyObject).gloss == "Auckland" }
assert(resultsMatchingAuckland?.count == 5)
}
func test_searchForStartsWithMainGloss() {
let results = signsDictionary.search(for: "bus");
let firstResult = results?[0] as! DictEntry;
assert(firstResult.gloss == "bus stop");
}
func test_searchForStartsWithMaoriGloss() {
let results = signsDictionary.search(for: "Aorang");
let firstResult = results?[0] as! DictEntry;
assert(firstResult.gloss == "Feilding");
}
func test_searchForPrioritisesResults() {
// A nice general term that returns a range of matched signs
let results = signsDictionary.search(for: "bus");
let result1 = results?[0] as! DictEntry;
let result2 = results?[1] as! DictEntry;
let result3 = results?[2] as! DictEntry;
assert(result1.gloss == "bus stop");
assert(result2.gloss == "bus, truck");
assert(result3.gloss == "bush, tree");
}
}