Skip to content

Commit

Permalink
Add (failing) unit tests which reproduce issue #6
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestytler committed Apr 16, 2020
1 parent 760e6df commit e656b22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/Test/StreamdeckContextTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,21 @@ TEST_F(StreamdeckContextComparisonTestFixture, dcs_id_float_compare_to_alphanume
EXPECT_EQ(esd_connection_manager.state_, 0);
}
TEST_F(StreamdeckContextComparisonTestFixture, dcs_id_float_compare_to_empty) {

// Send game state as empty -- should treat as string and not try comparison.
const std::string mock_dcs_message = "header*123=";
mock_dcs.DcsSend(mock_dcs_message);
dcs_interface.update_dcs_state();
context_with_greater_than.updateContextState(&dcs_interface, &esd_connection_manager);
EXPECT_EQ(esd_connection_manager.state_, 0);
}
TEST_F(StreamdeckContextComparisonTestFixture, dcs_id_float_compare_to_string_of_spaces) {
// Send game state value as string of spaces -- should treat as (non-numeric) string and not try comparison.
const std::string mock_dcs_message = "header*123= ";
mock_dcs.DcsSend(mock_dcs_message);
dcs_interface.update_dcs_state();
context_with_greater_than.updateContextState(&dcs_interface, &esd_connection_manager);
EXPECT_EQ(esd_connection_manager.state_, 0);
}
TEST_F(StreamdeckContextComparisonTestFixture, dcs_id_float_compare_to_dcs_id_float) {
// Send DCS ID as a float -- should not read update.
const std::string mock_dcs_message = "header*123.0=2.0";
Expand Down
10 changes: 10 additions & 0 deletions Sources/Test/StringUtilitiesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ TEST(StringUtilitiesTest, is_integer_with_trailing_spaces) {
EXPECT_EQ(std::stoi("0 "), 0);
}

TEST(StringUtilitiesTest, is_integer_with_only_spaces) {
EXPECT_FALSE(is_integer(" "));
EXPECT_FALSE(is_integer(" "));
}

TEST(StringUtilitiesTest, is_integer_with_alpha_chars) {
EXPECT_FALSE(is_integer("25a"));
EXPECT_FALSE(is_integer("b-25"));
Expand Down Expand Up @@ -67,6 +72,11 @@ TEST(StringUtilitiesTest, is_number_with_trailing_spaces) {
EXPECT_EQ(std::stod("0 "), 0);
}

TEST(StringUtilitiesTest, is_number_with_only_spaces) {
EXPECT_FALSE(is_number(" "));
EXPECT_FALSE(is_number(" "));
}

TEST(StringUtilitiesTest, is_number_with_alpha_chars) {
EXPECT_FALSE(is_number("25a"));
EXPECT_FALSE(is_number("b-25"));
Expand Down

0 comments on commit e656b22

Please sign in to comment.