Skip to content

Instantly share code, notes, and snippets.

@lizixroy
lizixroy / 3.GuardBlackSheep
Created September 10, 2016 21:53
examples for an article
extension XCTestCase {
func g<T>(array: [T], at index: Int, file: StaticString = #file, line: UInt = #line) -> T {
continueAfterFailure = false
guard index < array.count else {
XCTFail("index out of range", file: file, line: line)
precondition(false)
}
return array[index]
}
@lizixroy
lizixroy / 2.GuardBlackSheep
Created September 10, 2016 21:53
examples for an article
func uw<T>(variable: T?, file: StaticString = #file, line: UInt = #line) -> T {
continueAfterFailure = false
guard let variable = variable else {
XCTFail("unexpectedly found nil while unwrapping an Optional value", file: file, line: line)
precondition(false)
}
return variable
}
@lizixroy
lizixroy / 1.GuardBlackSheep
Created September 10, 2016 21:53
examples for an article
func g<T>(array: [T], at index: Int, file: StaticString = #file, line: UInt = #line) -> T {
continueAfterFailure = false
guard index < array.count else {
XCTFail("index out of range", file: file, line: line)
precondition(false)
}
return array[index]
}
@lizixroy
lizixroy / 0.GuardBlackSheep
Created September 10, 2016 21:53
examples for an article
extension XCTestCase {
// method 1
// method 2
}
@lizixroy
lizixroy / 2.demo.swift
Created September 9, 2016 01:41
This is a demo
class ClassTwo {
let variable = "this is 2ed class"
}
@lizixroy
lizixroy / 1.demo.swift
Created September 9, 2016 01:41
This is a demo
class ClassOne {
let variable = "this is 1st class"
}
@lizixroy
lizixroy / 0.demo.swift
Created September 9, 2016 01:41
This is a demo
class ClassZero {
let variable = "this is 0th class"
}
@lizixroy
lizixroy / 2.roypet.swift
Created September 8, 2016 02:34
Roy's pet
class hoopster_iosTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
@lizixroy
lizixroy / 1.roypet.swift
Created September 8, 2016 02:34
Roy's pet
class LogInViewModelTests: XCTestCase {
private let disposeBag = DisposeBag()
private let timeout = 1.0
var mockCellViewModelFactory: LabelAndTextFieldCellViewModelFactoryProtocol!
var mockLogInService: MockLogInService!
var logInViewModel: LogInViewModel!
override func setUp() {
@lizixroy
lizixroy / 0.roypet.swift
Created September 8, 2016 02:34
Roy's pet
Roy
Li
is
Pretty
Rad