Skip to content

Commit

Permalink
Added test cases for task 3 (see #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Vanhoef authored and Peter Vanhoef committed Mar 19, 2017
1 parent 98941d2 commit 89f3baa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Calculator/CalculatorTests/CalculatorBrainTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,25 @@ class CalculatorBrainTests: XCTestCase {
testBrain.performOperation("π")
testBrain.performOperation("cos")
XCTAssertEqual(testBrain.result, -1)

}

func testAdditionalOperationsTask3() {
var testBrain = CalculatorBrain()

testBrain.performOperation("π")
testBrain.performOperation("sin")
XCTAssertEqual(testBrain.result, 0)

testBrain.performOperation("π")
testBrain.performOperation("tan")
XCTAssertEqual(testBrain.result, 0)

testBrain.setOperand(18)
testBrain.performOperation("")
XCTAssertEqual(testBrain.result, 324)

testBrain.setOperand(4)
testBrain.performOperation("x⁻¹")
XCTAssertEqual(testBrain.result, 0.25)
}
}
22 changes: 22 additions & 0 deletions Calculator/CalculatorUITests/CalculatorUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,26 @@ class CalculatorUITests: XCTestCase {
buttonEqual.tap()
XCTAssert(app.staticTexts["3.27"].exists)
}

func testAdditionalOperationsTask3() {
let app = XCUIApplication()

app.buttons["π"].tap()
app.buttons["sin"].tap()
XCTAssert(app.staticTexts["0.0"].exists)

app.buttons["π"].tap()
app.buttons["tan"].tap()
XCTAssert(app.staticTexts["0.0"].exists)

app.buttons["1"].tap()
app.buttons["8"].tap()
app.buttons[""].tap()
XCTAssert(app.staticTexts["324.0"].exists)

app.buttons["4"].tap()
app.buttons["x⁻¹"].tap()
XCTAssert(app.staticTexts["0.25"].exists)
}

}

0 comments on commit 89f3baa

Please sign in to comment.