[UPDATE] Tests
This commit is contained in:
parent
c2cee9866e
commit
ca87c14af8
|
@ -430,6 +430,7 @@
|
|||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
|
||||
INFOPLIST_FILE = Splitflap/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
|
@ -451,6 +452,7 @@
|
|||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
|
||||
INFOPLIST_FILE = Splitflap/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
|
|
|
@ -29,8 +29,8 @@ import XCTest
|
|||
|
||||
class TokenGeneratorTests: XCTestCase {
|
||||
func testCurrentElement() {
|
||||
let nilGenerator = TokenGenerator(tokens: [])
|
||||
XCTAssertNil(nilGenerator.currentElement)
|
||||
let emptyGenerator = TokenGenerator(tokens: [])
|
||||
XCTAssertNil(emptyGenerator.currentElement)
|
||||
|
||||
let oneElementGenerator = TokenGenerator(tokens: ["a"])
|
||||
XCTAssertEqual(oneElementGenerator.currentElement, "a")
|
||||
|
@ -38,4 +38,39 @@ class TokenGeneratorTests: XCTestCase {
|
|||
let nElementsGenerator = TokenGenerator(tokens: ["a", "b", "c", "d"])
|
||||
XCTAssertEqual(nElementsGenerator.currentElement, "a")
|
||||
}
|
||||
|
||||
func testNext() {
|
||||
let emptyGenerator = TokenGenerator(tokens: [])
|
||||
XCTAssertNil(emptyGenerator.currentElement)
|
||||
|
||||
let nilElement = emptyGenerator.next()
|
||||
XCTAssertNil(nilElement)
|
||||
XCTAssertNil(emptyGenerator.currentElement)
|
||||
|
||||
let oneElementGenerator = TokenGenerator(tokens: ["a"])
|
||||
let aElement = oneElementGenerator.next()
|
||||
XCTAssertEqual(aElement, "a")
|
||||
XCTAssertEqual(oneElementGenerator.currentElement, "a")
|
||||
|
||||
let twoElementsGenerator = TokenGenerator(tokens: ["a", "b"])
|
||||
var twoElement = twoElementsGenerator.next()
|
||||
XCTAssertEqual(twoElement, "b")
|
||||
XCTAssertEqual(twoElementsGenerator.currentElement, "b")
|
||||
|
||||
twoElement = twoElementsGenerator.next()
|
||||
XCTAssertEqual(twoElement, "a")
|
||||
XCTAssertEqual(twoElementsGenerator.currentElement, "a")
|
||||
}
|
||||
|
||||
func testFirstToken() {
|
||||
let emptyGenerator = TokenGenerator(tokens: [])
|
||||
XCTAssertNil(emptyGenerator.firstToken)
|
||||
|
||||
let oneElementGenerator = TokenGenerator(tokens: ["a"])
|
||||
XCTAssertEqual(oneElementGenerator.firstToken, "a")
|
||||
|
||||
let nElementsGenerator = TokenGenerator(tokens: ["a", "b", "c", "d"])
|
||||
nElementsGenerator.next()
|
||||
XCTAssertEqual(nElementsGenerator.firstToken, "a")
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||

|
||||
|
||||
[](http://cocoadocs.org/docsets/Splitflap/) [](http://cocoadocs.org/docsets/Splitflap/) [](https://github.com/Carthage/Carthage)
|
||||
[](http://cocoadocs.org/docsets/Splitflap/) [](http://cocoadocs.org/docsets/Splitflap/) [](https://github.com/Carthage/Carthage) [](https://travis-ci.org/yannickl/Splitflap)
|
||||
|
||||
Splitflap is a simple to use component to present changeable alphanumeric text like often used as a public transport timetable in airports or railway stations or with some flip clocks.
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ final class FlapView: UIView {
|
|||
}
|
||||
|
||||
/// Display the given token. If animated it rotate the flaps.
|
||||
private func updateWithToken(token: String, animated: Bool) {
|
||||
private func updateWithToken(token: String?, animated: Bool) {
|
||||
let topBack = animationTime == .Tic ? topTicTile : topTacTile
|
||||
let bottomBack = animationTime == .Tic ? bottomTicTile : bottomTacTile
|
||||
let topFront = animationTime == .Tic ? topTacTile : topTicTile
|
||||
|
|
|
@ -41,7 +41,8 @@ final class TokenGenerator: GeneratorType {
|
|||
|
||||
// MARK: - Implementing GeneratorType
|
||||
|
||||
private(set) var currentIndex = 0
|
||||
/// Current element index
|
||||
private var currentIndex = 0
|
||||
|
||||
/// Returns the current element of the generator, nil otherwise.
|
||||
var currentElement: Element? {
|
||||
|
@ -63,7 +64,15 @@ final class TokenGenerator: GeneratorType {
|
|||
}
|
||||
}
|
||||
|
||||
/// Advance to the next element and return it, or `nil` if no next.
|
||||
/// element exists.
|
||||
func next() -> Element? {
|
||||
let tokenCount = tokens.count
|
||||
|
||||
guard tokenCount > 0 else {
|
||||
return nil
|
||||
}
|
||||
|
||||
currentIndex = (currentIndex + 1) % tokens.count
|
||||
|
||||
return tokens[currentIndex]
|
||||
|
@ -71,9 +80,10 @@ final class TokenGenerator: GeneratorType {
|
|||
|
||||
// MARK: - Convenience Methods
|
||||
|
||||
var firstToken: String {
|
||||
/// Returns the first token, or `nil` if no token.
|
||||
var firstToken: String? {
|
||||
get {
|
||||
return tokens.first ?? ""
|
||||
return tokens.first
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue