Source release 14.0.0

This commit is contained in:
John W. Bruce
2018-05-16 17:35:40 -07:00
parent 31381a1311
commit 3ab70cec4e
2053 changed files with 1585838 additions and 4614 deletions

View File

@@ -8,70 +8,57 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "metric_serialization.h"
#include "metrics.pb.h"
#include "scoped_ptr.h"
namespace wvcdm {
namespace metrics {
class MockMetricSerializer : public MetricSerializer {
public:
MOCK_METHOD2(SetString, void(const std::string& metric_id,
const std::string& value));
MOCK_METHOD2(SetInt32, void(const std::string& metric_id,
int32_t value));
MOCK_METHOD2(SetInt64, void(const std::string& metric_id,
int64_t value));
MOCK_METHOD2(SetDouble, void(const std::string& metric_id,
double value));
};
TEST(ValueMetricTest, StringValue) {
ValueMetric<std::string> metric;
metric.Record("foo");
class ValueMetricTest : public ::testing::Test {
public:
void SetUp() {
mock_serializer_.reset(new MockMetricSerializer());
}
protected:
scoped_ptr<MockMetricSerializer> mock_serializer_;
};
TEST_F(ValueMetricTest, StringValue) {
ValueMetric<std::string> value_metric("string/metric");
value_metric.Record("foo");
EXPECT_CALL(*mock_serializer_,
SetString("string/metric", "foo"));
value_metric.Serialize(mock_serializer_.get());
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
ASSERT_EQ("foo", metric_proto->string_value());
ASSERT_FALSE(metric_proto->has_error_code());
}
TEST_F(ValueMetricTest, DoubleValue) {
ValueMetric<double> value_metric("double/metric");
value_metric.Record(42.0);
TEST(ValueMetricTest, DoubleValue) {
ValueMetric<double> metric;
metric.Record(42.0);
EXPECT_CALL(*mock_serializer_,
SetDouble("double/metric", 42.0));
value_metric.Serialize(mock_serializer_.get());
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
ASSERT_EQ(42.0, metric_proto->double_value());
ASSERT_FALSE(metric_proto->has_error_code());
}
TEST_F(ValueMetricTest, Int32Value) {
ValueMetric<int32_t> value_metric("int32/metric");
value_metric.Record(42);
TEST(ValueMetricTest, Int32Value) {
ValueMetric<int32_t> metric;
metric.Record(42);
EXPECT_CALL(*mock_serializer_,
SetInt32("int32/metric", 42));
value_metric.Serialize(mock_serializer_.get());
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
ASSERT_EQ(42, metric_proto->int_value());
ASSERT_FALSE(metric_proto->has_error_code());
}
TEST_F(ValueMetricTest, Int64Value) {
ValueMetric<int64_t> value_metric("int64/metric");
value_metric.Record(42);
TEST(ValueMetricTest, Int64Value) {
ValueMetric<int64_t> metric;
metric.Record(42);
EXPECT_CALL(*mock_serializer_,
SetInt64("int64/metric", 42));
value_metric.Serialize(mock_serializer_.get());
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
ASSERT_EQ(42, metric_proto->int_value());
ASSERT_FALSE(metric_proto->has_error_code());
}
TEST(ValueMetricTest, SetError) {
ValueMetric<int64_t> metric;
metric.Record(42);
metric.SetError(7);
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
ASSERT_EQ(7, metric_proto->error_code());
ASSERT_FALSE(metric_proto->has_int_value());
}
} // namespace metrics
} // namespace wvcdm