소스 검색

tests.c: work around spurious compiler error when comparing large ints

Kosma Moczek 11 년 전
부모
커밋
b763062f8d
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      tests.c

+ 4 - 2
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);