Skip to content

Commit

Permalink
Use typed test for OtlpRecordable empty array test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel committed May 31, 2023
1 parent 0ecceaa commit c6dfea7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions exporters/otlp/test/otlp_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,23 @@ TEST(OtlpRecordable, SetArrayAttribute)
}
}

// Test empty array.
TEST(OtlpRecordable, SetEmptyArrayAttribute)
template <typename T>
struct EmptyArrayAttributeTest : public testing::Test
{
using ElementType = T;
};

using ArrayElementTypes =
testing::Types<bool, double, nostd::string_view, uint8_t, int, int64_t, unsigned int, uint64_t>;
TYPED_TEST_SUITE(EmptyArrayAttributeTest, ArrayElementTypes);

// Test empty arrays.
TYPED_TEST(EmptyArrayAttributeTest, SetEmptyArrayAttribute)
{
using ArrayElementType = typename TestFixture::ElementType;
OtlpRecordable rec;

std::vector<int64_t> empty_array = {};
nostd::span<const int64_t> span(empty_array);
nostd::span<const ArrayElementType> span = {};
rec.SetAttribute("empty_arr_attr", span);

EXPECT_TRUE(rec.span().attributes(0).value().has_array_value());
Expand Down

0 comments on commit c6dfea7

Please sign in to comment.