OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "modules/websockets/WebSocketDeflater.h" | 27 #include "modules/websockets/WebSocketDeflater.h" |
28 | 28 |
29 #include "wtf/Vector.h" | 29 #include "wtf/Vector.h" |
30 #include <gtest/gtest.h> | 30 #include <gtest/gtest.h> |
31 | 31 |
32 using namespace blink; | 32 namespace blink { |
33 | |
34 namespace { | 33 namespace { |
35 | 34 |
36 TEST(WebSocketDeflaterTest, TestCompressHello) | 35 TEST(WebSocketDeflaterTest, TestCompressHello) |
37 { | 36 { |
38 // Test the first example on section 4.3 of the specification. | 37 // Test the first example on section 4.3 of the specification. |
39 OwnPtr<WebSocketDeflater> deflater = WebSocketDeflater::create(15); | 38 OwnPtr<WebSocketDeflater> deflater = WebSocketDeflater::create(15); |
40 ASSERT_TRUE(deflater->initialize()); | 39 ASSERT_TRUE(deflater->initialize()); |
41 OwnPtr<WebSocketInflater> inflater = WebSocketInflater::create(); | 40 OwnPtr<WebSocketInflater> inflater = WebSocketInflater::create(); |
42 ASSERT_TRUE(inflater->initialize()); | 41 ASSERT_TRUE(inflater->initialize()); |
43 const char* inputData = "Hello"; | 42 const char* inputData = "Hello"; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 inputData.fill('a'); | 145 inputData.fill('a'); |
147 | 146 |
148 ASSERT_TRUE(deflater->addBytes(inputData.data(), inputData.size())); | 147 ASSERT_TRUE(deflater->addBytes(inputData.data(), inputData.size())); |
149 ASSERT_TRUE(deflater->finish()); | 148 ASSERT_TRUE(deflater->finish()); |
150 ASSERT_TRUE(inflater->addBytes(deflater->data(), deflater->size())); | 149 ASSERT_TRUE(inflater->addBytes(deflater->data(), deflater->size())); |
151 ASSERT_TRUE(inflater->finish()); | 150 ASSERT_TRUE(inflater->finish()); |
152 EXPECT_EQ(inputData.size(), inflater->size()); | 151 EXPECT_EQ(inputData.size(), inflater->size()); |
153 EXPECT_EQ(0, memcmp(inputData.data(), inflater->data(), inflater->size())); | 152 EXPECT_EQ(0, memcmp(inputData.data(), inflater->data(), inflater->size())); |
154 } | 153 } |
155 | 154 |
156 } | 155 } // namespace |
| 156 } // namespace blink |
OLD | NEW |