Skip to content

Commit 2d228e4

Browse files
committed
Add reproducer test set
1 parent 04510eb commit 2d228e4

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

test/Jamfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ run github_issue_1057.cpp ;
7070
compile-fail github_issue_1087.cpp ;
7171
run github_issue_1091.cpp ;
7272
run github_issue_1094.cpp ;
73+
run github_issue_1110.cpp ;
7374
run github_issue_1112.cpp ;
7475

7576
run link_1.cpp link_2.cpp link_3.cpp ;

test/github_issue_1110.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright 2025 Christopher Kormanyos
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
//
5+
// See: https://github.com/cppalliance/decimal/issues/1110
6+
7+
#include <boost/decimal/decimal128_t.hpp>
8+
#include <boost/decimal/cmath.hpp>
9+
#include <boost/decimal/iostream.hpp>
10+
11+
#include <boost/core/lightweight_test.hpp>
12+
13+
#include <iomanip>
14+
#include <iostream>
15+
#include <sstream>
16+
17+
using namespace boost::decimal;
18+
19+
namespace local {
20+
21+
auto test() -> void;
22+
23+
auto test() -> void
24+
{
25+
const boost::decimal::decimal128_t one { 1 };
26+
const boost::decimal::decimal128_t del { 1, -32 };
27+
const boost::decimal::decimal128_t sum { one + del };
28+
29+
const boost::decimal::decimal128_t sqr { sqrt(sum) };
30+
31+
{
32+
std::stringstream strm { };
33+
34+
strm << std::setprecision(std::numeric_limits<boost::decimal::decimal128_t>::digits10) << sqr;
35+
36+
BOOST_TEST_CSTR_EQ(strm.str().c_str(), "1.000000000000000000000000000000005");
37+
}
38+
39+
const boost::decimal::decimal128_t cbr { cbrt(sum) };
40+
41+
{
42+
std::stringstream strm { };
43+
44+
strm << std::setprecision(std::numeric_limits<boost::decimal::decimal128_t>::digits10)<< cbr;
45+
46+
// TODO: This tolerance isn't the best
47+
BOOST_TEST_CSTR_EQ(strm.str().c_str(), "1.000000000000000000000000000000641");
48+
}
49+
50+
const boost::decimal::decimal128_t lgt { log10(sum) };
51+
52+
{
53+
std::stringstream strm { };
54+
55+
strm << std::setprecision(std::numeric_limits<boost::decimal::decimal128_t>::digits10)<< lgt;
56+
57+
BOOST_TEST_CSTR_EQ(strm.str().c_str(), "4.4e-33");
58+
}
59+
}
60+
61+
} // namespace local
62+
63+
auto main() -> int
64+
{
65+
local::test();
66+
67+
return boost::report_errors();
68+
}

0 commit comments

Comments
 (0)