History

cleanup cpplint warnings

Suggested by James Zern to clear out cpplint warnings for all unit test code.

Yaowu Xu committed 13 years ago

Commit afffa3d1 parent e4e864527 files · +112 −102Browse files

Showing the changes to test/vp8_boolcoder_test.cc (1 of 27 files). Show all

Unified · Split

test/vp8_boolcoder_test.cc+18−16
@@ -8,10 +8,6 @@ · 7 unmodified lines
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
11extern "C" {
12#include "vp8/encoder/boolhuff.h"
13#include "vp8/decoder/dboolhuff.h"
14}
15 11
16#include <math.h>12#include <math.h>
17#include <stddef.h>13#include <stddef.h>
@@ -24,6 +20,11 @@ extern "C" { · 6 unmodified lines
24#include "third_party/googletest/src/include/gtest/gtest.h"20#include "third_party/googletest/src/include/gtest/gtest.h"
25#include "vpx/vpx_integer.h"21#include "vpx/vpx_integer.h"
26 22
23extern "C" {
24#include "vp8/encoder/boolhuff.h"
25#include "vp8/decoder/dboolhuff.h"
26}
27
27namespace {28namespace {
28const int num_tests = 10;29const int num_tests = 10;
29 30
@@ -44,7 +45,7 @@ void encrypt_buffer(uint8_t *buffer, int size) { · 14 unmodified lines
44 45
45void test_decrypt_cb(void *decrypt_state, const uint8_t *input,46void test_decrypt_cb(void *decrypt_state, const uint8_t *input,
46 uint8_t *output, int count) {47 uint8_t *output, int count) {
47 int offset = input - (uint8_t *)decrypt_state;48 int offset = input - reinterpret_cast<uint8_t *>(decrypt_state);
48 for (int i = 0; i < count; i++) {49 for (int i = 0; i < count; i++) {
49 output[i] = input[i] ^ secret_key[(offset + i) & 15];50 output[i] = input[i] ^ secret_key[(offset + i) & 15];
50 }51 }
@@ -58,10 +59,10 @@ TEST(VP8, TestBitIO) { · 7 unmodified lines
58 ACMRandom rnd(ACMRandom::DeterministicSeed());59 ACMRandom rnd(ACMRandom::DeterministicSeed());
59 for (int n = 0; n < num_tests; ++n) {60 for (int n = 0; n < num_tests; ++n) {
60 for (int method = 0; method <= 7; ++method) { // we generate various proba61 for (int method = 0; method <= 7; ++method) { // we generate various proba
61 const int bits_to_test = 1000;62 const int kBitsToTest = 1000;
62 uint8_t probas[bits_to_test];63 uint8_t probas[kBitsToTest];
63 64
64 for (int i = 0; i < bits_to_test; ++i) {65 for (int i = 0; i < kBitsToTest; ++i) {
65 const int parity = i & 1;66 const int parity = i & 1;
66 probas[i] =67 probas[i] =
67 (method == 0) ? 0 : (method == 1) ? 255 :68 (method == 0) ? 0 : (method == 1) ? 255 :
@@ -76,14 +77,14 @@ TEST(VP8, TestBitIO) { · 8 unmodified lines
76 }77 }
77 for (int bit_method = 0; bit_method <= 3; ++bit_method) {78 for (int bit_method = 0; bit_method <= 3; ++bit_method) {
78 const int random_seed = 6432;79 const int random_seed = 6432;
79 const int buffer_size = 10000;80 const int kBufferSize = 10000;
80 ACMRandom bit_rnd(random_seed);81 ACMRandom bit_rnd(random_seed);
81 BOOL_CODER bw;82 BOOL_CODER bw;
82 uint8_t bw_buffer[buffer_size];83 uint8_t bw_buffer[kBufferSize];
83 vp8_start_encode(&bw, bw_buffer, bw_buffer + buffer_size);84 vp8_start_encode(&bw, bw_buffer, bw_buffer + kBufferSize);
84 85
85 int bit = (bit_method == 0) ? 0 : (bit_method == 1) ? 1 : 0;86 int bit = (bit_method == 0) ? 0 : (bit_method == 1) ? 1 : 0;
86 for (int i = 0; i < bits_to_test; ++i) {87 for (int i = 0; i < kBitsToTest; ++i) {
87 if (bit_method == 2) {88 if (bit_method == 2) {
88 bit = (i & 1);89 bit = (i & 1);
89 } else if (bit_method == 3) {90 } else if (bit_method == 3) {
@@ -98,19 +99,20 @@ TEST(VP8, TestBitIO) { · 8 unmodified lines
98#if CONFIG_DECRYPT99#if CONFIG_DECRYPT
99 encrypt_buffer(bw_buffer, buffer_size);100 encrypt_buffer(bw_buffer, buffer_size);
100 vp8dx_start_decode(&br, bw_buffer, buffer_size,101 vp8dx_start_decode(&br, bw_buffer, buffer_size,
101 test_decrypt_cb, (void *)bw_buffer);102 test_decrypt_cb,
103 reinterpret_cast<void *>(bw_buffer));
102#else104#else
103 vp8dx_start_decode(&br, bw_buffer, buffer_size, NULL, NULL);105 vp8dx_start_decode(&br, bw_buffer, kBufferSize, NULL, NULL);
104#endif106#endif
105 bit_rnd.Reset(random_seed);107 bit_rnd.Reset(random_seed);
106 for (int i = 0; i < bits_to_test; ++i) {108 for (int i = 0; i < kBitsToTest; ++i) {
107 if (bit_method == 2) {109 if (bit_method == 2) {
108 bit = (i & 1);110 bit = (i & 1);
109 } else if (bit_method == 3) {111 } else if (bit_method == 3) {
110 bit = bit_rnd(2);112 bit = bit_rnd(2);
111 }113 }
112 GTEST_ASSERT_EQ(vp8dx_decode_bool(&br, probas[i]), bit)114 GTEST_ASSERT_EQ(vp8dx_decode_bool(&br, probas[i]), bit)
113 << "pos: "<< i << " / " << bits_to_test115 << "pos: "<< i << " / " << kBitsToTest
114 << " bit_method: " << bit_method116 << " bit_method: " << bit_method
115 << " method: " << method;117 << " method: " << method;
116 }118 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t