9 #include <gtest/gtest.h>
10 #include <gmock/gmock.h>
11 #include <nlohmann/json.hpp>
21 template <
typename Type>
25 using Types = ::testing::Types<ValueKeyword, EsoKeyword>;
29 using Keyword = TypeParam;
31 Keyword orig(
"name", 1.0,
"comment");
32 EXPECT_EQ(orig.name,
"name");
33 EXPECT_EQ(orig.value,
typename Keyword::ValueType(1.0));
34 EXPECT_EQ(orig.comment,
"comment");
38 EXPECT_EQ(orig, copy_assign);
40 Keyword move_assign(
"TOBE",
"replaced");
41 move_assign = std::move(copy_assign);
42 EXPECT_EQ(orig, move_assign);
44 Keyword copy_construct(orig);
45 EXPECT_EQ(orig, copy_construct);
47 Keyword move_construct(std::move(copy_construct));
48 EXPECT_EQ(orig, move_construct);
52 using Keyword = TypeParam;
54 Keyword orig(
"name", 1.0, std::nullopt);
55 EXPECT_EQ(orig.comment, std::nullopt);
63 using Keyword = TypeParam;
65 Keyword kw(
"name",
"str",
"comment");
66 ASSERT_TRUE(std::holds_alternative<std::string>(kw.value));
67 EXPECT_EQ(
"str", std::get<std::string>(kw.value));
71 using Keyword = TypeParam;
73 Keyword lhs(
"name", 1.0,
"comment");
74 Keyword rhs(
"name", 1.0,
"comment");
76 EXPECT_TRUE(lhs == rhs);
77 EXPECT_FALSE(lhs != rhs);
79 rhs.comment = std::nullopt;
84 using Keyword = TypeParam;
86 Keyword lhs(
"A", 1.0,
"comment");
87 Keyword rhs(
"B", 1.0,
"comment");
90 EXPECT_FALSE(rhs < lhs);
91 EXPECT_FALSE(lhs < lhs);
95 using Keyword = TypeParam;
98 using namespace ::testing;
102 Keyword kw(
"name", std::string(
"value"),
"comment");
103 std::stringstream ss;
105 EXPECT_EQ(ss.str(),
"name='name', value=(str)'value', comment='comment'");
108 Keyword kw(
"name",
true, std::nullopt);
109 std::stringstream ss;
111 EXPECT_EQ(ss.str(),
"name='name', value=(bool)true, comment=n/a");
114 Keyword kw(
"name", 1234ul, std::nullopt);
115 std::stringstream ss;
117 EXPECT_THAT(ss.str(),
"name='name', value=(uint64_t)1234, comment=n/a");
120 Keyword kw(
"name", 1234l, std::nullopt);
121 std::stringstream ss;
123 EXPECT_THAT(ss.str(),
"name='name', value=(int64_t)1234, comment=n/a");
126 Keyword kw(
"name", 1.234, std::nullopt);
127 std::stringstream ss;
129 EXPECT_THAT(ss.str(),
"name='name', value=(double)1.234, comment=n/a");
133 TEST(TestKeywordCombinations, Ordering) {
137 EXPECT_LT(value_kw, eso_kw);
140 EXPECT_FALSE(eso_kw < value_kw);
158 using namespace ::testing;
181 EXPECT_THAT(to, ContainerEq(result));