[libc] Extends the testing framework to support typed test
authorGuillaume Chatelet <gchatelet@google.com>
Fri, 16 Apr 2021 09:18:03 +0000 (09:18 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Fri, 16 Apr 2021 21:21:35 +0000 (21:21 +0000)
commit7c02dc22e487637abe752939c0e82d36be9921df
tree03e8a0ef1ac9eddf1bb235359666820550715f02
parent3e1045ec04a033c688aa40e961e26c38446f1139
[libc] Extends the testing framework to support typed test

This patch provides `TYPED_TEST` and `TYPED_TEST_F` (similar in functionnality to gtest).
This is needed to extensively test building blocks for memory functions.

Example for `TYPED_TEST_F`:
```
template <typename T> class LlvmLibcMyTestFixture : public testing::Test {};

using Types = testing::TypeList<char, int, long>;

TYPED_TEST_F(LlvmLibcMyTestFixture, Simple, Types) {
  EXPECT_LE(sizeof(ParamType), 8UL);
}
```

Example for `TYPED_TEST`:
```
using Types = testing::TypeList<char, int, long>;

TYPED_TEST(LlvmLibcMyTest, Simple, Types) {
  EXPECT_LE(sizeof(ParamType), 8UL);
}
```

`ParamType` is displayed as fully qualified canonical type which can be difficult to read, the user can provide a more readable name by using the `REGISTER_TYPE_NAME` macro.

Differential Revision: https://reviews.llvm.org/D100631
libc/utils/UnitTest/LibcTest.h