8 #include <gtest/gtest.h>
13 public ::testing::WithParamInterface<fits::KeywordVariant> {};
18 TEST(TestParseEx, FailsIfOperatorIsInvalid) {
19 using namespace detail;
21 EXPECT_THROW(
ParseEx(
""), std::invalid_argument);
22 EXPECT_THROW(
ParseEx(
"? *"), std::invalid_argument);
23 EXPECT_THROW(
ParseEx(
"a *"), std::invalid_argument);
26 TEST(TestParseEx, FailsIfScopeIsInValid) {
27 using namespace detail;
29 EXPECT_THROW(
ParseEx(
"+"), std::invalid_argument);
30 EXPECT_THROW(
ParseEx(
"+a *"), std::invalid_argument);
31 EXPECT_THROW(
ParseEx(
"+ve *"), std::invalid_argument);
32 EXPECT_THROW(
ParseEx(
"+cc *"), std::invalid_argument);
35 TEST(TestParseEx, FailsIfWhitespaceIsMssing) {
36 using namespace detail;
38 EXPECT_THROW(
ParseEx(
"+pattern"), std::invalid_argument);
39 EXPECT_THROW(
ParseEx(
"+vpattern"), std::invalid_argument);
42 TEST(TestParseEx, FailsIfPatternIsMissing) {
43 using namespace detail;
45 EXPECT_THROW(
ParseEx(
"+ "), std::invalid_argument);
46 EXPECT_THROW(
ParseEx(
"+e"), std::invalid_argument);
49 TEST(TestParseEx, IncludeEsoKw) {
50 using namespace detail;
54 EXPECT_EQ(r.op, Operator::Include);
56 EXPECT_EQ(r.pattern,
"*");
59 TEST(TestParseEx, ExcludeEsoKw) {
60 using namespace detail;
66 EXPECT_EQ(r.pattern,
"*");
69 TEST(TestParseEx, IncludeValueKw) {
70 using namespace detail;
74 EXPECT_EQ(r.op, Operator::Include);
76 EXPECT_EQ(r.pattern,
"*");
79 TEST(TestParseEx, IncludeCommentaryKw) {
80 using namespace detail;
84 EXPECT_EQ(r.op, Operator::Include);
86 EXPECT_EQ(r.pattern,
"*");
89 TEST(TestParseEx, IncludeAnyKw) {
90 using namespace detail;
94 EXPECT_EQ(r.op, Operator::Include);
95 EXPECT_EQ(r.scope, Scope::Any);
96 EXPECT_EQ(r.pattern,
"pat");
99 TEST(TestKeywordEx, Constructors) {
100 EXPECT_NO_THROW(
KeywordEx()) <<
"Default constructor";
101 EXPECT_NO_THROW(
KeywordEx(
"+ *")) <<
"Single rule";
102 EXPECT_NO_THROW(
KeywordEx({
"+ *",
"- *"})) <<
"From initilizer list";
103 std::vector<std::string> strings = {
"+ *",
"- *"};
104 EXPECT_NO_THROW(
KeywordEx(std::begin(strings), std::end(strings))) <<
"From iterators";
209 std::string long_name(70,
'A');
211 EXPECT_THROW(
KeywordTransform(kw, std::regex(
"^CAT"), long_name.c_str()), std::runtime_error);
223 std::string long_name(70,
'A');
225 EXPECT_THROW(
KeywordTransform(kw, std::regex(
"^CAT"), long_name.c_str()), std::runtime_error);
226 EXPECT_THROW(
KeywordTransform(kw, std::regex(
"^CAT"),
"%!@"), std::runtime_error);
232 LiteralKeyword kw1(
"HIERARCH ESO A1 = B");