1053d81ceSMarshall Clow //===----------------------------------------------------------------------===// 2053d81ceSMarshall Clow // 3053d81ceSMarshall Clow // The LLVM Compiler Infrastructure 4053d81ceSMarshall Clow // 5053d81ceSMarshall Clow // This file is dual licensed under the MIT and the University of Illinois Open 6053d81ceSMarshall Clow // Source Licenses. See LICENSE.TXT for details. 7053d81ceSMarshall Clow // 8053d81ceSMarshall Clow //===----------------------------------------------------------------------===// 9053d81ceSMarshall Clow 10053d81ceSMarshall Clow 11053d81ceSMarshall Clow // <string_view> 12053d81ceSMarshall Clow 13053d81ceSMarshall Clow // template<class Allocator> 14053d81ceSMarshall Clow // basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept 15053d81ceSMarshall Clow 16053d81ceSMarshall Clow 17053d81ceSMarshall Clow #include <string_view> 18053d81ceSMarshall Clow #include <string> 19053d81ceSMarshall Clow #include <cassert> 20053d81ceSMarshall Clow 21053d81ceSMarshall Clow #include "test_macros.h" 22053d81ceSMarshall Clow 23053d81ceSMarshall Clow struct dummy_char_traits : public std::char_traits<char> {}; 24053d81ceSMarshall Clow 25053d81ceSMarshall Clow template<typename CharT, typename Traits> 26053d81ceSMarshall Clow void test ( const std::basic_string<CharT, Traits> &str ) { 27*ac2b3e3aSMarshall Clow typedef std::basic_string_view<CharT, Traits> SV; 28*ac2b3e3aSMarshall Clow ASSERT_NOEXCEPT(SV(str)); 29*ac2b3e3aSMarshall Clow 30*ac2b3e3aSMarshall Clow SV sv1 ( str ); 31053d81ceSMarshall Clow assert ( sv1.size() == str.size()); 32053d81ceSMarshall Clow assert ( sv1.data() == str.data()); 33053d81ceSMarshall Clow } 34053d81ceSMarshall Clow 35053d81ceSMarshall Clow int main () { 36053d81ceSMarshall Clow 37053d81ceSMarshall Clow test ( std::string("QBCDE") ); 38053d81ceSMarshall Clow test ( std::string("") ); 39053d81ceSMarshall Clow test ( std::string() ); 40053d81ceSMarshall Clow 41053d81ceSMarshall Clow test ( std::wstring(L"QBCDE") ); 42053d81ceSMarshall Clow test ( std::wstring(L"") ); 43053d81ceSMarshall Clow test ( std::wstring() ); 44053d81ceSMarshall Clow 45053d81ceSMarshall Clow #if TEST_STD_VER >= 11 46053d81ceSMarshall Clow test ( std::u16string{u"QBCDE"} ); 47053d81ceSMarshall Clow test ( std::u16string{u""} ); 48053d81ceSMarshall Clow test ( std::u16string{} ); 49053d81ceSMarshall Clow 50053d81ceSMarshall Clow test ( std::u32string{U"QBCDE"} ); 51053d81ceSMarshall Clow test ( std::u32string{U""} ); 52053d81ceSMarshall Clow test ( std::u32string{} ); 53053d81ceSMarshall Clow #endif 54053d81ceSMarshall Clow 55053d81ceSMarshall Clow test ( std::basic_string<char, dummy_char_traits>("QBCDE") ); 56053d81ceSMarshall Clow test ( std::basic_string<char, dummy_char_traits>("") ); 57053d81ceSMarshall Clow test ( std::basic_string<char, dummy_char_traits>() ); 58053d81ceSMarshall Clow 59053d81ceSMarshall Clow } 60