OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/test_tools/quic_test_utils.h" | 5 #include "net/quic/test_tools/quic_test_utils.h" |
6 | 6 |
| 7 #include "net/quic/platform/api/quic_test.h" |
7 #include "testing/gtest/include/gtest/gtest-spi.h" | 8 #include "testing/gtest/include/gtest/gtest-spi.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 namespace test { | 11 namespace test { |
12 | 12 |
13 TEST(QuicTestUtilsTest, BasicApproxEq) { | 13 class QuicTestUtilsTest : public QuicTest {}; |
| 14 |
| 15 TEST_F(QuicTestUtilsTest, BasicApproxEq) { |
14 ExpectApproxEq(10, 10, 1e-6f); | 16 ExpectApproxEq(10, 10, 1e-6f); |
15 ExpectApproxEq(1000, 1001, 0.01f); | 17 ExpectApproxEq(1000, 1001, 0.01f); |
16 EXPECT_NONFATAL_FAILURE(ExpectApproxEq(1000, 1100, 0.01f), ""); | 18 EXPECT_NONFATAL_FAILURE(ExpectApproxEq(1000, 1100, 0.01f), ""); |
17 | 19 |
18 ExpectApproxEq(64, 31, 0.55f); | 20 ExpectApproxEq(64, 31, 0.55f); |
19 EXPECT_NONFATAL_FAILURE(ExpectApproxEq(31, 64, 0.55f), ""); | 21 EXPECT_NONFATAL_FAILURE(ExpectApproxEq(31, 64, 0.55f), ""); |
20 } | 22 } |
21 | 23 |
22 TEST(QuicTestUtilsTest, QuicTimeDelta) { | 24 TEST_F(QuicTestUtilsTest, QuicTimeDelta) { |
23 ExpectApproxEq(QuicTime::Delta::FromMicroseconds(1000), | 25 ExpectApproxEq(QuicTime::Delta::FromMicroseconds(1000), |
24 QuicTime::Delta::FromMicroseconds(1003), 0.01f); | 26 QuicTime::Delta::FromMicroseconds(1003), 0.01f); |
25 EXPECT_NONFATAL_FAILURE( | 27 EXPECT_NONFATAL_FAILURE( |
26 ExpectApproxEq(QuicTime::Delta::FromMicroseconds(1000), | 28 ExpectApproxEq(QuicTime::Delta::FromMicroseconds(1000), |
27 QuicTime::Delta::FromMicroseconds(1200), 0.01f), | 29 QuicTime::Delta::FromMicroseconds(1200), 0.01f), |
28 ""); | 30 ""); |
29 } | 31 } |
30 | 32 |
31 TEST(QuicTestUtilsTest, QuicBandwidth) { | 33 TEST_F(QuicTestUtilsTest, QuicBandwidth) { |
32 ExpectApproxEq(QuicBandwidth::FromBytesPerSecond(1000), | 34 ExpectApproxEq(QuicBandwidth::FromBytesPerSecond(1000), |
33 QuicBandwidth::FromBitsPerSecond(8005), 0.01f); | 35 QuicBandwidth::FromBitsPerSecond(8005), 0.01f); |
34 EXPECT_NONFATAL_FAILURE( | 36 EXPECT_NONFATAL_FAILURE( |
35 ExpectApproxEq(QuicBandwidth::FromBytesPerSecond(1000), | 37 ExpectApproxEq(QuicBandwidth::FromBytesPerSecond(1000), |
36 QuicBandwidth::FromBitsPerSecond(9005), 0.01f), | 38 QuicBandwidth::FromBitsPerSecond(9005), 0.01f), |
37 ""); | 39 ""); |
38 } | 40 } |
39 | 41 |
40 // Ensure that SimpleRandom does not change its output for a fixed seed. | 42 // Ensure that SimpleRandom does not change its output for a fixed seed. |
41 TEST(QuicTestUtilsTest, SimpleRandomStability) { | 43 TEST_F(QuicTestUtilsTest, SimpleRandomStability) { |
42 SimpleRandom rng; | 44 SimpleRandom rng; |
43 rng.set_seed(UINT64_C(0x1234567800010001)); | 45 rng.set_seed(UINT64_C(0x1234567800010001)); |
44 EXPECT_EQ(UINT64_C(14865409841904857791), rng.RandUint64()); | 46 EXPECT_EQ(UINT64_C(14865409841904857791), rng.RandUint64()); |
45 EXPECT_EQ(UINT64_C(12139094019410129741), rng.RandUint64()); | 47 EXPECT_EQ(UINT64_C(12139094019410129741), rng.RandUint64()); |
46 } | 48 } |
47 | 49 |
48 } // namespace test | 50 } // namespace test |
49 } // namespace net | 51 } // namespace net |
OLD | NEW |