comparison UnitTestsSources/FileStorageTests.cpp @ 1514:d73a2178b319

support of deflate and gzip content-types
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Aug 2015 16:43:59 +0200
parents f967bdf8534e
children e5e975e9b738
comparison
equal deleted inserted replaced
1513:fe07f82d83d3 1514:d73a2178b319
186 TEST(FileStorageAccessor, Compression) 186 TEST(FileStorageAccessor, Compression)
187 { 187 {
188 FilesystemStorage s("UnitTestsStorage"); 188 FilesystemStorage s("UnitTestsStorage");
189 CompressedFileStorageAccessor accessor(s); 189 CompressedFileStorageAccessor accessor(s);
190 190
191 accessor.SetCompressionForNextOperations(CompressionType_Zlib); 191 accessor.SetCompressionForNextOperations(CompressionType_ZlibWithSize);
192 std::string data = "Hello world"; 192 std::string data = "Hello world";
193 FileInfo info = accessor.Write(data, FileContentType_Dicom); 193 FileInfo info = accessor.Write(data, FileContentType_Dicom);
194 194
195 std::string r; 195 std::string r;
196 accessor.Read(r, info.GetUuid(), FileContentType_Unknown); 196 accessor.Read(r, info.GetUuid(), FileContentType_Unknown);
197 197
198 ASSERT_EQ(data, r); 198 ASSERT_EQ(data, r);
199 ASSERT_EQ(CompressionType_Zlib, info.GetCompressionType()); 199 ASSERT_EQ(CompressionType_ZlibWithSize, info.GetCompressionType());
200 ASSERT_EQ(11u, info.GetUncompressedSize()); 200 ASSERT_EQ(11u, info.GetUncompressedSize());
201 ASSERT_EQ(FileContentType_Dicom, info.GetContentType()); 201 ASSERT_EQ(FileContentType_Dicom, info.GetContentType());
202 } 202 }
203 203
204 204
209 209
210 std::string r; 210 std::string r;
211 std::string compressedData = "Hello"; 211 std::string compressedData = "Hello";
212 std::string uncompressedData = "HelloWorld"; 212 std::string uncompressedData = "HelloWorld";
213 213
214 accessor.SetCompressionForNextOperations(CompressionType_Zlib); 214 accessor.SetCompressionForNextOperations(CompressionType_ZlibWithSize);
215 FileInfo compressedInfo = accessor.Write(compressedData, FileContentType_Dicom); 215 FileInfo compressedInfo = accessor.Write(compressedData, FileContentType_Dicom);
216 216
217 accessor.SetCompressionForNextOperations(CompressionType_None); 217 accessor.SetCompressionForNextOperations(CompressionType_None);
218 FileInfo uncompressedInfo = accessor.Write(uncompressedData, FileContentType_Dicom); 218 FileInfo uncompressedInfo = accessor.Write(uncompressedData, FileContentType_Dicom);
219 219
220 accessor.SetCompressionForNextOperations(CompressionType_Zlib); 220 accessor.SetCompressionForNextOperations(CompressionType_ZlibWithSize);
221 accessor.Read(r, compressedInfo.GetUuid(), FileContentType_Unknown); 221 accessor.Read(r, compressedInfo.GetUuid(), FileContentType_Unknown);
222 ASSERT_EQ(compressedData, r); 222 ASSERT_EQ(compressedData, r);
223 223
224 accessor.SetCompressionForNextOperations(CompressionType_None); 224 accessor.SetCompressionForNextOperations(CompressionType_None);
225 accessor.Read(r, compressedInfo.GetUuid(), FileContentType_Unknown); 225 accessor.Read(r, compressedInfo.GetUuid(), FileContentType_Unknown);
226 ASSERT_NE(compressedData, r); 226 ASSERT_NE(compressedData, r);
227 227
228 /* 228 /*
229 // This test is too slow on Windows 229 // This test is too slow on Windows
230 accessor.SetCompressionForNextOperations(CompressionType_Zlib); 230 accessor.SetCompressionForNextOperations(CompressionType_ZlibWithSize);
231 ASSERT_THROW(accessor.Read(r, uncompressedInfo.GetUuid(), FileContentType_Unknown), OrthancException); 231 ASSERT_THROW(accessor.Read(r, uncompressedInfo.GetUuid(), FileContentType_Unknown), OrthancException);
232 */ 232 */
233 } 233 }