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

Side by Side Diff: webrtc/base/virtualsocket_unittest.cc

Issue 1405023016: Convert usage of ARRAY_SIZE to arraysize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: static_cast<int> Created 5 years, 1 month 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 | « webrtc/base/urlencode_unittest.cc ('k') | webrtc/base/win32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2006 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <math.h> 11 #include <math.h>
12 #include <time.h> 12 #include <time.h>
13 #if defined(WEBRTC_POSIX) 13 #if defined(WEBRTC_POSIX)
14 #include <netinet/in.h> 14 #include <netinet/in.h>
15 #endif 15 #endif
16 16
17 #include "webrtc/base/arraysize.h"
17 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
18 #include "webrtc/base/gunit.h" 19 #include "webrtc/base/gunit.h"
19 #include "webrtc/base/testclient.h" 20 #include "webrtc/base/testclient.h"
20 #include "webrtc/base/testutils.h" 21 #include "webrtc/base/testutils.h"
21 #include "webrtc/base/thread.h" 22 #include "webrtc/base/thread.h"
22 #include "webrtc/base/timeutils.h" 23 #include "webrtc/base/timeutils.h"
23 #include "webrtc/base/virtualsocketserver.h" 24 #include "webrtc/base/virtualsocketserver.h"
24 #include "webrtc/test/testsupport/gtest_disable.h" 25 #include "webrtc/test/testsupport/gtest_disable.h"
25 26
26 using namespace rtc; 27 using namespace rtc;
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 CrossFamilyDatagramTest(SocketAddress("::", 0), 1016 CrossFamilyDatagramTest(SocketAddress("::", 0),
1016 SocketAddress("0.0.0.0", 5000), 1017 SocketAddress("0.0.0.0", 5000),
1017 true); 1018 true);
1018 } 1019 }
1019 1020
1020 TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) { 1021 TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) {
1021 const uint32_t kTestMean[] = {10, 100, 333, 1000}; 1022 const uint32_t kTestMean[] = {10, 100, 333, 1000};
1022 const double kTestDev[] = { 0.25, 0.1, 0.01 }; 1023 const double kTestDev[] = { 0.25, 0.1, 0.01 };
1023 // TODO: The current code only works for 1000 data points or more. 1024 // TODO: The current code only works for 1000 data points or more.
1024 const uint32_t kTestSamples[] = {/*10, 100,*/ 1000}; 1025 const uint32_t kTestSamples[] = {/*10, 100,*/ 1000};
1025 for (size_t midx = 0; midx < ARRAY_SIZE(kTestMean); ++midx) { 1026 for (size_t midx = 0; midx < arraysize(kTestMean); ++midx) {
1026 for (size_t didx = 0; didx < ARRAY_SIZE(kTestDev); ++didx) { 1027 for (size_t didx = 0; didx < arraysize(kTestDev); ++didx) {
1027 for (size_t sidx = 0; sidx < ARRAY_SIZE(kTestSamples); ++sidx) { 1028 for (size_t sidx = 0; sidx < arraysize(kTestSamples); ++sidx) {
1028 ASSERT_LT(0u, kTestSamples[sidx]); 1029 ASSERT_LT(0u, kTestSamples[sidx]);
1029 const uint32_t kStdDev = 1030 const uint32_t kStdDev =
1030 static_cast<uint32_t>(kTestDev[didx] * kTestMean[midx]); 1031 static_cast<uint32_t>(kTestDev[didx] * kTestMean[midx]);
1031 VirtualSocketServer::Function* f = 1032 VirtualSocketServer::Function* f =
1032 VirtualSocketServer::CreateDistribution(kTestMean[midx], 1033 VirtualSocketServer::CreateDistribution(kTestMean[midx],
1033 kStdDev, 1034 kStdDev,
1034 kTestSamples[sidx]); 1035 kTestSamples[sidx]);
1035 ASSERT_TRUE(NULL != f); 1036 ASSERT_TRUE(NULL != f);
1036 ASSERT_EQ(kTestSamples[sidx], f->size()); 1037 ASSERT_EQ(kTestSamples[sidx], f->size());
1037 double sum = 0; 1038 double sum = 0;
(...skipping 13 matching lines...) Expand all
1051 << " N=" << kTestSamples[sidx]; 1052 << " N=" << kTestSamples[sidx];
1052 EXPECT_NEAR(kStdDev, stddev, 0.1 * kStdDev) 1053 EXPECT_NEAR(kStdDev, stddev, 0.1 * kStdDev)
1053 << "M=" << kTestMean[midx] 1054 << "M=" << kTestMean[midx]
1054 << " SD=" << kStdDev 1055 << " SD=" << kStdDev
1055 << " N=" << kTestSamples[sidx]; 1056 << " N=" << kTestSamples[sidx];
1056 delete f; 1057 delete f;
1057 } 1058 }
1058 } 1059 }
1059 } 1060 }
1060 } 1061 }
OLDNEW
« no previous file with comments | « webrtc/base/urlencode_unittest.cc ('k') | webrtc/base/win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698