Skip to content

Commit

Permalink
Fix warnings generated by NetworkConfigTest (#2469)
Browse files Browse the repository at this point in the history
This test was generating a warning about unused vairables. Unless built
in debug mode, `aserts`are often optimized out we should be using the
`ASSERT` macros from `gtest` instead.

Signed-off-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
arjo129 committed Jul 19, 2024
1 parent cd9a855 commit 3be099b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/network/NetworkConfig_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/


#include <gtest/gtest.h>

#include <gz/common/Console.hh>
Expand All @@ -30,38 +31,33 @@ TEST(NetworkManager, ValueConstructor)
{
// Primary without number of secondaries is invalid
auto config = NetworkConfig::FromValues("PRIMARY", 0);
assert(config.role == NetworkRole::None);
assert(config.numSecondariesExpected == 0);
ASSERT_EQ(config.role, NetworkRole::None);
ASSERT_EQ(config.numSecondariesExpected, 0);
// Expect console warning as well
(void) config;
}

{
// Primary with number of secondaries is valid
auto config = NetworkConfig::FromValues("PRIMARY", 3);
assert(config.role == NetworkRole::SimulationPrimary);
assert(config.numSecondariesExpected == 3);
(void) config;
ASSERT_EQ(config.role, NetworkRole::SimulationPrimary);
ASSERT_EQ(config.numSecondariesExpected, 3);
}

{
// Secondary is always valid
auto config = NetworkConfig::FromValues("SECONDARY", 0);
assert(config.role == NetworkRole::SimulationSecondary);
(void) config;
ASSERT_EQ(config.role, NetworkRole::SimulationSecondary);
}

{
// Readonly is always valid
auto config = NetworkConfig::FromValues("READONLY");
assert(config.role == NetworkRole::ReadOnly);
(void) config;
ASSERT_EQ(config.role, NetworkRole::ReadOnly);
}

{
// Anything else is invalid
auto config = NetworkConfig::FromValues("READ_WRITE");
assert(config.role == NetworkRole::None);
(void) config;
ASSERT_EQ(config.role, NetworkRole::None);
}
}

0 comments on commit 3be099b

Please sign in to comment.