diff options
author | Kyungwook Tak <k.tak@samsung.com> | 2016-06-29 17:31:59 +0900 |
---|---|---|
committer | Kyungwook Tak <k.tak@samsung.com> | 2016-06-29 17:32:20 +0900 |
commit | 27fca410346f874bf5060835df072be54e0948fa (patch) | |
tree | 08dcb56b5a0296018c37f708037854944c0b9609 /test | |
parent | ac6c55df2708be332f5cacc6fc2eba9a7be29a6f (diff) | |
download | csr-framework-27fca410346f874bf5060835df072be54e0948fa.tar.gz csr-framework-27fca410346f874bf5060835df072be54e0948fa.tar.bz2 csr-framework-27fca410346f874bf5060835df072be54e0948fa.zip |
Change file visitor to dfs style not to have queue
Change-Id: I2bb154ce573468cbaab8fb0d32aae8f0e746ef20
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/internals/test-file-system.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/test/internals/test-file-system.cpp b/test/internals/test-file-system.cpp index b0aba7e..b848473 100644 --- a/test/internals/test-file-system.cpp +++ b/test/internals/test-file-system.cpp @@ -181,8 +181,8 @@ BOOST_AUTO_TEST_CASE(file_visitor_positive_modified) // if modifiedSince is same to modified time in file stat, // the file will be regarded as ''not modified'' no File::create returns null. - CHECK_IS_NOT_NULL(File::create(file, nullptr, beforeWrite)); - CHECK_IS_NULL(File::create(file, nullptr, afterWrite)); + CHECK_IS_NOT_NULL(File::createIfModified(file, nullptr, beforeWrite)); + CHECK_IS_NULL(File::createIfModified(file, nullptr, afterWrite)); } BOOST_AUTO_TEST_CASE(file_visitor_negative_non_existing) @@ -194,16 +194,17 @@ BOOST_AUTO_TEST_CASE(directory_visitor_positive_existing) { std::string dir(TEST_DIR_VISIT); + int cnt = 0; + // test for existing dir - auto visitor = FsVisitor::create(dir, true); + auto visitor = FsVisitor::create([&](const FilePtr &) { + ++cnt; + }, dir, true); CHECK_IS_NOT_NULL(visitor); - int cnt = 0; + visitor->run(); - while (visitor->next()) - cnt++; - - ASSERT_IF(cnt, 8); + ASSERT_IF(cnt, 9); } BOOST_AUTO_TEST_CASE(directory_visitor_positive_modified) @@ -215,24 +216,26 @@ BOOST_AUTO_TEST_CASE(directory_visitor_positive_modified) __writeFile(file); - auto visitor = FsVisitor::create(dir, true, beforeWrite); - CHECK_IS_NOT_NULL(visitor); - int cnt = 0; - while (visitor->next()) - cnt++; + auto visitor = FsVisitor::create([&](const FilePtr &) { + ++cnt; + }, dir, true, beforeWrite); + CHECK_IS_NOT_NULL(visitor); + + visitor->run(); ASSERT_IF(cnt, 1); } BOOST_AUTO_TEST_CASE(app_directory_visitor_positive) { - auto visitor = FsVisitor::create(TEST_DIR_APPS(), true); + auto visitor = FsVisitor::create([&](const FilePtr &file) { + BOOST_MESSAGE("visit target name: " << file->getPath()); + }, TEST_DIR_APPS(), true); CHECK_IS_NOT_NULL(visitor); - while (auto file = visitor->next()) - BOOST_MESSAGE("visit target name: " << file->getPath()); + visitor->run(); } BOOST_AUTO_TEST_SUITE_END() |