1163953Srrs// Copyright (C) 2003 Free Software Foundation, Inc. 2169382Srrs// 3237896Stuexen// This file is part of the GNU ISO C++ Library. This library is free 4237896Stuexen// software; you can redistribute it and/or modify it under the 5163953Srrs// terms of the GNU General Public License as published by the 6163953Srrs// Free Software Foundation; either version 2, or (at your option) 7163953Srrs// any later version. 8163953Srrs 9163953Srrs// This library is distributed in the hope that it will be useful, 10231038Stuexen// but WITHOUT ANY WARRANTY; without even the implied warranty of 11163953Srrs// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12163953Srrs// GNU General Public License for more details. 13163953Srrs 14231038Stuexen// You should have received a copy of the GNU General Public License along 15163953Srrs// with this library; see the file COPYING. If not, write to the Free 16163953Srrs// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17163953Srrs// USA. 18163953Srrs 19163953Srrs// 27.8.1.4 Overridden virtual functions 20163953Srrs 21163953Srrs#include <fstream> 22163953Srrs#include <cstdio> 23163953Srrs#include <cstring> 24163953Srrs#include <testsuite_hooks.h> 25163953Srrs 26163953Srrs// libstdc++/12875 27163953Srrsvoid test02() 28163953Srrs{ 29163953Srrs using namespace std; 30163953Srrs bool test __attribute__((unused)) = true; 31163953Srrs 32237896Stuexen const char* name = "tmp_setbuf5"; 33163954Srrs static char buf[1024]; 34163953Srrs 35163953Srrs filebuf out; 36237896Stuexen out.open(name, ios_base::out); 37237896Stuexen streamsize r = out.sputn("Hello,", 6); 38237896Stuexen VERIFY( r == 6 ); 39163953Srrs out.pubsetbuf(buf, 1024); 40163953Srrs r = out.sputn(" world", 6); 41163953Srrs VERIFY( r == 6 ); 42163953Srrs VERIFY( out.close() ); 43163953Srrs 44163953Srrs FILE* in = fopen(name, "r"); 45163953Srrs char str[256]; 46163953Srrs fgets(str, 256, in); 47163953Srrs VERIFY( !strcmp(str, "Hello, world") ); 48163953Srrs fclose(in); 49163953Srrs} 50163953Srrs 51163953Srrsint main() 52163953Srrs{ 53163953Srrs test02(); 54166675Srrs return 0; 55163953Srrs} 56163953Srrs