Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: net/quic/test_tools/quic_test_utils_test.cc

Issue 2336913006: Introduce ExpectApproxEq, a helper function that allows making assertions that certain values are e… (Closed)
Patch Set: Fix MSVC warnings Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/quic_test_utils_test.cc
diff --git a/net/quic/test_tools/quic_test_utils_test.cc b/net/quic/test_tools/quic_test_utils_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6d4fb2766a6df531c13a152fcce648b7a30eeb5b
--- /dev/null
+++ b/net/quic/test_tools/quic_test_utils_test.cc
@@ -0,0 +1,41 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/test_tools/quic_test_utils.h"
+
+#include "testing/gtest/include/gtest/gtest-spi.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test {
+
+TEST(QuicTestUtilsTest, BasicApproxEq) {
+ ExpectApproxEq(10, 10, 1e-6f);
+ ExpectApproxEq(1000, 1001, 0.01f);
+ EXPECT_NONFATAL_FAILURE(ExpectApproxEq(1000, 1100, 0.01f), "");
+
+ ExpectApproxEq(64, 31, 0.55f);
+ EXPECT_NONFATAL_FAILURE(ExpectApproxEq(31, 64, 0.55f), "");
+}
+
+TEST(QuicTestUtilsTest, QuicTimeDelta) {
+ ExpectApproxEq(QuicTime::Delta::FromMicroseconds(1000),
+ QuicTime::Delta::FromMicroseconds(1003), 0.01f);
+ EXPECT_NONFATAL_FAILURE(
+ ExpectApproxEq(QuicTime::Delta::FromMicroseconds(1000),
+ QuicTime::Delta::FromMicroseconds(1200), 0.01f),
+ "");
+}
+
+TEST(QuicTestUtilsTest, QuicBandwidth) {
+ ExpectApproxEq(QuicBandwidth::FromBytesPerSecond(1000),
+ QuicBandwidth::FromBitsPerSecond(8005), 0.01f);
+ EXPECT_NONFATAL_FAILURE(
+ ExpectApproxEq(QuicBandwidth::FromBytesPerSecond(1000),
+ QuicBandwidth::FromBitsPerSecond(9005), 0.01f),
+ "");
+}
+
+} // namespace test
+} // namespace net
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698