diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/jaegertracing/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc')
-rw-r--r-- | src/jaegertracing/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/jaegertracing/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc b/src/jaegertracing/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc new file mode 100644 index 000000000..b7ef17244 --- /dev/null +++ b/src/jaegertracing/opentelemetry-cpp/sdk/test/common/attribute_utils_test.cc @@ -0,0 +1,53 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/sdk/common/attribute_utils.h" + +#include <gtest/gtest.h> + +TEST(AttributeMapTest, DefaultConstruction) +{ + + opentelemetry::sdk::common::AttributeMap attribute_map; + EXPECT_EQ(attribute_map.GetAttributes().size(), 0); +} + +TEST(OrderedAttributeMapTest, DefaultConstruction) +{ + opentelemetry::sdk::common::OrderedAttributeMap attribute_map; + EXPECT_EQ(attribute_map.GetAttributes().size(), 0); +} + +TEST(AttributeMapTest, AttributesConstruction) +{ + const int kNumAttributes = 3; + std::string keys[kNumAttributes] = {"attr1", "attr2", "attr3"}; + int values[kNumAttributes] = {15, 24, 37}; + std::map<std::string, int> attributes = { + {keys[0], values[0]}, {keys[1], values[1]}, {keys[2], values[2]}}; + + opentelemetry::common::KeyValueIterableView<std::map<std::string, int>> iterable(attributes); + opentelemetry::sdk::common::AttributeMap attribute_map(iterable); + + for (int i = 0; i < kNumAttributes; i++) + { + EXPECT_EQ(opentelemetry::nostd::get<int>(attribute_map.GetAttributes().at(keys[i])), values[i]); + } +} + +TEST(OrderedAttributeMapTest, AttributesConstruction) +{ + const int kNumAttributes = 3; + std::string keys[kNumAttributes] = {"attr1", "attr2", "attr3"}; + int values[kNumAttributes] = {15, 24, 37}; + std::map<std::string, int> attributes = { + {keys[0], values[0]}, {keys[1], values[1]}, {keys[2], values[2]}}; + + opentelemetry::common::KeyValueIterableView<std::map<std::string, int>> iterable(attributes); + opentelemetry::sdk::common::OrderedAttributeMap attribute_map(iterable); + + for (int i = 0; i < kNumAttributes; i++) + { + EXPECT_EQ(opentelemetry::nostd::get<int>(attribute_map.GetAttributes().at(keys[i])), values[i]); + } +} |