Mercurial > hg > orthanc-databases
comparison PostgreSQL/UnitTests/PostgreSQLTests.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 |
---|---|
354 std::string uuid = boost::lexical_cast<std::string>(i); | 354 std::string uuid = boost::lexical_cast<std::string>(i); |
355 std::string value = "Value " + boost::lexical_cast<std::string>(i * 2); | 355 std::string value = "Value " + boost::lexical_cast<std::string>(i * 2); |
356 storageArea.Create(transaction, uuid, value.c_str(), value.size(), OrthancPluginContentType_Unknown); | 356 storageArea.Create(transaction, uuid, value.c_str(), value.size(), OrthancPluginContentType_Unknown); |
357 } | 357 } |
358 | 358 |
359 std::string tmp; | 359 StorageAreaBuffer buffer; |
360 ASSERT_THROW(storageArea.ReadToString(tmp, transaction, "nope", OrthancPluginContentType_Unknown), | 360 ASSERT_THROW(storageArea.Read(buffer, transaction, "nope", OrthancPluginContentType_Unknown), |
361 Orthanc::OrthancException); | 361 Orthanc::OrthancException); |
362 | 362 |
363 ASSERT_EQ(10, CountLargeObjects(db)); | 363 ASSERT_EQ(10, CountLargeObjects(db)); |
364 storageArea.Remove(transaction, "5", OrthancPluginContentType_Unknown); | 364 storageArea.Remove(transaction, "5", OrthancPluginContentType_Unknown); |
365 | 365 |
367 | 367 |
368 for (int i = 0; i < 10; i++) | 368 for (int i = 0; i < 10; i++) |
369 { | 369 { |
370 std::string uuid = boost::lexical_cast<std::string>(i); | 370 std::string uuid = boost::lexical_cast<std::string>(i); |
371 std::string expected = "Value " + boost::lexical_cast<std::string>(i * 2); | 371 std::string expected = "Value " + boost::lexical_cast<std::string>(i * 2); |
372 std::string content; | |
373 | 372 |
374 if (i == 5) | 373 if (i == 5) |
375 { | 374 { |
376 ASSERT_THROW(storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown), | 375 ASSERT_THROW(storageArea.Read(buffer, transaction, uuid, OrthancPluginContentType_Unknown), |
377 Orthanc::OrthancException); | 376 Orthanc::OrthancException); |
378 } | 377 } |
379 else | 378 else |
380 { | 379 { |
381 storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown); | 380 storageArea.Read(buffer, transaction, uuid, OrthancPluginContentType_Unknown); |
382 ASSERT_EQ(expected, content); | 381 |
382 std::string s; | |
383 buffer.ToString(s); | |
384 ASSERT_EQ(expected, s); | |
383 } | 385 } |
384 } | 386 } |
385 | 387 |
386 for (int i = 0; i < 10; i++) | 388 for (int i = 0; i < 10; i++) |
387 { | 389 { |