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

Subversion Repositories openrisc

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

Go to most recent revision | 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 cmemlink& l)
9
{
10
    cout.format ("memlink{%zu}: ", l.size());
11
    const char* pc = reinterpret_cast<const char*>(l.cdata());
12
    size_t nc = l.size();
13
    if (pc[nc - 1] == 0)
14
        -- nc;
15
    cout.write (l.cdata(), nc);
16
    cout << endl;
17
}
18
 
19
void TestML (void)
20
{
21
    char str[] = "abcdefghijklmnopqrstuvwzyz";
22
    memlink::const_pointer cstr = str;
23
 
24
    memlink a, b;
25
    a.static_link (str);
26
    if (a.begin() != str)
27
        cout << "begin() failed on memlink\n";
28
    a.link (VectorRange(str));
29
    if (a.begin() + 5 != &str[5])
30
        cout << "begin() + 5 failed on memlink\n";
31
    if (0 != memcmp (a.begin(), str, VectorSize(str)))
32
        cout << "memcmp failed on memlink\n";
33
    WriteCML (a);
34
    b.link (cstr, VectorSize(str));
35
    if (b.data() != cstr)
36
        cout << "begin() of const failed on cmemlink\n";
37
    if (b.cmemlink::begin() != cstr)
38
        cout << "begin() failed on cmemlink\n";
39
    WriteCML (b);
40
    if (!(a == b))
41
        cout << "operator== failed on cmemlink\n";
42
    b.resize (VectorSize(str) - 2);
43
    a = b;
44
    if (a.data() != b.data())
45
        cout << "begin() after assignment failed on cmemlink\n";
46
    a.relink (str, VectorSize(str) - 1);
47
    WriteCML (a);
48
    a.insert (a.begin() + 5, 9);
49
    a.fill (a.begin() + 5, "-", 1, 9);
50
    WriteCML (a);
51
    a.erase (a.begin() + 9, 7);
52
    a.fill (a.end() - 7, "=", 1, 7);
53
    WriteCML (a);
54
    a.fill (a.begin() + 5, "TEST", 4, 3);
55
    WriteCML (a);
56
    a.copy (cstr, VectorSize(str) - 1);
57
    WriteCML (a);
58
}
59
 
60
StdBvtMain (TestML)

powered by: WebSVN 2.1.0

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