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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [tests/] [bvt02.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
void WriteCML (const memblock& l)
9
{
10
    cout.format ("memblock{%zu}: ", l.size());
11
    const char* pc = reinterpret_cast<const char*>(l.cdata());
12
    size_t nc = l.size();
13
    while (nc && pc[nc - 1] == 0)
14
        -- nc;
15
    cout.write (l.cdata(), nc);
16
    cout << endl;
17
}
18
 
19
void TestMB (void)
20
{
21
    char strTest[] = "abcdefghijklmnopqrstuvwxyz";
22
    const size_t strTestLen = strlen(strTest);
23
    const char* cstrTest = strTest;
24
 
25
    memblock a, b;
26
    a.link (strTest, strTestLen);
27
    if (a.begin() != strTest)
28
        cout << "begin() failed on memblock\n";
29
    if (a.begin() + 5 != &strTest[5])
30
        cout << "begin() + 5 failed on memblock\n";
31
    if (0 != memcmp (a.begin(), strTest, strTestLen))
32
        cout << "memcmp failed on memblock\n";
33
    WriteCML (a);
34
    b.link (cstrTest, strTestLen);
35
    if (b.data() != cstrTest)
36
        cout << "begin() of const failed on memblock\n";
37
    if (b.cmemlink::begin() != cstrTest)
38
        cout << "cmemlink::begin() failed on memblock\n";
39
    WriteCML (b);
40
    if (!(a == b))
41
        cout << "operator== failed on memblock\n";
42
    b.copy_link();
43
    if (b.data() == NULL || b.cdata() == cstrTest)
44
        cout << "copy_link failed on memblock\n";
45
    if (!(a == b))
46
        cout << "copy_link didn't copy\n";
47
    b.resize (strTestLen - 2);
48
    a = b;
49
    if (a.begin() == b.begin())
50
        cout << "Assignment does not copy a link\n";
51
    a.deallocate();
52
    a.resize (strTestLen);
53
    a.copy (strTest, strTestLen);
54
    WriteCML (a);
55
    a.insert (a.begin() + 5, 9);
56
    a.fill (a.begin() + 5, "-", 1, 9);
57
    WriteCML (a);
58
    a.erase (a.begin() + 2, 7);
59
    a.fill (a.end() - 7, "=", 1, 7);
60
    WriteCML (a);
61
    a.fill (a.begin() + 5, "TEST", 4, 3);
62
    WriteCML (a);
63
 
64
    a.resize (26 + 24);
65
    a.fill (a.begin() + 26, "-+=", 3, 24 / 3);
66
    WriteCML (a);
67
    a.resize (0);
68
    WriteCML (a);
69
    a.resize (strTestLen + strTestLen / 2);
70
    WriteCML (a);
71
}
72
 
73
StdBvtMain (TestMB)

powered by: WebSVN 2.1.0

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