core: add utils::findDataFile() / samples::findFile()

This commit is contained in:
Alexander Alekhin
2017-03-12 04:49:07 +00:00
parent e5afa62c3d
commit 2fa9bd221d
10 changed files with 715 additions and 5 deletions
+18
View File
@@ -2,6 +2,7 @@
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
#include "opencv2/core/utils/logger.hpp"
namespace opencv_test { namespace {
@@ -283,4 +284,21 @@ TEST(CommandLineParser, testScalar)
EXPECT_EQ(parser.get<Scalar>("s5"), Scalar(5, -4, 3, 2));
}
TEST(Samples, findFile)
{
cv::utils::logging::LogLevel prev = cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_VERBOSE);
cv::String path;
ASSERT_NO_THROW(path = samples::findFile("lena.jpg", false));
EXPECT_NE(std::string(), path.c_str());
cv::utils::logging::setLogLevel(prev);
}
TEST(Samples, findFile_missing)
{
cv::utils::logging::LogLevel prev = cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_VERBOSE);
cv::String path;
ASSERT_ANY_THROW(path = samples::findFile("non-existed.file", true));
cv::utils::logging::setLogLevel(prev);
}
}} // namespace