Skip to content
Bitcoin Roots

v29.4-roots.4 · Commit 30: [PATCH 30/37] fix(release): close local gate findings

src/test/streams_tests.cpp

Before: src/test/streams_tests.cpp · After: src/test/streams_tests.cpp

File metadata
index 777122df6d03aaee20453beb084870be2d30a86a..580682a353f55f912ea943211140b3118382a157 100644

Download original patch · Release notes

Diff rows 1–24 of 24. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

src/test/streams_tests.cpp CHANGED
@@ -14,6 +14,24 @@ using namespace std::string_literals;
14
14
 
15
15
  BOOST_FIXTURE_TEST_SUITE(streams_tests, BasicTestingSetup)
16
16
 
17
+ BOOST_AUTO_TEST_CASE(autofile_empty_write)
18
+ {
19
+ const fs::path path{m_args.GetDataDirBase() / "empty_write.bin"};
20
+ const std::vector<std::byte> empty;
21
+ {
22
+ AutoFile file{fsbridge::fopen(path, "wb")};
23
+ file << Span{empty};
24
+ file << std::byte{0x2a};
25
+ }
26
+ {
27
+ AutoFile file{fsbridge::fopen(path, "rb")};
28
+ std::byte value;
29
+ file >> value;
30
+ BOOST_CHECK_EQUAL(value, std::byte{0x2a});
31
+ BOOST_CHECK_EXCEPTION(file >> value, std::ios_base::failure, HasReason{"AutoFile::read: end of file"});
32
+ }
33
+ }
34
+
17
35
  BOOST_AUTO_TEST_CASE(xor_file)
18
36
  {
19
37
  fs::path xor_path{m_args.GetDataDirBase() / "test_xor.bin"};