Create a gist now

Instantly share code, notes, and snippets.

import XCTest
import HealthKit
@testable import Stepology
class StepUnitFormatterTests: XCTestCase {
//> (0, "0 steps")
//> (1, "1 step")
//> (2, "2 steps")
//> (999, "999 steps")
//> (1000, "1,000 steps")
//> (1000000, "1,000,000 steps")
//> (3.3, "3 steps")
//> (-5, "0 steps")
func testFormat(_ numberOfSteps: Double, _ expected: String) {
XCTAssertEqual(StepUnitFormatter().format(numberOfSteps), expected)
}
}
// DO NOT EDIT BELOW THIS LINE
extension StepUnitFormatterTests {
func testFormat0() {
testFormat(0, "0 steps")
}
func testFormat1() {
testFormat(1, "1 step")
}
func testFormat2() {
testFormat(2, "2 steps")
}
func testFormat3() {
testFormat(999, "999 steps")
}
func testFormat4() {
testFormat(1000, "1,000 steps")
}
func testFormat5() {
testFormat(1000000, "1,000,000 steps")
}
func testFormat6() {
testFormat(3.3, "3 steps")
}
func testFormat7() {
testFormat(-5, "0 steps")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment