1272343Sngie// 1999-06-09 bkoz
2272343Sngie
3272343Sngie// Copyright (C) 1994, 1999, 2000, 2003, 2009 Free Software Foundation, Inc.
4272343Sngie//
5272343Sngie// This file is part of the GNU ISO C++ Library.  This library is free
6272343Sngie// software; you can redistribute it and/or modify it under the
7272343Sngie// terms of the GNU General Public License as published by the
8272343Sngie// Free Software Foundation; either version 3, or (at your option)
9272343Sngie// any later version.
10272343Sngie
11272343Sngie// This library is distributed in the hope that it will be useful,
12272343Sngie// but WITHOUT ANY WARRANTY; without even the implied warranty of
13272343Sngie// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14272343Sngie// GNU General Public License for more details.
15272343Sngie
16272343Sngie// You should have received a copy of the GNU General Public License along
17272343Sngie// with this library; see the file COPYING3.  If not see
18272343Sngie// <http://www.gnu.org/licenses/>.
19272343Sngie
20272343Sngie// 21.3.6.3 basic_string find_first_of
21272343Sngie
22272343Sngie#include <string>
23272343Sngie#include <testsuite_hooks.h>
24272343Sngie
25272343Sngiebool test02(void)
26272343Sngie{
27272343Sngie  bool test __attribute__((unused)) = true;
28272343Sngie  typedef std::wstring::size_type csize_type;
29272343Sngie  csize_type npos = std::wstring::npos;
30272343Sngie  csize_type csz01, csz02;
31272343Sngie
32272343Sngie  const wchar_t str_lit01[] = L"mave";
33272343Sngie  const std::wstring str01(L"mavericks, santa cruz");
34272343Sngie  std::wstring str02(str_lit01);
35272343Sngie  std::wstring str03(L"s, s");
36272343Sngie  std::wstring str04;
37272343Sngie
38272343Sngie  // size_type find_first_of(const wstring&, size_type pos = 0) const;
39272343Sngie  std::wstring str05(L"xena rulez");
40272343Sngie  csz01 = str01.find_first_of(str01);
41272343Sngie  VERIFY( csz01 == 0 );
42272343Sngie  csz01 = str01.find_first_of(str01, 4);
43272343Sngie  VERIFY( csz01 == 4 );
44272343Sngie  csz01 = str01.find_first_of(str02, 0);
45272343Sngie  VERIFY( csz01 == 0 );
46272343Sngie  csz01 = str01.find_first_of(str02, 3);
47272343Sngie  VERIFY( csz01 == 3 );
48272343Sngie  csz01 = str01.find_first_of(str03, 0);
49272343Sngie  VERIFY( csz01 == 8 );
50272343Sngie  csz01 = str01.find_first_of(str03, 3);
51272343Sngie  VERIFY( csz01 == 8 );
52272343Sngie  csz01 = str01.find_first_of(str03, 12);
53272343Sngie  VERIFY( csz01 == 16 );
54272343Sngie  csz01 = str01.find_first_of(str05, 0);
55272343Sngie  VERIFY( csz01 == 1 );
56272343Sngie  csz01 = str01.find_first_of(str05, 4);
57272343Sngie  VERIFY( csz01 == 4 );
58272343Sngie
59272343Sngie  // An empty string consists of no characters
60272343Sngie  // therefore it should be found at every point in a string,
61272343Sngie  // except beyond the end
62272343Sngie  // However, str1.find_first_of(str2,pos) finds the first character in
63272343Sngie  // str1 (starting at pos) that exists in str2, which is none for empty str2
64272343Sngie  csz01 = str01.find_first_of(str04, 0);
65272343Sngie  VERIFY( csz01 == npos );
66272343Sngie  csz01 = str01.find_first_of(str04, 5);
67272343Sngie  VERIFY( csz01 == npos );
68272343Sngie
69272343Sngie  // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
70272343Sngie  csz01 = str01.find_first_of(str_lit01, 0, 3);
71272343Sngie  VERIFY( csz01 == 0 );
72272343Sngie  csz01 = str01.find_first_of(str_lit01, 3, 0);
73272343Sngie  VERIFY( csz01 == npos );
74272343Sngie
75272343Sngie  // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
76272343Sngie  csz01 = str01.find_first_of(str_lit01);
77272343Sngie  VERIFY( csz01 == 0 );
78272343Sngie  csz01 = str01.find_first_of(str_lit01, 3);
79272343Sngie  VERIFY( csz01 == 3 );
80272343Sngie
81272343Sngie  // size_type find_first_of(wchar_t c, size_type pos = 0) const;
82272343Sngie  csz01 = str01.find_first_of(L'z');
83272343Sngie  csz02 = str01.size() - 1;
84272343Sngie  VERIFY( csz01 == csz02 );
85272343Sngie  return test;
86272343Sngie}
87272343Sngie
88272343Sngieint main()
89272343Sngie{
90272343Sngie  test02();
91272343Sngie  return 0;
92272343Sngie}
93272343Sngie