Skip to content

Commit

Permalink
Use XCTAssertEqual instead of force unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Mar 29, 2018
1 parent 2a6edfa commit 86ef8e2
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions Tests/StencilSwiftKitTests/ParseBoolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ import XCTest

class ParseBoolTests: XCTestCase {
func testParseBool_TrueWithString() throws {
// swiftlint:disable force_unwrapping
XCTAssertTrue(try Filters.parseBool(from: ["true"])!)
XCTAssertTrue(try Filters.parseBool(from: ["yes"])!)
XCTAssertTrue(try Filters.parseBool(from: ["1"])!)
// swiftlint:enable force_unwrapping
XCTAssertEqual(try Filters.parseBool(from: ["true"]), true)
XCTAssertEqual(try Filters.parseBool(from: ["yes"]), true)
XCTAssertEqual(try Filters.parseBool(from: ["1"]), true)
}

func testParseBool_FalseWithString() throws {
// swiftlint:disable force_unwrapping
XCTAssertFalse(try Filters.parseBool(from: ["false"])!)
XCTAssertFalse(try Filters.parseBool(from: ["no"])!)
XCTAssertFalse(try Filters.parseBool(from: ["0"])!)
// swiftlint:enable force_unwrapping
XCTAssertEqual(try Filters.parseBool(from: ["false"]), false)
XCTAssertEqual(try Filters.parseBool(from: ["no"]), false)
XCTAssertEqual(try Filters.parseBool(from: ["0"]), false)
}

func testParseBool_WithOptionalInt() throws {
Expand Down Expand Up @@ -60,9 +56,7 @@ class ParseBoolTests: XCTestCase {
}

func testParseBool_WithNonZeroIndex() throws {
// swiftlint:disable force_unwrapping
XCTAssertTrue(try Filters.parseBool(from: ["test", "true"], at: 1)!)
XCTAssertFalse(try Filters.parseBool(from: ["test", "false"], at: 1)!)
// swiftlint:enable force_unwrapping
XCTAssertEqual(try Filters.parseBool(from: ["test", "true"], at: 1), true)
XCTAssertEqual(try Filters.parseBool(from: ["test", "false"], at: 1), false)
}
}

0 comments on commit 86ef8e2

Please sign in to comment.