This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Copy string_view tests from libstdc++


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fdc116781b03f5d30e93f5013159f39c4c0f3471

commit fdc116781b03f5d30e93f5013159f39c4c0f3471
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Mon Apr 9 13:31:05 2018 -0400

    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.

Diff:
---
 gdb/ChangeLog                                      |  75 +++++
 gdb/unittests/basic_string_view/capacity/1.cc      | 162 +++++++++
 .../basic_string_view/capacity/empty_neg.cc        |  28 ++
 gdb/unittests/basic_string_view/cons/char/1.cc     |  68 ++++
 gdb/unittests/basic_string_view/cons/char/2.cc     |  47 +++
 gdb/unittests/basic_string_view/cons/char/3.cc     |  39 +++
 gdb/unittests/basic_string_view/cons/wchar_t/1.cc  |  68 ++++
 gdb/unittests/basic_string_view/cons/wchar_t/2.cc  |  45 +++
 gdb/unittests/basic_string_view/cons/wchar_t/3.cc  |  38 +++
 .../basic_string_view/element_access/char/1.cc     |  70 ++++
 .../basic_string_view/element_access/char/2.cc     |  30 ++
 .../basic_string_view/element_access/char/empty.cc |  38 +++
 .../element_access/char/front_back.cc              |  42 +++
 .../basic_string_view/element_access/wchar_t/1.cc  |  71 ++++
 .../basic_string_view/element_access/wchar_t/2.cc  |  32 ++
 .../element_access/wchar_t/empty.cc                |  38 +++
 .../element_access/wchar_t/front_back.cc           |  42 +++
 gdb/unittests/basic_string_view/include.cc         |  25 ++
 .../basic_string_view/inserters/char/1.cc          |  65 ++++
 .../basic_string_view/inserters/char/2.cc          |  93 ++++++
 .../basic_string_view/inserters/char/3.cc          |  54 +++
 .../basic_string_view/inserters/pod/10081-out.cc   |  75 +++++
 .../basic_string_view/inserters/wchar_t/1.cc       |  70 ++++
 .../basic_string_view/inserters/wchar_t/2.cc       |  91 +++++
 .../basic_string_view/inserters/wchar_t/3.cc       |  53 +++
 gdb/unittests/basic_string_view/literals/types.cc  |  45 +++
 gdb/unittests/basic_string_view/literals/values.cc |  72 ++++
 .../modifiers/remove_prefix/char/1.cc              |  61 ++++
 .../modifiers/remove_prefix/wchar_t/1.cc           |  61 ++++
 .../modifiers/remove_suffix/char/1.cc              |  61 ++++
 .../modifiers/remove_suffix/wchar_t/1.cc           |  61 ++++
 .../basic_string_view/modifiers/swap/char/1.cc     |  35 ++
 .../basic_string_view/modifiers/swap/wchar_t/1.cc  |  35 ++
 .../basic_string_view/operations/compare/char/1.cc | 132 ++++++++
 .../operations/compare/char/13650.cc               |  49 +++
 .../basic_string_view/operations/compare/char/2.cc |  30 ++
 .../operations/compare/char/70483.cc               |  89 +++++
 .../operations/compare/wchar_t/1.cc                | 133 ++++++++
 .../operations/compare/wchar_t/13650.cc            |  49 +++
 .../operations/compare/wchar_t/2.cc                |  30 ++
 .../basic_string_view/operations/copy/char/1.cc    |  45 +++
 .../basic_string_view/operations/copy/wchar_t/1.cc |  46 +++
 .../basic_string_view/operations/data/char/1.cc    |  43 +++
 .../basic_string_view/operations/data/wchar_t/1.cc |  43 +++
 .../basic_string_view/operations/find/char/1.cc    | 164 +++++++++
 .../basic_string_view/operations/find/char/2.cc    | 161 +++++++++
 .../basic_string_view/operations/find/char/3.cc    | 161 +++++++++
 .../basic_string_view/operations/find/char/4.cc    |  44 +++
 .../basic_string_view/operations/find/wchar_t/1.cc | 163 +++++++++
 .../basic_string_view/operations/find/wchar_t/2.cc | 161 +++++++++
 .../basic_string_view/operations/find/wchar_t/3.cc | 161 +++++++++
 .../basic_string_view/operations/find/wchar_t/4.cc |  44 +++
 .../basic_string_view/operations/rfind/char/1.cc   |  94 ++++++
 .../basic_string_view/operations/rfind/char/2.cc   |  52 +++
 .../basic_string_view/operations/rfind/char/3.cc   |  66 ++++
 .../operations/rfind/wchar_t/1.cc                  |  94 ++++++
 .../operations/rfind/wchar_t/2.cc                  |  52 +++
 .../operations/rfind/wchar_t/3.cc                  |  66 ++++
 .../operations/string_conversion/1.cc              |  51 +++
 .../basic_string_view/operations/substr/char/1.cc  |  79 +++++
 .../operations/substr/wchar_t/1.cc                 |  79 +++++
 .../basic_string_view/operators/char/2.cc          | 367 +++++++++++++++++++++
 .../basic_string_view/operators/wchar_t/2.cc       | 367 +++++++++++++++++++++
 .../basic_string_view/range_access/char/1.cc       |  47 +++
 .../basic_string_view/range_access/wchar_t/1.cc    |  47 +++
 .../requirements/explicit_instantiation/1.cc       |  26 ++
 .../requirements/explicit_instantiation/char/1.cc  |  23 ++
 .../explicit_instantiation/char16_t/1.cc           |  24 ++
 .../explicit_instantiation/char32_t/1.cc           |  24 ++
 .../explicit_instantiation/wchar_t/1.cc            |  23 ++
 .../basic_string_view/requirements/typedefs.cc     |  47 +++
 gdb/unittests/basic_string_view/typedefs.cc        |  36 ++
 gdb/unittests/basic_string_view/types/1.cc         |  43 +++
 73 files changed, 5345 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 462fc7d..28520b6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,80 @@
 2018-04-09  Simon Marchi  <simon.marchi@polymtl.ca>
 
+	* 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.
+
+2018-04-09  Simon Marchi  <simon.marchi@polymtl.ca>
+
 	* common/gdb_string_view.h: Remove libstdc++ implementation
 	details, adjust to gdb reality.
 	* common/gdb_string_view.tcc: Likewise.
