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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.hp/] [gdb.defects/] [bs15503.cc] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
#include <string>
2
#include <iostream.h>
3
 
4
template <class T>
5
class StringTest {
6
public:
7
   virtual void runTest();
8
   void testFunction();
9
};
10
 
11
template <class T>
12
void StringTest<T>:: runTest() {
13
   testFunction ();
14
}
15
 
16
template <class T>
17
void StringTest <T>::testFunction() {
18
   // initialize s with string literal
19
   cout << "in StringTest" << endl;
20
   string s("I am a shot string");
21
   cout << s << endl;
22
 
23
   // insert 'r' to fix "shot"
24
   s.insert(s.begin()+10,'r' );
25
   cout << s << endl;
26
 
27
   // concatenate another string
28
   s += "and now a longer string";
29
   cout << s << endl;
30
 
31
   // find position where blank needs to be inserted
32
   string::size_type spos = s.find("and");
33
   s.insert(spos, " ");
34
   cout << s << endl;
35
 
36
   // erase the concatenated part
37
   s.erase(spos);
38
   cout << s << endl;
39
}
40
 
41
int main() {
42
   StringTest<wchar_t> ts;
43
   ts.runTest();
44
}
45
 
46
/* output:
47
I am a shot string
48
I am a short string
49
I am a short stringand now a longer string
50
I am a short string and now a longer string
51
I am a short string
52
*/

powered by: WebSVN 2.1.0

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