From 2cef015528db81a2ea1280d689d23a8c7a857487 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Wed, 28 Apr 2021 19:53:24 -0700 Subject: [PATCH] LibTest: Add EXPECT_NE(..) test assertion. --- Userland/Libraries/LibTest/Macros.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Libraries/LibTest/Macros.h b/Userland/Libraries/LibTest/Macros.h index aed190a707..64322d5adf 100644 --- a/Userland/Libraries/LibTest/Macros.h +++ b/Userland/Libraries/LibTest/Macros.h @@ -65,6 +65,16 @@ void current_test_case_did_fail(); } \ } while (false) +#define EXPECT_NE(a, b) \ + do { \ + auto lhs = (a); \ + auto rhs = (b); \ + if (lhs == rhs) { \ + ::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: EXPECT_NE({}, {}) failed with lhs={} and rhs={}", __FILE__, __LINE__, #a, #b, FormatIfSupported { lhs }, FormatIfSupported { rhs }); \ + ::Test::current_test_case_did_fail(); \ + } \ + } while (false) + #define EXPECT(x) \ do { \ if (!(x)) { \