Page MenuHomePhabricator

[FileCheck][unittest] Use parameterized unittests
AbandonedPublic

Authored by thopre on May 28 2020, 2:49 AM.

Details

Summary

Use parameterized unit tests to test FileCheck ExpressionValue API
rather than hand written code.

Diff Detail

Event Timeline

thopre created this revision.May 28 2020, 2:49 AM
grimar added a comment.EditedMay 29 2020, 1:29 AM

Honestly, my impression is that the code on the left reads much easier. And it is 100 lines shorter.
I am not familar with things like ::testing::TestWithParam though, may be there is a benefit of using it
that is not obvious to me atm.

I wonder what do other people think.

llvm/unittests/Support/FileCheckTest.cpp
296

You can use INT64_MAX instead.
(INT32_MAX/UINT32_MAX are used in many places in LLVM).

358

UINT32_MAX?

418

You can return here to avoid else:

  ASSERT_THAT_EXPECTED(SignedActualValue, Succeeded());
  EXPECT_EQ(*SignedExpectedValue, *SignedActualValue);
  return;
}

Thanks for looking at this. This hasn't quite collapsed the code in the way that I imagined it would, so I'm happy for this idea to be abandoned if you don't think it is worthwhile. Otherwise, I'll take a look next week.

thopre abandoned this revision.Jun 5 2020, 5:12 AM

Thanks for looking at this. This hasn't quite collapsed the code in the way that I imagined it would, so I'm happy for this idea to be abandoned if you don't think it is worthwhile. Otherwise, I'll take a look next week.

It could probably be quite shorter if there was a way to keep some parameter templated in the fixture (namely the distinction between signed and unsigned values). Unfortunately I had errors when I tried that.