Skip to content

Commit

Permalink
Add test for bugfix for addition
Browse files Browse the repository at this point in the history
  • Loading branch information
eskil committed Jan 22, 2025
1 parent 523ba80 commit 6ccf4a1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions DegreeCalculatorTests/DegreeCoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,22 @@ final class DegreeCoreTests: XCTestCase {

}

func testAddTwoValues() throws {
func testAddTwoValues_1() throws {
let lhs = Expr(Value(degrees: 1, minutes: 2.3))
let rhs = Expr(Value(degrees: 4, minutes: 5.6))
let expected = Value(degrees: 5, minutes: 7.9)
let expr = Expr(op: Operator.Add, left: lhs, right: rhs)
XCTAssertEqual(expr.value, expected)
}


func testAddTwoValues_minutes_overflow() throws {
let lhs = Expr(Value(degrees: 4, minutes: 30.0))
let rhs = Expr(Value(degrees: 4, minutes: 30.0))
let expected = Value(degrees: 9, minutes: 0.0)
let expr = Expr(op: Operator.Add, left: lhs, right: rhs)
XCTAssertEqual(expr.value, expected)
}

func testSubtractTwoValues() throws {
let lhs = Expr(Value(degrees: 4, minutes: 5.6))
let rhs = Expr(Value(degrees: 1, minutes: 2.3))
Expand Down

0 comments on commit 6ccf4a1

Please sign in to comment.