diff UnitTests/main.cpp @ 483:8c3573d28868

export dicom instances to the filesystem
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 16 Jul 2013 12:01:39 +0200
parents 4aae0261515e
children b22312081388 09b836088f63
line wrap: on
line diff
--- a/UnitTests/main.cpp	Tue Jul 16 11:30:24 2013 +0200
+++ b/UnitTests/main.cpp	Tue Jul 16 12:01:39 2013 +0200
@@ -451,6 +451,35 @@
 }
 
 
+TEST(Toolbox, WriteFile)
+{
+  std::string path;
+
+  {
+    Toolbox::TemporaryFile tmp;
+    path = tmp.GetPath();
+
+    std::string s;
+    s.append("Hello");
+    s.push_back('\0');
+    s.append("World");
+    ASSERT_EQ(11u, s.size());
+
+    Toolbox::WriteFile(s, path.c_str());
+
+    std::string t;
+    Toolbox::ReadFile(t, path.c_str());
+
+    ASSERT_EQ(11u, t.size());
+    ASSERT_EQ(0, t[5]);
+    ASSERT_EQ(0, memcmp(s.c_str(), t.c_str(), s.size()));
+  }
+
+  std::string u;
+  ASSERT_THROW(Toolbox::ReadFile(u, path.c_str()), OrthancException);
+}
+
+
 int main(int argc, char **argv)
 {
   // Initialize Google's logging library.