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

Side by Side Diff: net/filter/brotli_filter_unittest.cc

Issue 1616863002: Fix division by zero. Test filter with empty output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/filter/brotli_filter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/filter/brotli_filter.h" 9 #include "net/filter/brotli_filter.h"
10 #include "net/filter/mock_filter_context.h" 10 #include "net/filter/mock_filter_context.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 char corrupt_decode_buffer[kDefaultBufferSize]; 243 char corrupt_decode_buffer[kDefaultBufferSize];
244 int corrupt_decode_size = kDefaultBufferSize; 244 int corrupt_decode_size = kDefaultBufferSize;
245 245
246 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, 246 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len,
247 corrupt_decode_buffer, &corrupt_decode_size); 247 corrupt_decode_buffer, &corrupt_decode_size);
248 248
249 // Expect failures 249 // Expect failures
250 EXPECT_EQ(Filter::FILTER_ERROR, code); 250 EXPECT_EQ(Filter::FILTER_ERROR, code);
251 } 251 }
252 252
253 // Decoding brotli stream with empty output data.
254 TEST_F(BrotliUnitTest, DecodeEmptyData) {
255 char data[1] = {6}; // WBITS = 16, ISLAST = 1, ISLASTEMPTY = 1
256 int data_len = 1;
257
258 InitFilter();
259 char decode_buffer[kDefaultBufferSize];
260 int decode_size = kDefaultBufferSize;
261 int code = DecodeAllWithFilter(filter_.get(), data, data_len, decode_buffer,
262 &decode_size);
263
264 // Expect success / empty output.
265 EXPECT_EQ(Filter::FILTER_DONE, code);
266 EXPECT_EQ(0, decode_size);
267 }
268
253 } // namespace net 269 } // namespace net
OLDNEW
« no previous file with comments | « net/filter/brotli_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698