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

Side by Side Diff: third_party/WebKit/Source/wtf/text/CompressibleStringTest.cpp

Issue 1389383003: WIP: Introduce CompressibleString Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto crrev.com/1564773002 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "wtf/text/CompressibleString.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace WTF {
10
11 // The input and compressed data is copied from
12 // components/compression/compression_utils_unittest.cc
13 const char InputData[] = {
14 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
15 0x72, 0x6c, 0x64};
16
17 const char CompressedData[] = {
18 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0x00, 0xcb, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf,
20 0x2f, 0xca, 0x49, 0x01, 0x00, 0x85, 0x11, 0x4a, 0x0d,
21 0x0b, 0x00, 0x00, 0x00};
22
23 TEST(CompressibleStringTest, compress)
24 {
25 RefPtr<StringImpl> impl = StringImpl::create(InputData, sizeof(InputData));
26 RefPtr<CompressibleStringImpl> string = adoptRef(new CompressibleStringImpl( impl));
27 EXPECT_TRUE(!string->isCompressed());
28 EXPECT_EQ(sizeof(InputData), string->originalContentSizeInBytes());
29 EXPECT_EQ(sizeof(InputData), string->currentSizeInBytes());
30 string->compressString();
31 EXPECT_TRUE(string->isCompressed());
32 EXPECT_EQ(sizeof(InputData), string->originalContentSizeInBytes());
33 EXPECT_EQ(sizeof(CompressedData), string->currentSizeInBytes());
34 string->uncompressString();
35 EXPECT_TRUE(!string->isCompressed());
36 EXPECT_EQ(sizeof(InputData), string->originalContentSizeInBytes());
37 EXPECT_EQ(sizeof(InputData), string->currentSizeInBytes());
38 }
39
40 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/CompressibleString.cpp ('k') | third_party/WebKit/Source/wtf/wtf.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698