6 #include <gtest/gtest.h>
10 TEST(AnnotationMapTests, AnnotationKeyValueRetrieval)
15 Annotation stringAnnotation(
"string",
"value");
17 Annotation uintAnnotation(
"uint", (uint64_t)1);
21 EXPECT_EQ(stringAnnotation.
Label(),
"string");
22 EXPECT_EQ(stringAnnotation.
Value<std::string>(),
"value");
23 EXPECT_TRUE(stringAnnotation.
HasValueType<std::string>());
26 EXPECT_EQ(intAnnotation.
Label(),
"int");
27 EXPECT_EQ(intAnnotation.
Value<int64_t>(), -1);
31 EXPECT_EQ(uintAnnotation.
Label(),
"uint");
32 EXPECT_EQ(uintAnnotation.
Value<uint64_t>(), 1u);
35 EXPECT_EQ(doubleAnnotation.
Label(),
"double");
36 EXPECT_EQ(doubleAnnotation.
Value<
double>(), 1.0);
39 EXPECT_THROW((
void)doubleAnnotation.
Value<uint64_t>(), std::bad_variant_access);
42 TEST(AnnotationMapTests, AnnotationEquality)
47 Annotation stringAnnotation(
"string",
"value");
49 Annotation uintAnnotation(
"uint", (uint64_t)1);
53 EXPECT_NE(stringAnnotation, doubleAnnotation);
54 EXPECT_NE(stringAnnotation, intAnnotation);
55 EXPECT_NE(stringAnnotation, uintAnnotation);
57 Annotation otherStringAnnotation(
"string",
"value");
58 EXPECT_EQ(stringAnnotation, otherStringAnnotation);
60 Annotation otherIntAnnotation(
"uint", (int64_t)1);
61 EXPECT_NE(uintAnnotation, otherIntAnnotation);
69 constexpr
size_t key1 = 0;
70 constexpr
size_t key2 = 1;
81 EXPECT_EQ(annotations.size(), 1u);
82 EXPECT_EQ(annotations[0], annotation);
84 for (
auto & iteratedAnnotations : map.
Annotations())
86 for (
auto & iteratedAnnotation : iteratedAnnotations)
88 EXPECT_EQ(iteratedAnnotation, annotation);
TEST(AnnotationMapTests, AnnotationKeyValueRetrieval)
void AddAnnotation(const void *key, Annotation annotation)
const std::vector< Annotation > & GetAnnotations(const void *key) const noexcept
AnnotationRange Annotations() const
bool HasAnnotations(const void *key) const noexcept
bool HasValueType() const noexcept
const TValue & Value() const
const std::string_view & Label() const noexcept