ole / Ampere

Adding multiplication and division to the units of measurement types in Foundation.
https://oleb.net/blog/2016/07/unitproduct/
MIT License
171 stars 17 forks source link

UnitVolume tests fail on Linux #25

Open ole opened 4 years ago

ole commented 4 years ago

This test fails on Linux:

    func testWithNonBaseUnits() {
        let factor1 = Measurement(value: 100, unit: UnitArea.squareCentimeters)
        let factor2 = Measurement(value: 10, unit: UnitLength.millimeters)
        let actual: Measurement<UnitVolume> = factor1 * factor2
        let expected = Measurement(value: 100, unit: UnitVolume.cubicCentimeters)
        AmpereTest.assertEqual(actual, expected)
    }

XCTAssertEqual failed: ("0.0001 m³") is not equal to ("0.001 m³") - "0.0001 m³" is not equal to "100.0 cm³"

This is due to a bug in swift-corelibs-foundation. Some of the conversion coefficients for UnitVolume are wrong.

ole commented 4 years ago

Reported to bugs.swift.org: SR-11766.

PR: https://github.com/apple/swift-corelibs-foundation/pull/2561