summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--tests/testunitconversion.cpp14
-rw-r--r--tests/testunitconversion.h12
3 files changed, 29 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35736e674..35fc9ee18 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -114,3 +114,6 @@ ADD_DEPENDENCIES(subsurface_interface subsurface_generated_ui)
ADD_DEPENDENCIES(subsurface_generated_ui version)
ENABLE_TESTING()
+ADD_EXECUTABLE( TestUnitConversion tests/testunitconversion.cpp )
+TARGET_LINK_LIBRARIES( TestUnitConversion ${QT_LIBRARIES})
+ADD_TEST( NAME TestUnitConversion COMMAND TestUnitConversion) \ No newline at end of file
diff --git a/tests/testunitconversion.cpp b/tests/testunitconversion.cpp
new file mode 100644
index 000000000..54b7e1b7b
--- /dev/null
+++ b/tests/testunitconversion.cpp
@@ -0,0 +1,14 @@
+#include "testunitconversion.h"
+#include "dive.h"
+
+void TestUnitConversion::testUnitConversions()
+{
+ QCOMPARE(IS_FP_SAME(grams_to_lbs(1000), 2.20459), true);
+ QCOMPARE(lbs_to_grams(1), 454);
+ QCOMPARE(IS_FP_SAME(ml_to_cuft(1000), 0.0353147), true);
+ QCOMPARE(IS_FP_SAME(cuft_to_l(1), 28.3168), true);
+ QCOMPARE(IS_FP_SAME(mm_to_feet(1000), 3.28084), true);
+ QCOMPARE(feet_to_mm(1), (long unsigned int) 305);
+}
+
+QTEST_MAIN(TestUnitConversion) \ No newline at end of file
diff --git a/tests/testunitconversion.h b/tests/testunitconversion.h
new file mode 100644
index 000000000..b8f05858a
--- /dev/null
+++ b/tests/testunitconversion.h
@@ -0,0 +1,12 @@
+#ifndef TESTUNITCONVERSION_H
+#define TESTUNITCONVERSION_H
+
+#include <QtTest>
+
+class TestUnitConversion : public QObject{
+ Q_OBJECT
+private slots:
+ void testUnitConversions();
+};
+
+#endif \ No newline at end of file