annotate OrthancFramework/UnitTestsSources/StreamTests.cpp @ 4044:d25f4c0fa160 framework

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