1 // Copyright (c) Meta Platforms, Inc. and affiliates.
2
3 #include <c10/util/generic_math.h>
4
5 #include <gtest/gtest.h>
6
7 #include <cmath>
8
9 using namespace ::testing;
10
TEST(GenericMathTest,div_floor_test)11 TEST(GenericMathTest, div_floor_test) {
12 EXPECT_EQ(c10::div_floor_floating(5., 0.), INFINITY);
13 EXPECT_DOUBLE_EQ(c10::div_floor_floating(5., 2.), 2.);
14 EXPECT_DOUBLE_EQ(c10::div_floor_floating(5., -2.), -3.);
15 EXPECT_EQ(c10::div_floor_integer(5, 2), 2);
16 EXPECT_EQ(c10::div_floor_integer(5, -2), -3);
17 }
18