2017-04-27 18:21:27 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-04-14 17:27:32 +00:00
|
|
|
#include "testunitconversion.h"
|
2016-04-05 17:22:00 +00:00
|
|
|
#include "core/dive.h"
|
2022-08-30 16:13:13 +00:00
|
|
|
#include "core/subsurface-float.h"
|
2014-04-14 17:27:32 +00:00
|
|
|
|
|
|
|
void TestUnitConversion::testUnitConversions()
|
|
|
|
{
|
2022-08-30 15:55:43 +00:00
|
|
|
QCOMPARE(nearly_equal(grams_to_lbs(1000), 2.204586), true);
|
2014-04-14 17:27:32 +00:00
|
|
|
QCOMPARE(lbs_to_grams(1), 454);
|
2022-08-30 15:55:43 +00:00
|
|
|
QCOMPARE(nearly_equal(ml_to_cuft(1000), 0.0353147), true);
|
|
|
|
QCOMPARE(nearly_equal(cuft_to_l(1), 28.316847), true);
|
|
|
|
QCOMPARE(nearly_equal(mm_to_feet(1000), 3.280840), true);
|
2022-01-04 17:42:00 +00:00
|
|
|
QCOMPARE(feet_to_mm(1), 305L);
|
2022-08-30 15:55:43 +00:00
|
|
|
QCOMPARE(nearly_equal(mkelvin_to_C(647000), 373.85), true);
|
|
|
|
QCOMPARE(nearly_equal(mkelvin_to_F(647000), 704.93), true);
|
2022-01-04 17:42:00 +00:00
|
|
|
QCOMPARE(F_to_mkelvin(704.93), 647000UL);
|
|
|
|
QCOMPARE(C_to_mkelvin(373.85), 647000UL);
|
2022-08-30 15:55:43 +00:00
|
|
|
QCOMPARE(nearly_equal(psi_to_bar(14.6959488), 1.01325), true);
|
2022-01-04 17:42:00 +00:00
|
|
|
QCOMPARE(psi_to_mbar(14.6959488), 1013L);
|
2024-09-01 19:48:31 +00:00
|
|
|
QCOMPARE(nearly_equal(to_PSI(pressure_t{ .mbar = 1013}), 14.6923228594), true);
|
2022-08-30 15:55:43 +00:00
|
|
|
QCOMPARE(nearly_equal(bar_to_atm(1.013), 1.0), true);
|
|
|
|
QCOMPARE(nearly_equal(mbar_to_atm(1013), 1.0), true);
|
|
|
|
QCOMPARE(nearly_equal(mbar_to_PSI(1013), 14.6923228594), true);
|
2014-04-14 17:27:32 +00:00
|
|
|
}
|
|
|
|
|
2017-02-05 22:26:51 +00:00
|
|
|
QTEST_GUILESS_MAIN(TestUnitConversion)
|