Mercurial > hg > orthanc-databases
comparison MySQL/UnitTests/UnitTestsMain.cpp @ 194:a51ce147dbe0
refactoring using new class StorageAreaBuffer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 08 Jan 2021 14:40:03 +0100 |
parents | 3236894320d6 |
children | 53bd9022c58b |
comparison
equal
deleted
inserted
replaced
193:3236894320d6 | 194:a51ce147dbe0 |
---|---|
161 std::string uuid = boost::lexical_cast<std::string>(i); | 161 std::string uuid = boost::lexical_cast<std::string>(i); |
162 std::string value = "Value " + boost::lexical_cast<std::string>(i * 2); | 162 std::string value = "Value " + boost::lexical_cast<std::string>(i * 2); |
163 storageArea.Create(transaction, uuid, value.c_str(), value.size(), OrthancPluginContentType_Unknown); | 163 storageArea.Create(transaction, uuid, value.c_str(), value.size(), OrthancPluginContentType_Unknown); |
164 } | 164 } |
165 | 165 |
166 std::string tmp; | 166 OrthancDatabases::StorageAreaBuffer buffer; |
167 ASSERT_THROW(storageArea.ReadToString(tmp, transaction, "nope", OrthancPluginContentType_Unknown), | 167 ASSERT_THROW(storageArea.Read(buffer, transaction, "nope", OrthancPluginContentType_Unknown), |
168 Orthanc::OrthancException); | 168 Orthanc::OrthancException); |
169 | 169 |
170 ASSERT_EQ(10, CountFiles(db)); | 170 ASSERT_EQ(10, CountFiles(db)); |
171 storageArea.Remove(transaction, "5", OrthancPluginContentType_Unknown); | 171 storageArea.Remove(transaction, "5", OrthancPluginContentType_Unknown); |
172 | 172 |
178 std::string expected = "Value " + boost::lexical_cast<std::string>(i * 2); | 178 std::string expected = "Value " + boost::lexical_cast<std::string>(i * 2); |
179 std::string content; | 179 std::string content; |
180 | 180 |
181 if (i == 5) | 181 if (i == 5) |
182 { | 182 { |
183 ASSERT_THROW(storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown), | 183 ASSERT_THROW(storageArea.Read(buffer, transaction, uuid, OrthancPluginContentType_Unknown), |
184 Orthanc::OrthancException); | 184 Orthanc::OrthancException); |
185 } | 185 } |
186 else | 186 else |
187 { | 187 { |
188 storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown); | 188 storageArea.Read(buffer, transaction, uuid, OrthancPluginContentType_Unknown); |
189 ASSERT_EQ(expected, content); | 189 |
190 std::string s; | |
191 buffer.ToString(s); | |
192 ASSERT_EQ(expected, s); | |
190 } | 193 } |
191 } | 194 } |
192 | 195 |
193 for (int i = 0; i < 10; i++) | 196 for (int i = 0; i < 10; i++) |
194 { | 197 { |