comparison UnitTestsSources/UnitTestsMain.cpp @ 3357:c0aa5f1cf2f5

new class: FileBuffer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 May 2019 09:22:36 +0200
parents b21d4cc8e5d1
children c08bb6ac3b7f
comparison
equal deleted inserted replaced
3356:f744730c294b 3357:c0aa5f1cf2f5
37 #include "gtest/gtest.h" 37 #include "gtest/gtest.h"
38 38
39 #include <ctype.h> 39 #include <ctype.h>
40 40
41 #include "../Core/DicomFormat/DicomTag.h" 41 #include "../Core/DicomFormat/DicomTag.h"
42 #include "../Core/FileBuffer.h"
42 #include "../Core/HttpServer/HttpToolbox.h" 43 #include "../Core/HttpServer/HttpToolbox.h"
43 #include "../Core/Logging.h" 44 #include "../Core/Logging.h"
44 #include "../Core/MetricsRegistry.h" 45 #include "../Core/MetricsRegistry.h"
45 #include "../Core/OrthancException.h" 46 #include "../Core/OrthancException.h"
46 #include "../Core/TemporaryFile.h" 47 #include "../Core/TemporaryFile.h"
674 ASSERT_EQ(0, memcmp(s.c_str(), h.c_str(), s.size())); 675 ASSERT_EQ(0, memcmp(s.c_str(), h.c_str(), s.size()));
675 } 676 }
676 677
677 std::string u; 678 std::string u;
678 ASSERT_THROW(SystemToolbox::ReadFile(u, path.c_str()), OrthancException); 679 ASSERT_THROW(SystemToolbox::ReadFile(u, path.c_str()), OrthancException);
680 }
681
682
683 TEST(Toolbox, FileBuffer)
684 {
685 FileBuffer f;
686 f.Append("a", 1);
687 f.Append("", 0);
688 f.Append("bc", 2);
689
690 std::string s;
691 f.Read(s);
692 ASSERT_EQ("abc", s);
693
694 ASSERT_THROW(f.Append("d", 1), OrthancException); // File is closed
679 } 695 }
680 696
681 697
682 TEST(Toolbox, Wildcard) 698 TEST(Toolbox, Wildcard)
683 { 699 {