Skip to content

Commit

Permalink
iox-#454 Add additional check for cmd line option validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mossmaurice committed Mar 8, 2021
1 parent 608834c commit d9cfc21
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions iceoryx_posh/test/moduletests/test_roudi_cmd_line_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class CmdLineParser_test : public Test

ASSERT_FALSE(result.has_error());
EXPECT_EQ(result.value().logLevel, level);
EXPECT_TRUE(result.value().run);

// Reset optind to be able to parse again
optind = 0;
Expand All @@ -76,6 +77,7 @@ class CmdLineParser_test : public Test

ASSERT_FALSE(result.has_error());
EXPECT_EQ(result.value().monitoringMode, mode);
EXPECT_TRUE(result.value().run);

// Reset optind to be able to parse again
optind = 0;
Expand All @@ -88,6 +90,7 @@ class CmdLineParser_test : public Test

ASSERT_FALSE(result.has_error());
EXPECT_EQ(result.value().compatibilityCheckLevel, level);
EXPECT_TRUE(result.value().run);

// Reset optind to be able to parse again
optind = 0;
Expand Down Expand Up @@ -293,6 +296,7 @@ TEST_F(CmdLineParser_test, KillDelayLongOptionLeadsToCorrectDelay)

ASSERT_FALSE(result.has_error());
EXPECT_EQ(result.value().processKillDelay, Duration::fromSeconds(73));
EXPECT_TRUE(result.value().run);
}

TEST_F(CmdLineParser_test, KillDelayShortOptionLeadsToCorrectDelay)
Expand All @@ -311,6 +315,7 @@ TEST_F(CmdLineParser_test, KillDelayShortOptionLeadsToCorrectDelay)

ASSERT_FALSE(result.has_error());
EXPECT_EQ(result.value().processKillDelay, Duration::fromSeconds(42));
EXPECT_TRUE(result.value().run);
}

TEST_F(CmdLineParser_test, KillDelayOptionOutOfBoundsLeadsToProgrammNotRunning)
Expand Down Expand Up @@ -394,6 +399,7 @@ TEST_F(CmdLineParser_test, UniqueIdLongOptionLeadsToCorrectUniqueId)
ASSERT_FALSE(result.has_error());
ASSERT_TRUE(result.value().uniqueRouDiId.has_value());
EXPECT_EQ(result.value().uniqueRouDiId.value(), 4242);
EXPECT_TRUE(result.value().run);
}

TEST_F(CmdLineParser_test, UniqueIdShortOptionLeadsToCorrectUniqueId)
Expand All @@ -413,6 +419,7 @@ TEST_F(CmdLineParser_test, UniqueIdShortOptionLeadsToCorrectUniqueId)
ASSERT_FALSE(result.has_error());
ASSERT_TRUE(result.value().uniqueRouDiId.has_value());
EXPECT_EQ(result.value().uniqueRouDiId.value(), 4242);
EXPECT_TRUE(result.value().run);
}

TEST_F(CmdLineParser_test, OutOfBoundsUniqueIdOptionLeadsToProgrammNotRunning)
Expand Down Expand Up @@ -455,6 +462,7 @@ TEST_F(CmdLineParser_test, CmdLineParsingModeEqualToOneHandlesOnlyTheFirstOption
ASSERT_TRUE(result.value().uniqueRouDiId.has_value());
EXPECT_EQ(result.value().uniqueRouDiId.value(), 4242);
EXPECT_EQ(result.value().processKillDelay, Duration::fromSeconds(45)); // default value for kill delay
EXPECT_TRUE(result.value().run);

optind = 0;

Expand All @@ -464,6 +472,7 @@ TEST_F(CmdLineParser_test, CmdLineParsingModeEqualToOneHandlesOnlyTheFirstOption
ASSERT_TRUE(res.value().uniqueRouDiId.has_value());
EXPECT_EQ(res.value().uniqueRouDiId.value(), 4242);
EXPECT_EQ(res.value().processKillDelay, Duration::fromSeconds(42));
EXPECT_TRUE(result.value().run);
}

} // namespace test
Expand Down

0 comments on commit d9cfc21

Please sign in to comment.