Skip to content

Commit a70cc0d

Browse files
committed
Add expanded reproducer test set
1 parent 965194a commit a70cc0d

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

test/Jamfile.v2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,7 @@ test-suite misc :
12811281
[ run git_issue_636.cpp : : : [ check-target-builds ../config//has_float128 : <source>quadmath : <build>no ] ]
12821282
[ run git_issue_652.cpp ]
12831283
[ run git_issue_734.cpp ]
1284+
[ run git_issue_759.cpp : : : [ check-target-builds ../config//has_float128 : <source>quadmath : <build>no ] ]
12841285
[ compile git_issue_98.cpp :
12851286
[ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ]
12861287
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]

test/git_issue_759.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright 2026 Matt Borland. Distributed under the Boost
3+
// Software License, Version 1.0. (See accompanying file
4+
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
//
6+
// See: https://github.com/boostorg/multiprecision/issues/759
7+
8+
#include <complex>
9+
#include <iostream>
10+
#include <limits>
11+
#include <boost/multiprecision/float128.hpp>
12+
#include "test.hpp"
13+
14+
int main()
15+
{
16+
using REAL = boost::multiprecision::float128;
17+
18+
const REAL inf_v = std::numeric_limits<REAL>::infinity();
19+
20+
{
21+
using std::abs;
22+
const REAL r = abs(inf_v);
23+
BOOST_CHECK((boost::multiprecision::isinf)(r));
24+
}
25+
26+
{
27+
using std::abs;
28+
const std::complex<REAL> z{inf_v, REAL(0)};
29+
const REAL r = abs(z);
30+
BOOST_CHECK((boost::multiprecision::isinf)(r));
31+
BOOST_CHECK(!(boost::multiprecision::isnan)(r));
32+
}
33+
34+
{
35+
using std::abs;
36+
const std::complex<REAL> z{REAL(0), inf_v};
37+
const REAL r = abs(z);
38+
BOOST_CHECK((boost::multiprecision::isinf)(r));
39+
BOOST_CHECK(!(boost::multiprecision::isnan)(r));
40+
}
41+
42+
{
43+
using std::abs;
44+
const std::complex<REAL> z{-inf_v, REAL(3)};
45+
const REAL r = abs(z);
46+
BOOST_CHECK((boost::multiprecision::isinf)(r));
47+
BOOST_CHECK(!(boost::multiprecision::isnan)(r));
48+
}
49+
50+
{
51+
// Per IEEE 754: hypot(inf, NaN) = inf.
52+
using std::abs;
53+
const REAL nan_v = std::numeric_limits<REAL>::quiet_NaN();
54+
const std::complex<REAL> z{inf_v, nan_v};
55+
const REAL r = abs(z);
56+
BOOST_CHECK((boost::multiprecision::isinf)(r));
57+
}
58+
59+
{
60+
// Sanity check on a finite value: abs(3 + 4i) == 5.
61+
using std::abs;
62+
const std::complex<REAL> z{REAL(3), REAL(4)};
63+
const REAL r = abs(z);
64+
BOOST_CHECK_EQUAL(r, REAL(5));
65+
}
66+
67+
return boost::report_errors();
68+
}

0 commit comments

Comments
 (0)