From 50715d3d8783dd081a403c1e580b34177ffa57bf Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Sun, 29 Dec 2013 12:14:29 -0500 Subject: Test parsing boolean. --- tests/read_tests.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/read_tests.c b/tests/read_tests.c index 62ced1f9..71b0ab65 100644 --- a/tests/read_tests.c +++ b/tests/read_tests.c @@ -6,18 +6,29 @@ const uint64_t BIG_ENDIAN_TEST_DATA = __builtin_bswap64(0xEB00000000000000); START_TEST (test_parse_float) { - float result = bitfield_parse_float(BIG_ENDIAN_TEST_DATA, 2, 4, 1001.0, -30000.0); + float result = bitfield_parse_float(BIG_ENDIAN_TEST_DATA, 2, 4, 1001.0, + -30000.0); float correctResult = 0xA * 1001.0 - 30000.0; fail_unless(result == correctResult, "parse is incorrect: %f but should be %f", result, correctResult); } END_TEST +START_TEST (test_parse_bool) +{ + float result = bitfield_parse_bool(BIG_ENDIAN_TEST_DATA, 0, 1, 1.0, 0); + float correctResult = true; + fail_unless(result == correctResult, + "parse is incorrect: %d but should be %d", result, correctResult); +} +END_TEST + Suite* canreadSuite(void) { Suite* s = suite_create("read"); TCase *tc_core = tcase_create("core"); tcase_add_checked_fixture(tc_core, NULL, NULL); tcase_add_test(tc_core, test_parse_float); + tcase_add_test(tc_core, test_parse_bool); suite_add_tcase(s, tc_core); return s; -- cgit 1.2.3-korg