onekiloparsec / SwiftAA

The most comprehensive collection of accurate astronomical algorithms in (C++, Objective-C and) Swift.
http://www.onekiloparsec.dev/
MIT License
172 stars 31 forks source link

Improved tests #33

Closed alex-vasenin closed 7 years ago

alex-vasenin commented 7 years ago

Type-safe testing for all types conforming to NumericType

XCTAssertEqualWithAccuracy(equatorial.rightAscension.value, 134.688470/15.0, accuracy: 0.1/3600.0) // before
AssertEqual(equatorial.rightAscension, Degree(134.688470).inHours, accuracy: ArcMinute(0.1).inHours) // after

Also several convenience initializers

XCTAssertEqualWithAccuracy(trueObliquity.value, 23.0 + 26.0/60.0 + 36.850/3600.0, accuracy: 0.01/3600.0) // before
AssertEqual(trueObliquity, Degree(23, 26, 36.850), accuracy: ArcSecond(0.01).inDegrees) // after