summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-11-28 16:53:35 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2018-11-28 16:53:35 +0000
commit0a1369fa9598019354484651f1a16dd8cf7d70c9 (patch)
treef5c28280a8914c96d056de241eb2903b4d29fa74 /libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr
parent188588e443008dd7795947db60b68571ed724fe3 (diff)
downloadgcc-0a1369fa9598019354484651f1a16dd8cf7d70c9.tar.gz
PR libstdc++/83511 add default argument to basic_string_view::substr
PR libstdc++/83511 * include/std/string_view (basic_string_view::substr): Add default argument to first parameter. * include/experimental/string_view (basic_string_view::substr): Likewise. * testsuite/21_strings/basic_string_view/operations/substr/char/ 83511.cc: New test. * testsuite/21_strings/basic_string_view/operations/substr/wchar_t/ 83511.cc: New test. * testsuite/experimental/string_view/operations/substr/char/83511.cc: New test. * testsuite/experimental/string_view/operations/substr/wchar_t/83511.cc: New test. From-SVN: r266568
Diffstat (limited to 'libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr')
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/char/83511.cc38
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/wchar_t/83511.cc38
2 files changed, 76 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/char/83511.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/char/83511.cc
new file mode 100644
index 00000000000..60899130b83
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/char/83511.cc
@@ -0,0 +1,38 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++17 } }
+
+// Copyright (C) 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::substr
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ const std::string_view s = "abcdef";
+ VERIFY( s.substr() == s );
+ VERIFY( std::string_view{}.substr().empty() );
+}
+
+int
+main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/wchar_t/83511.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/wchar_t/83511.cc
new file mode 100644
index 00000000000..478194d138f
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/substr/wchar_t/83511.cc
@@ -0,0 +1,38 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++17 } }
+
+// Copyright (C) 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::substr
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ const std::wstring_view s = L"abcdef";
+ VERIFY( s.substr() == s );
+ VERIFY( std::wstring_view{}.substr().empty() );
+}
+
+int
+main()
+{
+ test01();
+}