annotate UnitTestsSources/StreamTests.cpp @ 1525:f9b0169eb6bb

testing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Aug 2015 17:50:38 +0200
parents
children 096a8af528c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1525
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "PrecompiledHeadersUnitTests.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "gtest/gtest.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../Core/Toolbox.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/OrthancException.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../Core/Uuid.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "../Core/HttpServer/BufferHttpSender.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include "../Core/HttpServer/FilesystemHttpSender.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include "../Core/HttpServer/HttpStreamTranscoder.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include "../Core/Compression/ZlibCompressor.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include "../Core/Compression/GzipCompressor.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 using namespace Orthanc;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 TEST(Gzip, Basic)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 std::string s = "Hello world";
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 std::string compressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 GzipCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ASSERT_FALSE(c.HasPrefixWithUncompressedSize());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 std::string uncompressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 IBufferCompressor::Uncompress(uncompressed, c, compressed);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 ASSERT_EQ(s.size(), uncompressed.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ASSERT_EQ(0, memcmp(&s[0], &uncompressed[0], s.size()));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 TEST(Gzip, Empty)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 std::string s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 std::string compressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 GzipCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ASSERT_FALSE(c.HasPrefixWithUncompressedSize());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 c.SetPrefixWithUncompressedSize(false);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 std::string uncompressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 IBufferCompressor::Uncompress(uncompressed, c, compressed);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 ASSERT_EQ(0, uncompressed.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 TEST(Gzip, BasicWithPrefix)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 std::string s = "Hello world";
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 std::string compressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 GzipCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 c.SetPrefixWithUncompressedSize(true);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 ASSERT_TRUE(c.HasPrefixWithUncompressedSize());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 std::string uncompressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 IBufferCompressor::Uncompress(uncompressed, c, compressed);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 ASSERT_EQ(s.size(), uncompressed.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 ASSERT_EQ(0, memcmp(&s[0], &uncompressed[0], s.size()));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 TEST(Gzip, EmptyWithPrefix)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 std::string s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 std::string compressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 GzipCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 c.SetPrefixWithUncompressedSize(true);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 ASSERT_TRUE(c.HasPrefixWithUncompressedSize());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 std::string uncompressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 IBufferCompressor::Uncompress(uncompressed, c, compressed);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 ASSERT_EQ(0, uncompressed.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 TEST(Zlib, Basic)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 std::string s = Toolbox::GenerateUuid();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 s = s + s + s + s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 std::string compressed, compressed2;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 ZlibCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 ASSERT_TRUE(c.HasPrefixWithUncompressedSize());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 std::string uncompressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 IBufferCompressor::Uncompress(uncompressed, c, compressed);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 ASSERT_EQ(s.size(), uncompressed.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 ASSERT_EQ(0, memcmp(&s[0], &uncompressed[0], s.size()));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 TEST(Zlib, Level)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 std::string s = Toolbox::GenerateUuid();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 s = s + s + s + s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 std::string compressed, compressed2;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 ZlibCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 c.SetCompressionLevel(9);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 c.SetCompressionLevel(0);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 IBufferCompressor::Compress(compressed2, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 ASSERT_TRUE(compressed.size() < compressed2.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 TEST(Zlib, DISABLED_Corrupted) // Disabled because it may result in a crash
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 std::string s = Toolbox::GenerateUuid();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 s = s + s + s + s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 std::string compressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 ZlibCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 compressed[compressed.size() - 1] = 'a';
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 std::string u;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 ASSERT_THROW(IBufferCompressor::Uncompress(u, c, compressed), OrthancException);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 TEST(Zlib, Empty)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 std::string s = "";
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 std::string compressed, compressed2;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 ZlibCompressor c;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 IBufferCompressor::Compress(compressed, c, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 ASSERT_EQ(compressed, compressed2);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 std::string uncompressed;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 IBufferCompressor::Uncompress(uncompressed, c, compressed);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 ASSERT_EQ(0u, uncompressed.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 static bool ReadAllStream(std::string& result,
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 IHttpStreamAnswer& stream,
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 bool allowGzip = false,
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 bool allowDeflate = false)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 result.resize(stream.GetContentLength());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 stream.SetupHttpCompression(allowGzip, allowDeflate);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 size_t pos = 0;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 while (stream.ReadNextChunk())
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 size_t s = stream.GetChunkSize();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 if (pos + s > result.size())
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 return false;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 memcpy(&result[pos], stream.GetChunkContent(), s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 pos += s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 return pos == result.size();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 TEST(BufferHttpSender, Basic)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 const std::string s = "Hello world";
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 std::string t;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 sender.SetChunkSize(0);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 sender.GetBuffer() = s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 ASSERT_TRUE(ReadAllStream(t, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 ASSERT_EQ(s, t);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 sender.SetChunkSize(1);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 sender.GetBuffer() = s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 ASSERT_TRUE(ReadAllStream(t, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 ASSERT_EQ(s, t);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 sender.SetChunkSize(1);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 ASSERT_TRUE(ReadAllStream(t, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 ASSERT_EQ(0u, t.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 sender.SetChunkSize(3);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 sender.GetBuffer() = s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 ASSERT_TRUE(ReadAllStream(t, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 ASSERT_EQ(s, t);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 sender.SetChunkSize(300);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 sender.GetBuffer() = s;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 ASSERT_TRUE(ReadAllStream(t, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 ASSERT_EQ(s, t);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 TEST(FilesystemHttpSender, Basic)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 const std::string& path = "UnitTestsResults/stream";
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 const std::string s = "Hello world";
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 std::string t;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 Toolbox::WriteFile(s, path);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 FilesystemHttpSender sender(path);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 ASSERT_TRUE(ReadAllStream(t, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 ASSERT_EQ(s, t);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 Toolbox::WriteFile("", path);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 FilesystemHttpSender sender(path);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 ASSERT_TRUE(ReadAllStream(t, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 ASSERT_EQ(0u, t.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 TEST(HttpStreamTranscoder, Basic)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 ZlibCompressor compressor;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 const std::string s = "Hello world " + Toolbox::GenerateUuid();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 std::string t;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 IBufferCompressor::Compress(t, compressor, s);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 for (int cs = 0; cs < 3; cs++)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 sender.SetChunkSize(cs);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 sender.GetBuffer() = t;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 std::string u;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 ASSERT_TRUE(ReadAllStream(u, sender));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 std::string v;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 IBufferCompressor::Uncompress(v, compressor, u);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 ASSERT_EQ(s, v);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 // Pass-through test, no decompression occurs
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 for (int cs = 0; cs < 3; cs++)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 sender.SetChunkSize(cs);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 sender.GetBuffer() = t;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 HttpStreamTranscoder transcode(sender, CompressionType_None);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 std::string u;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 ASSERT_TRUE(ReadAllStream(u, transcode));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 ASSERT_EQ(t, u);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 // Pass-through test, decompression occurs
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 for (int cs = 0; cs < 3; cs++)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 sender.SetChunkSize(cs);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 sender.GetBuffer() = t;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 HttpStreamTranscoder transcode(sender, CompressionType_ZlibWithSize);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 std::string u;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 ASSERT_TRUE(ReadAllStream(u, transcode, false, false));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 ASSERT_EQ(s, u);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 // Pass-through test with zlib, no decompression occurs but deflate is sent
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 for (int cs = 0; cs < 3; cs++)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 BufferHttpSender sender;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 sender.SetChunkSize(cs);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 sender.GetBuffer() = t;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 HttpStreamTranscoder transcode(sender, CompressionType_ZlibWithSize);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 std::string u;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 ASSERT_TRUE(ReadAllStream(u, transcode, false, true));
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 ASSERT_EQ(t.size() - sizeof(uint64_t), u.size());
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 ASSERT_EQ(t.substr(sizeof(uint64_t)), u);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 }