10#include <gmock/gmock.h>
11#include <gtest/gtest.h>
13using namespace ::testing;
14using core::dit::did::DataType;
15using core::dit::did::Record;
17#define EXPECT_THROW_THAT(stmt, etype, matcher) \
19 try { stmt; } catch (const etype& ex) { \
20 EXPECT_THAT(std::string(ex.what()), matcher); \
32 core::dit::did::DataTypeToStr(DataType::STRING),
38 core::dit::did::DataTypeToStr(DataType::DOUBLE),
44 core::dit::did::DataTypeToStr(DataType::DOUBLE),
50 core::dit::did::DataTypeToStr(DataType::BOOL),
56 core::dit::did::DataTypeToStr(DataType::INTEGER),
77 HasSubstr(
"parsing floating point value"));
85 HasSubstr(
"invalid character"));
88 HasSubstr(
"invalid character"));
94 HasSubstr(
"parsing floating point value"));
97 HasSubstr(
"parsing floating point value"));
100 HasSubstr(
"parsing floating point value"));
103 HasSubstr(
"parsing floating point value"));
106 HasSubstr(
"parsing floating point value"));
109 HasSubstr(
"parsing floating point value"));
115 HasSubstr(
"parsing base-10 integer value"))
116 <<
"floats should not be demoted to integers";
119 HasSubstr(
"parsing base-10 integer value"));
122 HasSubstr(
"parsing base-10 integer value"));
125 HasSubstr(
"parsing base-10 integer value"));
128 HasSubstr(
"parsing base-10 integer value"));
131 HasSubstr(
"parsing base-10 integer value"));
134 HasSubstr(
"parsing base-10 integer value"));
137 HasSubstr(
"parsing base-10 integer value"));
143 HasSubstr(
"is not `T` or `F`"));
146 HasSubstr(
"is not `T` or `F`"));
149 HasSubstr(
"is not `T` or `F`"));
152 HasSubstr(
"is not `T` or `F`"));
155 HasSubstr(
"is not `T` or `F`"));
162 ASSERT_EQ(befor.GetType(), KeywordType::Value);
168 ASSERT_EQ(befor.GetType(), KeywordType::Value);
174 ASSERT_EQ(befor.GetType(), KeywordType::Value);
178 auto befor =
LiteralKeyword(
"HIERARCH ESO NAME = 'string ' /comment");
179 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 'string ' / comment");
180 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
184 auto befor =
LiteralKeyword(
"HIERARCH ESO NAME = 'str''ng' /comment");
185 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 'str''ng' / comment");
186 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
191 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 'str''ng' / COMMENT");
192 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
193 EXPECT_EQ(
Format(befor, m_str_record), after) <<
"Expected comment from record to be added";
201 ASSERT_EQ(befor.GetType(), KeywordType::Value);
207 ASSERT_EQ(befor.GetType(), KeywordType::Value);
213 ASSERT_EQ(befor.GetType(), KeywordType::Value);
215 <<
"Integers are allowed to be promoted to float";
219 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 12.000 / comment");
220 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
225 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 12.100 / COMMENT");
226 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
231 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 12.000 / COMMENT");
232 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
234 <<
"Integers are allowed to be promoted to float";
242 ASSERT_EQ(befor.GetType(), KeywordType::Value);
248 ASSERT_EQ(befor.GetType(), KeywordType::Value);
254 ASSERT_EQ(befor.GetType(), KeywordType::Value);
256 <<
"Integers are allowed to be promoted to float";
259 auto befor =
LiteralKeyword(
"HIERARCH ESO NAME = 12.3456 /comment");
260 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 12.3456 / comment");
261 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
266 auto after =
LiteralKeyword(
"HIERARCH ESO NAME = 12.1 / COMMENT");
267 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
273 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
275 <<
"Integers are allowed to be promoted to float";
283 ASSERT_EQ(befor.GetType(), KeywordType::Value);
289 ASSERT_EQ(befor.GetType(), KeywordType::Value);
295 ASSERT_EQ(befor.GetType(), KeywordType::Value);
301 ASSERT_EQ(befor.GetType(), KeywordType::Eso);
308 auto befor =
ValueKeyword(
"NAME",
"str'in'g",
"comment");
337 auto record = Record(
"NAME",
338 core::dit::did::DataTypeToStr(DataType::DOUBLE),
351 auto befor =
ValueKeyword(
"NAME",
static_cast<std::uint64_t
>(12u),
"");
364 auto record = Record(
"NAME", core::dit::did::DataTypeToStr(DataType::INTEGER),
"",
"",
"");
374 HasSubstr(
"dictionary specifies value to be DidBoolKey"));
380 HasSubstr(
"dictionary specifies value to be DidBoolKey"));
386 HasSubstr(
"dictionary specifies value to be DidBoolKey"));
392 HasSubstr(
"dictionary specifies value to be DidIntKey"));
397 Format(
ValueKeyword(
"NAME",
static_cast<std::uint64_t
>(1),
"comment"), m_bool_record),
399 HasSubstr(
"dictionary specifies value to be DidBoolKey but value is uint64"));
403 HasSubstr(
"dictionary specifies value to be DidBoolKey but value is int64"));
409 HasSubstr(
"dictionary specifies value to be DidIntKey but value is bool"));
Indicates keyword is invalid for some reason.
Represents the literal 80-character FITS keyword record.
LiteralKeyword Format(KeywordVariant const &keyword)
BasicKeyword< ValueKeywordTraits > ValueKeyword
Standard FITS value keyword.
BasicKeyword< EsoKeywordTraits > EsoKeyword
ESO hiearchical keyword.
TEST_F(TestDpmClient, StartMonitoringSendsRequestAndReceivesReply)
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
ASSERT_EQ(meta.keyword_rules.size(), 1u)