aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/deco_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/deco_test.c')
-rw-r--r--test/deco_test.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/deco_test.c b/test/deco_test.c
new file mode 100644
index 0000000..0b492f2
--- /dev/null
+++ b/test/deco_test.c
@@ -0,0 +1,57 @@
+#include "minunit.h"
+
+#include "../deco.h"
+
+MU_TEST(test_bar_to_msw)
+{
+ mu_assert_double_eq(10, bar_to_msw(1));
+}
+
+MU_TEST(test_msw_to_bar)
+{
+ mu_assert_double_eq(1, msw_to_bar(10));
+}
+
+MU_TEST(test_abs_gauge)
+{
+ mu_assert_double_eq(1, abs_depth(gauge_depth(1)));
+}
+
+MU_TEST(test_gas)
+{
+ gas_t foo = gas_new(21, 35, MOD_AUTO);
+ gas_t bar = gas_new(21, 0, MOD_AUTO);
+ gas_t baz = gas_new(21, 35, MOD_AUTO);
+ gas_t qux = gas_new(21, 35, 99);
+
+ mu_assert_int_eq(21, gas_o2(&foo));
+ mu_assert_int_eq(35, gas_he(&foo));
+ mu_assert_int_eq(44, gas_n2(&foo));
+
+ mu_check(gas_equal(&foo, &foo));
+ mu_check(!gas_equal(&foo, &bar));
+ mu_check(gas_equal(&foo, &baz));
+ mu_check(!gas_equal(&foo, &qux));
+
+ mu_assert_double_eq(abs_depth(msw_to_bar(51.6)), gas_mod(&foo));
+ mu_assert_double_eq(abs_depth(msw_to_bar(30)), gas_mod(&bar));
+ mu_assert_double_eq(99, gas_mod(&qux));
+}
+
+void testsuite_deco_setup(void)
+{
+}
+
+void testsuite_deco_teardown(void)
+{
+}
+
+MU_TEST_SUITE(testsuite_deco)
+{
+ MU_SUITE_CONFIGURE(&testsuite_deco_setup, &testsuite_deco_teardown);
+
+ MU_RUN_TEST(test_bar_to_msw);
+ MU_RUN_TEST(test_msw_to_bar);
+ MU_RUN_TEST(test_abs_gauge);
+ MU_RUN_TEST(test_gas);
+}