1 //==========================================================================
5 // Tests for the Cdl::compare_versions() function.
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
10 // ----------------------------------------------------------------------------
11 // Copyright (C) 1999, 2000 Red Hat, Inc.
13 // This file is part of the eCos host tools.
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)
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
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.
29 // ----------------------------------------------------------------------------
31 //####COPYRIGHTEND####
32 //==========================================================================
33 //#####DESCRIPTIONBEGIN####
36 // Contributors: bartv
38 // Description: A variety of tests for Cdl::compare_versions()
40 //####DESCRIPTIONEND####
41 //==========================================================================
44 #include <cdlconfig.h>
46 #include <cyg/infra/testcase.h>
49 static struct version_data {
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 },
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 }
83 main(int argc, char** argv)
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) {
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());
97 CYG_TEST_PASS("all version comparisons successful");