From 0b044db606c58cd3284377cad92bb4dedaff5be1 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Mon, 3 Mar 2014 15:22:59 +0100 Subject: [PATCH] tests: specify maximum minmea_scan coordinate range --- tests.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests.c b/tests.c index 1229698..4fdd324 100644 --- a/tests.c +++ b/tests.c @@ -117,6 +117,20 @@ START_TEST(test_minmea_scan_f) ck_assert(minmea_scan("-1.23,V", "f", &value, &scale) == true); ck_assert_int_eq(value, -123); ck_assert_int_eq(scale, 100); + + /* some GPS units have absurdly big precision. handle whatever int handles. */ + ck_assert(minmea_scan("5106.94091", "f", &value, &scale) == true); + ck_assert_int_eq(value, 510694091); + ck_assert_int_eq(scale, 100000); + + /* for now we support +-180 degrees with 5 decimal digits; anything + * more will overflow. */ + ck_assert(minmea_scan("18000.00000", "f", &value, &scale) == true); + ck_assert_int_eq(value, 1800000000); + ck_assert_int_eq(scale, 100000); + ck_assert(minmea_scan("-18000.00000", "f", &value, &scale) == true); + ck_assert_int_eq(value, -1800000000); + ck_assert_int_eq(scale, 100000); } END_TEST