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