diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons')
6 files changed, 323 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/1.cc new file mode 100644 index 000000000..c879cc7e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/1.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view constructors. + +#include <experimental/string_view> +#include <string> +#include <cstring> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test [[gnu::unused]] = true; + typedef std::experimental::string_view::size_type csize_type; + + // basic_string_view() + const std::experimental::string_view str00{}; + VERIFY( str00.length() == 0 ); + VERIFY( str00.data() != nullptr ); + + // basic_string_view(const char*) + const char str_lit01[] = "rodeo beach, marin"; + const std::experimental::string_view str01{str_lit01}; + VERIFY( str01.length() == 18 ); + VERIFY( str01.data() == str_lit01 ); + const std::experimental::string_view str02{"baker beach, san francisco"}; + VERIFY( str02.length() == 26 ); + + // basic_string_view(const string_view&) + std::experimental::string_view str04{str01}; + VERIFY( str04.length() == str01.length() ); + VERIFY( str04.data() == str01.data() ); + + // basic_string_view(const char* s) + csize_type len_lit01 = strlen(str_lit01); + std::experimental::string_view str05{str_lit01, len_lit01}; + VERIFY( str05.length() == len_lit01 ); + VERIFY( str05.data() == str_lit01 ); + + // basic_string_view(const char* s, std::size_t l) + std::experimental::string_view str06{nullptr, len_lit01}; + VERIFY( str06.length() == 0 ); + VERIFY( str06.data() != nullptr ); + + // basic_string_view(basic_string& s) + std::string istr07(10, 'z'); + std::experimental::string_view str07{istr07}; + VERIFY( str07.length() == 10 ); +} + +int +main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/2.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/2.cc new file mode 100644 index 000000000..b58dfb561 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/2.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view constructors. + +#include <new> +#include <experimental/string_view> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test03() +{ + bool test [[gnu::unused]] = true; + const char* with_nulls = "This contains \0 a zero byte."; + + // These are tests to see how basic_string_view handles data with NUL + // bytes. Obviously basic_string_view(char*) will halt at the first one, but + // nothing else should. + std::experimental::string_view s1(with_nulls, 28); + VERIFY( s1.size() == 28 ); + std::experimental::string_view s2(s1); + VERIFY( s2.size() == 28 ); +} + +int +main() +{ + test03(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/3.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/3.cc new file mode 100644 index 000000000..fdb37d51e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/3.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view constructors. + +#include <experimental/string_view> +#include <vector> +#include <testsuite_hooks.h> + +void +test05() +{ + bool test [[gnu::unused]] = true; + + char const * s = 0; + std::experimental::string_view zero_length_built_with_NULL(s, 0); +} + +int +main() +{ + test05(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc new file mode 100644 index 000000000..12db72f28 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view constructors. + +#include <experimental/string_view> +#include <string> +#include <cwchar> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test [[gnu::unused]] = true; + typedef std::experimental::wstring_view::size_type csize_type; + + // basic_string_view() + const std::experimental::wstring_view str00{}; + VERIFY( str00.length() == 0 ); + VERIFY( str00.data() != nullptr ); + + // basic_string_view(const char*) + const wchar_t str_lit01[] = L"rodeo beach, marin"; + const std::experimental::wstring_view str01{str_lit01}; + VERIFY( str01.length() == 18 ); + VERIFY( str01.data() == str_lit01 ); + const std::experimental::wstring_view str02{L"baker beach, san francisco"}; + VERIFY( str02.length() == 26 ); + + // basic_string_view(const string_view&) + std::experimental::wstring_view str04{str01}; + VERIFY( str04.length() == str01.length() ); + VERIFY( str04.data() == str01.data() ); + + // basic_string_view(const char* s) + csize_type len_lit01 = wcslen(str_lit01); + std::experimental::wstring_view str05{str_lit01, len_lit01}; + VERIFY( str05.length() == len_lit01 ); + VERIFY( str05.data() == str_lit01 ); + + // basic_string_view(const wchar_t* s, std::size_t l) + std::experimental::wstring_view str06{nullptr, len_lit01}; + VERIFY( str06.length() == 0 ); + VERIFY( str06.data() != nullptr ); + + // basic_string_view(basic_string& s) + std::wstring istr07(10, L'z'); + std::experimental::wstring_view str07{istr07}; + VERIFY( str07.length() == 10 ); +} + +int +main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/2.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/2.cc new file mode 100644 index 000000000..1d73f2f12 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/2.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view constructors. + +#include <experimental/string_view> +#include <testsuite_hooks.h> + +void +test03() +{ + bool test [[gnu::unused]] = true; + const wchar_t* with_nulls = L"This contains \0 a zero byte."; + + // These are tests to see how basic_string_view handles data with NUL + // bytes. Obviously basic_string_view(char*) will halt at the first one, but + // nothing else should. + std::experimental::wstring_view s1 (with_nulls, 28); + VERIFY( s1.size() == 28 ); + std::experimental::wstring_view s2 (s1); + VERIFY( s2.size() == 28 ); +} + +int +main() +{ + test03(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/3.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/3.cc new file mode 100644 index 000000000..76a1e9436 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/3.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view constructors. + +#include <experimental/string_view> +#include <testsuite_hooks.h> + +void +test05() +{ + bool test [[gnu::unused]] = true; + + wchar_t const * s = 0; + std::experimental::wstring_view zero_length_built_with_NULL(s, 0); +} + +int +main() +{ + test05(); + + return 0; +} |