From d84f7a93151aad059d6780362dea1776ff8ea358 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sun, 14 Feb 2021 00:06:35 +1300 Subject: Prefer FLT_EPSILON to hardcoded literal --- test_data_manager.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test_data_manager.c b/test_data_manager.c index 56a9f9e..f21cc97 100644 --- a/test_data_manager.c +++ b/test_data_manager.c @@ -1,3 +1,5 @@ +#include + #include "data_manager.h" #include "test_runner.h" #include "unity.h" @@ -6,16 +8,16 @@ RUNNER_DECLARE_TEST(test_data_manager_init_setting) { struct data_ctx ctx; data_manager_init(&ctx); - TEST_ASSERT_FLOAT_WITHIN(0.001, 1013.25, ctx.setting); + TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1013.25, ctx.setting); } RUNNER_DECLARE_TEST(test_data_manager_first_readings) { struct data_ctx ctx; data_manager_init(&ctx); - TEST_ASSERT_FLOAT_WITHIN(0.001, 1019.5, ctx.pressure); + TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1019.5, ctx.pressure); data_manager_tick(&ctx); - TEST_ASSERT_FLOAT_WITHIN(0.001, 1019.45, ctx.pressure); + TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1019.45, ctx.pressure); } RUNNER_DECLARE_TEST(test_data_manager_reinit) @@ -23,9 +25,9 @@ RUNNER_DECLARE_TEST(test_data_manager_reinit) struct data_ctx ctx; /* init 1 */ data_manager_init(&ctx); - TEST_ASSERT_FLOAT_WITHIN(0.001, 1019.5, ctx.pressure); + TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1019.5, ctx.pressure); /* check re-init */ data_manager_init(&ctx); - TEST_ASSERT_FLOAT_WITHIN(0.001, 1019.5, ctx.pressure); + TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1019.5, ctx.pressure); } -- cgit v1.1