[UPDATE] Test cases
This commit is contained in:
parent
ca87c14af8
commit
5fe140d8ce
17
.travis.yml
17
.travis.yml
|
@ -1,12 +1,17 @@
|
|||
language: objective-c
|
||||
osx_image: xcode7.1
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
env:
|
||||
matrix:
|
||||
- DESTINATION="OS=9.1,name=iPad 2"
|
||||
- DESTINATION="OS=9.1,name=iPad Air"
|
||||
- DESTINATION="OS=9.1,name=iPhone 5"
|
||||
- DESTINATION="OS=9.1,name=iPhone 6s"
|
||||
- DESTINATION="OS=8.4,name=iPhone 6"
|
||||
- DESTINATION="OS=8.4,name=iPad Air"
|
||||
before_install:
|
||||
- gem install xcpretty
|
||||
script:
|
||||
- set -o pipefail
|
||||
- xcodebuild -project Example/SplitflapExample.xcodeproj -scheme SplitflapTests -sdk iphonesimulator -destination "id=74B65E5F-38DA-42D9-AD99-1DF06695DC54" -configuration Release test | xcpretty -c
|
||||
- xcodebuild -version
|
||||
- xcodebuild -project Example/SplitflapExample.xcodeproj -scheme SplitflapTests -sdk iphonesimulator -destination "$DESTINATION" -enableCodeCoverage YES -configuration Release test | xcpretty -c
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash) -d
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
CE525DBF1BF4FC3200429200 /* TileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB139B91BF266FC00DE6BA9 /* TileView.swift */; };
|
||||
CE525DC01BF4FC3200429200 /* TokenGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE525D7F1BF3425C00429200 /* TokenGenerator.swift */; };
|
||||
CE525DC11BF4FC3200429200 /* TokenParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE525D811BF3467D00429200 /* TokenParser.swift */; };
|
||||
CE525DC31BF5134D00429200 /* TokenParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE525DC21BF5134D00429200 /* TokenParserTests.swift */; };
|
||||
CEB139A41BF266DD00DE6BA9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB139A31BF266DD00DE6BA9 /* AppDelegate.swift */; };
|
||||
CEB139A61BF266DD00DE6BA9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB139A51BF266DD00DE6BA9 /* ViewController.swift */; };
|
||||
CEB139A91BF266DD00DE6BA9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CEB139A71BF266DD00DE6BA9 /* Main.storyboard */; };
|
||||
|
@ -89,6 +90,7 @@
|
|||
CE525DAD1BF4FBC800429200 /* SplitflapTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SplitflapTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CE525DB11BF4FBC800429200 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
CE525DB71BF4FBE400429200 /* TokenGeneratorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenGeneratorTests.swift; sourceTree = "<group>"; };
|
||||
CE525DC21BF5134D00429200 /* TokenParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenParserTests.swift; sourceTree = "<group>"; };
|
||||
CEB139A01BF266DD00DE6BA9 /* SplitflapExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SplitflapExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CEB139A31BF266DD00DE6BA9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
CEB139A51BF266DD00DE6BA9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -139,8 +141,9 @@
|
|||
CE525DAE1BF4FBC800429200 /* SplitflapTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CE525DB71BF4FBE400429200 /* TokenGeneratorTests.swift */,
|
||||
CE525DB11BF4FBC800429200 /* Info.plist */,
|
||||
CE525DB71BF4FBE400429200 /* TokenGeneratorTests.swift */,
|
||||
CE525DC21BF5134D00429200 /* TokenParserTests.swift */,
|
||||
);
|
||||
path = SplitflapTests;
|
||||
sourceTree = "<group>";
|
||||
|
@ -357,6 +360,7 @@
|
|||
files = (
|
||||
CE525DBC1BF4FC3200429200 /* SplitflapDataSource.swift in Sources */,
|
||||
CE525DBE1BF4FC3200429200 /* SplitflapTokens.swift in Sources */,
|
||||
CE525DC31BF5134D00429200 /* TokenParserTests.swift in Sources */,
|
||||
CE525DC11BF4FC3200429200 /* TokenParser.swift in Sources */,
|
||||
CE525DBF1BF4FC3200429200 /* TileView.swift in Sources */,
|
||||
CE525DB81BF4FBE400429200 /* TokenGeneratorTests.swift in Sources */,
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Splitflap
|
||||
*
|
||||
* Copyright 2015-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
import UIKit
|
||||
import XCTest
|
||||
|
||||
class TokenParserTests: XCTestCase {
|
||||
func testParseEmptyString() {
|
||||
let parser = TokenParser(tokens: [])
|
||||
|
||||
XCTAssertEqual(parser.parseString(""), [])
|
||||
XCTAssertEqual(parser.parseString(" "), [])
|
||||
XCTAssertEqual(parser.parseString("hello"), [])
|
||||
}
|
||||
|
||||
func testParseOneSimpleTokenString() {
|
||||
let parser = TokenParser(tokens: ["a"])
|
||||
|
||||
XCTAssertEqual(parser.parseString(""), [])
|
||||
XCTAssertEqual(parser.parseString("hello"), [])
|
||||
XCTAssertEqual(parser.parseString("a"), ["a"])
|
||||
XCTAssertEqual(parser.parseString("aaaaa"), ["a", "a", "a", "a", "a"])
|
||||
XCTAssertEqual(parser.parseString("abracadabra"), ["a"])
|
||||
XCTAssertEqual(parser.parseString("ba_alababa"), [])
|
||||
}
|
||||
|
||||
func testParseAlphabeticTokenString() {
|
||||
let parser = TokenParser(tokens: SplitflapTokens.Alphabetic)
|
||||
|
||||
XCTAssertEqual(parser.parseString(""), [])
|
||||
XCTAssertEqual(parser.parseString("hello"), ["h", "e", "l", "l", "o"])
|
||||
XCTAssertEqual(parser.parseString("Hello"), ["H", "e", "l", "l", "o"])
|
||||
XCTAssertEqual(parser.parseString("h0ello"), ["h"])
|
||||
XCTAssertEqual(parser.parseString(" hello"), [])
|
||||
}
|
||||
|
||||
func testParseOneComplexTokenString() {
|
||||
let parser = TokenParser(tokens: ["foo"])
|
||||
|
||||
XCTAssertEqual(parser.parseString(""), [])
|
||||
XCTAssertEqual(parser.parseString("f"), [])
|
||||
XCTAssertEqual(parser.parseString("fo"), [])
|
||||
XCTAssertEqual(parser.parseString("foo"), ["foo"])
|
||||
XCTAssertEqual(parser.parseString("foof"), ["foo"])
|
||||
XCTAssertEqual(parser.parseString("foofo"), ["foo"])
|
||||
XCTAssertEqual(parser.parseString("foofoo"), ["foo", "foo"])
|
||||
XCTAssertEqual(parser.parseString("footfoo"), ["foo"])
|
||||
XCTAssertEqual(parser.parseString("playfoot"), [])
|
||||
}
|
||||
|
||||
func testParseComplexTokenString() {
|
||||
let parser = TokenParser(tokens: ["foo", "bar", "pop"])
|
||||
|
||||
XCTAssertEqual(parser.parseString(""), [])
|
||||
XCTAssertEqual(parser.parseString("foo"), ["foo"])
|
||||
XCTAssertEqual(parser.parseString("foopop"), ["foo", "pop"])
|
||||
XCTAssertEqual(parser.parseString("popbarfoopop"), ["pop", "bar", "foo", "pop"])
|
||||
XCTAssertEqual(parser.parseString("afoo"), [])
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue