3.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // { dg-options "-std=gnu++17" }
  2. // Copyright (C) 2013-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. // inserters
  17. // NB: This file is predicated on sstreams, istreams, and ostreams
  18. // working, not to mention other major details like char_traits, and
  19. // all of the string_view class.
  20. #include <string_view>
  21. #include <sstream>
  22. #include <iomanip>
  23. #include <testsuite_hooks.h>
  24. void
  25. test09()
  26. {
  27. std::wstring_view foo{L"peace\0\0\0& love"};
  28. std::wostringstream oss1;
  29. oss1 << foo;
  30. VERIFY( oss1.str() == foo );
  31. std::wostringstream oss2;
  32. oss2.width(20);
  33. oss2 << foo;
  34. VERIFY( oss2.str() != foo );
  35. VERIFY( oss2.str().size() == 20 );
  36. }
  37. int
  38. main()
  39. {
  40. test09();
  41. return 0;
  42. }