| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "net/quic/congestion_control/cube_root.h" | 6 #include "net/quic/congestion_control/cube_root.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 namespace test { | 10 namespace test { |
| 11 | 11 |
| 12 class CubeRootTest : public ::testing::Test { | 12 class CubeRootTest : public ::testing::Test { |
| 13 protected: | 13 protected: |
| 14 CubeRootTest() { | 14 CubeRootTest() {} |
| 15 } | |
| 16 }; | 15 }; |
| 17 | 16 |
| 18 TEST_F(CubeRootTest, LowRoot) { | 17 TEST_F(CubeRootTest, LowRoot) { |
| 19 for (uint32 i = 1; i < 256; ++i) { | 18 for (uint32 i = 1; i < 256; ++i) { |
| 20 uint64 cube = i * i * i; | 19 uint64 cube = i * i * i; |
| 21 uint8 cube_root = CubeRoot::Root(cube); | 20 uint8 cube_root = CubeRoot::Root(cube); |
| 22 EXPECT_EQ(i, cube_root); | 21 EXPECT_EQ(i, cube_root); |
| 23 } | 22 } |
| 24 } | 23 } |
| 25 | 24 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 38 uint64 cube = i * i * i; | 37 uint64 cube = i * i * i; |
| 39 uint32 cube_root = CubeRoot::Root(cube); | 38 uint32 cube_root = CubeRoot::Root(cube); |
| 40 uint32 margin = cube_root >> 9; | 39 uint32 margin = cube_root >> 9; |
| 41 EXPECT_LE(i - margin, cube_root); | 40 EXPECT_LE(i - margin, cube_root); |
| 42 EXPECT_GE(i + margin, cube_root); | 41 EXPECT_GE(i + margin, cube_root); |
| 43 } | 42 } |
| 44 } | 43 } |
| 45 | 44 |
| 46 } // namespace test | 45 } // namespace test |
| 47 } // namespace net | 46 } // namespace net |
| OLD | NEW |