Test if write_file() creates empty files, too
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 15 Feb 2012 09:01:27 +0000 (10:01 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 15 Feb 2012 09:01:27 +0000 (10:01 +0100)
test/test_filefunc.cpp

index 09c6d3b..860439e 100644 (file)
@@ -415,4 +415,23 @@ BOOST_AUTO_TEST_CASE(ChangeDirectory)
     BOOST_REQUIRE_EQUAL(current_directory, I2n::getcwd());
 }
 
+BOOST_AUTO_TEST_CASE(WriteFileEmptyData)
+{
+    // just to be sure
+    unlink(".foobar");
+
+    I2n::Stat stat(".foobar");
+    BOOST_CHECK_EQUAL( false, (bool)stat );
+
+    // Call write_file() with empty data. Should still create the file.
+    write_file(".foobar","");
+
+    stat.recheck();
+
+    BOOST_CHECK_EQUAL( true, (bool)stat );
+    BOOST_CHECK_EQUAL( true, stat.size() == 0 );
+
+    unlink(".foobar");
+}
+
 BOOST_AUTO_TEST_SUITE_END()