aboutsummaryrefslogtreecommitdiffstats
path: root/metrics/src/tests/metric_timer_test.cpp
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-05-09 07:47:56 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-05-09 09:01:50 +0000
commite8ca6eeeb580292ece4ade40ad995f7932c55204 (patch)
tree1e68592c197d232334799470a2661d99a905000d /metrics/src/tests/metric_timer_test.cpp
parent72db80647f7b9e6dab491dc6634b1bd477cf59cd (diff)
Rewrite metrics tests from cppunit to gtest.
Diffstat (limited to 'metrics/src/tests/metric_timer_test.cpp')
-rw-r--r--metrics/src/tests/metric_timer_test.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/metrics/src/tests/metric_timer_test.cpp b/metrics/src/tests/metric_timer_test.cpp
index 0087da713b9..cf73c86e4f2 100644
--- a/metrics/src/tests/metric_timer_test.cpp
+++ b/metrics/src/tests/metric_timer_test.cpp
@@ -1,46 +1,31 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/metrics/valuemetric.h>
#include <vespa/metrics/metrictimer.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <thread>
namespace metrics {
-struct MetricTimerTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(MetricTimerTest);
- CPPUNIT_TEST(timer_duration_is_correct_for_double_value_metric);
- CPPUNIT_TEST(timer_duration_is_correct_for_long_value_metric);
- CPPUNIT_TEST_SUITE_END();
-
- void timer_duration_is_correct_for_double_value_metric();
- void timer_duration_is_correct_for_long_value_metric();
-
- template <typename MetricType>
- void do_test_metric_timer_for_metric_type();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(MetricTimerTest);
-
using namespace std::literals::chrono_literals;
template <typename MetricType>
-void MetricTimerTest::do_test_metric_timer_for_metric_type() {
+void do_test_metric_timer_for_metric_type() {
MetricTimer timer;
MetricType metric("foo", {}, "");
std::this_thread::sleep_for(5ms); // Guaranteed to be monotonic time
timer.stop(metric);
// getDoubleValue() is present for both long and double metric types
- CPPUNIT_ASSERT(metric.getDoubleValue("last") >= 5.0);
+ EXPECT_GE(metric.getDoubleValue("last"), 5.0);
}
-void MetricTimerTest::timer_duration_is_correct_for_double_value_metric() {
+TEST(MetricTimerTest, timer_duration_is_correct_for_double_value_metric) {
do_test_metric_timer_for_metric_type<DoubleAverageMetric>();
}
-void MetricTimerTest::timer_duration_is_correct_for_long_value_metric() {
+TEST(MetricTimerTest, timer_duration_is_correct_for_long_value_metric) {
do_test_metric_timer_for_metric_type<LongAverageMetric>();
}
-} // metrics
+}