1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <strstream> 11 12// class strstreambuf 13 14// pos_type seekpos(pos_type sp, 15// ios_base::openmode which = ios_base::in | ios_base::out); 16 17#include <strstream> 18#include <cassert> 19 20int main() 21{ 22 { 23 char buf[] = "0123456789"; 24 std::strstreambuf sb(buf, 0); 25 assert(sb.pubseekpos(3, std::ios_base::out) == -1); 26 assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1); 27 assert(sb.pubseekpos(3, std::ios_base::in) == 3); 28 assert(sb.sgetc() == '3'); 29 } 30 { 31 char buf[] = "0123456789"; 32 std::strstreambuf sb(buf, 0, buf); 33 assert(sb.pubseekpos(3, std::ios_base::in) == 3); 34 assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3); 35 assert(sb.pubseekpos(3, std::ios_base::out) == 3); 36 assert(sb.sputc('a') == 'a'); 37 assert(sb.str() == std::string("012a456789")); 38 } 39} 40