You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
875 B

//===- MathExtrasTest.cpp - MathExtras Tests ------------------------------===//
//
// 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 "mlir/Support/MathExtras.h"
#include "gmock/gmock.h"
using namespace mlir;
using ::testing::Eq;
TEST(MathExtrasTest, CeilDivTest) {
EXPECT_THAT(ceilDiv(14, 3), Eq(5));
EXPECT_THAT(ceilDiv(14, -3), Eq(-4));
EXPECT_THAT(ceilDiv(-14, -3), Eq(5));
EXPECT_THAT(ceilDiv(-14, 3), Eq(-4));
}
TEST(MathExtrasTest, FloorDivTest) {
EXPECT_THAT(floorDiv(14, 3), Eq(4));
EXPECT_THAT(floorDiv(14, -3), Eq(-5));
EXPECT_THAT(floorDiv(-14, -3), Eq(4));
EXPECT_THAT(floorDiv(-14, 3), Eq(-5));
}