|
7 | 7 |
|
8 | 8 | #include <string>
|
9 | 9 |
|
| 10 | +static void read_from_decompressor(int fd) { |
| 11 | + osmium::io::Bzip2Decompressor decomp{fd}; |
| 12 | + decomp.read(); |
| 13 | + decomp.close(); |
| 14 | +} |
| 15 | + |
10 | 16 | TEST_CASE("Invalid file descriptor of bzip2-compressed file") {
|
11 |
| - REQUIRE_THROWS_AS(osmium::io::Bzip2Decompressor{-1}, std::system_error); |
| 17 | + REQUIRE_THROWS(read_from_decompressor(-1)); |
12 | 18 | }
|
13 | 19 |
|
14 | 20 | TEST_CASE("Non-open file descriptor of bzip2-compressed file") {
|
15 | 21 | // 12345 is just a random file descriptor that should not be open
|
16 |
| - REQUIRE_THROWS_AS(osmium::io::Bzip2Decompressor{12345}, std::system_error); |
| 22 | + REQUIRE_THROWS(read_from_decompressor(12345)); |
17 | 23 | }
|
18 | 24 |
|
19 | 25 | TEST_CASE("Empty bzip2-compressed file") {
|
@@ -93,13 +99,19 @@ TEST_CASE("Corrupted bzip2-compressed file") {
|
93 | 99 | REQUIRE(count == count_fds());
|
94 | 100 | }
|
95 | 101 |
|
| 102 | +static void write_to_compressor(int fd) { |
| 103 | + osmium::io::Bzip2Compressor comp{fd, osmium::io::fsync::yes}; |
| 104 | + comp.write("foo"); |
| 105 | + comp.close(); |
| 106 | +} |
| 107 | + |
96 | 108 | TEST_CASE("Compressor: Invalid file descriptor for bzip2-compressed file") {
|
97 |
| - REQUIRE_THROWS_AS(osmium::io::Bzip2Compressor(-1, osmium::io::fsync::yes), std::system_error); |
| 109 | + REQUIRE_THROWS(write_to_compressor(-1)); |
98 | 110 | }
|
99 | 111 |
|
100 | 112 | TEST_CASE("Compressor: Non-open file descriptor for bzip2-compressed file") {
|
101 | 113 | // 12345 is just a random file descriptor that should not be open
|
102 |
| - REQUIRE_THROWS_AS(osmium::io::Bzip2Compressor(12345, osmium::io::fsync::yes), std::system_error); |
| 114 | + REQUIRE_THROWS(write_to_compressor(12345)); |
103 | 115 | }
|
104 | 116 |
|
105 | 117 | TEST_CASE("Write bzip2-compressed file with explicit close") {
|
|
0 commit comments