From 019edd065fd1eefd5f705c42bce23255bb5e20ac Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 14 Apr 2014 14:27:32 -0300 Subject: [PATCH] First test case implemented. This is just a stub test case to show how a test case should be implemented. every 'private slot' on the test classes will be automatically executed when you run 'make test' on the terminal, and a report will be generated with a failure / success. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 3 +++ tests/testunitconversion.cpp | 14 ++++++++++++++ tests/testunitconversion.h | 12 ++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 tests/testunitconversion.cpp create mode 100644 tests/testunitconversion.h 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 + +class TestUnitConversion : public QObject{ + Q_OBJECT +private slots: + void testUnitConversions(); +}; + +#endif \ No newline at end of file