OLD | NEW |
(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 |
OLD | NEW |