SoundMetrics / aris-integration-sdk

SDK for building custom controllers for the ARIS sonar.
MIT License
5 stars 2 forks source link

Fix depth unit test for invalid sanity #47

Closed fvasquez closed 7 years ago

fvasquez commented 7 years ago

If there is no match for salinity input (35 = salt water, 15 = brackish) the depth calculation defaults to a salinity of 0. This is causing the following unit test to fail in svn right now.

// salinity of 50 PPT is invalid so treat as salt water
bool TestDepthWrongWater() {
    const float pressure = 37.0;
    const uint32_t salinity = 50;
    const float waterTemp = 10;
    const float saltWaterDensity10C = 1.027;
    const float expected = (pressure - kAtmosphere) * kMetersPerPSI / saltWaterDensity10C;
    const float actual = CalculateDepthM(pressure, salinity, waterTemp);
    const bool success = (actual == expected);

    if (!success) { std::cerr << "TestWrongWater failed!" << std::endl; }

    return success;
} 
fvasquez commented 7 years ago

This is not the bug I thought it was. It is also not so serious. It is just a unit test failing because of lost precision due to mixing floats and doubles. The original depth calculation code used floats. The current depth calculation in the ARIS Integration SDK uses doubles. The depth unit tests still use floats.

fvasquez commented 7 years ago

Fixed in aris-onboard software build by svn revision 8578.