Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4aad4a3b authored by Yi Kong's avatar Yi Kong
Browse files

Suppress -Winteger-overflow compiler warning

The tests intentionally tests overflow behaviour.

strings_test.cc:56:29: error: overflow in expression; result is -2147483648 with type 'int' [-Werror,-Winteger-overflow]
   56 |     ASSERT_EQ(ToHexString(1 + INT_MAX), "INT_MIN");
      |     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Test: presubmit
Change-Id: I4da2f67db9b01bc5b73153395b047487c7391a18
parent a013cded
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ static inline bool is_arch64() {
  return sizeof(long) == 8;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winteger-overflow"
TEST(StringsTest, to_hex_string_from_number) {
  ASSERT_EQ(ToHexString(0), "0x00000000");
  ASSERT_EQ(ToHexString(3), "0x00000003");
@@ -87,6 +89,7 @@ TEST(StringsTest, to_hex_string_from_number_unsigned_int) {
  ASSERT_EQ(ToHexString(1U + UINT_MAX), "0x00000000");  // Rolled over
  ASSERT_EQ(ToHexString(2U + UINT_MAX), "0x00000001");  // Rolled over
}
#pragma clang diagnostic pop

TEST(StringsTest, trim_string_test) {
  ASSERT_EQ(StringTrim("  aa bb"), "aa bb");