1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

Tests: Prefer TRY_OR_FAIL() and MUST() over EXPECT(!.is_error())

Note that in some cases (in particular SQL::Result and PDFErrorOr),
there is no Formatter defined for the error type, hence TRY_OR_FAIL
cannot work as-is. Furthermore, this commit leaves untouched the places
where MUST could be replaced by TRY_OR_FAIL.

Inspired by:
https://github.com/SerenityOS/serenity/pull/18710#discussion_r1186892445
This commit is contained in:
Ben Wiederhake 2023-05-07 20:14:06 +02:00 committed by Andrew Kaster
parent 87a7299078
commit f890b70eae
23 changed files with 415 additions and 742 deletions

View file

@ -141,7 +141,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
ScopeGuard guard([]() { unlink("/tmp/test.db"); });
{
auto heap = SQL::Heap::construct("/tmp/test.db");
EXPECT(!heap->open().is_error());
TRY_OR_FAIL(heap->open());
SQL::Serializer serializer(heap);
auto hash_index = setup_hash_index(serializer);
@ -159,7 +159,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
{
auto heap = SQL::Heap::construct("/tmp/test.db");
EXPECT(!heap->open().is_error());
TRY_OR_FAIL(heap->open());
SQL::Serializer serializer(heap);
auto hash_index = setup_hash_index(serializer);
@ -239,7 +239,7 @@ void insert_into_and_scan_hash_index(int num_keys)
ScopeGuard guard([]() { unlink("/tmp/test.db"); });
{
auto heap = SQL::Heap::construct("/tmp/test.db");
EXPECT(!heap->open().is_error());
TRY_OR_FAIL(heap->open());
SQL::Serializer serializer(heap);
auto hash_index = setup_hash_index(serializer);
@ -257,7 +257,7 @@ void insert_into_and_scan_hash_index(int num_keys)
{
auto heap = SQL::Heap::construct("/tmp/test.db");
EXPECT(!heap->open().is_error());
TRY_OR_FAIL(heap->open());
SQL::Serializer serializer(heap);
auto hash_index = setup_hash_index(serializer);
Vector<bool> found;