aboutsummaryrefslogtreecommitdiff
path: root/test_data_manager.c
blob: f21cc978e6db0930c3ff7397258e3ad4e37e95b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <float.h>

#include "data_manager.h"
#include "test_runner.h"
#include "unity.h"

RUNNER_DECLARE_TEST(test_data_manager_init_setting)
{
	struct data_ctx ctx;
	data_manager_init(&ctx);
	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(FLT_EPSILON, 1019.5, ctx.pressure);
	data_manager_tick(&ctx);
	TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1019.45, ctx.pressure);
}

RUNNER_DECLARE_TEST(test_data_manager_reinit)
{
	struct data_ctx ctx;
	/* init 1 */
	data_manager_init(&ctx);
	TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1019.5, ctx.pressure);

	/* check re-init */
	data_manager_init(&ctx);
	TEST_ASSERT_FLOAT_WITHIN(FLT_EPSILON, 1019.5, ctx.pressure);
}