summaryrefslogtreecommitdiff
path: root/gdb/unittests/basic_string_view/operations/find
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-04-09 13:31:05 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2018-04-09 14:20:47 -0400
commitfdc116781b03f5d30e93f5013159f39c4c0f3471 (patch)
tree2ee31f9c22a67f5cef8d33cc6b7e47208bed782f /gdb/unittests/basic_string_view/operations/find
parent8345c4a2670711eafd41c8b6a8726cf8b0771d6e (diff)
downloadbinutils-gdb-fdc116781b03f5d30e93f5013159f39c4c0f3471.tar.gz
Copy string_view tests from libstdc++
This patch copies the string_view tests from the gcc repository (commit 02a4441f002c). ${gcc}/libstdc++-v3/testsuite/21_strings/basic_string_view -> ${binutils-gdb}/gdb/unittests/basic_string_view The local modifications are done in the following patch, so that it's easier to review them. gdb/ChangeLog: * unittests/basic_string_view/capacity/1.cc: New file. * unittests/basic_string_view/capacity/empty_neg.cc: New file. * unittests/basic_string_view/cons/char/1.cc: New file. * unittests/basic_string_view/cons/char/2.cc: New file. * unittests/basic_string_view/cons/char/3.cc: New file. * unittests/basic_string_view/cons/wchar_t/1.cc: New file. * unittests/basic_string_view/cons/wchar_t/2.cc: New file. * unittests/basic_string_view/cons/wchar_t/3.cc: New file. * unittests/basic_string_view/element_access/char/1.cc: New file. * unittests/basic_string_view/element_access/char/2.cc: New file. * unittests/basic_string_view/element_access/char/empty.cc: New file. * unittests/basic_string_view/element_access/char/front_back.cc: New file. * unittests/basic_string_view/element_access/wchar_t/1.cc: New file. * unittests/basic_string_view/element_access/wchar_t/2.cc: New file. * unittests/basic_string_view/element_access/wchar_t/empty.cc: New file. * unittests/basic_string_view/element_access/wchar_t/front_back.cc: New file. * unittests/basic_string_view/include.cc: New file. * unittests/basic_string_view/inserters/char/1.cc: New file. * unittests/basic_string_view/inserters/char/2.cc: New file. * unittests/basic_string_view/inserters/char/3.cc: New file. * unittests/basic_string_view/inserters/pod/10081-out.cc: New file. * unittests/basic_string_view/inserters/wchar_t/1.cc: New file. * unittests/basic_string_view/inserters/wchar_t/2.cc: New file. * unittests/basic_string_view/inserters/wchar_t/3.cc: New file. * unittests/basic_string_view/literals/types.cc: New file. * unittests/basic_string_view/literals/values.cc: New file. * unittests/basic_string_view/modifiers/remove_prefix/char/1.cc: New file. * unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc: New file. * unittests/basic_string_view/modifiers/remove_suffix/char/1.cc: New file. * unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc: New file. * unittests/basic_string_view/modifiers/swap/char/1.cc: New file. * unittests/basic_string_view/modifiers/swap/wchar_t/1.cc: New file. * unittests/basic_string_view/operations/compare/char/1.cc: New file. * unittests/basic_string_view/operations/compare/char/13650.cc: New file. * unittests/basic_string_view/operations/compare/char/2.cc: New file. * unittests/basic_string_view/operations/compare/char/70483.cc: New file. * unittests/basic_string_view/operations/compare/wchar_t/1.cc: New file. * unittests/basic_string_view/operations/compare/wchar_t/13650.cc: New file. * unittests/basic_string_view/operations/compare/wchar_t/2.cc: New file. * unittests/basic_string_view/operations/copy/char/1.cc: New file. * unittests/basic_string_view/operations/copy/wchar_t/1.cc: New file. * unittests/basic_string_view/operations/data/char/1.cc: New file. * unittests/basic_string_view/operations/data/wchar_t/1.cc: New file. * unittests/basic_string_view/operations/find/char/1.cc: New file. * unittests/basic_string_view/operations/find/char/2.cc: New file. * unittests/basic_string_view/operations/find/char/3.cc: New file. * unittests/basic_string_view/operations/find/char/4.cc: New file. * unittests/basic_string_view/operations/find/wchar_t/1.cc: New file. * unittests/basic_string_view/operations/find/wchar_t/2.cc: New file. * unittests/basic_string_view/operations/find/wchar_t/3.cc: New file. * unittests/basic_string_view/operations/find/wchar_t/4.cc: New file. * unittests/basic_string_view/operations/rfind/char/1.cc: New file. * unittests/basic_string_view/operations/rfind/char/2.cc: New file. * unittests/basic_string_view/operations/rfind/char/3.cc: New file. * unittests/basic_string_view/operations/rfind/wchar_t/1.cc: New file. * unittests/basic_string_view/operations/rfind/wchar_t/2.cc: New file. * unittests/basic_string_view/operations/rfind/wchar_t/3.cc: New file. * unittests/basic_string_view/operations/string_conversion/1.cc: New file. * unittests/basic_string_view/operations/substr/char/1.cc: New file. * unittests/basic_string_view/operations/substr/wchar_t/1.cc: New file. * unittests/basic_string_view/operators/char/2.cc: New file. * unittests/basic_string_view/operators/wchar_t/2.cc: New file. * unittests/basic_string_view/range_access/char/1.cc: New file. * unittests/basic_string_view/range_access/wchar_t/1.cc: New file. * unittests/basic_string_view/requirements/explicit_instantiation/1.cc: New file. * unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc: New file. * unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc: New file. * unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc: New file. * unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc: New file. * unittests/basic_string_view/requirements/typedefs.cc: New file. * unittests/basic_string_view/typedefs.cc: New file. * unittests/basic_string_view/types/1.cc: New file.
Diffstat (limited to 'gdb/unittests/basic_string_view/operations/find')
-rw-r--r--gdb/unittests/basic_string_view/operations/find/char/1.cc164
-rw-r--r--gdb/unittests/basic_string_view/operations/find/char/2.cc161
-rw-r--r--gdb/unittests/basic_string_view/operations/find/char/3.cc161
-rw-r--r--gdb/unittests/basic_string_view/operations/find/char/4.cc44
-rw-r--r--gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc163
-rw-r--r--gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc161
-rw-r--r--gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc161
-rw-r--r--gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc44
8 files changed, 1059 insertions, 0 deletions
diff --git a/gdb/unittests/basic_string_view/operations/find/char/1.cc b/gdb/unittests/basic_string_view/operations/find/char/1.cc
new file mode 100644
index 00000000000..d7d2f37706e
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/char/1.cc
@@ -0,0 +1,164 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef std::string_view::size_type csize_type;
+ typedef std::string_view::const_reference cref;
+ typedef std::string_view::reference ref;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01, csz02;
+
+ const char str_lit01[] = "mave";
+ const std::string_view str01("mavericks, santa cruz");
+ std::string_view str02(str_lit01);
+ std::string_view str03("s, s");
+ std::string_view str04;
+
+ // size_type find(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
+ // size_type find(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const char* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(char c, size_type pos = 0) const;
+ csz01 = str01.find('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find('/');
+ VERIFY( csz01 == npos );
+}
+
+constexpr bool
+test02()
+{
+ typedef std::string_view::size_type csize_type;
+ typedef std::string_view::const_reference cref;
+ typedef std::string_view::reference ref;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const char str_lit01[] = "mave";
+ const std::string_view str01("mavericks, santa cruz");
+ std::string_view str02(str_lit01);
+ std::string_view str03("s, s");
+ std::string_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
+ // size_type find(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const char* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(char c, size_type pos = 0) const;
+ csz01 = str01.find('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find('/');
+ VERIFY( csz01 == npos );
+
+ return true;
+}
+
+
+int
+main()
+{
+ test01();
+ static_assert( test02() );
+
+ return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/find/char/2.cc b/gdb/unittests/basic_string_view/operations/find/char/2.cc
new file mode 100644
index 00000000000..af8a526d12c
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/char/2.cc
@@ -0,0 +1,161 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find_first_of
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test02()
+{
+ typedef std::string_view::size_type csize_type;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01, csz02;
+
+ const char str_lit01[] = "mave";
+ const std::string_view str01("mavericks, santa cruz");
+ std::string_view str02(str_lit01);
+ std::string_view str03("s, s");
+ std::string_view str04;
+
+ // size_type find_first_of(const string_view&, size_type pos = 0) const;
+ std::string_view str05("xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_of('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+}
+
+constexpr bool
+test03()
+{
+ typedef std::string_view::size_type csize_type;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const char str_lit01[] = "mave";
+ const std::string_view str01("mavericks, santa cruz");
+ std::string_view str02(str_lit01);
+ std::string_view str03("s, s");
+ std::string_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_of(const string_view&, size_type pos = 0) const;
+ std::string_view str05("xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_of('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+
+ return true;
+}
+
+int
+main()
+{
+ test02();
+ static_assert( test03() );
+
+ return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/find/char/3.cc b/gdb/unittests/basic_string_view/operations/find/char/3.cc
new file mode 100644
index 00000000000..5ec651ef3f9
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/char/3.cc
@@ -0,0 +1,161 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find_first_not_of
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+ typedef std::string_view::size_type csize_type;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01;
+
+ const std::string_view str01("Bob Rock, per me");
+ const char str_lit01[] = "Bob Rock";
+ std::string_view str02("ovvero Trivi");
+ std::string_view str03(str_lit01);
+ std::string_view str04;
+
+ // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of('B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of('o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of('z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of('S');
+ VERIFY( csz01 == npos );
+}
+
+constexpr bool
+test04()
+{
+ typedef std::string_view::size_type csize_type;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01 = 0;
+
+ const std::string_view str01("Bob Rock, per me");
+ const char str_lit01[] = "Bob Rock";
+ std::string_view str02("ovvero Trivi");
+ std::string_view str03(str_lit01);
+ std::string_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of('B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of('o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of('z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of('S');
+ VERIFY( csz01 == npos );
+
+ return true;
+}
+
+int
+main()
+{
+ test03();
+ static_assert( test04() );
+
+ return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/find/char/4.cc b/gdb/unittests/basic_string_view/operations/find/char/4.cc
new file mode 100644
index 00000000000..ca4b1f17db4
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/char/4.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+// libstdc++/31401
+void
+test01()
+{
+ typedef std::string_view::size_type csize_type;
+ csize_type npos = std::string_view::npos;
+
+ std::string_view use = "anu";
+ csize_type pos1 = use.find("a", npos);
+
+ VERIFY( pos1 == npos );
+}
+
+int
+main()
+{
+ test01();
+
+ return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
new file mode 100644
index 00000000000..535b2d5e383
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
@@ -0,0 +1,163 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef std::wstring_view::size_type csize_type;
+ typedef std::wstring_view::const_reference cref;
+ typedef std::wstring_view::reference ref;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01, csz02;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring_view str01(L"mavericks, santa cruz");
+ std::wstring_view str02(str_lit01);
+ std::wstring_view str03(L"s, s");
+ std::wstring_view str04;
+
+ // size_type find(const wstring_view&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
+ // size_type find(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find(L'/');
+ VERIFY( csz01 == npos );
+}
+
+constexpr bool
+test02()
+{
+ typedef std::wstring_view::size_type csize_type;
+ typedef std::wstring_view::const_reference cref;
+ typedef std::wstring_view::reference ref;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring_view str01(L"mavericks, santa cruz");
+ std::wstring_view str02(str_lit01);
+ std::wstring_view str03(L"s, s");
+ std::wstring_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find(const wstring_view&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
+ // size_type find(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find(L'/');
+ VERIFY( csz01 == npos );
+
+ return true;
+}
+
+int
+main()
+{
+ test01();
+ static_assert( test02() );
+
+ return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
new file mode 100644
index 00000000000..2802bf4442c
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
@@ -0,0 +1,161 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find_first_of
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test02()
+{
+ typedef std::wstring_view::size_type csize_type;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01, csz02;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring_view str01(L"mavericks, santa cruz");
+ std::wstring_view str02(str_lit01);
+ std::wstring_view str03(L"s, s");
+ std::wstring_view str04;
+
+ // size_type find_first_of(const wstring_view&, size_type pos = 0) const;
+ std::wstring_view str05(L"xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find_first_of(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+}
+
+constexpr bool
+test04()
+{
+ typedef std::wstring_view::size_type csize_type;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring_view str01(L"mavericks, santa cruz");
+ std::wstring_view str02(str_lit01);
+ std::wstring_view str03(L"s, s");
+ std::wstring_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_of(const wstring_view&, size_type pos = 0) const;
+ std::wstring_view str05(L"xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find_first_of(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+
+ return true;
+}
+
+int
+main()
+{
+ test02();
+ static_assert( test04() );
+
+ return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
new file mode 100644
index 00000000000..6623bbdfc39
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
@@ -0,0 +1,161 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find_first_not_of
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+ typedef std::wstring_view::size_type csize_type;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01;
+
+ const std::wstring_view str01(L"Bob Rock, per me");
+ const wchar_t str_lit01[] = L"Bob Rock";
+ std::wstring_view str02(L"ovvero Trivi");
+ std::wstring_view str03(str_lit01);
+ std::wstring_view str04;
+
+ // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(L'B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of(L'o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of(L'z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of(L'S');
+ VERIFY( csz01 == npos );
+}
+
+constexpr bool
+test04()
+{
+ typedef std::wstring_view::size_type csize_type;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01 = 0;
+
+ const std::wstring_view str01(L"Bob Rock, per me");
+ const wchar_t str_lit01[] = L"Bob Rock";
+ std::wstring_view str02(L"ovvero Trivi");
+ std::wstring_view str03(str_lit01);
+ std::wstring_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(L'B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of(L'o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of(L'z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of(L'S');
+ VERIFY( csz01 == npos );
+
+ return true;
+}
+
+int
+main()
+{
+ test03();
+ static_assert( test04() );
+
+ return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
new file mode 100644
index 00000000000..213bf78cf93
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2018 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 find
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+// libstdc++/31401
+void
+test01()
+{
+ typedef std::wstring_view::size_type csize_type;
+ csize_type npos = std::wstring_view::npos;
+
+ std::wstring_view use = L"anu";
+ csize_type pos1 = use.find(L"a", npos);
+
+ VERIFY( pos1 == npos );
+}
+
+int
+main()
+{
+ test01();
+
+ return 0;
+}