[ProfileData] Avoid repeated hash lookups (NFC) (#125464)
[llvm-project.git] / libcxx / test / std / input.output / string.streams / istringstream / istringstream.cons / string-alloc.mode.pass.cpp
blob7e784667a6ccda2c1feada9b9d4bb5fbc694eec8
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // <sstream>
13 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
14 // class basic_istringstream
16 // template <class SAlloc>
17 // explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s, ios_base::openmode which = ios_base::in)
19 #include <sstream>
20 #include <cassert>
22 #include "make_string.h"
23 #include "test_allocator.h"
24 #include "test_macros.h"
25 #include "operator_hijacker.h"
27 #define STR(S) MAKE_STRING(CharT, S)
28 #define SV(S) MAKE_STRING_VIEW(CharT, S)
30 template <class CharT, class Allocator>
31 static void test() {
33 const std::basic_string<CharT> s(STR("testing"));
34 const std::basic_istringstream<CharT, std::char_traits<CharT>, Allocator> ss(s);
35 assert(ss.view() == SV("testing"));
38 const std::basic_string<CharT> s(STR("testing"));
39 const std::basic_istringstream<CharT, std::char_traits<CharT>, Allocator> ss(s, std::ios_base::binary);
40 assert(ss.view() == SV("testing"));
44 int main(int, char**) {
45 test<char, test_allocator<char>>();
46 test<char, operator_hijacker_allocator<char>>();
47 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
48 test<wchar_t, test_allocator<wchar_t>>();
49 test<wchar_t, operator_hijacker_allocator<wchar_t>>();
50 #endif
51 return 0;