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

Side by Side Diff: components/compression/compression_utils_unittest.cc

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/compression/compression_utils.h" 5 #include "components/compression/compression_utils.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <string> 10 #include <string>
8 11
9 #include "base/basictypes.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 namespace compression { 16 namespace compression {
14 17
15 namespace { 18 namespace {
16 19
17 // The data to be compressed by gzip. This is the hex representation of "hello 20 // The data to be compressed by gzip. This is the hex representation of "hello
18 // world". 21 // world".
19 const uint8 kData[] = 22 const uint8_t kData[] = {0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20,
20 {0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 23 0x77, 0x6f, 0x72, 0x6c, 0x64};
21 0x72, 0x6c, 0x64};
22 24
23 // This is the string representation of gzip compressed string above. It was 25 // This is the string representation of gzip compressed string above. It was
24 // obtained by running echo -n "hello world" | gzip -c | hexdump -e '8 1 ", 26 // obtained by running echo -n "hello world" | gzip -c | hexdump -e '8 1 ",
25 // 0x%x"' followed by 0'ing out the OS byte (10th byte) in the header. This is 27 // 0x%x"' followed by 0'ing out the OS byte (10th byte) in the header. This is
26 // so that the test passes on all platforms (that run various OS'es). 28 // so that the test passes on all platforms (that run various OS'es).
27 const uint8 kCompressedData[] = 29 const uint8_t kCompressedData[] = {
28 {0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb,
29 0x00, 0xcb, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf, 31 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf, 0x2f, 0xca, 0x49, 0x01,
30 0x2f, 0xca, 0x49, 0x01, 0x00, 0x85, 0x11, 0x4a, 0x0d, 32 0x00, 0x85, 0x11, 0x4a, 0x0d, 0x0b, 0x00, 0x00, 0x00};
31 0x0b, 0x00, 0x00, 0x00};
32 33
33 } // namespace 34 } // namespace
34 35
35 TEST(CompressionUtilsTest, GzipCompression) { 36 TEST(CompressionUtilsTest, GzipCompression) {
36 std::string data(reinterpret_cast<const char*>(kData), arraysize(kData)); 37 std::string data(reinterpret_cast<const char*>(kData), arraysize(kData));
37 std::string compressed_data; 38 std::string compressed_data;
38 EXPECT_TRUE(GzipCompress(data, &compressed_data)); 39 EXPECT_TRUE(GzipCompress(data, &compressed_data));
39 std::string golden_compressed_data( 40 std::string golden_compressed_data(
40 reinterpret_cast<const char*>(kCompressedData), 41 reinterpret_cast<const char*>(kCompressedData),
41 arraysize(kCompressedData)); 42 arraysize(kCompressedData));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 arraysize(kCompressedData)); 82 arraysize(kCompressedData));
82 83
83 std::string data(original_data); 84 std::string data(original_data);
84 EXPECT_TRUE(GzipCompress(data, &data)); 85 EXPECT_TRUE(GzipCompress(data, &data));
85 EXPECT_EQ(golden_compressed_data, data); 86 EXPECT_EQ(golden_compressed_data, data);
86 EXPECT_TRUE(GzipUncompress(data, &data)); 87 EXPECT_TRUE(GzipUncompress(data, &data));
87 EXPECT_EQ(original_data, data); 88 EXPECT_EQ(original_data, data);
88 } 89 }
89 90
90 } // namespace compression 91 } // namespace compression
OLDNEW
« no previous file with comments | « components/compression/compression_utils.cc ('k') | components/constrained_window/constrained_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698