]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/from_chars/6.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / from_chars / 6.cc
CommitLineData
7adcbafe 1// Copyright (C) 2020-2022 Free Software Foundation, Inc.
2251b4a5
JW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
18// <charconv> is supported in C++14 as a GNU extension
19// { dg-do run { target c++14 } }
20// { dg-add-options ieee }
21
22#include <charconv>
23#include <string>
24#include <cfenv>
25#include <testsuite_hooks.h>
26
27void
28test01()
29{
f1a68574 30#if __cpp_lib_to_chars >= 201611L
2251b4a5
JW
31#if _GLIBCXX_USE_C99_FENV_TR1
32 double d;
33 std::fesetround(FE_DOWNWARD);
34 const std::string s = "0.099999999999999999999999999";
35 auto res = std::from_chars(s.data(), s.data() + s.length(), d);
36 VERIFY( res.ec == std::errc{} );
37 VERIFY( res.ptr == s.data() + s.length() );
38 // std::from_chars should ignore the current rounding mode
39 // and always round to nearest.
40 VERIFY( d == 0.1 );
41#endif
42#endif
43}
44
45int
46main()
47{
48 test01();
49}