brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 74ffdc8 Raw
49 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 xsputn(const 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 setp(char* pbeg, char* pend)30    {31        base::setp(pbeg, pend);32    }33};34 35int main(int, char**)36{37    {38        test t;39        char in[] = "123456";40        assert(t.sputn(in, sizeof(in)) == 0);41        char out[sizeof(in)] = {0};42        t.setp(out, out+sizeof(out));43        assert(t.sputn(in, sizeof(in)) == sizeof(in));44        assert(std::strcmp(in, out) == 0);45    }46 47  return 0;48}49