Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / 21_strings / basic_string / find / char / 1.cc
blobf35b4aec62794312f5df9f01fee7139f99465071
1 // 1999-06-09 bkoz
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.
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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // 21.3.6.1 basic_string find
23 #include <string>
24 #include <testsuite_hooks.h>
26 bool test01(void)
28 bool test __attribute__((unused)) = true;
29 typedef std::string::size_type csize_type;
30 typedef std::string::const_reference cref;
31 typedef std::string::reference ref;
32 csize_type npos = std::string::npos;
33 csize_type csz01, csz02;
35 const char str_lit01[] = "mave";
36 const std::string str01("mavericks, santa cruz");
37 std::string str02(str_lit01);
38 std::string str03("s, s");
39 std::string str04;
41 // size_type find(const string&, 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 );
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 );
69 // size_type find(const char* 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 );
75 // size_type find(const char* 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 );
81 // size_type find(char c, size_type pos = 0) const;
82 csz01 = str01.find('z');
83 csz02 = str01.size() - 1;
84 VERIFY( csz01 == csz02 );
85 csz01 = str01.find('/');
86 VERIFY( csz01 == npos );
87 return test;
90 int main()
92 test01();
93 return 0;