This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add [EXPECT|ASSERT]_[TRUE|FALSE] unittest macros.
ClosedPublic

Authored by sivachandra on Jan 29 2020, 3:34 PM.

Details

Summary

These macros can only be used for values of type bool.

Event Timeline

sivachandra created this revision.Jan 29 2020, 3:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 29 2020, 3:34 PM
abrachet added inline comments.
libc/utils/UnitTest/Test.h
91

This doesn't call internal::test and won't give an error message.

196–197

Will this give an error message that makes sense? I think it will do something like "expected true but was true"

sivachandra marked an inline comment as done.Jan 30 2020, 8:41 AM
sivachandra added inline comments.
libc/utils/UnitTest/Test.h
91

Ah sorry, this was supposed to be a demo patch. I will update this to make it review ready and update soon.

Ready for a review.

I am convinced (thanks to @gchatelet) that we can safely extend our macros to bool. Some of them, like EXPECT_LE might not be meaningful for bool, but I do not see any reason to make special effort to prevent such uses.

abrachet accepted this revision.Jan 30 2020, 11:47 AM
abrachet added inline comments.
libc/utils/UnitTest/Test.h
68–69

@gchatelet will be happy about this change :)

190–191

Could we shorten this to EXPECT_EQ(VAL, true)?

This revision is now accepted and ready to land.Jan 30 2020, 11:47 AM
sivachandra marked an inline comment as done.Jan 30 2020, 12:05 PM
sivachandra added inline comments.
libc/utils/UnitTest/Test.h
190–191

Indeed!

This revision was automatically updated to reflect the committed changes.
gchatelet marked an inline comment as done.Jan 31 2020, 1:12 AM

Thx!

libc/utils/UnitTest/Test.h
68–69

woohoo \O/