From b763062f8d80814a4d391128aeb12da49edc3cc9 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Tue, 2 Sep 2014 22:40:54 +0200 Subject: [PATCH] tests.c: work around spurious compiler error when comparing large ints --- tests.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests.c b/tests.c index 461a0c5..f1efce8 100644 --- a/tests.c +++ b/tests.c @@ -159,13 +159,15 @@ START_TEST(test_minmea_scan_f) /* doesn't fit, bail out */ ck_assert(minmea_scan("2147483648", "f", &f) == false); } else if (sizeof(int_least32_t) == 8) { + /* Casting to int64_t is ugly, but otherwise we get this on machines with 32-bit int_least32_t: + * error: comparison is always false due to limited range of data type [-Werror=type-limits] */ /* fits in 64 bits */ ck_assert(minmea_scan("9223372036854775807", "f", &f) == true); - ck_assert_int_eq(f.value, 9223372036854775807); + ck_assert_int_eq((int64_t) f.value, 9223372036854775807LL); ck_assert_int_eq(f.scale, 1); /* doesn't fit, truncate precision */ ck_assert(minmea_scan("9223372036854775.808", "f", &f) == true); - ck_assert_int_eq(f.value, 922337203685477580); + ck_assert_int_eq((int64_t) f.value, 922337203685477580LL); ck_assert_int_eq(f.scale, 100); /* doesn't fit, bail out */ ck_assert(minmea_scan("9223372036854775808", "f", &f) == false);