Source release 17.1.0

This commit is contained in:
John "Juce" Bruce
2022-07-07 17:14:31 -07:00
parent 8c17574083
commit 694cf6fb25
2233 changed files with 272026 additions and 223371 deletions

View File

@@ -1,19 +1,17 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
// Unit tests for ValueMetric.
#include "value_metric.h"
#include <memory>
#include <string>
#include "value_metric.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "wv_metrics.pb.h"
#include <gtest/gtest.h>
namespace wvcdm {
namespace metrics {
TEST(ValueMetricTest, StringValue) {
ValueMetric<std::string> metric;
metric.Record("foo");
@@ -60,5 +58,31 @@ TEST(ValueMetricTest, SetError) {
ASSERT_FALSE(metric_proto->has_int_value());
}
TEST(ValueMetricTest, ValueOverflow) {
constexpr int64_t kMaxValue = std::numeric_limits<int64_t>::max();
constexpr uint64_t kMaxU64 = std::numeric_limits<uint64_t>::max();
constexpr size_t kMaxSizeT = std::numeric_limits<size_t>::max();
ValueMetric<uint64_t> metric_u64;
metric_u64.Record(kMaxU64);
// Runtime value should not be capped.
ASSERT_EQ(kMaxU64, metric_u64.GetValue());
std::unique_ptr<drm_metrics::ValueMetric> metric_proto(metric_u64.ToProto());
// Proto value should be capped.
ASSERT_EQ(kMaxValue, metric_proto->int_value());
ASSERT_FALSE(metric_proto->has_error_code());
ValueMetric<uint64_t> metric_z;
metric_z.Record(kMaxSizeT);
ASSERT_EQ(kMaxSizeT, metric_z.GetValue());
metric_proto.reset(metric_z.ToProto());
if (sizeof(int64_t) <= sizeof(size_t) &&
static_cast<size_t>(kMaxValue) <= kMaxSizeT) {
ASSERT_EQ(kMaxValue, metric_proto->int_value());
} else {
ASSERT_GT(kMaxValue, metric_proto->int_value());
}
}
} // namespace metrics
} // namespace wvcdm