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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [tests/] [bvt09.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 TestStringStreams (void)
9
{
10
    const unsigned char magic_Char = 'c';
11
    const unsigned short magic_Short = 1234;
12
    const long magic_Int = -12345678;
13
    const unsigned long magic_UInt = 12345678;
14
    const float magic_Float = 123.45678;
15
    const double magic_Double = 123456789123456.789;
16
    const bool magic_Bool = true;
17
 
18
    char c = magic_Char;
19
    unsigned char uc = magic_Char;
20
    int i = magic_Int;
21
    short si = magic_Short;
22
    long li = magic_Int;
23
    unsigned int ui = magic_UInt;
24
    unsigned short usi = magic_Short;
25
    unsigned long uli = magic_UInt;
26
    float f = magic_Float;
27
    double d = magic_Double;
28
    bool bv = magic_Bool;
29
 
30
    ostringstream os;
31
    os << c << endl;
32
    os << uc << endl;
33
    os << bv << endl;
34
    os << i << endl;
35
    os << ui << endl;
36
    os << li << endl;
37
    os << uli << endl;
38
    os << f << endl;
39
    os << d << endl;
40
    os << si << endl;
41
    os << usi << endl << ends;
42
    os.flush();
43
    cout << os.pos() << " bytes written" << endl;
44
 
45
    c = 0;
46
    uc = 0;
47
    bv = false;
48
    i = ui = li = uli = 0;
49
    f = 0; d = 0;
50
    si = usi = 0;
51
 
52
    istringstream is (os.str());
53
    is >> c;
54
    is >> uc;
55
    is >> bv;
56
    is >> i;
57
    is >> ui;
58
    is >> li;
59
    is >> uli;
60
    is >> f;
61
    is >> d;
62
    is >> si;
63
    is >> usi;
64
 
65
    cout << "Values:" << endl;
66
    cout.format ("char:    '%c'\n", static_cast<int>(c));
67
    cout.format ("u_char:  '%c'\n", static_cast<int>(uc));
68
    cout.format ("bool:    %d\n", static_cast<int>(bv));
69
    cout.format ("int:     %d\n", i);
70
    cout.format ("u_int:   %d\n", ui);
71
    cout.format ("long:    %ld\n", li);
72
    cout.format ("u_long:  %ld\n", uli);
73
    cout.format ("float:   %.2f\n", f);
74
    cout.format ("double:  %.2f\n", d);
75
    cout.format ("short:   %hd\n", static_cast<int>(si));
76
    cout.format ("u_short: %hd\n", static_cast<int>(usi));
77
    cout << endl;
78
 
79
    cout << "Dump:" << endl;
80
    cout << os.str().cdata() << endl;
81
    cout << endl;
82
}
83
 
84
StdBvtMain (TestStringStreams)

powered by: WebSVN 2.1.0

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