LibCrypto: Add Formatter<SignedBigInteger>
Useful for seeing SignedBigInteger values in test failure messages.
This commit is contained in:
parent
b87e517deb
commit
ec37eadb39
Notes:
sideshowbarker
2024-07-18 00:34:07 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/ec37eadb394 Pull-request: https://github.com/SerenityOS/serenity/pull/11996 Reviewed-by: https://github.com/alimpfard
2 changed files with 12 additions and 0 deletions
|
@ -308,3 +308,10 @@ bool SignedBigInteger::operator>=(const SignedBigInteger& other) const
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
ErrorOr<void> AK::Formatter<Crypto::SignedBigInteger>::format(FormatBuilder& fmtbuilder, const Crypto::SignedBigInteger& value)
|
||||
{
|
||||
if (value.is_negative())
|
||||
TRY(fmtbuilder.put_string("-"));
|
||||
return Formatter<Crypto::UnsignedBigInteger>::format(fmtbuilder, value.unsigned_value());
|
||||
}
|
||||
|
|
|
@ -143,6 +143,11 @@ struct SignedDivisionResult {
|
|||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Crypto::SignedBigInteger> : AK::Formatter<Crypto::UnsignedBigInteger> {
|
||||
ErrorOr<void> format(FormatBuilder&, Crypto::SignedBigInteger const&);
|
||||
};
|
||||
|
||||
inline Crypto::SignedBigInteger
|
||||
operator""_sbigint(const char* string, size_t length)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue