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;
59 TEST(TestParseEx, ExcludeEsoKw) {
60 using namespace detail;
69 TEST(TestParseEx, IncludeValueKw) {
70 using namespace detail;
79 TEST(TestParseEx, IncludeCommentaryKw) {
80 using namespace detail;
89 TEST(TestParseEx, IncludeAnyKw) {
90 using namespace detail;
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");
Create keyword expression that memoize the provided string pattern.
Represents the literal 80-character FITS keyword record.
std::optional< std::reference_wrapper< elt::configng::CiiConfigInstanceNode const > > GetParam(std::string const &query, elt::configng::CiiConfigInstanceNode const &node)
Performs lookup of parameters in the form root/node/leaf relative to the provided node.
Rule ParseEx(std::string_view ex)
Parse expression of the form documented in KeywordEx.
fits::KeywordVariant KeywordTransform(fits::KeywordVariant const &keyword, std::regex const &re, char const *fmt)
Transforms keyword name using regex.
bool KeywordMatch(fits::KeywordVariant const &keyword, KeywordEx const &ex)
INSTANTIATE_TEST_SUITE_P(Test, TestKeywordMatchP, testing::Values(fits::EsoKeyword("VALUE", "value"), fits::ValueKeyword("VALUE", 0.0), fits::LiteralKeyword("VALUE = 'tgt' / comment"), fits::LiteralKeyword("VALUE Comment")))
TEST_P(TestKeywordMatchP, EmptyPatternDoesntMatch)
TEST_F(TestDaqController, ScheduledTransitionsToTransferring)
TEST(TestParseEx, FailsIfOperatorIsInvalid)
std::variant< ValueKeyword, EsoKeyword, LiteralKeyword > KeywordVariant
The different variants of keywords that are supported.
BasicKeyword< ValueKeywordTraits > ValueKeyword
Standard FITS value keyword.
BasicKeyword< EsoKeywordTraits > EsoKeyword
ESO hiearchical keyword.
A type safe version of LiteralKeyword that consist of the three basic components of a FITS keyword ke...
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")