1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 10:27:36 +00:00

AK: Cover TestComplex with more tests

Related:
- video detailing the process of writing these tests: https://www.youtube.com/watch?v=enxglLlALvI
- PR fixing bugs the above effort found: https://github.com/SerenityOS/serenity/pull/22025
This commit is contained in:
Martin Janiczek 2023-12-30 16:27:41 +01:00 committed by Andrew Kaster
parent d52ffcd830
commit 5a8781393a
2 changed files with 199 additions and 0 deletions

View file

@ -277,6 +277,14 @@ static constexpr Complex<T> cexp(Complex<T> const& a)
}
}
template<AK::Concepts::Arithmetic T>
struct AK::Formatter<AK::Complex<T>> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, AK::Complex<T> c)
{
return Formatter<StringView>::format(builder, TRY(String::formatted("{}{:+}i", c.real(), c.imag())));
}
};
#if USING_AK_GLOBALLY
using AK::approx_eq;
using AK::cexp;