mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
AK/ByteBuffer+Everywhere: Handle errors in ByteBuffer::slice()
This commit is contained in:
parent
c0486f93d4
commit
c10d48b72c
12 changed files with 45 additions and 34 deletions
|
@ -72,9 +72,9 @@ static bool test_single(Testcase<TArg> const& testcase)
|
|||
|
||||
// Checking the results:
|
||||
bool return_ok = actual_return == testcase.expected_return;
|
||||
bool canary_1_ok = actual.slice(0, SANDBOX_CANARY_SIZE) == expected.slice(0, SANDBOX_CANARY_SIZE);
|
||||
bool main_ok = actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n);
|
||||
bool canary_2_ok = actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE);
|
||||
bool canary_1_ok = MUST(actual.slice(0, SANDBOX_CANARY_SIZE)) == MUST(expected.slice(0, SANDBOX_CANARY_SIZE));
|
||||
bool main_ok = MUST(actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)) == MUST(expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n));
|
||||
bool canary_2_ok = MUST(actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)) == MUST(expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE));
|
||||
bool buf_ok = actual == expected;
|
||||
|
||||
// Evaluate gravity:
|
||||
|
@ -85,20 +85,20 @@ static bool test_single(Testcase<TArg> const& testcase)
|
|||
if (!canary_1_ok) {
|
||||
warnln("Canary 1 overwritten: Expected {}\n"
|
||||
" instead got {}",
|
||||
show(expected.slice(0, SANDBOX_CANARY_SIZE)),
|
||||
show(actual.slice(0, SANDBOX_CANARY_SIZE)));
|
||||
show(MUST(expected.slice(0, SANDBOX_CANARY_SIZE))),
|
||||
show(MUST(actual.slice(0, SANDBOX_CANARY_SIZE))));
|
||||
}
|
||||
if (!main_ok) {
|
||||
warnln("Wrong output: Expected {}\n"
|
||||
" instead, got {}",
|
||||
show(expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)),
|
||||
show(actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)));
|
||||
show(MUST(expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n))),
|
||||
show(MUST(actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n))));
|
||||
}
|
||||
if (!canary_2_ok) {
|
||||
warnln("Canary 2 overwritten: Expected {}\n"
|
||||
" instead, got {}",
|
||||
show(expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)),
|
||||
show(actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)));
|
||||
show(MUST(expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE))),
|
||||
show(MUST(actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE))));
|
||||
}
|
||||
if (!return_ok) {
|
||||
warnln("Wrong return value: Expected {}, got {} instead!", testcase.expected_return, actual_return);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue