From c6dfea75fb3b7cef6f6bb1c4572b3c0dc0fb2c91 Mon Sep 17 00:00:00 2001 From: Matthijs Brobbel Date: Wed, 31 May 2023 15:42:19 +0200 Subject: [PATCH] Use typed test for `OtlpRecordable` empty array test --- exporters/otlp/test/otlp_recordable_test.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/exporters/otlp/test/otlp_recordable_test.cc b/exporters/otlp/test/otlp_recordable_test.cc index e8af9f13b4..f1b1c73741 100644 --- a/exporters/otlp/test/otlp_recordable_test.cc +++ b/exporters/otlp/test/otlp_recordable_test.cc @@ -284,13 +284,23 @@ TEST(OtlpRecordable, SetArrayAttribute) } } -// Test empty array. -TEST(OtlpRecordable, SetEmptyArrayAttribute) +template +struct EmptyArrayAttributeTest : public testing::Test +{ + using ElementType = T; +}; + +using ArrayElementTypes = + testing::Types; +TYPED_TEST_SUITE(EmptyArrayAttributeTest, ArrayElementTypes); + +// Test empty arrays. +TYPED_TEST(EmptyArrayAttributeTest, SetEmptyArrayAttribute) { + using ArrayElementType = typename TestFixture::ElementType; OtlpRecordable rec; - std::vector empty_array = {}; - nostd::span span(empty_array); + nostd::span span = {}; rec.SetAttribute("empty_arr_attr", span); EXPECT_TRUE(rec.span().attributes(0).value().has_array_value());