Mercurial > hg > orthanc
annotate UnitTestsSources/FileStorage.cpp @ 2750:4c271054e044 Orthanc-0.7.3
close old branch
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 17 Jul 2018 09:39:43 +0200 |
parents | 9e3f21441903 |
children | 78b9f64b6b7b |
rev | line source |
---|---|
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #include "gtest/gtest.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 #include <ctype.h> |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 #include <glog/logging.h> |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 |
234 | 6 #include "../Core/FileStorage/FileStorage.h" |
224
4eb0c7ce86c9
refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
7 #include "../OrthancServer/ServerIndex.h" |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 #include "../Core/Toolbox.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 #include "../Core/OrthancException.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 #include "../Core/Uuid.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 #include "../Core/HttpServer/FilesystemHttpSender.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 #include "../Core/HttpServer/BufferHttpSender.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 #include "../Core/FileStorage/FileStorageAccessor.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 #include "../Core/FileStorage/CompressedFileStorageAccessor.h" |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 using namespace Orthanc; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 |
712 | 18 |
19 static void StringToVector(std::vector<uint8_t>& v, | |
20 const std::string& s) | |
21 { | |
22 v.resize(s.size()); | |
23 for (size_t i = 0; i < s.size(); i++) | |
24 v[i] = s[i]; | |
25 } | |
26 | |
27 | |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 TEST(FileStorage, Basic) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 FileStorage s("FileStorageUnitTests"); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 std::string data = Toolbox::GenerateUuid(); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 std::string uid = s.Create(data); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 std::string d; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 s.ReadFile(d, uid); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 ASSERT_EQ(d.size(), data.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size())); |
712 | 38 ASSERT_EQ(s.GetCompressedSize(uid), data.size()); |
39 } | |
40 | |
41 TEST(FileStorage, Basic2) | |
42 { | |
43 FileStorage s("FileStorageUnitTests"); | |
44 | |
45 std::vector<uint8_t> data; | |
46 StringToVector(data, Toolbox::GenerateUuid()); | |
47 std::string uid = s.Create(data); | |
48 std::string d; | |
49 s.ReadFile(d, uid); | |
50 ASSERT_EQ(d.size(), data.size()); | |
51 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size())); | |
52 ASSERT_EQ(s.GetCompressedSize(uid), data.size()); | |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 TEST(FileStorage, EndToEnd) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 FileStorage s("FileStorageUnitTests"); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 s.Clear(); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 std::list<std::string> u; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 for (unsigned int i = 0; i < 10; i++) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 u.push_back(s.Create(Toolbox::GenerateUuid())); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 std::set<std::string> ss; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 s.ListAllFiles(ss); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 ASSERT_EQ(10u, ss.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 unsigned int c = 0; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 for (std::list<std::string>::iterator |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 i = u.begin(); i != u.end(); i++, c++) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 ASSERT_TRUE(ss.find(*i) != ss.end()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 if (c < 5) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 s.Remove(*i); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 s.ListAllFiles(ss); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 ASSERT_EQ(5u, ss.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 s.Clear(); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 s.ListAllFiles(ss); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 ASSERT_EQ(0u, ss.size()); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 TEST(FileStorageAccessor, Simple) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 FileStorage s("FileStorageUnitTests"); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 FileStorageAccessor accessor(s); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 std::string data = "Hello world"; |
233 | 94 FileInfo info = accessor.Write(data, FileContentType_Dicom); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 std::string r; |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
97 accessor.Read(r, info.GetUuid()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 ASSERT_EQ(data, r); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
100 ASSERT_EQ(CompressionType_None, info.GetCompressionType()); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
101 ASSERT_EQ(11u, info.GetUncompressedSize()); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
102 ASSERT_EQ(11u, info.GetCompressedSize()); |
233 | 103 ASSERT_EQ(FileContentType_Dicom, info.GetContentType()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 TEST(FileStorageAccessor, NoCompression) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 FileStorage s("FileStorageUnitTests"); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 CompressedFileStorageAccessor accessor(s); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 accessor.SetCompressionForNextOperations(CompressionType_None); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 std::string data = "Hello world"; |
233 | 114 FileInfo info = accessor.Write(data, FileContentType_Dicom); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 std::string r; |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
117 accessor.Read(r, info.GetUuid()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 ASSERT_EQ(data, r); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
120 ASSERT_EQ(CompressionType_None, info.GetCompressionType()); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
121 ASSERT_EQ(11u, info.GetUncompressedSize()); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
122 ASSERT_EQ(11u, info.GetCompressedSize()); |
233 | 123 ASSERT_EQ(FileContentType_Dicom, info.GetContentType()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
712 | 127 TEST(FileStorageAccessor, NoCompression2) |
128 { | |
129 FileStorage s("FileStorageUnitTests"); | |
130 CompressedFileStorageAccessor accessor(s); | |
131 | |
132 accessor.SetCompressionForNextOperations(CompressionType_None); | |
133 std::vector<uint8_t> data; | |
134 StringToVector(data, "Hello world"); | |
135 FileInfo info = accessor.Write(data, FileContentType_Dicom); | |
136 | |
137 std::string r; | |
138 accessor.Read(r, info.GetUuid()); | |
139 | |
140 ASSERT_EQ(0, memcmp(&r[0], &data[0], data.size())); | |
141 ASSERT_EQ(CompressionType_None, info.GetCompressionType()); | |
142 ASSERT_EQ(11u, info.GetUncompressedSize()); | |
143 ASSERT_EQ(11u, info.GetCompressedSize()); | |
144 ASSERT_EQ(FileContentType_Dicom, info.GetContentType()); | |
145 } | |
146 | |
147 | |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 TEST(FileStorageAccessor, Compression) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 FileStorage s("FileStorageUnitTests"); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 CompressedFileStorageAccessor accessor(s); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 accessor.SetCompressionForNextOperations(CompressionType_Zlib); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 std::string data = "Hello world"; |
233 | 155 FileInfo info = accessor.Write(data, FileContentType_Dicom); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 std::string r; |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
158 accessor.Read(r, info.GetUuid()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 ASSERT_EQ(data, r); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
161 ASSERT_EQ(CompressionType_Zlib, info.GetCompressionType()); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
162 ASSERT_EQ(11u, info.GetUncompressedSize()); |
233 | 163 ASSERT_EQ(FileContentType_Dicom, info.GetContentType()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 } |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 TEST(FileStorageAccessor, Mix) |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 FileStorage s("FileStorageUnitTests"); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 CompressedFileStorageAccessor accessor(s); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 std::string r; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 std::string compressedData = "Hello"; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 std::string uncompressedData = "HelloWorld"; |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 accessor.SetCompressionForNextOperations(CompressionType_Zlib); |
233 | 177 FileInfo compressedInfo = accessor.Write(compressedData, FileContentType_Dicom); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 accessor.SetCompressionForNextOperations(CompressionType_None); |
233 | 180 FileInfo uncompressedInfo = accessor.Write(uncompressedData, FileContentType_Dicom); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 accessor.SetCompressionForNextOperations(CompressionType_Zlib); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
183 accessor.Read(r, compressedInfo.GetUuid()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 ASSERT_EQ(compressedData, r); |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 |
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 accessor.SetCompressionForNextOperations(CompressionType_None); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
187 accessor.Read(r, compressedInfo.GetUuid()); |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 ASSERT_NE(compressedData, r); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
189 |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
190 /* |
224
4eb0c7ce86c9
refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
191 // This test is too slow on Windows |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 accessor.SetCompressionForNextOperations(CompressionType_Zlib); |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
193 ASSERT_THROW(accessor.Read(r, uncompressedInfo.GetUuid()), OrthancException); |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
194 */ |
222
bd934af46ba4
unit test of storagearea in separate file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 } |