-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7658c1
commit 3b116eb
Showing
4 changed files
with
110 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ | |
/// @brief Test the offset logarithmic integral function. | ||
/// Li(x) = li(x) - li(2) | ||
/// | ||
/// Copyright (C) 2021 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
/// | ||
|
||
#include <primecount-internal.hpp> | ||
#include <int128_t.hpp> | ||
#include <imath.hpp> | ||
|
||
#include <stdint.h> | ||
|
@@ -97,6 +98,28 @@ int main() | |
} | ||
} | ||
|
||
{ | ||
int64_t x = std::numeric_limits<int64_t>::max() / 10; | ||
int64_t res = Li_inverse(x); | ||
if (res != std::numeric_limits<int64_t>::max()) | ||
{ | ||
std::cout << "Li_inverse(" << x << ") != INT64_MAX, failed to prevent integer overflow!" << std::endl; | ||
std::exit(1); | ||
} | ||
} | ||
|
||
#if defined(HAVE_INT128_T) | ||
{ | ||
int128_t x = std::numeric_limits<int128_t>::max() / 10; | ||
int128_t res = Li_inverse(x); | ||
if (res != std::numeric_limits<int128_t>::max()) | ||
{ | ||
std::cout << "Li_inverse(" << x << ") != INT128_MAX, failed to prevent integer overflow!" << std::endl; | ||
std::exit(1); | ||
} | ||
} | ||
#endif | ||
|
||
std::cout << std::endl; | ||
std::cout << "All tests passed successfully!" << std::endl; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,14 @@ | |
/// @file Ri.cpp | ||
/// @brief Test the Riemann R function. | ||
/// | ||
/// Copyright (C) 2021 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
/// | ||
|
||
#include <primecount-internal.hpp> | ||
#include <int128_t.hpp> | ||
#include <imath.hpp> | ||
|
||
#include <stdint.h> | ||
|
@@ -126,6 +127,28 @@ int main() | |
} | ||
} | ||
|
||
{ | ||
int64_t x = std::numeric_limits<int64_t>::max() / 10; | ||
int64_t res = Ri_inverse(x); | ||
if (res != std::numeric_limits<int64_t>::max()) | ||
{ | ||
std::cout << "Ri_inverse(" << x << ") != INT64_MAX, failed to prevent integer overflow!" << std::endl; | ||
std::exit(1); | ||
} | ||
} | ||
|
||
#if defined(HAVE_INT128_T) | ||
{ | ||
int128_t x = std::numeric_limits<int128_t>::max() / 10; | ||
int128_t res = Ri_inverse(x); | ||
if (res != std::numeric_limits<int128_t>::max()) | ||
{ | ||
std::cout << "Ri_inverse(" << x << ") != INT128_MAX, failed to prevent integer overflow!" << std::endl; | ||
std::exit(1); | ||
} | ||
} | ||
#endif | ||
|
||
std::cout << std::endl; | ||
std::cout << "All tests passed successfully!" << std::endl; | ||
|
||
|