readFileAsString(): Accept path as boost::filesystem::path instead of string

This commit is contained in:
Kamil Śliwak
2021-08-17 12:58:33 +02:00
parent 790d08f24b
commit cb1a0f08ca
9 changed files with 25 additions and 27 deletions
+1 -1
View File
@@ -168,7 +168,7 @@ pair<SourceMap, size_t> TestCaseReader::parseSourcesAndSettingsWithLineNumber(is
if (!fs::exists(externalSourceFullPath))
BOOST_THROW_EXCEPTION(runtime_error("External Source '" + externalSourceTarget.string() + "' not found."));
else
externalSourceContent = util::readFileAsString(externalSourceFullPath.string());
externalSourceContent = util::readFileAsString(externalSourceFullPath);
if (sources.count(externalSourceName))
BOOST_THROW_EXCEPTION(runtime_error("Multiple definitions of test source \"" + externalSourceName + "\"."));
+3 -3
View File
@@ -44,13 +44,13 @@ BOOST_AUTO_TEST_CASE(readFileAsString_regular_file)
TemporaryDirectory tempDir("common-io-test-");
createFileWithContent(tempDir.path() / "test.txt", "ABC\ndef\n");
BOOST_TEST(readFileAsString((tempDir.path() / "test.txt").string()) == "ABC\ndef\n");
BOOST_TEST(readFileAsString(tempDir.path() / "test.txt") == "ABC\ndef\n");
}
BOOST_AUTO_TEST_CASE(readFileAsString_directory)
{
TemporaryDirectory tempDir("common-io-test-");
BOOST_CHECK_THROW(readFileAsString(tempDir.path().string()), NotAFile);
BOOST_CHECK_THROW(readFileAsString(tempDir.path()), NotAFile);
}
BOOST_AUTO_TEST_CASE(readFileAsString_symlink)
@@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(readFileAsString_symlink)
if (!createSymlinkIfSupportedByFilesystem("test.txt", tempDir.path() / "symlink.txt"))
return;
BOOST_TEST(readFileAsString((tempDir.path() / "symlink.txt").string()) == "ABC\ndef\n");
BOOST_TEST(readFileAsString(tempDir.path() / "symlink.txt") == "ABC\ndef\n");
}
BOOST_AUTO_TEST_SUITE_END()