Skip to content

Commit e4daa7b

Browse files
committed
Tested the exp2 constructor with point data
1 parent b9e5df6 commit e4daa7b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

sdk/test/metrics/aggregation_test.cc

+20-1
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,28 @@ TEST(aggregation, Base2ExponentialHistogramAggregation)
246246
EXPECT_EQ(histo_point.scale_, SCALE0);
247247
EXPECT_EQ(histo_point.max_buckets_, MAX_BUCKETS0);
248248
ASSERT_TRUE(histo_point.positive_buckets_.Empty());
249+
ASSERT_TRUE(histo_point.negative_buckets_.Empty());
250+
251+
// Create a new aggreagte based in point data
252+
{
253+
auto point_data = histo_point;
254+
Base2ExponentialHistogramAggregation scale0_aggr2(point_data);
255+
scale0_aggr2.Aggregate(0.0, {});
256+
257+
auto histo_point2 = nostd::get<Base2ExponentialHistogramPointData>(point);
258+
EXPECT_EQ(histo_point2.count_, 0);
259+
EXPECT_EQ(histo_point2.sum_, 0.0);
260+
EXPECT_EQ(histo_point2.zero_count_, 0);
261+
EXPECT_EQ(histo_point2.min_, (std::numeric_limits<double>::max)());
262+
EXPECT_EQ(histo_point2.max_, (std::numeric_limits<double>::min)());
263+
EXPECT_EQ(histo_point2.scale_, SCALE0);
264+
EXPECT_EQ(histo_point2.max_buckets_, MAX_BUCKETS0);
265+
ASSERT_TRUE(histo_point2.positive_buckets_.Empty());
266+
ASSERT_TRUE(histo_point2.negative_buckets_.Empty());
267+
}
249268

250269
// zero point
251-
scale0_aggr.Aggregate(0.0, {});
270+
scale0_aggr.Aggregate(static_cast<int64_t>(0.0), {});
252271
histo_point = nostd::get<Base2ExponentialHistogramPointData>(scale0_aggr.ToPoint());
253272
EXPECT_EQ(histo_point.count_, 1);
254273
EXPECT_EQ(histo_point.zero_count_, 1);

0 commit comments

Comments
 (0)