Add negative forEachFile tests 12/238812/2
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 17 Jul 2020 12:11:56 +0000 (14:11 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 20 Jul 2020 08:52:20 +0000 (08:52 +0000)
Change-Id: Ic4869009234676967e3571868ad2fa1e1d950c6a

unit-tests/test_for-each-file.cpp

index 6a7954f..7de5ec3 100644 (file)
  * @author     Kyungwook Tak (k.tak@samsung.com)
  * @version    1.0
  */
-#include <for-each-file.h>
+#include <vector>
+#include <string>
 
 #include <boost_macros_wrapper.h>
 #include <boost/test/results_reporter.hpp>
 
-#include <vector>
-#include <string>
+#include <for-each-file.h>
+#include <exception.h>
 
 using namespace CKM;
 
+namespace {
+void unexpectedCallback(const std::string&)
+{
+       BOOST_FAIL("Unexpected callback");
+}
+
+} // anonymous namespace
+
 BOOST_AUTO_TEST_SUITE(TRAVERSE_DIR_TEST)
 
 POSITIVE_TEST_CASE(T010_check_prefix)
@@ -45,4 +54,16 @@ POSITIVE_TEST_CASE(T010_check_prefix)
                                                  "files num in traverse dir should be 10");
 }
 
+NEGATIVE_TEST_CASE(T020_not_existing_dir)
+{
+       BOOST_REQUIRE_THROW(forEachFile("/not/existing/dir", unexpectedCallback),
+                           Exc::FileSystemFailed);
+}
+
+NEGATIVE_TEST_CASE(T030_not_a_directory)
+{
+       BOOST_REQUIRE_THROW(forEachFile(DB_TEST_DIR "/traverse/res-1", unexpectedCallback),
+                           Exc::FileSystemFailed);
+}
+
 BOOST_AUTO_TEST_SUITE_END()