1 //===- MathExtrasTest.cpp - MathExtras Tests ------------------------------===//
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 //===----------------------------------------------------------------------===//
8
9 #include "mlir/Support/MathExtras.h"
10 #include "gmock/gmock.h"
11
12 using namespace mlir;
13 using ::testing::Eq;
14
TEST(MathExtrasTest,CeilDivTest)15 TEST(MathExtrasTest, CeilDivTest) {
16 EXPECT_THAT(ceilDiv(14, 3), Eq(5));
17 EXPECT_THAT(ceilDiv(14, -3), Eq(-4));
18 EXPECT_THAT(ceilDiv(-14, -3), Eq(5));
19 EXPECT_THAT(ceilDiv(-14, 3), Eq(-4));
20 }
21
TEST(MathExtrasTest,FloorDivTest)22 TEST(MathExtrasTest, FloorDivTest) {
23 EXPECT_THAT(floorDiv(14, 3), Eq(4));
24 EXPECT_THAT(floorDiv(14, -3), Eq(-5));
25 EXPECT_THAT(floorDiv(-14, -3), Eq(4));
26 EXPECT_THAT(floorDiv(-14, 3), Eq(-5));
27 }
28