Bug 1222866: P2. Add gtest checking on seconds -> microseconds -> seconds. r=gerald
☠☠ backed out by 9bdf5bae3a63 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 20 Nov 2015 11:07:30 +1100
changeset 273437 74caf0456e1e12c6e531a6d9c614f92109e5f815
parent 273436 002714e2ccbac1d3bd2a73f86a3fc2eef277d1a0
child 273439 ca10d0f073cab0142b5566776535f8fa030d6486
push id68280
push userjyavenard@mozilla.com
push dateFri, 20 Nov 2015 04:43:31 +0000
treeherdermozilla-inbound@74caf0456e1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1222866
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1222866: P2. Add gtest checking on seconds -> microseconds -> seconds. r=gerald
dom/media/gtest/TestTimeUnit.cpp
new file mode 100644
--- /dev/null
+++ b/dom/media/gtest/TestTimeUnit.cpp
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "gtest/gtest.h"
+#include "TimeUnits.h"
+#include <algorithm>
+#include <vector>
+
+using namespace mozilla;
+
+TEST(TimeUnit, Rounding)
+{
+  int64_t usecs = 66261715;
+  double seconds = media::TimeUnit::FromMicroseconds(usecs).ToSeconds();
+  EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs);
+
+  seconds = 4.169470;
+  usecs = 4169470;
+  EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs);
+}