libstdc++: Complete __gnu_debug::string Standard conformity
Add testsuite/testsuite_string.h header to help testing __gnu_debug::basic_string like std::basic_string depending on _GLIBCXX_DEBUG. Add using of base type methods in __gnu_debug::basic_string to make use of the method overloads when there is no debug version. Fix _GLIBCXX_DEBUG_PEDANTIC assertions in <debug/string>. This header has to be used directly like __gnu_debug::string, it is not included by _GLIBCXX_DEBUG. It means that _GLIBCXX_DEBUG_PEDANTIC is not considered to define __glibcxx_check_string and __glibcxx_check_string_len which are then empty macros. Now those macros are defined directly in <debug/string> and properly consider _GLIBCXX_DEBUG_PEDANTIC. libstdc++-v3/ChangeLog: * include/debug/debug.h [_GLIBCXX_DEBUG](__glibcxx_requires_string): Define using _GLIBCXX_DEBUG_PEDASSERT. [_GLIBCXX_DEBUG](__glibcxx_requires_string_len): Likewise. * include/debug/macros.h (__glibcxx_check_string, __glibcxx_check_string_len): Move... * include/debug/string (__glibcxx_check_string, __glibcxx_check_string_len): ...here. And define depending on _GLIBCXX_DEBUG_PEDANTIC no matter if _GLIBCXX_DEBUG is defined. Add using of std::string find, rfind, find_first_of, find_last_of, find_first_not_of and find_last_not_of. Remove debug implementations having no debug assertion. * testsuite/util/testsuite_string.h: New file. Provides __gnu_test::string and __gnu_test::wtring which definition depends on _GLIBCXX_DEBUG. * testsuite/21_strings/basic_string/debug/find1_neg.cc: New test case. * testsuite/21_strings/basic_string/debug/find2_neg.cc: New test case. * testsuite/21_strings/basic_string/operations/find/char/1.cc: Include <testsuite_string.h> and use __gnu_test::string. * testsuite/21_strings/basic_string/operations/find/char/2.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/3.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/4.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/5.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/6.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc: Include <testsuite_string.h> and use __gnu_test::wstring. * testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc: Likewise.
This commit is contained in:
parent
68f37670ef
commit
c66dc02384
18 changed files with 199 additions and 123 deletions
|
@ -118,9 +118,10 @@ namespace __gnu_debug
|
|||
__glibcxx_check_heap(_First,_Last)
|
||||
# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
|
||||
__glibcxx_check_heap_pred(_First,_Last,_Pred)
|
||||
# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
|
||||
# define __glibcxx_requires_string(_String) \
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_String != 0)
|
||||
# define __glibcxx_requires_string_len(_String,_Len) \
|
||||
__glibcxx_check_string_len(_String,_Len)
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
|
||||
# define __glibcxx_requires_irreflexive(_First,_Last) \
|
||||
__glibcxx_check_irreflexive(_First,_Last)
|
||||
# define __glibcxx_requires_irreflexive2(_First,_Last) \
|
||||
|
|
|
@ -467,8 +467,4 @@ _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \
|
|||
_M_message(__gnu_debug::__msg_equal_allocs) \
|
||||
._M_sequence(_This, "this"))
|
||||
|
||||
#define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
|
||||
#define __glibcxx_check_string_len(_String,_Len) \
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,20 @@
|
|||
# define _GLIBCXX_INSERT_RETURNS_ITERATOR_ONLY(expr)
|
||||
#endif
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG_PEDANTIC
|
||||
# define __glibcxx_check_string(_String) \
|
||||
_GLIBCXX_DEBUG_VERIFY_STR_COND_AT(_String != 0, \
|
||||
__FILE__, __LINE__, \
|
||||
__PRETTY_FUNCTION__);
|
||||
# define __glibcxx_check_string_len(_String,_Len) \
|
||||
_GLIBCXX_DEBUG_VERIFY_STR_COND_AT(_String != 0 || _Len == 0, \
|
||||
__FILE__, __LINE__, \
|
||||
__PRETTY_FUNCTION__);
|
||||
#else
|
||||
# define __glibcxx_check_string(_String)
|
||||
# define __glibcxx_check_string_len(_String,_Len)
|
||||
#endif
|
||||
|
||||
namespace __gnu_debug
|
||||
{
|
||||
/** Checks that __s is non-NULL or __n == 0, and then returns __s. */
|
||||
|
@ -868,34 +882,28 @@ namespace __gnu_debug
|
|||
|
||||
using _Base::get_allocator;
|
||||
|
||||
size_type
|
||||
find(const basic_string& __str, size_type __pos = 0) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find(__str, __pos); }
|
||||
using _Base::find;
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find(__s, __pos, __n);
|
||||
}
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find(const _CharT* __s, size_type __pos = 0) const
|
||||
find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find(__s, __pos);
|
||||
}
|
||||
|
||||
size_type
|
||||
find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find(__c, __pos); }
|
||||
|
||||
size_type
|
||||
rfind(const basic_string& __str, size_type __pos = _Base::npos) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{ return _Base::rfind(__str, __pos); }
|
||||
using _Base::rfind;
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
rfind(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
|
@ -903,6 +911,7 @@ namespace __gnu_debug
|
|||
return _Base::rfind(__s, __pos, __n);
|
||||
}
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
rfind(const _CharT* __s, size_type __pos = _Base::npos) const
|
||||
{
|
||||
|
@ -910,105 +919,85 @@ namespace __gnu_debug
|
|||
return _Base::rfind(__s, __pos);
|
||||
}
|
||||
|
||||
size_type
|
||||
rfind(_CharT __c, size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
|
||||
{ return _Base::rfind(__c, __pos); }
|
||||
|
||||
size_type
|
||||
find_first_of(const basic_string& __str, size_type __pos = 0) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_first_of(__str, __pos); }
|
||||
using _Base::find_first_of;
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find_first_of(__s, __pos, __n);
|
||||
}
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_first_of(const _CharT* __s, size_type __pos = 0) const
|
||||
find_first_of(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find_first_of(__s, __pos);
|
||||
}
|
||||
|
||||
size_type
|
||||
find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_first_of(__c, __pos); }
|
||||
|
||||
size_type
|
||||
find_last_of(const basic_string& __str,
|
||||
size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_last_of(__str, __pos); }
|
||||
using _Base::find_last_of;
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find_last_of(__s, __pos, __n);
|
||||
}
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find_last_of(__s, __pos);
|
||||
}
|
||||
|
||||
size_type
|
||||
find_last_of(_CharT __c, size_type __pos = _Base::npos) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_last_of(__c, __pos); }
|
||||
|
||||
size_type
|
||||
find_first_not_of(const basic_string& __str, size_type __pos = 0) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_first_not_of(__str, __pos); }
|
||||
using _Base::find_first_not_of;
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string_len(__s, __n);
|
||||
return _Base::find_first_not_of(__s, __pos, __n);
|
||||
}
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_first_not_of(const _CharT* __s, size_type __pos = 0) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find_first_not_of(__s, __pos);
|
||||
}
|
||||
|
||||
size_type
|
||||
find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_first_not_of(__c, __pos); }
|
||||
|
||||
size_type
|
||||
find_last_not_of(const basic_string& __str,
|
||||
size_type __pos = _Base::npos) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_last_not_of(__str, __pos); }
|
||||
using _Base::find_last_not_of;
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find_last_not_of(__s, __pos, __n);
|
||||
}
|
||||
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
size_type
|
||||
find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_string(__s);
|
||||
return _Base::find_last_not_of(__s, __pos);
|
||||
}
|
||||
|
||||
size_type
|
||||
find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
|
||||
_GLIBCXX_NOEXCEPT
|
||||
{ return _Base::find_last_not_of(__c, __pos); }
|
||||
|
||||
basic_string
|
||||
substr(size_type __pos = 0, size_type __n = _Base::npos) const
|
||||
{ return basic_string(_Base::substr(__pos, __n)); }
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2022 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-do run { xfail *-*-* } }
|
||||
|
||||
#define _GLIBCXX_DEBUG_PEDANTIC
|
||||
|
||||
#include <debug/string>
|
||||
|
||||
void test01()
|
||||
{
|
||||
const char* __null_str = 0;
|
||||
__gnu_debug::string str;
|
||||
str.find(__null_str);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2022 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-do run { xfail *-*-* } }
|
||||
|
||||
#define _GLIBCXX_DEBUG_PEDANTIC
|
||||
|
||||
#include <debug/string>
|
||||
|
||||
void test01()
|
||||
{
|
||||
const char* __null_str = 0;
|
||||
__gnu_debug::string str;
|
||||
str.find(__null_str, 0, 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -19,22 +19,22 @@
|
|||
|
||||
// 21.3.6.1 basic_string find
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01(void)
|
||||
{
|
||||
typedef std::string::size_type csize_type;
|
||||
typedef std::string::const_reference cref;
|
||||
typedef std::string::reference ref;
|
||||
csize_type npos = std::string::npos;
|
||||
typedef __gnu_test::string::size_type csize_type;
|
||||
typedef __gnu_test::string::const_reference cref;
|
||||
typedef __gnu_test::string::reference ref;
|
||||
csize_type npos = __gnu_test::string::npos;
|
||||
csize_type csz01, csz02;
|
||||
|
||||
const char str_lit01[] = "mave";
|
||||
const std::string str01("mavericks, santa cruz");
|
||||
std::string str02(str_lit01);
|
||||
std::string str03("s, s");
|
||||
std::string str04;
|
||||
const __gnu_test::string str01("mavericks, santa cruz");
|
||||
__gnu_test::string str02(str_lit01);
|
||||
__gnu_test::string str03("s, s");
|
||||
__gnu_test::string str04;
|
||||
|
||||
// size_type find(const string&, size_type pos = 0) const;
|
||||
csz01 = str01.find(str01);
|
||||
|
|
|
@ -19,23 +19,23 @@
|
|||
|
||||
// 21.3.6.3 basic_string find_first_of
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test02(void)
|
||||
{
|
||||
typedef std::string::size_type csize_type;
|
||||
csize_type npos = std::string::npos;
|
||||
typedef __gnu_test::string::size_type csize_type;
|
||||
csize_type npos = __gnu_test::string::npos;
|
||||
csize_type csz01, csz02;
|
||||
|
||||
const char str_lit01[] = "mave";
|
||||
const std::string str01("mavericks, santa cruz");
|
||||
std::string str02(str_lit01);
|
||||
std::string str03("s, s");
|
||||
std::string str04;
|
||||
const __gnu_test::string str01("mavericks, santa cruz");
|
||||
__gnu_test::string str02(str_lit01);
|
||||
__gnu_test::string str03("s, s");
|
||||
__gnu_test::string str04;
|
||||
|
||||
// size_type find_first_of(const string&, size_type pos = 0) const;
|
||||
std::string str05("xena rulez");
|
||||
__gnu_test::string str05("xena rulez");
|
||||
csz01 = str01.find_first_of(str01);
|
||||
VERIFY( csz01 == 0 );
|
||||
csz01 = str01.find_first_of(str01, 4);
|
||||
|
|
|
@ -19,20 +19,20 @@
|
|||
|
||||
// 21.3.6.5 basic_string find_first_not_of
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test03(void)
|
||||
{
|
||||
typedef std::string::size_type csize_type;
|
||||
csize_type npos = std::string::npos;
|
||||
typedef __gnu_test::string::size_type csize_type;
|
||||
csize_type npos = __gnu_test::string::npos;
|
||||
csize_type csz01;
|
||||
|
||||
const std::string str01("Bob Rock, per me");
|
||||
const __gnu_test::string str01("Bob Rock, per me");
|
||||
const char str_lit01[] = "Bob Rock";
|
||||
std::string str02("ovvero Trivi");
|
||||
std::string str03(str_lit01);
|
||||
std::string str04;
|
||||
__gnu_test::string str02("ovvero Trivi");
|
||||
__gnu_test::string str03(str_lit01);
|
||||
__gnu_test::string str04;
|
||||
|
||||
// size_type find_first_not_of(const string&, size_type pos = 0) const;
|
||||
csz01 = str01.find_first_not_of(str01);
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
|
||||
// 21.3.6.1 basic_string find
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/31401
|
||||
void test01()
|
||||
{
|
||||
typedef std::string::size_type csize_type;
|
||||
csize_type npos = std::string::npos;
|
||||
typedef __gnu_test::string::size_type csize_type;
|
||||
csize_type npos = __gnu_test::string::npos;
|
||||
|
||||
std::string use = "anu";
|
||||
__gnu_test::string use = "anu";
|
||||
csize_type pos1 = use.find("a", npos);
|
||||
|
||||
VERIFY( pos1 == npos );
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
// [string::find.first.not.of]
|
||||
// [string::find.last.not.of]
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test03()
|
||||
{
|
||||
std::string_view str1("bar");
|
||||
std::string str2("foobar");
|
||||
__gnu_test::string str2("foobar");
|
||||
|
||||
auto x = str2.find(str1);
|
||||
VERIFY (x == 3);
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
// C++11 21.4.7.2 [string::find] basic_string find
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// https://gcc.gnu.org/ml/libstdc++/2017-01/msg00021.html
|
||||
void test01()
|
||||
{
|
||||
typedef std::string string_type;
|
||||
typedef __gnu_test::string string_type;
|
||||
string_type::size_type npos = string_type::npos;
|
||||
|
||||
string_type use = "aaa";
|
||||
|
|
|
@ -19,22 +19,22 @@
|
|||
|
||||
// 21.3.6.1 basic_string find
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01(void)
|
||||
{
|
||||
typedef std::wstring::size_type csize_type;
|
||||
typedef std::wstring::const_reference cref;
|
||||
typedef std::wstring::reference ref;
|
||||
csize_type npos = std::wstring::npos;
|
||||
typedef __gnu_test::wstring::size_type csize_type;
|
||||
typedef __gnu_test::wstring::const_reference cref;
|
||||
typedef __gnu_test::wstring::reference ref;
|
||||
csize_type npos = __gnu_test::wstring::npos;
|
||||
csize_type csz01, csz02;
|
||||
|
||||
const wchar_t str_lit01[] = L"mave";
|
||||
const std::wstring str01(L"mavericks, santa cruz");
|
||||
std::wstring str02(str_lit01);
|
||||
std::wstring str03(L"s, s");
|
||||
std::wstring str04;
|
||||
const __gnu_test::wstring str01(L"mavericks, santa cruz");
|
||||
__gnu_test::wstring str02(str_lit01);
|
||||
__gnu_test::wstring str03(L"s, s");
|
||||
__gnu_test::wstring str04;
|
||||
|
||||
// size_type find(const wstring&, size_type pos = 0) const;
|
||||
csz01 = str01.find(str01);
|
||||
|
|
|
@ -19,23 +19,23 @@
|
|||
|
||||
// 21.3.6.3 basic_string find_first_of
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test02(void)
|
||||
{
|
||||
typedef std::wstring::size_type csize_type;
|
||||
csize_type npos = std::wstring::npos;
|
||||
typedef __gnu_test::wstring::size_type csize_type;
|
||||
csize_type npos = __gnu_test::wstring::npos;
|
||||
csize_type csz01, csz02;
|
||||
|
||||
const wchar_t str_lit01[] = L"mave";
|
||||
const std::wstring str01(L"mavericks, santa cruz");
|
||||
std::wstring str02(str_lit01);
|
||||
std::wstring str03(L"s, s");
|
||||
std::wstring str04;
|
||||
const __gnu_test::wstring str01(L"mavericks, santa cruz");
|
||||
__gnu_test::wstring str02(str_lit01);
|
||||
__gnu_test::wstring str03(L"s, s");
|
||||
__gnu_test::wstring str04;
|
||||
|
||||
// size_type find_first_of(const wstring&, size_type pos = 0) const;
|
||||
std::wstring str05(L"xena rulez");
|
||||
__gnu_test::wstring str05(L"xena rulez");
|
||||
csz01 = str01.find_first_of(str01);
|
||||
VERIFY( csz01 == 0 );
|
||||
csz01 = str01.find_first_of(str01, 4);
|
||||
|
|
|
@ -19,20 +19,20 @@
|
|||
|
||||
// 21.3.6.5 basic_string find_first_not_of
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test03(void)
|
||||
{
|
||||
typedef std::wstring::size_type csize_type;
|
||||
csize_type npos = std::wstring::npos;
|
||||
typedef __gnu_test::wstring::size_type csize_type;
|
||||
csize_type npos = __gnu_test::wstring::npos;
|
||||
csize_type csz01;
|
||||
|
||||
const std::wstring str01(L"Bob Rock, per me");
|
||||
const __gnu_test::wstring str01(L"Bob Rock, per me");
|
||||
const wchar_t str_lit01[] = L"Bob Rock";
|
||||
std::wstring str02(L"ovvero Trivi");
|
||||
std::wstring str03(str_lit01);
|
||||
std::wstring str04;
|
||||
__gnu_test::wstring str02(L"ovvero Trivi");
|
||||
__gnu_test::wstring str03(str_lit01);
|
||||
__gnu_test::wstring str04;
|
||||
|
||||
// size_type find_first_not_of(const string&, size_type pos = 0) const;
|
||||
csz01 = str01.find_first_not_of(str01);
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
|
||||
// 21.3.6.1 basic_string find
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/31401
|
||||
void test01()
|
||||
{
|
||||
typedef std::wstring::size_type csize_type;
|
||||
csize_type npos = std::wstring::npos;
|
||||
typedef __gnu_test::wstring::size_type csize_type;
|
||||
csize_type npos = __gnu_test::wstring::npos;
|
||||
|
||||
std::wstring use = L"anu";
|
||||
__gnu_test::wstring use = L"anu";
|
||||
csize_type pos1 = use.find(L"a", npos);
|
||||
|
||||
VERIFY( pos1 == npos );
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
// [string::find.first.not.of]
|
||||
// [string::find.last.not.of]
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test03()
|
||||
{
|
||||
std::wstring_view str1(L"bar");
|
||||
std::wstring str2(L"foobar");
|
||||
__gnu_test::wstring str2(L"foobar");
|
||||
|
||||
auto x = str2.find(str1);
|
||||
VERIFY (x == 3);
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
// C++11 21.4.7.2 [string::find] basic_string find
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_string.h>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// https://gcc.gnu.org/ml/libstdc++/2017-01/msg00021.html
|
||||
void test01()
|
||||
{
|
||||
typedef std::wstring string_type;
|
||||
typedef __gnu_test::wstring string_type;
|
||||
string_type::size_type npos = string_type::npos;
|
||||
|
||||
string_type use = L"aaa";
|
||||
|
|
20
libstdc++-v3/testsuite/util/testsuite_string.h
Normal file
20
libstdc++-v3/testsuite/util/testsuite_string.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef _GLIBCXX_TESTSUITE_STRING_H
|
||||
#define _GLIBCXX_TESTSUITE_STRING_H
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
# include <debug/string>
|
||||
namespace __gnu_test
|
||||
{
|
||||
using __gnu_debug::string;
|
||||
using __gnu_debug::wstring;
|
||||
}
|
||||
#else
|
||||
# include <string>
|
||||
namespace __gnu_test
|
||||
{
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue