[all-commits] [llvm/llvm-project] 7c02dc: [libc] Extends the testing framework to support ty...

Guillaume Chatelet via All-commits all-commits at lists.llvm.org
Fri Apr 16 14:21:57 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7c02dc22e487637abe752939c0e82d36be9921df
      https://github.com/llvm/llvm-project/commit/7c02dc22e487637abe752939c0e82d36be9921df
  Author: Guillaume Chatelet <gchatelet at google.com>
  Date:   2021-04-16 (Fri, 16 Apr 2021)

  Changed paths:
    M libc/utils/UnitTest/LibcTest.h

  Log Message:
  -----------
  [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




More information about the All-commits mailing list