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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [tests/] [bvt08.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
 
6
#include "stdtest.h"
7
 
8
inline void PrintString (const string& str)
9
{
10
    cout << str << endl;
11
}
12
 
13
void TestStringVector (void)
14
{
15
    vector<string> v;
16
 
17
    vector<string>::iterator bogusi = find (v, string("bogus"));
18
    if (bogusi != v.end())
19
        cout << "bogus found at position " << bogusi - v.begin() << endl;
20
 
21
    v.push_back (string("Hello world!"));
22
    v.push_back (string("Hello again!"));
23
    v.push_back (string("element3"));
24
    v.push_back (string("element4"));
25
    v.push_back (string("element5_long_element5"));
26
    for_each (v, &PrintString);
27
 
28
    if (!(v[2] == string("element3")))
29
        cout << "operator== failed" << endl;
30
    vector<string>::iterator el3i = find (v, string("element3"));
31
    if (el3i != v.end())
32
        cout << *el3i << " found at position " << el3i - v.begin() << endl;
33
    bogusi = find (v, string("bogus"));
34
    if (bogusi != v.end())
35
        cout << *bogusi << " found at position " << bogusi - v.begin()<< endl;
36
 
37
    vector<string> v2;
38
    v2 = v;
39
    v = v2;
40
    v.erase (v.end(), v.end());
41
    cout << "After erase (end,end):" << endl;
42
    for_each (v, &PrintString);
43
    v = v2;
44
    v.erase (v.begin() + 2, 2);
45
    cout << "After erase (2,2):" << endl;
46
    for_each (v, &PrintString);
47
    v = v2;
48
    v.pop_back();
49
    cout << "After pop_back():" << endl;
50
    for_each (v, &PrintString);
51
    v = v2;
52
    v.insert (v.begin() + 1, v2.begin() + 1, v2.begin() + 1 + 3);
53
    cout << "After insert(1,1,3):" << endl;
54
    for_each (v, &PrintString);
55
}
56
 
57
StdBvtMain (TestStringVector)

powered by: WebSVN 2.1.0

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