自分用の覚え書き。
たぶんこのままだとコンパイルエラーになります。
Swiftの例外はObCの例外機構と異なるため、SwiftにはExpression関連のアサート関数が存在しない。
import XCTest
@testable import test
class testTests: 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()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
let expression = false
let expression2 = true
let msg = "msg"
let nilObj:String?
let accuracy:Float = 1.0
let num01 = 1
let num02 = 2
XCTAssert(expression, msg)
XCTAssertTrue(expression, msg)
XCTAssertFalse(expression, msg)
XCTAssertNil(nilObj, msg)
XCTAssertNotNil(nilObj, msg)
XCTAssertEqual(expression, expression2, msg)
XCTAssertNotEqual(expression, expression2, msg)
XCTAssertEqualWithAccuracy(expression, expression2, accuracy, msg)
XCTAssertNotEqualWithAccuracy(expression, expression2, accuracy, msg)
// num01がnum02より同じか小さいことを期待する
XCTAssertLessThanOrEqual(num01, num02, msg)
// num02がnum02より小さいことを期待する
XCTAssertLessThan(num01, num02, msg)
// num01がnum02より同じか大きいことを期待する
XCTAssertGreaterThanOrEqual(num01, num02, msg)
// num02がnum02より大きいことを期待する
XCTAssertGreaterThan(num01, num02, msg)
// 必ず失敗する
XCTFail(msg)
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
// Put the code you want to measure the time of here.
}
}
}