From c1a0882a58c841c3f07e2ea3f54fbe2cae346f93 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Wed, 25 Jan 2017 09:58:08 +0100 Subject: [PATCH] Ensure filefunc unit test works with all working dirs The __FILE__ macro contains an absolute path. --- test/test_filefunc.cpp | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/test_filefunc.cpp b/test/test_filefunc.cpp index 1fb51f8..4d5f931 100644 --- a/test/test_filefunc.cpp +++ b/test/test_filefunc.cpp @@ -98,7 +98,7 @@ BOOST_FIXTURE_TEST_SUITE(TestFileFunc, TestFileFuncFixture) BOOST_AUTO_TEST_CASE(StatTest1) { - I2n::Stat stat("Makefile"); + I2n::Stat stat(__FILE__); BOOST_CHECK_EQUAL( true, (bool)stat ); BOOST_CHECK_EQUAL( true, stat.is_regular_file() ); @@ -151,18 +151,20 @@ BOOST_AUTO_TEST_CASE(DirTest1) typedef std::vector< std::string > StringVector; StringVector names; - bool res= I2n::get_dir(".",names); + string test_dir = dirname(__FILE__); + bool res= I2n::get_dir(test_dir,names); BOOST_CHECK_EQUAL( true, res ); BOOST_CHECK( ! names.empty() ); - StringVector::iterator it = std::find( names.begin(), names.end(), "Makefile"); + BOOST_MESSAGE("Looking for " << basename(__FILE__) << " in " << test_dir); + StringVector::iterator it = std::find( names.begin(), names.end(), basename(__FILE__)); BOOST_CHECK( it != names.end() ); it = std::find( names.begin(), names.end(), "." ); BOOST_CHECK( it == names.end() ); - names= get_dir(".",true); + names= get_dir(test_dir,true); BOOST_CHECK( ! names.empty() ); for (it= names.begin(); it!=names.end(); ++it) -- 1.7.1