Fix ArgumentList with multiple values.
This commit is contained in:
parent
01012dbd88
commit
e4e2fab557
|
@ -19,7 +19,7 @@ public struct ArgumentList {
|
||||||
FatalErrorNotifier.currentNotifier.notify("Expected \(T.self) parameter at index \(index) but got nothing: file \(file), line \(line)")
|
FatalErrorNotifier.currentNotifier.notify("Expected \(T.self) parameter at index \(index) but got nothing: file \(file), line \(line)")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if let value = _args[0] as? T {
|
if let value = _args[index] as? T {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
FatalErrorNotifier.currentNotifier.notify("Expected \(T.self) parameter at index \(index) but got \(_args[0].dynamicType): file \(file), line \(line)")
|
FatalErrorNotifier.currentNotifier.notify("Expected \(T.self) parameter at index \(index) but got \(_args[0].dynamicType): file \(file), line \(line)")
|
||||||
|
|
|
@ -43,7 +43,18 @@ class ArgumentListTests: XCTestCase {
|
||||||
let line = #line - 2
|
let line = #line - 2
|
||||||
|
|
||||||
notifier.assertLastMessage("Expected NSDictionary parameter at index 0 but got nothing: file \(file), line \(line)")
|
notifier.assertLastMessage("Expected NSDictionary parameter at index 0 but got nothing: file \(file), line \(line)")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testShouldUseMultipleParams() {
|
||||||
|
let list = ArgumentList(args: ["Hello", 12])
|
||||||
|
|
||||||
|
let text: String = list.at(0)
|
||||||
|
let number: Int = list.at(1)
|
||||||
|
|
||||||
|
XCTAssertEqual(text, "Hello")
|
||||||
|
XCTAssertEqual(number, 12)
|
||||||
|
notifier.assertNotErrors()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,10 @@ class TestFatalErrorNotifier: FatalErrorNotifierProtocol {
|
||||||
lastMessage = message
|
lastMessage = message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertNotErrors(file: StaticString = #file, line: UInt = #line) {
|
||||||
|
XCTAssertNil(lastMessage, "Should not raise any errors")
|
||||||
|
}
|
||||||
|
|
||||||
func assertLastMessage(message: String, file: StaticString = #file, line: UInt = #line) {
|
func assertLastMessage(message: String, file: StaticString = #file, line: UInt = #line) {
|
||||||
XCTAssertEqual(lastMessage!, message, file: file, line: line)
|
XCTAssertEqual(lastMessage!, message, file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue