File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ run ../examples/charconv.cpp ;
9797run github_issue_207.cpp ;
9898run github_issue_210.cpp ;
9999run github_issue_221.cpp ;
100+ run github_issue_272.cpp ;
100101
101102# Compilation of individual headers
102103compile compile_tests/int128_master_header_compile.cpp ;
Original file line number Diff line number Diff line change 1+ // Copyright 2025 Matt Borland
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/int128/issues/272
6+
7+ #include < boost/int128.hpp>
8+ #include < boost/core/lightweight_test.hpp>
9+ #include < sstream>
10+ #include < iostream>
11+
12+ template <typename T>
13+ void endpos_using_istream (const std::string& str, const int expected_endpos)
14+ {
15+ std::istringstream is (str);
16+ T x;
17+
18+ is >> x;
19+ is.clear ();
20+ const auto endpos = is.tellg ();
21+
22+ if (!BOOST_TEST_EQ (endpos, expected_endpos))
23+ {
24+ // LCOV_EXCL_START
25+ std::cerr << " String: " << str << ' \n '
26+ << " Expected: " << expected_endpos << ' \n '
27+ << " Got: " << is.tellg () << std::endl;
28+ // LCOV_EXCL_STOP
29+ }
30+ }
31+
32+ template <typename T>
33+ void check_endpos ()
34+ {
35+ endpos_using_istream<T>(" Inf" , 0 );
36+ endpos_using_istream<T>(" Nan" , 0 );
37+
38+ endpos_using_istream<T>(" 127.0.0.1" , 3 );
39+ endpos_using_istream<T>(" 42" , 2 );
40+
41+ endpos_using_istream<T>(" 42Junk" , 2 );
42+ }
43+
44+ int main ()
45+ {
46+ check_endpos<boost::int128::uint128_t >();
47+ check_endpos<boost::int128::int128_t >();
48+
49+ return boost::report_errors ();
50+ }
You can’t perform that action at this time.
0 commit comments