From 7384d58a0a93a1e0f275506ad02a6a134c8cff11 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Thu, 23 Apr 2020 02:52:26 +0430 Subject: [PATCH] Userland: Adapt test-crypto to the new AK::Result API --- Userland/test-crypto.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Userland/test-crypto.cpp b/Userland/test-crypto.cpp index 2c97afb57f..5fc18b7e02 100644 --- a/Userland/test-crypto.cpp +++ b/Userland/test-crypto.cpp @@ -88,7 +88,11 @@ int run(Function fn) return 1; } auto file = Core::File::open(filename, Core::IODevice::OpenMode::ReadOnly); - auto buffer = file->read_all(); + if (file.is_error()) { + printf("That's a weird file man...\n"); + return 1; + } + auto buffer = file.value()->read_all(); fn((const char*)buffer.data(), buffer.size()); } return 0; @@ -1014,8 +1018,13 @@ void tls_test_client_hello() tls->on_tls_finished = [&] { PASS; auto file = Core::File::open("foo.response", Core::IODevice::WriteOnly); - file->write(contents); - file->close(); + if (file.is_error()) { + printf("Can't write there, %s\n", file.error().characters()); + loop.quit(2); + return; + } + file.value()->write(contents); + file.value()->close(); loop.quit(0); }; tls->on_tls_error = [&](TLS::AlertDescription) {