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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [tests/] [bvt00.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 ("cmemlink{%zu}: ", l.size());
11
    const void* pv = l.cdata();
12
    const char* pc = reinterpret_cast<const char*>(pv);
13
    size_t nc = l.size();
14
    if (pc[nc - 1] == 0)
15
        -- nc;
16
    cout.write (l.begin(), nc);
17
    cout << endl;
18
}
19
 
20
void TestCML (void)
21
{
22
    const char hello[] = "Hello world!";
23
    const char* phello = hello; // const storage is sometimes copied on pointing
24
 
25
    cmemlink a, b;
26
    a.link (phello, VectorSize(hello));
27
    if (a.begin() != phello)
28
        cout.format ("a.begin() failed: %p != %p\n", a.begin(), phello);
29
    a.link (VectorRange (hello));
30
    if (*(const char*)(a.begin() + 5) != hello[5])
31
        cout.format ("begin()[5] failed: %c != %c\n", *(const char*)(a.begin() + 5), VectorElement(hello,5));
32
    if (a.size() != VectorSize(hello))
33
        cout << "link to VectorRange doesn't work\n";
34
    if (0 != memcmp (a.begin(), hello, VectorSize(hello)))
35
        cout << "memcmp failed on cmemlink\n";
36
    b.static_link (hello);
37
    WriteCML (a);
38
    WriteCML (b);
39
    if (!(a == b))
40
        cout << "operator== failed on cmemlink\n";
41
    b.resize (VectorSize(hello) - 5);
42
    a = b;
43
    WriteCML (a);
44
}
45
 
46
StdBvtMain (TestCML)

powered by: WebSVN 2.1.0

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