minix/external/bsd/libc++/dist/libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
Lionel Sambuc 4684ddb6aa LLVM Minix changes
- import libcxx
 - reduce targets to the one when compiled as a tools

Change-Id: Iabb8427f80ff8e89463559a28bcb8b4f2bdbc496
2014-07-28 17:05:59 +02:00

96 lines
3 KiB
C++

//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <strstream>
// class strstreambuf
// strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
#include <strstream>
#include <cassert>
int main()
{
{
unsigned char buf[] = "abcd";
std::strstreambuf sb(buf, sizeof(buf));
assert(sb.sgetc() == 'a');
assert(sb.snextc() == 'b');
assert(sb.snextc() == 'c');
assert(sb.snextc() == 'd');
assert(sb.snextc() == 0);
assert(sb.snextc() == EOF);
}
{
unsigned char buf[] = "abcd";
std::strstreambuf sb(buf, 0);
assert(sb.sgetc() == 'a');
assert(sb.snextc() == 'b');
assert(sb.snextc() == 'c');
assert(sb.snextc() == 'd');
assert(sb.snextc() == EOF);
}
{
unsigned char buf[] = "abcd";
std::strstreambuf sb(buf, sizeof(buf), buf);
assert(sb.sgetc() == EOF);
assert(sb.sputc('e') == 'e');
assert(sb.sputc('f') == 'f');
assert(sb.sputc('g') == 'g');
assert(sb.sputc('h') == 'h');
assert(sb.sputc('i') == 'i');
assert(sb.sputc('j') == EOF);
assert(sb.sgetc() == 'e');
assert(sb.snextc() == 'f');
assert(sb.snextc() == 'g');
assert(sb.snextc() == 'h');
assert(sb.snextc() == 'i');
assert(sb.snextc() == EOF);
}
{
unsigned char buf[] = "abcd";
std::strstreambuf sb(buf, 0, buf);
assert(sb.sgetc() == EOF);
assert(sb.sputc('e') == 'e');
assert(sb.sputc('f') == 'f');
assert(sb.sputc('g') == 'g');
assert(sb.sputc('h') == 'h');
assert(sb.sputc('i') == EOF);
assert(sb.sgetc() == 'e');
assert(sb.snextc() == 'f');
assert(sb.snextc() == 'g');
assert(sb.snextc() == 'h');
assert(sb.snextc() == EOF);
}
{
unsigned char buf[10] = "abcd";
int s = std::strlen((char*)buf);
std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
assert(sb.sgetc() == 'a');
assert(sb.snextc() == 'b');
assert(sb.snextc() == 'c');
assert(sb.snextc() == 'd');
assert(sb.snextc() == EOF);
assert(sb.sputc('e') == 'e');
assert(sb.sputc('f') == 'f');
assert(sb.sputc('g') == 'g');
assert(sb.sputc('h') == 'h');
assert(sb.sputc('i') == 'i');
assert(sb.sputc('j') == 'j');
assert(sb.sputc('j') == EOF);
assert(sb.sgetc() == 'e');
assert(sb.snextc() == 'f');
assert(sb.snextc() == 'g');
assert(sb.snextc() == 'h');
assert(sb.snextc() == 'i');
assert(sb.snextc() == 'j');
assert(sb.snextc() == EOF);
}
}