mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
AK: Add ability to check Optional equality with an OptionalNone
While we don't want to be writing this type of code in 'normal' code this is useful to do in tests as: EXPECT_EQ(my_optional, OptionalNone {}); Has a much better error on assertion failure when compared with: EXPECT(!my_optional.has_value());
This commit is contained in:
parent
e70272ddef
commit
f05c0509c3
Notes:
github-actions[bot]
2025-03-15 11:40:17 +00:00
Author: https://github.com/shannonbooth
Commit: f05c0509c3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3812
Reviewed-by: https://github.com/tcl3
Reviewed-by: https://github.com/trflynn89
1 changed files with 6 additions and 0 deletions
|
@ -570,6 +570,12 @@ ALWAYS_INLINE bool operator==(Optional<T1> const& first, T2 const& second)
|
|||
return first.has_value() && first.value() == second;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE bool operator==(Optional<T> const& first, OptionalNone)
|
||||
{
|
||||
return !first.has_value();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue