• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <strstream>
10 
11 // class strstreambuf
12 
13 // pos_type seekpos(pos_type sp,
14 //                  ios_base::openmode which = ios_base::in | ios_base::out);
15 
16 #include <strstream>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 
main(int,char **)21 int main(int, char**)
22 {
23     {
24         char buf[] = "0123456789";
25         std::strstreambuf sb(buf, 0);
26         assert(sb.pubseekpos(3, std::ios_base::out) == -1);
27         assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
28         assert(sb.pubseekpos(3, std::ios_base::in) == 3);
29         assert(sb.sgetc() == '3');
30     }
31     {
32         char buf[] = "0123456789";
33         std::strstreambuf sb(buf, 0, buf);
34         assert(sb.pubseekpos(3, std::ios_base::in) == 3);
35         assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
36         assert(sb.pubseekpos(3, std::ios_base::out) == 3);
37         assert(sb.sputc('a') == 'a');
38         assert(sb.str() == std::string("012a456789"));
39     }
40 
41   return 0;
42 }
43