3 // Copyright (C) 1994, 1999, 2000, 2003 Free Software Foundation, Inc.
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)
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.
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 21.3.6.1 basic_string find
24 #include <testsuite_hooks.h>
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;
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");
41 // size_type find(const wstring&, size_type pos = 0) const;
42 csz01 = str01.find(str01);
44 csz01 = str01.find(str01, 4);
45 VERIFY( csz01 == npos );
46 csz01 = str01.find(str02, 0);
48 csz01 = str01.find(str02, 3);
49 VERIFY( csz01 == npos );
50 csz01 = str01.find(str03, 0);
52 csz01 = str01.find(str03, 3);
54 csz01 = str01.find(str03, 12);
55 VERIFY( csz01 == npos );
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);
62 csz01 = str01.find(str04, 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 );
69 // size_type find(const wchar_t* s, size_type pos, size_type n) const;
70 csz01 = str01.find(str_lit01, 0, 3);
72 csz01 = str01.find(str_lit01, 3, 0);
75 // size_type find(const wchar_t* s, size_type pos = 0) const;
76 csz01 = str01.find(str_lit01);
78 csz01 = str01.find(str_lit01, 3);
79 VERIFY( csz01 == npos );
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 );