Skip to content

Commit

Permalink
Add test case for extra credit 1 (see #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Vanhoef authored and Peter Vanhoef committed Mar 26, 2017
1 parent 3e6d8ec commit 62ca500
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Calculator/Calculator/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,25 @@
<rect key="frame" x="0.0" y="0.0" width="343" height="95"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4ss-pM-0I2">
<rect key="frame" x="0.0" y="0.0" width="60.5" height="95"/>
<rect key="frame" x="0.0" y="0.0" width="49" height="95"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<state key="normal" title="C"/>
<state key="normal" title="BS"/>
<connections>
<action selector="clear:" destination="BYZ-38-t0r" eventType="touchUpInside" id="qr1-Ca-0eX"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NCt-oF-aVp">
<rect key="frame" x="59" y="0.0" width="48.5" height="95"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<state key="normal" title="C"/>
<connections>
<action selector="clear:" destination="BYZ-38-t0r" eventType="touchUpInside" id="hMo-Oe-7sL"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cJB-pf-Plh">
<rect key="frame" x="70.5" y="0.0" width="60.5" height="95"/>
<rect key="frame" x="117.5" y="0.0" width="49" height="95"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<state key="normal" title="+">
Expand All @@ -66,7 +75,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AAq-mp-WTl">
<rect key="frame" x="141" y="0.0" width="61" height="95"/>
<rect key="frame" x="176.5" y="0.0" width="49" height="95"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<state key="normal" title="">
Expand All @@ -77,7 +86,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MDW-9A-9Fm">
<rect key="frame" x="212" y="0.0" width="60.5" height="95"/>
<rect key="frame" x="235.5" y="0.0" width="48.5" height="95"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<state key="normal" title="÷">
Expand All @@ -88,7 +97,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZGO-VJ-SLt">
<rect key="frame" x="282.5" y="0.0" width="60.5" height="95"/>
<rect key="frame" x="294" y="0.0" width="49" height="95"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<state key="normal" title="×">
Expand Down
33 changes: 33 additions & 0 deletions Calculator/CalculatorUITests/CalculatorUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,37 @@ class CalculatorUITests: XCTestCase {
XCTAssert(app.staticTexts["(1 + 3)⁻¹ ="].exists)
XCTAssert(app.staticTexts["0.25"].exists)
}

func testBackSpaceExtraCredit1() {
let app = XCUIApplication()

XCTAssert(app.staticTexts["0"].exists)
app.buttons["BS"].tap()
XCTAssert(app.staticTexts["0"].exists)
app.buttons["3"].tap()
XCTAssert(app.staticTexts["3"].exists)
app.buttons["BS"].tap()
XCTAssert(app.staticTexts["0"].exists)
app.buttons["5"].tap()
app.buttons["3"].tap()
app.buttons["8"].tap()
app.buttons["9"].tap()
XCTAssert(app.staticTexts["5389"].exists)
app.buttons["BS"].tap()
XCTAssert(app.staticTexts["538"].exists)
app.buttons["BS"].tap()
XCTAssert(app.staticTexts["53"].exists)
app.buttons["7"].tap()
app.buttons["6"].tap()
XCTAssert(app.staticTexts["5376"].exists)
app.buttons["BS"].tap()
app.buttons["BS"].tap()
app.buttons["BS"].tap()
XCTAssert(app.staticTexts["5"].exists)
app.buttons["+"].tap()
app.buttons["3"].tap()
app.buttons["="].tap()
XCTAssert(app.staticTexts["5 + 3 ="].exists)
XCTAssert(app.staticTexts["8"].exists)
}
}

0 comments on commit 62ca500

Please sign in to comment.