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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [libcdl/] [testsuite/] [libcdl/] [cdl4.cxx] - Blame information for rev 300

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//==========================================================================
2
//
3
//      cdl4.cxx
4
//
5
//      Tests for the Cdl::compare_versions() function.
6
//
7
//==========================================================================
8
//####COPYRIGHTBEGIN####
9
//                                                                          
10
// ----------------------------------------------------------------------------
11
// Copyright (C) 1999, 2000 Red Hat, Inc.
12
//
13
// This file is part of the eCos host tools.
14
//
15
// This program is free software; you can redistribute it and/or modify it 
16
// under the terms of the GNU General Public License as published by the Free 
17
// Software Foundation; either version 2 of the License, or (at your option) 
18
// any later version.
19
// 
20
// This program is distributed in the hope that it will be useful, but WITHOUT 
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
23
// more details.
24
// 
25
// You should have received a copy of the GNU General Public License along with
26
// this program; if not, write to the Free Software Foundation, Inc., 
27
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28
//
29
// ----------------------------------------------------------------------------
30
//                                                                          
31
//####COPYRIGHTEND####
32
//==========================================================================
33
//#####DESCRIPTIONBEGIN####                                             
34
//
35
// Author(s):           bartv
36
// Contributors:        bartv
37
// Date:                1999-01-22
38
// Description:         A variety of tests for Cdl::compare_versions()
39
//
40
//####DESCRIPTIONEND####
41
//==========================================================================
42
 
43
#include <cstdio>
44
#include <cdlconfig.h>
45
#include <cdl.hxx>
46
#include <cyg/infra/testcase.h>
47
#include <cstdlib>
48
 
49
static struct version_data {
50
    char*       arg1;
51
    char*       arg2;
52
    int         expected;
53
} versions[] = {
54
    { "current",        "v0.1",         -1 },
55
    { "v0.1",           "current",       1 },
56
    { "current",        "current",       0 },
57
    { "v0.1",           "v0.1",          0 },
58
    { "v0.1",           "V0.1",          0 },
59
    { "v0_1",           "V0.1",          0 },
60
    { "V0-1",           "v0_1",          0 },
61
    { "v0.2",           "v0.1",         -1 },
62
    { "v0.1",           "v0.2",          1 },
63
    { "v0.10",          "v0.2",         -1 },
64
    { "0.2",            "0.10",          1 },
65
    { "19990122",       "19981224",     -1 },
66
    { "19990122",       "19990124",      1 },
67
    { "ss20000101",     "ss19991231",   -1 },
68
    { "ss19700101",     "ss20380704",    1 },
69
    { "v0.1.2",         "v0.1.3",        1 },
70
    { "v0.1.3",         "v0.1.2",       -1 },
71
    { "v1.0",           "v0.1.3",       -1 },
72
    { "v0.2.5",         "v2.1",          1 },
73
    { "v1.0beta2",      "v1.0",          1 },
74
    { "v0.6",           "v1.0b",         1 },
75
    { "v1.0",           "v1.0a",        -1 },
76
    { "v1.0.p1",        "v1.0",         -1 },
77
    { "v1.0",           "v1.0.p2",       1 },
78
    { "v1.1",           "v1.0,p3",      -1 },
79
    { "finished",       "done",          0 }
80
};
81
 
82
int
83
main(int argc, char** argv)
84
{
85
    bool        ok = true;
86
 
87
    for (int i = 0; 0 != strcmp("finished", versions[i].arg1); i++) {
88
        if (Cdl::compare_versions(versions[i].arg1, versions[i].arg2) != versions[i].expected) {
89
 
90
            std::string result = "comparison of " + std::string(versions[i].arg1) + " and " +
91
                std::string(versions[i].arg2) + " gave wrong result";
92
            CYG_TEST_FAIL(result.c_str());
93
            ok = false;
94
        }
95
    }
96
    if (ok) {
97
        CYG_TEST_PASS("all version comparisons successful");
98
    }
99
    return EXIT_SUCCESS;
100
}

powered by: WebSVN 2.1.0

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