13189.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // { dg-require-iconv "ISO-8859-1" }
  2. // Copyright (C) 2003-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License along
  14. // with this library; see the file COPYING3. If not see
  15. // <http://www.gnu.org/licenses/>.
  16. #include <testsuite_hooks.h>
  17. #include <ext/enc_filebuf.h>
  18. void test01()
  19. {
  20. using namespace std;
  21. typedef char char_type;
  22. typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
  23. typedef filebuf_type::state_type state_type;
  24. typedef codecvt<char_type, char, state_type> enc_codecvt;
  25. ios_base::openmode mode = ios_base::in | ios_base::out | ios_base::trunc;
  26. try
  27. {
  28. state_type st;
  29. filebuf_type fbuf(st);
  30. locale loc(locale::classic(), new enc_codecvt);
  31. fbuf.pubimbue(loc);
  32. fbuf.open("tmp_13189c", mode);
  33. fbuf.sputc('a');
  34. fbuf.pubseekoff(0, ios_base::beg);
  35. fbuf.sgetc();
  36. fbuf.close();
  37. }
  38. catch(...)
  39. {
  40. }
  41. }
  42. int main()
  43. {
  44. test01();
  45. return 0;
  46. }