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

Side by Side Diff: webrtc/base/stringencode_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/socket_unittest.cc ('k') | webrtc/base/task_unittest.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 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 "webrtc/base/arraysize.h"
11 #include "webrtc/base/common.h" 12 #include "webrtc/base/common.h"
12 #include "webrtc/base/gunit.h" 13 #include "webrtc/base/gunit.h"
13 #include "webrtc/base/stringencode.h" 14 #include "webrtc/base/stringencode.h"
14 #include "webrtc/base/stringutils.h" 15 #include "webrtc/base/stringutils.h"
15 16
16 namespace rtc { 17 namespace rtc {
17 18
18 TEST(Utf8EncodeTest, EncodeDecode) { 19 TEST(Utf8EncodeTest, EncodeDecode) {
19 const struct Utf8Test { 20 const struct Utf8Test {
20 const char* encoded; 21 const char* encoded;
(...skipping 20 matching lines...) Expand all
41 &val)); 42 &val));
42 unsigned long result = (kTests[i].enclen == 0) ? 0 : kTests[i].decoded; 43 unsigned long result = (kTests[i].enclen == 0) ? 0 : kTests[i].decoded;
43 ASSERT_EQ(result, val); 44 ASSERT_EQ(result, val);
44 45
45 if (kTests[i].decoded == 0) { 46 if (kTests[i].decoded == 0) {
46 // Not an interesting encoding test case 47 // Not an interesting encoding test case
47 continue; 48 continue;
48 } 49 }
49 50
50 char buffer[5]; 51 char buffer[5];
51 memset(buffer, 0x01, ARRAY_SIZE(buffer)); 52 memset(buffer, 0x01, arraysize(buffer));
52 ASSERT_EQ(kTests[i].enclen, utf8_encode(buffer, 53 ASSERT_EQ(kTests[i].enclen, utf8_encode(buffer,
53 kTests[i].encsize, 54 kTests[i].encsize,
54 kTests[i].decoded)); 55 kTests[i].decoded));
55 ASSERT_TRUE(memcmp(buffer, kTests[i].encoded, kTests[i].enclen) == 0); 56 ASSERT_TRUE(memcmp(buffer, kTests[i].encoded, kTests[i].enclen) == 0);
56 // Make sure remainder of buffer is unchanged 57 // Make sure remainder of buffer is unchanged
57 ASSERT_TRUE(memory_check(buffer + kTests[i].enclen, 58 ASSERT_TRUE(memory_check(buffer + kTests[i].enclen,
58 0x1, 59 0x1,
59 ARRAY_SIZE(buffer) - kTests[i].enclen)); 60 arraysize(buffer) - kTests[i].enclen));
60 } 61 }
61 } 62 }
62 63
63 class HexEncodeTest : public testing::Test { 64 class HexEncodeTest : public testing::Test {
64 public: 65 public:
65 HexEncodeTest() : enc_res_(0), dec_res_(0) { 66 HexEncodeTest() : enc_res_(0), dec_res_(0) {
66 for (size_t i = 0; i < sizeof(data_); ++i) { 67 for (size_t i = 0; i < sizeof(data_); ++i) {
67 data_[i] = (i + 128) & 0xff; 68 data_[i] = (i + 128) & 0xff;
68 } 69 }
69 memset(decoded_, 0x7f, sizeof(decoded_)); 70 memset(decoded_, 0x7f, sizeof(decoded_));
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 440
440 TEST(BoolTest, RoundTrip) { 441 TEST(BoolTest, RoundTrip) {
441 bool value; 442 bool value;
442 EXPECT_TRUE(FromString(ToString(true), &value)); 443 EXPECT_TRUE(FromString(ToString(true), &value));
443 EXPECT_TRUE(value); 444 EXPECT_TRUE(value);
444 EXPECT_TRUE(FromString(ToString(false), &value)); 445 EXPECT_TRUE(FromString(ToString(false), &value));
445 EXPECT_FALSE(value); 446 EXPECT_FALSE(value);
446 } 447 }
447 448
448 } // namespace rtc 449 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/socket_unittest.cc ('k') | webrtc/base/task_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698