v30.3-roots.1 · Commit 2: [PATCH 02/68] feat(runtime): preserve Roots operator controls on Core 30.3
src/test/fs_tests.cpp
Before: src/test/fs_tests.cpp · After: src/test/fs_tests.cpp
File metadata
index c237963af3e96de8852377628140e5d9ba656747..3fdedc413698cc398c3ff1f47d72869a10d0360d 100644
Download original patch · Release notes
Diff rows 1–34 of 34. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/test/fs_tests.cpp
CHANGED
|
@@ -8,9 +8,12 @@
|
|
| 8 |
|
| 9 |
#include <boost/test/unit_test.hpp>
|
| 10 |
|
|
|
|
| 11 |
#include <fstream>
|
| 12 |
#include <ios>
|
|
|
|
| 13 |
#include <string>
|
|
|
|
| 14 |
|
| 15 |
BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
|
| 16 |
|
|
@@ -163,4 +166,22 @@ BOOST_AUTO_TEST_CASE(create_directories)
|
|
| 163 |
}
|
| 164 |
#endif // __MINGW64__
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
BOOST_AUTO_TEST_SUITE_END()
|
|
|
|
| 8 |
|
| 9 |
#include <boost/test/unit_test.hpp>
|
| 10 |
|
| 11 |
+
#include <cstdio>
|
| 12 |
#include <fstream>
|
| 13 |
#include <ios>
|
| 14 |
+
#include <memory>
|
| 15 |
#include <string>
|
| 16 |
+
#include <vector>
|
| 17 |
|
| 18 |
BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
|
| 19 |
|
|
|
|
| 166 |
}
|
| 167 |
#endif // __MINGW64__
|
| 168 |
|
| 169 |
+
BOOST_AUTO_TEST_CASE(allocate_file_range_preserves_data)
|
| 170 |
+
{
|
| 171 |
+
const auto path{m_args.GetDataDirBase() / "allocate-range.dat"};
|
| 172 |
+
const auto close_file{[](FILE* file) { std::fclose(file); }};
|
| 173 |
+
std::unique_ptr<FILE, decltype(close_file)> file{fsbridge::fopen(path, "w+b"), close_file};
|
| 174 |
+
BOOST_REQUIRE(file);
|
| 175 |
+
std::vector<unsigned char> contents(3 * 65536);
|
| 176 |
+
for (size_t i{0}; i < contents.size(); ++i) contents[i] = static_cast<unsigned char>(i / 65536 + 1);
|
| 177 |
+
BOOST_REQUIRE_EQUAL(std::fwrite(contents.data(), 1, contents.size(), file.get()), contents.size());
|
| 178 |
+
BOOST_REQUIRE_EQUAL(std::fflush(file.get()), 0);
|
| 179 |
+
|
| 180 |
+
AllocateFileRange(file.get(), 0, static_cast<unsigned int>(contents.size() + 256));
|
| 181 |
+
BOOST_REQUIRE_EQUAL(std::fseek(file.get(), 0, SEEK_SET), 0);
|
| 182 |
+
std::vector<unsigned char> actual(contents.size());
|
| 183 |
+
BOOST_REQUIRE_EQUAL(std::fread(actual.data(), 1, actual.size(), file.get()), actual.size());
|
| 184 |
+
BOOST_CHECK(actual == contents);
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
BOOST_AUTO_TEST_SUITE_END()
|