brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · db10657 Raw
46 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// <streambuf>10 11// template <class charT, class traits = char_traits<charT> >12// class basic_streambuf;13 14// streamsize xsgetn(char_type* s, streamsize n);15 16#include <streambuf>17#include <cassert>18#include <cstring>19 20#include "test_macros.h"21 22struct test23    : public std::basic_streambuf<char>24{25    typedef std::basic_streambuf<char> base;26 27    test() {}28 29    void setg(char* gbeg, char* gnext, char* gend)30    {31        base::setg(gbeg, gnext, gend);32    }33};34 35int main(int, char**)36{37    test t;38    char input[7] = "123456";39    t.setg(input, input, input+7);40    char output[sizeof(input)] = {0};41    assert(t.sgetn(output, 10) == 7);42    assert(std::strcmp(input, output) == 0);43 44  return 0;45}46