pytorch/c10/test/util/generic_math_test.cpp
Jez Ng 110339a310 Fix c10::div_floor_floating compile error (#115647)
Introduced by #113276. I've added a test to catch future regressions.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/115647
Approved by: https://github.com/desertfire, https://github.com/vfdev-5
2023-12-20 00:09:01 +00:00

18 lines
471 B
C++

// Copyright (c) Meta Platforms, Inc. and affiliates.
#include <c10/util/generic_math.h>
#include <gtest/gtest.h>
#include <cmath>
using namespace ::testing;
TEST(GenericMathTest, div_floor_test) {
EXPECT_EQ(c10::div_floor_floating(5., 0.), INFINITY);
EXPECT_DOUBLE_EQ(c10::div_floor_floating(5., 2.), 2.);
EXPECT_DOUBLE_EQ(c10::div_floor_floating(5., -2.), -3.);
EXPECT_EQ(c10::div_floor_integer(5, 2), 2);
EXPECT_EQ(c10::div_floor_integer(5, -2), -3);
}