-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgithub_issue_272.cpp
More file actions
43 lines (34 loc) · 956 Bytes
/
github_issue_272.cpp
File metadata and controls
43 lines (34 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2025 Matt Borland
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// See: https://github.com/cppalliance/int128/issues/272
#include <boost/int128.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <iostream>
template <typename T>
void endpos_using_istream(const std::string& str, const int expected_endpos)
{
std::istringstream is(str);
T x;
is >> x;
is.clear();
const auto endpos = is.tellg();
BOOST_TEST_EQ(endpos, expected_endpos);
}
template <typename T>
void check_endpos()
{
endpos_using_istream<T>("Inf", 0);
endpos_using_istream<T>("Nan", 0);
endpos_using_istream<T>("127.0.0.1", 3);
endpos_using_istream<T>("42", 2);
endpos_using_istream<T>("42Junk", 2);
}
int main()
{
check_endpos<boost::int128::uint128_t>();
check_endpos<boost::int128::int128_t>();
return boost::report_errors();
}