brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · d8518f3 Raw
62 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <istream>10 11// template <class charT, class traits = char_traits<charT> >12// class basic_istream;13 14// explicit basic_istream(basic_streambuf<charT,traits>* sb);15 16#include <istream>17#include <cassert>18#include <streambuf>19 20#include "test_macros.h"21 22template <class CharT>23struct testbuf24    : public std::basic_streambuf<CharT>25{26    testbuf() {}27};28 29int main(int, char**)30{31    {32        testbuf<char> sb;33        std::basic_istream<char> is(&sb);34        assert(is.rdbuf() == &sb);35        assert(is.tie() == 0);36        assert(is.fill() == ' ');37        assert(is.rdstate() == is.goodbit);38        assert(is.exceptions() == is.goodbit);39        assert(is.flags() == (is.skipws | is.dec));40        assert(is.precision() == 6);41        assert(is.getloc().name() == "C");42        assert(is.gcount() == 0);43    }44#ifndef TEST_HAS_NO_WIDE_CHARACTERS45    {46        testbuf<wchar_t> sb;47        std::basic_istream<wchar_t> is(&sb);48        assert(is.rdbuf() == &sb);49        assert(is.tie() == 0);50        assert(is.fill() == L' ');51        assert(is.rdstate() == is.goodbit);52        assert(is.exceptions() == is.goodbit);53        assert(is.flags() == (is.skipws | is.dec));54        assert(is.precision() == 6);55        assert(is.getloc().name() == "C");56        assert(is.gcount() == 0);57    }58#endif59 60  return 0;61}62