OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [21_strings/] [basic_string/] [find/] [wchar_t/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 1999-06-09 bkoz
2
 
3
// Copyright (C) 1994, 1999, 2000, 2003 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// 21.3.6.1 basic_string find
22
 
23
#include <string>
24
#include <testsuite_hooks.h>
25
 
26
bool test01(void)
27
{
28
  bool test __attribute__((unused)) = true;
29
  typedef std::wstring::size_type csize_type;
30
  typedef std::wstring::const_reference cref;
31
  typedef std::wstring::reference ref;
32
  csize_type npos = std::wstring::npos;
33
  csize_type csz01, csz02;
34
 
35
  const wchar_t str_lit01[] = L"mave";
36
  const std::wstring str01(L"mavericks, santa cruz");
37
  std::wstring str02(str_lit01);
38
  std::wstring str03(L"s, s");
39
  std::wstring str04;
40
 
41
  // size_type find(const wstring&, size_type pos = 0) const;
42
  csz01 = str01.find(str01);
43
  VERIFY( csz01 == 0 );
44
  csz01 = str01.find(str01, 4);
45
  VERIFY( csz01 == npos );
46
  csz01 = str01.find(str02, 0);
47
  VERIFY( csz01 == 0 );
48
  csz01 = str01.find(str02, 3);
49
  VERIFY( csz01 == npos );
50
  csz01 = str01.find(str03, 0);
51
  VERIFY( csz01 == 8 );
52
  csz01 = str01.find(str03, 3);
53
  VERIFY( csz01 == 8 );
54
  csz01 = str01.find(str03, 12);
55
  VERIFY( csz01 == npos );
56
 
57
  // An empty string consists of no characters
58
  // therefore it should be found at every point in a string,
59
  // except beyond the end
60
  csz01 = str01.find(str04, 0);
61
  VERIFY( csz01 == 0 );
62
  csz01 = str01.find(str04, 5);
63
  VERIFY( csz01 == 5 );
64
  csz01 = str01.find(str04, str01.size());
65
  VERIFY( csz01 == str01.size() );
66
  csz01 = str01.find(str04, str01.size()+1);
67
  VERIFY( csz01 == npos );
68
 
69
  // size_type find(const wchar_t* s, size_type pos, size_type n) const;
70
  csz01 = str01.find(str_lit01, 0, 3);
71
  VERIFY( csz01 == 0 );
72
  csz01 = str01.find(str_lit01, 3, 0);
73
  VERIFY( csz01 == 3 );
74
 
75
  // size_type find(const wchar_t* s, size_type pos = 0) const;
76
  csz01 = str01.find(str_lit01);
77
  VERIFY( csz01 == 0 );
78
  csz01 = str01.find(str_lit01, 3);
79
  VERIFY( csz01 == npos );
80
 
81
  // size_type find(wchar_t c, size_type pos = 0) const;
82
  csz01 = str01.find(L'z');
83
  csz02 = str01.size() - 1;
84
  VERIFY( csz01 == csz02 );
85
  csz01 = str01.find(L'/');
86
  VERIFY( csz01 == npos );
87
  return test;
88
}
89
 
90
int main()
91
{
92
  test01();
93
  return 0;
94
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.