[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / libc / test / src / stdlib / DivTest.h
blob90fae6c4df44ff3e3205f7382c2415aa3b5b52af
1 //===-- A template class for testing div functions --------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "test/UnitTest/Test.h"
11 template <typename IntType, typename ReturnType>
12 class DivTest : public LIBC_NAMESPACE::testing::Test {
13 public:
14 using DivFunc = ReturnType(IntType, IntType);
16 void simpleTest(DivFunc func) {
17 auto result = func(10, 3);
18 EXPECT_EQ(result.quot, IntType(3));
19 EXPECT_EQ(result.rem, IntType(1));
21 result = func(-10, 3);
22 EXPECT_EQ(result.quot, IntType(-3));
23 EXPECT_EQ(result.rem, IntType(-1));
25 result = func(-10, -3);
26 EXPECT_EQ(result.quot, IntType(3));
27 EXPECT_EQ(result.rem, IntType(-1));
29 result = func(10, -3);
30 EXPECT_EQ(result.quot, IntType(-3));
31 EXPECT_EQ(result.rem, IntType(1));
35 #define LIST_DIV_TESTS(IntType, ReturnType, func) \
36 using LlvmLibcDivTest = DivTest<IntType, ReturnType>; \
37 TEST_F(LlvmLibcDivTest, SimpleTest##ReturnType) { simpleTest(func); }