MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/util/overflow_test.cc:24–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace {
23
24TEST(OverflowTest, Nonnegative) {
25 // Various interesting values
26 std::vector<int64> interesting = {0, std::numeric_limits<int64>::max()};
27 for (int i = 0; i < 63; i++) {
28 int64 bit = static_cast<int64>(1) << i;
29 interesting.push_back(bit);
30 interesting.push_back(bit + 1);
31 interesting.push_back(bit - 1);
32 }
33 for (const int64 mid : {static_cast<int64>(1) << 32,
34 static_cast<int64>(std::pow(2, 63.0 / 2))}) {
35 for (int i = -5; i < 5; i++) {
36 interesting.push_back(mid + i);
37 }
38 }
39
40 // Check all pairs
41 for (auto x : interesting) {
42 for (auto y : interesting) {
43 int64 xy = MultiplyWithoutOverflow(x, y);
44 long double dxy = static_cast<long double>(x) * y;
45 if (dxy > std::numeric_limits<int64>::max()) {
46 EXPECT_LT(xy, 0);
47 } else {
48 EXPECT_EQ(dxy, xy);
49 }
50 }
51 }
52}
53
54TEST(OverflowTest, Negative) {
55 const int64 negatives[] = {-1, std::numeric_limits<int64>::min()};

Callers

nothing calls this directly

Calls 6

EXPECT_DEATHFunction · 0.85
MultiplyWithoutOverflowFunction · 0.70
maxFunction · 0.50
powClass · 0.50
minFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected