summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2022-12-11 19:21:36 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-12 14:16:42 +0100
commit9a3e95785e80a6b03e8d71605ddb603bb6776b69 (patch)
treeabeba5b04e7b452041dc3054fbac56dc1b91d482 /Tests
parent6c7c5a6786f5f168b9e228f9d4b41ed1e64bc8f3 (diff)
downloadserenity-9a3e95785e80a6b03e8d71605ddb603bb6776b69.zip
LibCore: Propagate errors from `Stream::*_entire_buffer`
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibCore/TestLibCoreStream.cpp14
-rw-r--r--Tests/LibCpp/test-cpp-parser.cpp3
-rw-r--r--Tests/LibCpp/test-cpp-preprocessor.cpp3
-rw-r--r--Tests/LibJS/test-test262.cpp4
-rw-r--r--Tests/LibMarkdown/TestCommonmark.cpp3
-rw-r--r--Tests/LibTLS/TestTLSHandshake.cpp6
6 files changed, 15 insertions, 18 deletions
diff --git a/Tests/LibCore/TestLibCoreStream.cpp b/Tests/LibCore/TestLibCoreStream.cpp
index a56bc32044..40c7f92fd5 100644
--- a/Tests/LibCore/TestLibCoreStream.cpp
+++ b/Tests/LibCore/TestLibCoreStream.cpp
@@ -87,17 +87,17 @@ TEST_CASE(file_seeking_around)
EXPECT(!file->seek(500, Core::Stream::SeekMode::SetPosition).is_error());
EXPECT_EQ(file->tell().release_value(), 500);
- EXPECT(file->read_entire_buffer(buffer));
+ EXPECT(!file->read_entire_buffer(buffer).is_error());
EXPECT_EQ(buffer_contents, expected_seek_contents1);
EXPECT(!file->seek(234, Core::Stream::SeekMode::FromCurrentPosition).is_error());
EXPECT_EQ(file->tell().release_value(), 750);
- EXPECT(file->read_entire_buffer(buffer));
+ EXPECT(!file->read_entire_buffer(buffer).is_error());
EXPECT_EQ(buffer_contents, expected_seek_contents2);
EXPECT(!file->seek(-105, Core::Stream::SeekMode::FromEndPosition).is_error());
EXPECT_EQ(file->tell().release_value(), 8597);
- EXPECT(file->read_entire_buffer(buffer));
+ EXPECT(!file->read_entire_buffer(buffer).is_error());
EXPECT_EQ(buffer_contents, expected_seek_contents3);
}
@@ -120,7 +120,7 @@ TEST_CASE(file_adopt_fd)
EXPECT(!file->seek(500, Core::Stream::SeekMode::SetPosition).is_error());
EXPECT_EQ(file->tell().release_value(), 500);
- EXPECT(file->read_entire_buffer(buffer));
+ EXPECT(!file->read_entire_buffer(buffer).is_error());
EXPECT_EQ(buffer_contents, expected_seek_contents1);
// A single seek & read test should be fine for now.
@@ -218,7 +218,7 @@ TEST_CASE(tcp_socket_write)
auto server_socket = maybe_server_socket.release_value();
EXPECT(!server_socket->set_blocking(true).is_error());
- EXPECT(client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }));
+ EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error());
client_socket->close();
auto maybe_receive_buffer = ByteBuffer::create_uninitialized(64);
@@ -282,7 +282,7 @@ TEST_CASE(udp_socket_read_write)
auto client_socket = maybe_client_socket.release_value();
EXPECT(client_socket->is_open());
- EXPECT(client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }));
+ EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error());
// FIXME: UDPServer::receive sadly doesn't give us a way to block on it,
// currently.
@@ -400,7 +400,7 @@ TEST_CASE(local_socket_write)
EXPECT(!maybe_client_socket.is_error());
auto client_socket = maybe_client_socket.release_value();
- EXPECT(client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }));
+ EXPECT(!client_socket->write_entire_buffer({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error());
client_socket->close();
return 0;
diff --git a/Tests/LibCpp/test-cpp-parser.cpp b/Tests/LibCpp/test-cpp-parser.cpp
index da019721ec..681368d2ca 100644
--- a/Tests/LibCpp/test-cpp-parser.cpp
+++ b/Tests/LibCpp/test-cpp-parser.cpp
@@ -18,8 +18,7 @@ static DeprecatedString read_all(DeprecatedString const& path)
auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
auto file_size = MUST(file->size());
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
- if (!file->read_entire_buffer(content.bytes()))
- VERIFY_NOT_REACHED();
+ MUST(file->read_entire_buffer(content.bytes()));
return DeprecatedString { content.bytes() };
}
diff --git a/Tests/LibCpp/test-cpp-preprocessor.cpp b/Tests/LibCpp/test-cpp-preprocessor.cpp
index 8b973615e6..924d5c4d53 100644
--- a/Tests/LibCpp/test-cpp-preprocessor.cpp
+++ b/Tests/LibCpp/test-cpp-preprocessor.cpp
@@ -17,8 +17,7 @@ static DeprecatedString read_all(DeprecatedString const& path)
auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
auto file_size = MUST(file->size());
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
- if (!file->read_entire_buffer(content.bytes()))
- VERIFY_NOT_REACHED();
+ MUST(file->read_entire_buffer(content.bytes()));
return DeprecatedString { content.bytes() };
}
diff --git a/Tests/LibJS/test-test262.cpp b/Tests/LibJS/test-test262.cpp
index 46651647dd..efc28fb039 100644
--- a/Tests/LibJS/test-test262.cpp
+++ b/Tests/LibJS/test-test262.cpp
@@ -161,7 +161,7 @@ public:
}
for (DeprecatedString const& line : lines) {
- if (!m_output->write_entire_buffer(DeprecatedString::formatted("{}\n", line).bytes()))
+ if (m_output->write_entire_buffer(DeprecatedString::formatted("{}\n", line).bytes()).is_error())
break;
}
@@ -427,7 +427,7 @@ void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<Deprec
complete_results.set("duration", time_taken_in_ms / 1000.);
complete_results.set("results", result_object);
- if (!file->write_entire_buffer(complete_results.to_deprecated_string().bytes()))
+ if (file->write_entire_buffer(complete_results.to_deprecated_string().bytes()).is_error())
warnln("Failed to write per-file");
file->close();
}
diff --git a/Tests/LibMarkdown/TestCommonmark.cpp b/Tests/LibMarkdown/TestCommonmark.cpp
index a3a5e720cd..5d85c61023 100644
--- a/Tests/LibMarkdown/TestCommonmark.cpp
+++ b/Tests/LibMarkdown/TestCommonmark.cpp
@@ -22,8 +22,7 @@ TEST_SETUP
auto file = file_or_error.release_value();
auto file_size = MUST(file->size());
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
- if (!file->read_entire_buffer(content.bytes()))
- VERIFY_NOT_REACHED();
+ MUST(file->read_entire_buffer(content.bytes()));
DeprecatedString test_data { content.bytes() };
auto tests = JsonParser(test_data).parse().value().as_array();
diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp
index f9b47d657f..8f0a96e7cb 100644
--- a/Tests/LibTLS/TestTLSHandshake.cpp
+++ b/Tests/LibTLS/TestTLSHandshake.cpp
@@ -96,17 +96,17 @@ TEST_CASE(test_TLS_hello_handshake)
loop.quit(0);
};
- if (!tls->write_entire_buffer("GET / HTTP/1.1\r\nHost: "_b)) {
+ if (tls->write_entire_buffer("GET / HTTP/1.1\r\nHost: "_b).is_error()) {
FAIL("write(0) failed");
return;
}
auto the_server = DEFAULT_SERVER;
- if (!tls->write_entire_buffer(the_server.bytes())) {
+ if (tls->write_entire_buffer(the_server.bytes()).is_error()) {
FAIL("write(1) failed");
return;
}
- if (!tls->write_entire_buffer("\r\nConnection : close\r\n\r\n"_b)) {
+ if (tls->write_entire_buffer("\r\nConnection : close\r\n\r\n"_b).is_error()) {
FAIL("write(2) failed");
return;
}