1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_ostream;
14 // basic_ostream<charT,traits>& seekp(pos_type pos);
19 #include "test_macros.h"
21 int seekpos_called
= 0;
23 template <class CharT
>
25 : public std::basic_streambuf
<CharT
>
27 typedef std::basic_streambuf
<CharT
> base
;
32 typename
base::pos_type
33 seekpos(typename
base::pos_type sp
, std::ios_base::openmode which
)
36 assert(which
== std::ios_base::out
);
45 std::ostream
os((std::streambuf
*)0);
46 assert(&os
.seekp(5) == &os
);
47 assert(seekpos_called
== 0);
53 assert(&os
.seekp(10) == &os
);
54 assert(seekpos_called
== 1);
56 assert(&os
.seekp(-1) == &os
);
57 assert(seekpos_called
== 2);
60 { // See https://llvm.org/PR21361
64 os
.setstate(std::ios_base::eofbit
);
65 assert(&os
.seekp(10) == &os
);
66 assert(seekpos_called
== 1);
67 assert(os
.rdstate() == std::ios_base::eofbit
);