diff options
author | Archibald Elliott <archibald.elliott@arm.com> | 2022-01-21 13:14:58 +0000 |
---|---|---|
committer | Archibald Elliott <archibald.elliott@arm.com> | 2022-01-21 13:15:04 +0000 |
commit | 38ac4093d9d2ae28d631ca1cc5802533989165c5 (patch) | |
tree | 546e6b8ae75f6ef046e4e33f7c0bfb89ed172f1b /llvm/unittests/Support/ErrorTest.cpp | |
parent | 2b8e4c6e5fbd5ec3bf7b75fd6b1e11d66fde78a9 (diff) | |
download | llvm-38ac4093d9d2ae28d631ca1cc5802533989165c5.zip llvm-38ac4093d9d2ae28d631ca1cc5802533989165c5.tar.gz llvm-38ac4093d9d2ae28d631ca1cc5802533989165c5.tar.bz2 |
[NFCI][Support] Avoid ASSERT_/EXPECT_TRUE(A <op> B)
The error messages in tests are far better when a test fails if the test
is written using ASSERT_/EXPECT_<operator>(A, B) rather than
ASSERT_/EXPECT_TRUE(A <operator> B).
This commit updates all of llvm/unittests/Support to use these macros
where possible.
This change has not been possible in:
- llvm/unittests/Support/FSUniqueIDTest.cpp - due to not overloading
operators beyond ==, != and <.
- llvm/unittests/Support/BranchProbabilityTest.cpp - where the unchanged
tests are of the operator overloads themselves.
There are other possibilities of this conversion not being valid, which
have not applied in these tests, as they do not use NULL (they use
nullptr), and they do not use const char* (they use std::string or
StringRef).
Reviewed By: mubashar_
Differential Revision: https://reviews.llvm.org/D117319
Diffstat (limited to 'llvm/unittests/Support/ErrorTest.cpp')
-rw-r--r-- | llvm/unittests/Support/ErrorTest.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp index 3ca94b2..d4daced 100644 --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -179,7 +179,7 @@ TEST(Error, HandleCustomError) { CaughtErrorInfo = CE.getInfo(); }); - EXPECT_TRUE(CaughtErrorInfo == 42) << "Wrong result from CustomError handler"; + EXPECT_EQ(CaughtErrorInfo, 42) << "Wrong result from CustomError handler"; } // Check that handler type deduction also works for handlers @@ -253,7 +253,8 @@ TEST(Error, HandleCustomErrorWithCustomBaseClass) { CaughtErrorExtraInfo = SE.getExtraInfo(); }); - EXPECT_TRUE(CaughtErrorInfo == 42 && CaughtErrorExtraInfo == 7) + EXPECT_EQ(CaughtErrorInfo, 42) << "Wrong result from CustomSubError handler"; + EXPECT_EQ(CaughtErrorExtraInfo, 7) << "Wrong result from CustomSubError handler"; } @@ -270,9 +271,9 @@ TEST(Error, FirstHandlerOnly) { }, [&](const CustomError &CE) { DummyInfo = CE.getInfo(); }); - EXPECT_TRUE(CaughtErrorInfo == 42 && CaughtErrorExtraInfo == 7 && - DummyInfo == 0) - << "Activated the wrong Error handler(s)"; + EXPECT_EQ(CaughtErrorInfo, 42) << "Activated the wrong Error handler(s)"; + EXPECT_EQ(CaughtErrorExtraInfo, 7) << "Activated the wrong Error handler(s)"; + EXPECT_EQ(DummyInfo, 0) << "Activated the wrong Error handler(s)"; } // Check that general handlers shadow specific ones. @@ -289,7 +290,11 @@ TEST(Error, HandlerShadowing) { DummyExtraInfo = SE.getExtraInfo(); }); - EXPECT_TRUE(CaughtErrorInfo == 42 && DummyInfo == 0 && DummyExtraInfo == 0) + EXPECT_EQ(CaughtErrorInfo, 42) + << "General Error handler did not shadow specific handler"; + EXPECT_EQ(DummyInfo, 0) + << "General Error handler did not shadow specific handler"; + EXPECT_EQ(DummyExtraInfo, 0) << "General Error handler did not shadow specific handler"; } @@ -317,9 +322,9 @@ TEST(Error, CheckJoinErrors) { CustomErrorInfo1 = CE.getInfo(); }); - EXPECT_TRUE(CustomErrorInfo1 == 7 && CustomErrorInfo2 == 42 && - CustomErrorExtraInfo == 7) - << "Failed handling compound Error."; + EXPECT_EQ(CustomErrorInfo1, 7) << "Failed handling compound Error."; + EXPECT_EQ(CustomErrorInfo2, 42) << "Failed handling compound Error."; + EXPECT_EQ(CustomErrorExtraInfo, 7) << "Failed handling compound Error."; // Test appending a single item to a list. { |