From c9638d2669ced9348eac869dadc7be24df85a9a8 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 9 Apr 2018 13:31:06 -0400 Subject: Adapt and integrate string_view tests The previous patch copied the string_view tests from libstdc++. This patch adjusts them in a similar way that the libstdc++ optional tests are integrated in our unit test suite. Not all tests are used, some of them require language features not present in c++11. For example, we can't use a string_view constructor where the length is not explicit in a constexpr, because std::char_traits::length is not a constexpr itself (it is in c++17 though). Nevertheless, a good number of tests are integrated, which covers pretty well the string_view features. gdb/ChangeLog: * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add string_view-selftests.c. * unittests/basic_string_view/capacity/1.cc: Adapt to GDB testsuite. * unittests/basic_string_view/cons/char/1.cc: Likewise. * unittests/basic_string_view/cons/char/2.cc: Likewise. * unittests/basic_string_view/cons/char/3.cc: Likewise. * unittests/basic_string_view/element_access/char/1.cc: Likewise. * unittests/basic_string_view/element_access/char/empty.cc: Likewise. * unittests/basic_string_view/element_access/char/front_back.cc: Likewise. * unittests/basic_string_view/inserters/char/2.cc: Likewise. * unittests/basic_string_view/modifiers/remove_prefix/char/1.cc: Likewise. * unittests/basic_string_view/modifiers/remove_suffix/char/1.cc: Likewise. * unittests/basic_string_view/modifiers/swap/char/1.cc: Likewise. * unittests/basic_string_view/operations/compare/char/1.cc: Likewise. * unittests/basic_string_view/operations/compare/char/13650.cc: Likewise. * unittests/basic_string_view/operations/copy/char/1.cc: Likewise. * unittests/basic_string_view/operations/data/char/1.cc: Likewise. * unittests/basic_string_view/operations/find/char/1.cc: Likewise. * unittests/basic_string_view/operations/find/char/2.cc: Likewise. * unittests/basic_string_view/operations/find/char/3.cc: Likewise. * unittests/basic_string_view/operations/find/char/4.cc: Likewise. * unittests/basic_string_view/operations/rfind/char/1.cc: Likewise. * unittests/basic_string_view/operations/rfind/char/2.cc: Likewise. * unittests/basic_string_view/operations/rfind/char/3.cc: Likewise. * unittests/basic_string_view/operations/substr/char/1.cc: Likewise. * unittests/basic_string_view/operators/char/2.cc: Likewise. * unittests/string_view-selftests.c: New file. --- gdb/unittests/basic_string_view/capacity/1.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'gdb/unittests/basic_string_view/capacity') diff --git a/gdb/unittests/basic_string_view/capacity/1.cc b/gdb/unittests/basic_string_view/capacity/1.cc index d49ecbd..f297853 100644 --- a/gdb/unittests/basic_string_view/capacity/1.cc +++ b/gdb/unittests/basic_string_view/capacity/1.cc @@ -19,9 +19,7 @@ // string_view size, length -#include -#include -#include +namespace capacity_1 { template struct A { }; @@ -36,13 +34,19 @@ template struct B { }; +} // namespace capacity_1 +} // namespace string_view +} // namespace selftests + // char_traits specialization namespace std { template<> - struct char_traits > + struct char_traits > { - typedef A char_type; + typedef selftests::string_view::capacity_1::A< + selftests::string_view::capacity_1::B> char_type; // Unsigned as wint_t in unsigned. typedef unsigned long int_type; typedef streampos pos_type; @@ -123,11 +127,15 @@ namespace std }; } // namespace std +namespace selftests { +namespace string_view { +namespace capacity_1 { + void test01() { - std::basic_string_view> str02; - typedef std::basic_string_view< A >::size_type size_type_o; + gdb::basic_string_view> str02; + typedef gdb::basic_string_view< A >::size_type size_type_o; size_type_o sz03; size_type_o sz04; @@ -160,3 +168,5 @@ main() return 0; } + +} // namespace capacity_1 -- cgit v1.1