diff --git a/gdb/unittests/basic_string_view/capacity/1.cc b/gdb/unittests/basic_string_view/capacity/1.cc
new file mode 100644
index 0000000..d49ecbd
--- /dev/null
+++ b/gdb/unittests/basic_string_view/capacity/1.cc
@@ -0,0 +1,162 @@
+// { 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/>.
+
+// string_view size, length
+
+#include <string_view>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+template<typename T>
+  struct A { };
+
+template<typename T>
+  bool
+  operator==(const A<T>&, const A<T>&) { return true; }
+
+template<typename T>
+  bool
+  operator<(const A<T>&, const A<T>&) { return true; }
+
+struct B { };
+
+// char_traits specialization
+namespace std
+{
+  template<>
+    struct char_traits<A<B> >
+    {
+      typedef A<B> 		char_type;
+      // Unsigned as wint_t in unsigned.
+      typedef unsigned long  	int_type;
+      typedef streampos 	pos_type;
+      typedef streamoff 	off_type;
+      typedef mbstate_t 	state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2)
+      { __c1 = __c2; }
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2)
+      { return __c1 == __c2; }
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2)
+      { return __c1 < __c2; }
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n)
+      { 
+	for (size_t __i = 0; __i < __n; ++__i)
+	  if (!eq(__s1[__i], __s2[__i]))
+	    return lt(__s1[__i], __s2[__i]) ? -1 : 1;
+	return 0; 
+      }
+
+      static size_t
+      length(const char_type* __s)
+      { 
+	const char_type* __p = __s; 
+	while (__p) 
+	  ++__p; 
+	return (__p - __s); 
+      }
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a)
+      { 
+	for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
+	  if (*__p == __a) return __p;
+	return 0;
+      }
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a)
+      { 
+	for (char_type* __p = __s; __p < __s + __n; ++__p) 
+	  assign(*__p, __a);
+        return __s; 
+      }
+
+      static char_type 
+      to_char_type(const int_type&)
+      { return char_type(); }
+
+      static int_type 
+      to_int_type(const char_type&) { return int_type(); }
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2)
+      { return __c1 == __c2; }
+
+      static int_type 
+      eof() { return static_cast<int_type>(-1); }
+
+      static int_type 
+      not_eof(const int_type& __c)
+      { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
+    };
+} // namespace std
+
+void
+test01()
+{
+  std::basic_string_view<A<B>> str02;
+  typedef std::basic_string_view< A<B> >::size_type size_type_o;
+  size_type_o sz03;
+  size_type_o sz04;
+
+  // non-POD types: size, length, max_size, empty()
+  bool b01 = str02.empty();  
+  VERIFY( b01 == true );
+  sz03 = str02.size();
+  sz04 = str02.length();
+  VERIFY( sz03 == sz04 );
+  str02.data();
+  sz03 = str02.size();
+  sz04 = str02.length();
+  VERIFY( sz03 == sz04 );
+
+  sz03 = str02.max_size();  
+  VERIFY( sz03 >= sz04 );
+
+  sz03 = str02.size();
+  str02 = {};
+  b01 = str02.empty(); 
+  VERIFY( b01 == true );
+  sz04 = str02.size();  
+  VERIFY( sz03 >= sz04 );
+}
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/capacity/empty_neg.cc b/gdb/unittests/basic_string_view/capacity/empty_neg.cc
new file mode 100644
index 0000000..4ea5063
--- /dev/null
+++ b/gdb/unittests/basic_string_view/capacity/empty_neg.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2017-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/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <string_view>
+
+void
+test01()
+{
+  std::string_view s;
+  s.empty();  // { dg-warning "ignoring return value" }
+}
diff --git a/gdb/unittests/basic_string_view/cons/char/1.cc b/gdb/unittests/basic_string_view/cons/char/1.cc
new file mode 100644
index 0000000..f80ae92
--- /dev/null
+++ b/gdb/unittests/basic_string_view/cons/char/1.cc
@@ -0,0 +1,68 @@
+// { 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 constructors.
+
+#include <string_view>
+#include <string>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  typedef std::string_view::size_type csize_type;
+
+  // basic_string_view()
+  const std::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::string_view str01{str_lit01};
+  VERIFY( str01.length() == 18 );
+  VERIFY( str01.data() == str_lit01 );
+  const std::string_view str02{"baker beach, san francisco"};
+  VERIFY( str02.length() == 26 );
+
+  // basic_string_view(const string_view&)
+  std::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::string_view str05{str_lit01, len_lit01};
+  VERIFY( str05.length() == len_lit01 );
+  VERIFY( str05.data() == str_lit01 );
+
+  // basic_string_view(basic_string& s)
+  std::string istr07(10, 'z');
+  std::string_view str07{istr07};
+  VERIFY( str07.length() == 10 );
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/cons/char/2.cc b/gdb/unittests/basic_string_view/cons/char/2.cc
new file mode 100644
index 0000000..8dbca7a
--- /dev/null
+++ b/gdb/unittests/basic_string_view/cons/char/2.cc
@@ -0,0 +1,47 @@
+// { 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 constructors.
+
+#include <new>
+#include <string_view>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+  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::string_view s1(with_nulls, 28);
+  VERIFY( s1.size() == 28 );
+  std::string_view s2(s1);
+  VERIFY( s2.size() == 28 );
+}
+
+int
+main()
+{ 
+  test03();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/cons/char/3.cc b/gdb/unittests/basic_string_view/cons/char/3.cc
new file mode 100644
index 0000000..c892cbc
--- /dev/null
+++ b/gdb/unittests/basic_string_view/cons/char/3.cc
@@ -0,0 +1,39 @@
+// { 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 constructors.
+
+#include <string_view>
+#include <vector>
+#include <testsuite_hooks.h>
+
+void
+test05()
+{
+  char const * s = 0;
+  std::string_view zero_length_built_with_NULL(s, 0);
+}
+
+int
+main()
+{ 
+  test05();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc b/gdb/unittests/basic_string_view/cons/wchar_t/1.cc
new file mode 100644
index 0000000..4f935d5
--- /dev/null
+++ b/gdb/unittests/basic_string_view/cons/wchar_t/1.cc
@@ -0,0 +1,68 @@
+// { 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 constructors.
+
+#include <string_view>
+#include <string>
+#include <cwchar>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  typedef std::wstring_view::size_type csize_type;
+
+  // basic_string_view()
+  const std::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::wstring_view str01{str_lit01};
+  VERIFY( str01.length() == 18 );
+  VERIFY( str01.data() == str_lit01 );
+  const std::wstring_view str02{L"baker beach, san francisco"};
+  VERIFY( str02.length() == 26 );
+
+  // basic_string_view(const string_view&)
+  std::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::wstring_view str05{str_lit01, len_lit01};
+  VERIFY( str05.length() == len_lit01 );
+  VERIFY( str05.data() == str_lit01 );
+
+  // basic_string_view(basic_string& s)
+  std::wstring istr07(10, L'z');
+  std::wstring_view str07{istr07};
+  VERIFY( str07.length() == 10 );
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc b/gdb/unittests/basic_string_view/cons/wchar_t/2.cc
new file mode 100644
index 0000000..3134ec0
--- /dev/null
+++ b/gdb/unittests/basic_string_view/cons/wchar_t/2.cc
@@ -0,0 +1,45 @@
+// { 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 constructors.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+  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::wstring_view s1 (with_nulls, 28);
+  VERIFY( s1.size() == 28 );
+  std::wstring_view s2 (s1);
+  VERIFY( s2.size() == 28 );
+}
+
+int
+main()
+{ 
+  test03();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc b/gdb/unittests/basic_string_view/cons/wchar_t/3.cc
new file mode 100644
index 0000000..c49dc25
--- /dev/null
+++ b/gdb/unittests/basic_string_view/cons/wchar_t/3.cc
@@ -0,0 +1,38 @@
+// { 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 constructors.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test05()
+{
+  wchar_t const * s = 0;
+  std::wstring_view zero_length_built_with_NULL(s, 0);
+}
+
+int
+main()
+{ 
+  test05();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/element_access/char/1.cc b/gdb/unittests/basic_string_view/element_access/char/1.cc
new file mode 100644
index 0000000..03c588e
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/char/1.cc
@@ -0,0 +1,70 @@
+// { 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 element access
+
+#include <string_view>
+#include <stdexcept>
+#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 csz01, csz02;
+
+  const std::string_view str01("tamarindo, costa rica");
+  std::string_view str02("41st street beach, capitola, california");
+  std::string_view str03;
+
+  // const_reference operator[] (size_type pos) const;
+  csz01 = str01.size();
+  cref cref1 = str01[csz01 - 1];
+  VERIFY( cref1 == 'a' );
+  // Undefined behavior at size().
+  //cref cref2 = str01[csz01];
+  //VERIFY( cref2 == char() );
+
+  // const_reference at(size_type pos) const;
+  csz01 = str01.size();
+  cref cref3 = str01.at(csz01 - 1);
+  VERIFY( cref3 == 'a' );
+  try
+  {
+    str01.at(csz01);
+    VERIFY( false ); // Should not get here, as exception thrown.
+  }
+  catch (std::out_of_range& fail)
+  {
+    VERIFY( true );
+  }
+  catch (...)
+  {
+    VERIFY( false );
+  }
+}
+
+int
+main()
+{ 
+  test01();
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/element_access/char/2.cc b/gdb/unittests/basic_string_view/element_access/char/2.cc
new file mode 100644
index 0000000..4ee2b64a
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/char/2.cc
@@ -0,0 +1,30 @@
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++17 -O0" }
+// { dg-require-debug-mode "" }
+
+// 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/>.
+
+#include <string_view>
+
+int
+main()
+{
+  typedef std::string_view string_view_type;
+  string_view_type s;
+  s[0]; // abort
+}
diff --git a/gdb/unittests/basic_string_view/element_access/char/empty.cc b/gdb/unittests/basic_string_view/element_access/char/empty.cc
new file mode 100644
index 0000000..fad5eb7
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/char/empty.cc
@@ -0,0 +1,38 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 3 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/>.
+//
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+  {
+    std::string_view empty;
+    VERIFY( empty.empty() );
+  }
+
+  {
+    const std::string_view empty;
+    VERIFY( empty.empty() );
+  }
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/element_access/char/front_back.cc b/gdb/unittests/basic_string_view/element_access/char/front_back.cc
new file mode 100644
index 0000000..efff787
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/char/front_back.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++17" }
+// { dg-require-string-conversions "" }
+
+// 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/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  std::string_view str("ramifications");
+  const std::string_view cstr("melodien");
+
+  VERIFY( str.front() == 'r' );
+  VERIFY( str.back() == 's' );
+  VERIFY( cstr.front() == 'm' );
+  VERIFY( cstr.back() == 'n' );
+}
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
new file mode 100644
index 0000000..b74ee29
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
@@ -0,0 +1,71 @@
+// { 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 element access
+
+#include <string_view>
+#include <stdexcept>
+#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 csz01, csz02;
+
+  const std::wstring_view str01(L"tamarindo, costa rica");
+  std::wstring_view str02(L"41st street beach, capitola, california");
+  std::wstring_view str03;
+
+  // const_reference operator[] (size_type pos) const;
+  csz01 = str01.size();
+  cref cref1 = str01[csz01 - 1];
+  VERIFY( cref1 == L'a' );
+  // Undefined behavior at size().
+  //cref cref2 = str01[csz01];
+  //VERIFY( cref2 == wchar_t() );
+
+  // const_reference at(size_type pos) const;
+  csz01 = str01.size();
+  cref cref3 = str01.at(csz01 - 1);
+  VERIFY( cref3 == L'a' );
+  try
+  {
+    str01.at(csz01);
+    VERIFY( false ); // Should not get here, as exception thrown.
+  }
+  catch (std::out_of_range& fail)
+  {
+    VERIFY( true );
+  }
+  catch (...)
+  {
+    VERIFY( false );
+  }
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
new file mode 100644
index 0000000..5b7421f
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
@@ -0,0 +1,32 @@
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++17 -O0" }
+// { dg-require-debug-mode "" }
+
+// 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/>.
+
+#include <string_view>
+
+// libstdc++/21674
+// NB: Should work without any inlining or optimizations (ie. -O0).
+int
+main()
+{
+  typedef std::wstring_view string_view_type;
+  string_view_type s;
+  s[0]; // abort
+}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
new file mode 100644
index 0000000..b1ac051
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
@@ -0,0 +1,38 @@
+// { 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/>.
+//
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+  {
+    std::wstring_view empty;
+    VERIFY( empty.empty() );
+  }
+
+  {
+    const std::wstring_view empty;
+    VERIFY( empty.empty() );
+  }
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
new file mode 100644
index 0000000..a7c8483
--- /dev/null
+++ b/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++17" }
+// { dg-require-string-conversions "" }
+
+// 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/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  std::wstring_view str(L"ramifications");
+  const std::wstring_view cstr(L"melodien");
+
+  VERIFY( str.front() == L'r' );
+  VERIFY( str.back() == L's' );
+  VERIFY( cstr.front() == L'm' );
+  VERIFY( cstr.back() == L'n' );
+}
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/include.cc b/gdb/unittests/basic_string_view/include.cc
new file mode 100644
index 0000000..59dc47d
--- /dev/null
+++ b/gdb/unittests/basic_string_view/include.cc
@@ -0,0 +1,25 @@
+// -*- C++ -*-
+
+// 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/>.
+
+// NB: This issue affected only debug-mode.
+
+// { dg-options "-std=gnu++17 -fno-rtti" }
+// { dg-do compile }
+
+#include <string_view>
diff --git a/gdb/unittests/basic_string_view/inserters/char/1.cc b/gdb/unittests/basic_string_view/inserters/char/1.cc
new file mode 100644
index 0000000..26bd0fd
--- /dev/null
+++ b/gdb/unittests/basic_string_view/inserters/char/1.cc
@@ -0,0 +1,65 @@
+// { 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/>.
+
+// inserters
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string_view class.
+
+#include <string_view>
+#include <stdexcept>
+#include <sstream>
+#include <fstream>
+#include <iostream>
+#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;
+
+  const std::string_view str01("sailing grand traverse bay\n"
+	       "\t\t\t    from Elk Rapids to the point reminds me of miles");
+    
+  // ostream& operator<<(ostream&, const basic_string_view&)
+  std::ostringstream ostrs01;
+  try 
+    {
+      ostrs01 << str01;
+      VERIFY( ostrs01.str() == str01 );
+    }
+  catch(std::exception& fail) 
+    {
+      VERIFY( false );
+    }
+  
+  std::string_view hello_world;
+  std::cout << hello_world;
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/inserters/char/2.cc b/gdb/unittests/basic_string_view/inserters/char/2.cc
new file mode 100644
index 0000000..6562d58
--- /dev/null
+++ b/gdb/unittests/basic_string_view/inserters/char/2.cc
@@ -0,0 +1,93 @@
+
+// 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/>.
+
+// inserters
+
+// NB: This file is predicated on sstreams, ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string_view class.
+
+// { dg-options "-std=gnu++17" }
+// { dg-require-fileio "" }
+
+#include <string_view>
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <testsuite_hooks.h>
+
+// testing basic_filebuf::xsputn via stress testing with large string_views
+// based on a bug report libstdc++ 9
+// mode == out
+void
+test05(std::size_t size)
+{
+  bool test = true;
+
+  const char filename[] = "inserters_extractors-2.txt";
+  const char fillc = 'f';
+  std::ofstream ofs(filename);
+  std::string str(size, fillc);
+  std::string_view strv{str};
+
+  // sanity checks
+  VERIFY( str.size() == size );
+  VERIFY( ofs.good() );
+
+  // stress test
+  ofs << str << std::endl;
+  if (!ofs.good()) 
+    test = false;
+
+  ofs << str << std::endl;
+  if (!ofs.good()) 
+    test = false;
+
+  VERIFY( str.size() == size );
+  VERIFY( ofs.good() );
+
+  ofs.close();
+
+  // sanity check on the written file
+  std::ifstream ifs(filename);
+  std::size_t count = 0;
+  char c;
+  while (count <= (2 * size) + 4)
+    {
+      ifs >> c;
+      if (ifs.good() && c == fillc)
+	{
+	  ++count;
+	  c = '0';
+	}
+      else 
+	break;
+    }
+
+  VERIFY( count == 2 * size );
+}
+
+int
+main()
+{
+  test05(1); 
+  test05(1000); 
+  test05(10000);
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/inserters/char/3.cc b/gdb/unittests/basic_string_view/inserters/char/3.cc
new file mode 100644
index 0000000..7905661
--- /dev/null
+++ b/gdb/unittests/basic_string_view/inserters/char/3.cc
@@ -0,0 +1,54 @@
+// { 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/>.
+
+// inserters
+
+// NB: This file is predicated on sstreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string_view class.
+
+#include <string_view>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+// libstdc++/2830
+void
+test09()
+{
+  std::string_view foo{"peace\0\0\0& love"};
+
+  std::ostringstream oss1;
+  oss1 << foo;
+  VERIFY( oss1.str() == foo );
+
+  std::ostringstream oss2;
+  oss2.width(20);
+  oss2 << foo;
+  VERIFY( oss2.str() != foo );
+  VERIFY( oss2.str().size() == 20 );
+}
+
+int
+main()
+{ 
+  test09();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc b/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
new file mode 100644
index 0000000..15538a4
--- /dev/null
+++ b/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
@@ -0,0 +1,75 @@
+// { 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/>.
+
+// class basic_istream::sentry
+
+#include <string_view>
+#include <ostream>
+#include <sstream>
+#include <locale>
+#include <typeinfo>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+void
+test01()
+{
+  using namespace std;
+
+  using __gnu_test::pod_ushort;
+  typedef basic_string_view<pod_ushort> 	string_type;
+  typedef basic_stringbuf<pod_ushort> 	stringbuf_type;
+  typedef basic_ostream<pod_ushort> 	ostream_type;
+
+  string_type str;
+  stringbuf_type strbuf01;
+  ostream_type stream(&strbuf01);
+
+  try
+    {
+      stream << str;
+    }
+  catch (std::bad_cast& obj)
+    {
+      // Ok, throws bad_cast because locale has no ctype facet.
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+
+  const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
+  stream.imbue(loc);
+  try
+    {
+      stream << str;
+    }
+  catch (...)
+    {
+      VERIFY( false );
+    }
+}
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
new file mode 100644
index 0000000..c5cbdba
--- /dev/null
+++ b/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
@@ -0,0 +1,70 @@
+// { 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/>.
+
+// inserters
+
+// NB: This file is predicated on sstreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string_view class.
+
+#include <string_view>
+#include <stdexcept>
+#include <sstream>
+#include <fstream>
+#include <iostream>
+#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;
+
+  const std::wstring_view str01(L"sailing grand traverse bay\n"
+	       L"\t\t\t    from Elk Rapids to the point reminds me of miles");
+  const std::wstring_view str02(L"sailing");
+  const std::wstring_view str03(L"grand");
+  const std::wstring_view str04(L"traverse");
+  const std::wstring_view str05;
+  std::wstring_view str10;
+
+  // ostream& operator<<(ostream&, const basic_string_view&)
+  std::wostringstream ostrs01;
+  try 
+    {
+      ostrs01 << str01;
+      VERIFY( ostrs01.str() == str01 );
+    }
+  catch(std::exception& fail) 
+    {
+      VERIFY( false );
+    }
+  
+  std::wstring_view hello_world;
+  std::wcout << hello_world;
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
new file mode 100644
index 0000000..ebb2752
--- /dev/null
+++ b/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
@@ -0,0 +1,91 @@
+// { 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/>.
+
+// inserters
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string_view class.
+
+#include <string_view>
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <testsuite_hooks.h>
+
+// testing basic_filebuf::xsputn via stress testing with large string_views
+// based on a bug report libstdc++ 9
+// mode == out
+void
+test05(std::size_t size)
+{
+  bool test = true;
+
+  const char filename[] = "inserters_extractors-2.txt";
+  const wchar_t fillc = L'f';
+  std::wofstream ofs(filename);
+  std::wstring str(size, fillc);
+  std::wstring_view strv(str);
+
+  // sanity checks
+  VERIFY( str.size() == size );
+  VERIFY( ofs.good() );
+
+  // stress test
+  ofs << str << std::endl;
+  if (!ofs.good()) 
+    test = false;
+
+  ofs << str << std::endl;
+  if (!ofs.good()) 
+    test = false;
+
+  VERIFY( str.size() == size );
+  VERIFY( ofs.good() );
+
+  ofs.close();
+
+  // sanity check on the written file
+  std::wifstream ifs(filename);
+  std::size_t count = 0;
+  wchar_t c;
+  while (count <= (2 * size) + 4)
+    {
+      ifs >> c;
+      if (ifs.good() && c == fillc)
+	{
+	  ++count;
+	  c = '0';
+	}
+      else 
+	break;
+    }
+
+  VERIFY( count == 2 * size );
+}
+
+int
+main()
+{
+  test05(1); 
+  test05(1000); 
+  test05(10000);
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
new file mode 100644
index 0000000..569c421
--- /dev/null
+++ b/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
@@ -0,0 +1,53 @@
+// { 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/>.
+
+// inserters
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string_view class.
+
+#include <string_view>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void
+test09()
+{
+  std::wstring_view foo{L"peace\0\0\0& love"};
+  
+  std::wostringstream oss1;
+  oss1 << foo;
+  VERIFY( oss1.str() == foo );
+  
+  std::wostringstream oss2;
+  oss2.width(20);
+  oss2 << foo;
+  VERIFY( oss2.str() != foo );
+  VERIFY( oss2.str().size() == 20 );
+}
+
+int
+main()
+{ 
+  test09();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/literals/types.cc b/gdb/unittests/basic_string_view/literals/types.cc
new file mode 100644
index 0000000..8b3b467
--- /dev/null
+++ b/gdb/unittests/basic_string_view/literals/types.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// 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/>.
+
+#include <string_view>
+#include <type_traits>
+
+void
+test01()
+{
+  using namespace std::literals::string_view_literals;
+
+  static_assert(std::is_same<decltype("Hello"sv), std::string_view>::value,
+		"\"Hello\"s is std::string_view");
+
+  static_assert(std::is_same<decltype(u8"Hello"sv), std::string_view>::value,
+		"u8\"Hello\"s is std::string_view");
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  static_assert(std::is_same<decltype(L"Hello"sv), std::wstring_view>::value,
+		"L\"Hello\"s is std::wstring_view");
+#endif
+
+  static_assert(std::is_same<decltype(u"Hello"sv), std::u16string_view>::value,
+		"u\"Hello\"s is std::u16string_view");
+
+  static_assert(std::is_same<decltype(U"Hello"sv), std::u32string_view>::value,
+		"U\"Hello\"s is std::u32string_view");
+}
diff --git a/gdb/unittests/basic_string_view/literals/values.cc b/gdb/unittests/basic_string_view/literals/values.cc
new file mode 100644
index 0000000..b2897a1
--- /dev/null
+++ b/gdb/unittests/basic_string_view/literals/values.cc
@@ -0,0 +1,72 @@
+// { 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/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  using namespace std::literals::string_view_literals;
+
+  std::string_view planet = "Mercury"sv;
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wstring_view wplanet = L"Venus"sv;
+#endif
+  std::string_view u8planet = u8"Mars"sv;
+  std::u16string_view u16planet = u"Jupiter"sv;
+  std::u32string_view u32planet = U"Saturn"sv;
+
+  VERIFY( planet == std::string_view("Mercury") );
+#ifdef _GLIBCXX_USE_WCHAR_T
+  VERIFY( wplanet == std::wstring_view(L"Venus") );
+#endif
+  VERIFY( u8planet == std::string_view(u8"Mars") );
+  VERIFY( u16planet == std::u16string_view(u"Jupiter") );
+  VERIFY( u32planet == std::u32string_view(U"Saturn") );
+}
+
+void
+test02()
+{
+  using namespace std::literals::string_view_literals;
+
+  std::string_view planet_cratered = "Mercury\0cratered"sv;
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
+#endif
+  std::string_view u8planet_cratered = u8"Mars\0cratered"sv;
+  std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
+  std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
+
+  VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) );
+#ifdef _GLIBCXX_USE_WCHAR_T
+  VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
+#endif
+  VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) );
+  VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) );
+  VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) );
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
new file mode 100644
index 0000000..ba08a98
--- /dev/null
+++ b/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
@@ -0,0 +1,61 @@
+// { 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/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  using std::string_view;
+
+  string_view str0{"olympus mons"};
+  string_view::pointer p = str0.data();
+  str0.remove_prefix(4);
+  VERIFY( str0.data() == p + 4);
+  VERIFY( str0.length() == 8 );
+  VERIFY( str0 == string_view{"pus mons"} );
+}
+
+constexpr bool
+test02()
+{
+  using std::string_view;
+
+  string_view str0{"olympus mons"};
+  string_view::pointer p = str0.data();
+  str0.remove_prefix(4);
+  if ( str0.data() != p + 4)
+    return false;
+  if ( str0.length() != 8 )
+    return false;
+  if ( str0 != string_view{"pus mons"} )
+    return false;
+
+  return true;
+}
+
+int
+main()
+{ 
+  test01();
+  static_assert( test02() );
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
new file mode 100644
index 0000000..3c69118
--- /dev/null
+++ b/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
@@ -0,0 +1,61 @@
+// { 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/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  using std::wstring_view;
+
+  wstring_view str0{L"olympus mons"};
+  wstring_view::pointer p = str0.data();
+  str0.remove_prefix(4);
+  VERIFY( str0.data() == p + 4);
+  VERIFY( str0.length() == 8 );
+  VERIFY( str0 == wstring_view{L"pus mons"} );
+}
+
+constexpr bool
+test02()
+{
+  using std::wstring_view;
+
+  wstring_view str0{L"olympus mons"};
+  wstring_view::pointer p = str0.data();
+  str0.remove_prefix(4);
+  if ( str0.data() != p + 4)
+    return false;
+  if ( str0.length() != 8 )
+    return false;
+  if ( str0 != wstring_view{L"pus mons"} )
+    return false;
+
+  return true;
+}
+
+int
+main()
+{ 
+  test01();
+  static_assert( test02() );
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
new file mode 100644
index 0000000..1b71ee9
--- /dev/null
+++ b/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
@@ -0,0 +1,61 @@
+// { 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/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  using std::string_view;
+
+  string_view str0{"olympus mons"};
+  string_view::pointer p = str0.data();
+  str0.remove_suffix(2);
+  VERIFY( str0.data() == p);
+  VERIFY( str0.length() == 10 );
+  VERIFY( str0 == string_view{"olympus mo"} );
+}
+
+constexpr bool
+test02()
+{
+  using std::string_view;
+
+  string_view str0{"olympus mons"};
+  string_view::pointer p = str0.data();
+  str0.remove_suffix(2);
+  if ( str0.data() != p)
+    return false;
+  if ( str0.length() != 10 )
+    return false;
+  if ( str0 != string_view{"olympus mo"} )
+    return false;
+
+  return true;
+}
+
+int
+main()
+{ 
+  test01();
+  static_assert( test02() );
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
new file mode 100644
index 0000000..0f94a09
--- /dev/null
+++ b/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
@@ -0,0 +1,61 @@
+// { 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/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  using std::wstring_view;
+
+  wstring_view str0{L"olympus mons"};
+  wstring_view::pointer p = str0.data();
+  str0.remove_suffix(2);
+  VERIFY( str0.data() == p);
+  VERIFY( str0.length() == 10 );
+  VERIFY( str0 == wstring_view{L"olympus mo"} );
+}
+
+constexpr bool
+test02()
+{
+  using std::wstring_view;
+
+  wstring_view str0{L"olympus mons"};
+  wstring_view::pointer p = str0.data();
+  str0.remove_suffix(2);
+  if ( str0.data() != p)
+    return false;
+  if ( str0.length() != 10 )
+    return false;
+  if ( str0 != wstring_view{L"olympus mo"} )
+    return false;
+
+  return true;
+}
+
+int
+main()
+{ 
+  test01();
+  static_assert( test02() );
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
new file mode 100644
index 0000000..90d2669
--- /dev/null
+++ b/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2017-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/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <string_view>
+
+constexpr bool
+test01()
+{
+  using std::string_view;
+
+  string_view s1{"last"};
+  string_view s2{"first"};
+
+  s1.swap(s2);
+  return s1 == "first" && s2 == "last";
+}
+
+static_assert( test01() );
diff --git a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
new file mode 100644
index 0000000..bd757ec
--- /dev/null
+++ b/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2017-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/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <string_view>
+
+constexpr bool
+test01()
+{
+  using std::wstring_view;
+
+  wstring_view s1{L"last"};
+  wstring_view s2{L"first"};
+
+  s1.swap(s2);
+  return s1 == L"first" && s2 == L"last";
+}
+
+static_assert( test01() );
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/1.cc b/gdb/unittests/basic_string_view/operations/compare/char/1.cc
new file mode 100644
index 0000000..46691eb
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/compare/char/1.cc
@@ -0,0 +1,132 @@
+// { 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::compare
+// int compare(const basic_string_view& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string_view& str,
+//             size_type pos2, size_type n2) const;
+// int compare(const charT* s) const;
+// int compare(size_type pos1, size_type n1,
+//             const charT* s, size_type n2 = npos) const;
+
+// NB compare should be thought of as a lexographical compare, ie how
+// things would be sorted in a dictionary.
+
+#include <string_view>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+enum want_value {lt=0, z=1, gt=2};
+
+int
+test_value(int result, want_value expected);
+
+int
+test_value(int result, want_value expected)
+{
+  bool pass = false;
+
+  switch (expected) {
+  case lt:
+    if (result < 0)
+      pass = true;
+    break;
+  case z:
+    if (!result)
+      pass = true;
+    break;
+  case gt:
+    if (result > 0)
+      pass = true;
+    break;
+  default:
+    pass = false; //should not get here
+  }
+  VERIFY(pass);
+  return 0;
+}
+
+int
+test01()
+{
+  using std::string_view;
+
+  string_view 	str_0("costa rica");
+  string_view 	str_1("costa marbella");
+  string_view 	str_2;
+
+  //sanity check
+  test_value(strcmp("costa marbella", "costa rica"), lt);
+  test_value(strcmp("costa rica", "costa rica"), z);
+  test_value(strcmp(str_1.data(), str_0.data()), lt);
+  test_value(strcmp(str_0.data(), str_1.data()), gt);
+  test_value(strncmp(str_1.data(), str_0.data(), 6), z);
+  test_value(strncmp(str_1.data(), str_0.data(), 14), lt);
+  test_value(memcmp(str_1.data(), str_0.data(), 6), z);
+  test_value(memcmp(str_1.data(), str_0.data(), 10), lt);
+  test_value(memcmp("costa marbella", "costa rica", 10), lt);
+
+  // int compare(const basic_string_view& str) const;
+  test_value(str_0.compare(str_1), gt); //because r>m
+  test_value(str_1.compare(str_0), lt); //because m<r
+  str_2 = str_0;
+  test_value(str_2.compare(str_0), z);
+  str_2 = "cost";
+  test_value(str_2.compare(str_0), lt);
+  str_2 = "costa ricans";
+  test_value(str_2.compare(str_0), gt);
+
+  // int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
+  test_value(str_1.compare(0, 6, str_0), lt);
+  str_2 = "cost";
+  test_value(str_1.compare(0, 4, str_2), z);
+  test_value(str_1.compare(0, 5, str_2), gt);
+
+  // int compare(size_type pos1, size_type n1, const basic_string_view& str,
+  //		 size_type pos2, size_type n2) const;
+  test_value(str_1.compare(0, 6, str_0, 0, 6), z);
+  test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
+  test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
+
+  // int compare(const charT* s) const;
+  test_value(str_0.compare("costa marbella"), gt);
+  test_value(str_1.compare("costa rica"), lt);
+  str_2 = str_0;
+  test_value(str_2.compare("costa rica"), z);
+  test_value(str_2.compare("cost"), gt);
+  test_value(str_2.compare("costa ricans"), lt);
+
+  // int compare(size_type pos, size_type n1, const charT* str,
+  //             size_type n2 = npos) const;
+  test_value(str_1.compare(0, 6, "costa rica", 0, 6), z);
+  test_value(str_1.compare(0, 7, "costa rica", 0, 7), lt);
+  test_value(str_0.compare(0, 7, "costa marbella", 0, 7), gt);
+
+  return 0;
+}
+
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/13650.cc b/gdb/unittests/basic_string_view/operations/compare/char/13650.cc
new file mode 100644
index 0000000..ef9df20
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/compare/char/13650.cc
@@ -0,0 +1,49 @@
+// { 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::compare [lib.string_view::compare]
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+// libstdc++/13650
+void
+test01()
+{
+  using std::string_view;
+
+  const char lit_01[]{ 'w', 'e', '\0', 'r', 'd' };
+  const char lit_02[]{ 'w', 'e', 'i', '\0', 'd' };
+
+  const char lit_ref_a[]{ 'w', 'e', '\0', 'q', 'd' };
+  const string_view str_a(lit_ref_a, 5);
+  VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
+
+  const char lit_ref_b[]{ 'w', 'e', 'i' };
+  const string_view str_b(lit_ref_b, 3);
+  VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
+}
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/2.cc b/gdb/unittests/basic_string_view/operations/compare/char/2.cc
new file mode 100644
index 0000000..ad9945a
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/compare/char/2.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2017-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/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <string_view>
+
+constexpr char c1[] = "one";
+constexpr char c2[] = "two";
+
+constexpr std::string_view s1{c1};
+constexpr std::string_view s2{c2};
+
+constexpr int n1 = s1.compare(s1);
+constexpr int n2 = s1.compare(s2);
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc b/gdb/unittests/basic_string_view/operations/compare/char/70483.cc
new file mode 100644
index 0000000..5954d57
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/compare/char/70483.cc
@@ -0,0 +1,89 @@
+// Copyright (C) 2017-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/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <string_view>
+
+struct constexpr_char_traits : std::char_traits<char>
+{
+  static constexpr size_t
+  length(const char* val)
+  {
+    size_t res = 0;
+    for (; val[res] != '\0'; ++res)
+      ;
+    return res;
+  }
+
+  static constexpr int
+  compare(const char* lhs, const char* rhs, std::size_t count)
+  {
+    for (size_t pos = 0; pos < count; ++pos)
+    {
+      if (lhs[pos] != rhs[pos])
+        return lhs[pos] - rhs[pos];
+    }
+    return 0;
+  }
+};
+
+using string_view = std::basic_string_view<char, constexpr_char_traits>;
+
+constexpr
+string_view get()
+{
+    string_view res = "x::";
+    string_view start_pattern = "x";
+    res = res.substr(res.find(start_pattern) + start_pattern.size());
+    res = res.substr(0, res.find_first_of(";]"));
+    res = res.substr(res.rfind("::"));
+    return res;
+}
+
+static_assert( get() == get() );
+
+using std::u16string_view;
+
+constexpr
+u16string_view get16()
+{
+    u16string_view res = u"x::";
+    u16string_view start_pattern = u"x";
+    res = res.substr(res.find(start_pattern) + start_pattern.size());
+    res = res.substr(0, res.find_first_of(u";]"));
+    res = res.substr(res.rfind(u"::"));
+    return res;
+}
+
+static_assert( get16() == get16() );
+
+using std::u32string_view;
+
+constexpr
+u32string_view get32()
+{
+    u32string_view res = U"x::";
+    u32string_view start_pattern = U"x";
+    res = res.substr(res.find(start_pattern) + start_pattern.size());
+    res = res.substr(0, res.find_first_of(U";]"));
+    res = res.substr(res.rfind(U"::"));
+    return res;
+}
+
+static_assert( get32() == get32() );
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
new file mode 100644
index 0000000..15de7cc
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
@@ -0,0 +1,133 @@
+// { 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::compare
+// int compare(const basic_string_view& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string_view& str,
+//             size_type pos2, size_type n2) const;
+// int compare(const charT* s) const;
+// int compare(size_type pos1, size_type n1,
+//             const charT* s, size_type n2 = npos) const;
+
+// NB compare should be thought of as a lexographical compare, ie how
+// things would be sorted in a dictionary.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+enum want_value {lt=0, z=1, gt=2};
+
+int
+test_value(int result, want_value expected);
+
+int
+test_value(int result, want_value expected)
+{
+  bool pass = false;
+
+  switch (expected) {
+  case lt:
+    if (result < 0)
+      pass = true;
+    break;
+  case z:
+    if (!result)
+      pass = true;
+    break;
+  case gt:
+    if (result > 0)
+      pass = true;
+    break;
+  default:
+    pass = false; //should not get here
+  }
+
+  VERIFY(pass);
+  return 0;
+}
+
+
+int
+test01()
+{
+  using std::wstring_view;
+
+  wstring_view 	str_0(L"costa rica");
+  wstring_view 	str_1(L"costa marbella");
+  wstring_view 	str_2;
+
+  //sanity check
+  test_value(wcscmp(L"costa marbella", L"costa rica"), lt);
+  test_value(wcscmp(L"costa rica", L"costa rica"), z);
+  test_value(wcscmp(str_1.data(), str_0.data()), lt);
+  test_value(wcscmp(str_0.data(), str_1.data()), gt);
+  test_value(wcsncmp(str_1.data(), str_0.data(), 6), z);
+  test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt);
+  test_value(wmemcmp(str_1.data(), str_0.data(), 6), z);
+  test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt);
+  test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt);
+
+  // int compare(const basic_string_view& str) const;
+  test_value(str_0.compare(str_1), gt); //because r>m
+  test_value(str_1.compare(str_0), lt); //because m<r
+  str_2 = str_0;
+  test_value(str_2.compare(str_0), z);
+  str_2 = L"cost";
+  test_value(str_2.compare(str_0), lt);
+  str_2 = L"costa ricans";
+  test_value(str_2.compare(str_0), gt);
+
+  // int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
+  test_value(str_1.compare(0, 6, str_0), lt);
+  str_2 = L"cost";
+  test_value(str_1.compare(0, 4, str_2), z);
+  test_value(str_1.compare(0, 5, str_2), gt);
+
+  // int compare(size_type pos1, size_type n1, const basic_string_view& str,
+  //		 size_type pos2, size_type n2) const;
+  test_value(str_1.compare(0, 6, str_0, 0, 6), z);
+  test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
+  test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
+
+  // int compare(const charT* s) const;
+  test_value(str_0.compare(L"costa marbella"), gt);
+  test_value(str_1.compare(L"costa rica"), lt);
+  str_2 = str_0;
+  test_value(str_2.compare(L"costa rica"), z);
+  test_value(str_2.compare(L"cost"), gt);
+  test_value(str_2.compare(L"costa ricans"), lt);
+
+  // int compare(size_type pos, size_type n1, const charT* str,
+  //             size_type n2 = npos) const;
+  test_value(str_1.compare(0, 6, L"costa rica", 0, 6), z);
+  test_value(str_1.compare(0, 7, L"costa rica", 0, 7), lt);
+  test_value(str_0.compare(0, 7, L"costa marbella", 0, 7), gt);
+
+  return 0;
+}
+
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
new file mode 100644
index 0000000..dd19eb8
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
@@ -0,0 +1,49 @@
+// { 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::compare [lib.string_view::compare]
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+// libstdc++/13650
+void
+test01()
+{
+  using std::wstring_view;
+
+  const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' };
+  const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' };
+
+  const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' };
+  const wstring_view str_a(lit_ref_a, 5);
+  VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
+
+  const wchar_t lit_ref_b[] = { L'w', L'e', L'i' };
+  const wstring_view str_b(lit_ref_b, 3);
+  VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
+}
+
+int
+main()
+{
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
new file mode 100644
index 0000000..250129c
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2017-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/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <string_view>
+
+constexpr wchar_t c1[] = L"one";
+constexpr wchar_t c2[] = L"two";
+
+constexpr std::wstring_view s1{c1};
+constexpr std::wstring_view s2{c2};
+
+constexpr int n1 = s1.compare(s1);
+constexpr int n2 = s1.compare(s2);
diff --git a/gdb/unittests/basic_string_view/operations/copy/char/1.cc b/gdb/unittests/basic_string_view/operations/copy/char/1.cc
new file mode 100644
index 0000000..6caf0e1
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/copy/char/1.cc
@@ -0,0 +1,45 @@
+// { 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::copy
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  typedef std::string_view::size_type csize_type;
+
+  const char str_lit01[] = "123456789A";
+  const std::string_view str01(str_lit01);
+  char buffer[4] = { 0 };
+
+  csize_type len = str01.copy(buffer, sizeof(buffer), 8);
+  VERIFY( 2 == len );
+  VERIFY( '9' == buffer[0] );
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
new file mode 100644
index 0000000..84f3208
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
@@ -0,0 +1,46 @@
+// { 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::copy
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  typedef std::wstring_view::size_type csize_type;
+  csize_type csz01;
+
+  const wchar_t str_lit01[] = L"123456789A";
+  const std::wstring_view str01(str_lit01);
+  wchar_t buffer[4] = { 0 };
+
+  csize_type len = str01.copy(buffer, sizeof(buffer), 8);
+  VERIFY( 2 == len );
+  VERIFY( L'9' == buffer[0] );
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/data/char/1.cc b/gdb/unittests/basic_string_view/operations/data/char/1.cc
new file mode 100644
index 0000000..18fc9f5
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/data/char/1.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++17" }
+
+// 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/>.
+
+// string_view operations
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+test01()
+{
+  std::string_view empty;
+
+  VERIFY( empty.size() == 0 );
+  const std::string_view::value_type* p = empty.data();
+  VERIFY( p == nullptr );
+
+  return 0;
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
diff --git a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
new file mode 100644
index 0000000..6596db5
--- /dev/null
+++ b/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++17" }
+
+// 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/>.
+
+// string_view operations
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+int
+test01()
+{
+  std::wstring_view empty;
+
+  VERIFY( empty.size() == 0 );
+  const std::wstring_view::value_type* p = empty.data();
+  VERIFY( p == nullptr );
+
+  return 0;
+}
+
+int
+main()
+{ 
+  test01();
+
+  return 0;
+}
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 0000000..d7d2f37
--- /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 0000000..af8a526
--- /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[...]

[diff truncated at 100000 bytes]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]