polybar-dwm/tests/unit_tests/components/parser.cpp
patrick96 9e595d388e fix(gtest): INSTANTIATE_TEST_CASE_P with zero variadic arguments
Due to google/googletest#1419 [1], we had to add a comma after the last
argument of INSTANTIATE_TEST_CASE_P.

This was "fixed" in a backwards incompatible way in the googletest
project in 7c4164bf404d899b6d4c74beb1070da5647f55a2

[1]: https://github.com/google/googletest/issues/1419
2019-02-07 10:20:08 +01:00

38 lines
995 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_CASE_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);
}