From c5935370f66200a2cbf873f5915ef1b0e053dd69 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 15 Feb 2012 10:01:27 +0100 Subject: [PATCH] Test if write_file() creates empty files, too --- test/test_filefunc.cpp | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/test/test_filefunc.cpp b/test/test_filefunc.cpp index 09c6d3b..860439e 100644 --- a/test/test_filefunc.cpp +++ b/test/test_filefunc.cpp @@ -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() -- 1.7.1