Skip to content

Commit

Permalink
Fix a compile warning with g++ 13.2.0. (#207)
Browse files Browse the repository at this point in the history
* Fix a compile warning with g++ 13.2.0.

When building the tests with g++ 13.2.0, it complains
that the EXPECT_LONG_DOUBLE_EQ macro has no effect.
That ends up being true; because it is just a x == y,
with no EXPECT statement around it, it actually does
nothing.

Here, I just remove this macro because it is unnecessary;
we can just do EXPECT_TRUE(x == y) and get the same effect
with less code.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>

* Revert "Fix a compile warning with g++ 13.2.0."

This reverts commit 28b32de.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refactor EXPECT_LONG_DOUBLE_EQ.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Make expectations be checked.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
clalancette and MiguelCompany authored Mar 29, 2024
1 parent f44cbf6 commit 75b2be7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions test/cdr/ResizeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include <gtest/gtest.h>

#define EXPECT_LONG_DOUBLE_EQ(val1, val2) (val1 == val2)

using namespace eprosima::fastcdr;
using namespace ::exception;

Expand Down Expand Up @@ -180,6 +178,13 @@ static void EXPECT_ARRAY_DOUBLE_EQ(
}
}

static void EXPECT_LONG_DOUBLE_EQ(
const long double val1,
const long double val2)
{
EXPECT_TRUE(val1 == val2);
}

static void EXPECT_ARRAY_LONG_DOUBLE_EQ(
long double* array1,
const long double* array2,
Expand Down
9 changes: 7 additions & 2 deletions test/cdr/SimpleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#include <gtest/gtest.h>

#define EXPECT_LONG_DOUBLE_EQ(val1, val2) (val1 == val2)

using namespace eprosima::fastcdr;
using namespace ::exception;

Expand Down Expand Up @@ -194,6 +192,13 @@ static void EXPECT_ARRAY_DOUBLE_EQ(
}
}

static void EXPECT_LONG_DOUBLE_EQ(
const long double val1,
const long double val2)
{
EXPECT_TRUE(val1 == val2);
}

static void EXPECT_ARRAY_LONG_DOUBLE_EQ(
long double* array1,
const long double* array2,
Expand Down

0 comments on commit 75b2be7

Please sign in to comment.