This is an archive of the discontinued LLVM Phabricator instance.

[NFCI][Support] Avoid ASSERT_/EXPECT_TRUE(A <op> B)
ClosedPublic

Authored by lenary on Jan 14 2022, 7:32 AM.

Details

Summary

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).

Diff Detail

Event Timeline

lenary created this revision.Jan 14 2022, 7:32 AM
lenary requested review of this revision.Jan 14 2022, 7:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2022, 7:32 AM
mubashar_ accepted this revision.Jan 14 2022, 8:40 AM

It seems ok to me.

This revision is now accepted and ready to land.Jan 14 2022, 8:40 AM