polybar-dwm/tests/unit_tests/components/parser.cpp
patrick96 6d3b323f16 refactor(gtest): TestCase->TestSuite
googletest deprecated the TEST_CASE terminology in
3a460a26b7a91abf87af7f31b93d29f930e25c82
2019-02-07 10:20:08 +01:00

38 lines
996 B
C++

#include "common/test.hpp"
#include "events/signal_emitter.hpp"
#include "components/parser.hpp"
using namespace polybar;
class TestableParser : public parser {
using parser::parser;
public: using parser::parse_action_cmd;
};
class Parser : public ::testing::Test {
protected:
TestableParser m_parser{signal_emitter::make()};
};
/**
* The first element of the pair is the expected return text, the second element
* is the input to parse_action_cmd
*/
class ParseActionCmd :
public Parser,
public ::testing::WithParamInterface<pair<string, string>> {};
vector<pair<string, string>> parse_action_cmd_list = {
{"abc", ":abc:\\abc"},
{"abc\\:", ":abc\\::\\abc"},
{"\\:\\:\\:", ":\\:\\:\\::\\abc"},
};
INSTANTIATE_TEST_SUITE_P(Inst, ParseActionCmd,
::testing::ValuesIn(parse_action_cmd_list));
TEST_P(ParseActionCmd, correctness) {
auto input = GetParam().second;
auto result = m_parser.parse_action_cmd(std::move(input));
EXPECT_EQ(GetParam().first, result);
}