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

Side by Side Diff: net/quic/congestion_control/cube_root_test.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « net/quic/congestion_control/cube_root.cc ('k') | net/quic/congestion_control/cubic.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/basictypes.h"
6 #include "net/quic/congestion_control/cube_root.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace net {
10 namespace test {
11
12 class CubeRootTest : public ::testing::Test {
13 protected:
14 CubeRootTest() {
15 }
16 };
17
18 TEST_F(CubeRootTest, LowRoot) {
19 for (uint32 i = 1; i < 256; ++i) {
20 uint64 cube = i * i * i;
21 uint8 cube_root = CubeRoot::Root(cube);
22 EXPECT_EQ(i, cube_root);
23 }
24 }
25
26 TEST_F(CubeRootTest, HighRoot) {
27 // Test the range we will opperate in, 1300 to 130 000.
28 // We expect some loss in accuracy, accepting +-0.2%.
29 for (uint64 i = 1300; i < 20000; i += 100) {
30 uint64 cube = i * i * i;
31 uint32 cube_root = CubeRoot::Root(cube);
32 uint32 margin = cube_root >> 9; // Calculate 0.2% roughly by
33 // dividing by 512.
34 EXPECT_LE(i - margin, cube_root);
35 EXPECT_GE(i + margin, cube_root);
36 }
37 for (uint64 i = 20000; i < 130000; i *= 2) {
38 uint64 cube = i * i * i;
39 uint32 cube_root = CubeRoot::Root(cube);
40 uint32 margin = cube_root >> 9;
41 EXPECT_LE(i - margin, cube_root);
42 EXPECT_GE(i + margin, cube_root);
43 }
44 }
45
46 } // namespace test
47 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/cube_root.cc ('k') | net/quic/congestion_control/cubic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698