15a83710eSEric Fiselier //===----------------------------------------------------------------------===// 25a83710eSEric Fiselier // 357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65a83710eSEric Fiselier // 75a83710eSEric Fiselier //===----------------------------------------------------------------------===// 85a83710eSEric Fiselier 95a83710eSEric Fiselier // <iomanip> 105a83710eSEric Fiselier 115a83710eSEric Fiselier // T5 setprecision(int n); 125a83710eSEric Fiselier 135a83710eSEric Fiselier #include <iomanip> 145a127cdcSMarshall Clow #include <istream> 155a127cdcSMarshall Clow #include <ostream> 165a83710eSEric Fiselier #include <cassert> 175a83710eSEric Fiselier 187fc6a556SMarshall Clow #include "test_macros.h" 197fc6a556SMarshall Clow 205a83710eSEric Fiselier template <class CharT> 215a83710eSEric Fiselier struct testbuf 225a83710eSEric Fiselier : public std::basic_streambuf<CharT> 235a83710eSEric Fiselier { testbuftestbuf245a83710eSEric Fiselier testbuf() {} 255a83710eSEric Fiselier }; 265a83710eSEric Fiselier main(int,char **)272df59c50SJF Bastienint main(int, char**) 285a83710eSEric Fiselier { 295a83710eSEric Fiselier { 305a83710eSEric Fiselier testbuf<char> sb; 315a83710eSEric Fiselier std::istream is(&sb); 325a83710eSEric Fiselier is >> std::setprecision(10); 335a83710eSEric Fiselier assert(is.precision() == 10); 345a83710eSEric Fiselier } 355a83710eSEric Fiselier { 365a83710eSEric Fiselier testbuf<char> sb; 375a83710eSEric Fiselier std::ostream os(&sb); 385a83710eSEric Fiselier os << std::setprecision(10); 395a83710eSEric Fiselier assert(os.precision() == 10); 405a83710eSEric Fiselier } 41*f4c1258dSLouis Dionne #ifndef TEST_HAS_NO_WIDE_CHARACTERS 425a83710eSEric Fiselier { 435a83710eSEric Fiselier testbuf<wchar_t> sb; 445a83710eSEric Fiselier std::wistream is(&sb); 455a83710eSEric Fiselier is >> std::setprecision(10); 465a83710eSEric Fiselier assert(is.precision() == 10); 475a83710eSEric Fiselier } 485a83710eSEric Fiselier { 495a83710eSEric Fiselier testbuf<wchar_t> sb; 505a83710eSEric Fiselier std::wostream os(&sb); 515a83710eSEric Fiselier os << std::setprecision(10); 525a83710eSEric Fiselier assert(os.precision() == 10); 535a83710eSEric Fiselier } 54*f4c1258dSLouis Dionne #endif 552df59c50SJF Bastien 562df59c50SJF Bastien return 0; 575a83710eSEric Fiselier } 58