mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-08 10:51:17 +02:00
test: Add fs_tests/rename unit test
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
parent
d4999d40b9
commit
dc01cbc538
@ -118,4 +118,38 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(rename)
|
||||||
|
{
|
||||||
|
const fs::path tmpfolder{m_args.GetDataDirBase()};
|
||||||
|
|
||||||
|
const fs::path path1{GetUniquePath(tmpfolder)};
|
||||||
|
const fs::path path2{GetUniquePath(tmpfolder)};
|
||||||
|
|
||||||
|
const std::string path1_contents{"1111"};
|
||||||
|
const std::string path2_contents{"2222"};
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ofstream file{path1};
|
||||||
|
file << path1_contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ofstream file{path2};
|
||||||
|
file << path2_contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename path1 -> path2.
|
||||||
|
BOOST_CHECK(RenameOver(path1, path2));
|
||||||
|
|
||||||
|
BOOST_CHECK(!fs::exists(path1));
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ifstream file{path2};
|
||||||
|
std::string contents;
|
||||||
|
file >> contents;
|
||||||
|
BOOST_CHECK_EQUAL(contents, path1_contents);
|
||||||
|
}
|
||||||
|
fs::remove(path2);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
Loading…
x
Reference in New Issue
Block a user