/
GitCaptain
/
llvm-project
Обзор
Документация
Войти
/
GitCaptain
/
llvm-project
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
fix-tests
libc/test/src/stdlib/DivTest.h
37 строк
1 KB
Alex Brachet
[libc] Make div test names unique
07 июл 2022, 18:06
07 июл 2022, 18:06
a442c62
Код
Авторство
О чём код?
//===-- A template class for testing div functions --------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "utils/UnitTest/Test.h" template <typename IntType, typename ReturnType> class DivTest : public __llvm_libc::testing::Test { public: using DivFunc = ReturnType(IntType, IntType); void simpleTest(DivFunc func) { auto result = func(10, 3); EXPECT_EQ(result.quot, IntType(3)); EXPECT_EQ(result.rem, IntType(1)); result = func(-10, 3); EXPECT_EQ(result.quot, IntType(-3)); EXPECT_EQ(result.rem, IntType(-1)); result = func(-10, -3); EXPECT_EQ(result.quot, IntType(3)); EXPECT_EQ(result.rem, IntType(-1)); result = func(10, -3); EXPECT_EQ(result.quot, IntType(-3)); EXPECT_EQ(result.rem, IntType(1)); } }; #define LIST_DIV_TESTS(IntType, ReturnType, func) \ using LlvmLibcDivTest = DivTest<IntType, ReturnType>; \ TEST_F(LlvmLibcDivTest, SimpleTest##ReturnType) { simpleTest(func); }