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 // strstreambuf(const unsigned char* gnext_arg, streamsize n);
14 
15 #include <strstream>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 
main(int,char **)20 int main(int, char**)
21 {
22     {
23         unsigned char buf[] = "abcd";
24         std::strstreambuf sb(buf, sizeof(buf));
25         assert(sb.sgetc() == 'a');
26         assert(sb.snextc() == 'b');
27         assert(sb.snextc() == 'c');
28         assert(sb.snextc() == 'd');
29         assert(sb.snextc() == 0);
30         assert(sb.snextc() == EOF);
31     }
32     {
33         unsigned char buf[] = "abcd";
34         std::strstreambuf sb(buf, 0);
35         assert(sb.sgetc() == 'a');
36         assert(sb.snextc() == 'b');
37         assert(sb.snextc() == 'c');
38         assert(sb.snextc() == 'd');
39         assert(sb.snextc() == EOF);
40     }
41 
42   return 0;
43 }
44