mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
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
18 lines
471 B
C++
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);
|
|
}
|