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
12using namespace mlir;
13using ::testing::Eq;
14
15TEST(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 EXPECT_THAT(ceilDiv(0, 3), Eq(0));
21 EXPECT_THAT(ceilDiv(0, -3), Eq(0));
22}
23
24TEST(MathExtrasTest, FloorDivTest) {
25 EXPECT_THAT(floorDiv(14, 3), Eq(4));
26 EXPECT_THAT(floorDiv(14, -3), Eq(-5));
27 EXPECT_THAT(floorDiv(-14, -3), Eq(4));
28 EXPECT_THAT(floorDiv(-14, 3), Eq(-5));
29 EXPECT_THAT(floorDiv(0, 3), Eq(0));
30 EXPECT_THAT(floorDiv(0, -3), Eq(0));
31}
32

source code of mlir/unittests/Support/MathExtrasTest.cpp