1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <cppunit/TestAssert.h>
23 #include <cppunit/TestFixture.h>
24 #include <cppunit/extensions/HelperMacros.h>
25 #include <cppunit/plugin/TestPlugIn.h>
27 #include <rtl/string.hxx>
28 #include <sal/types.h>
30 #include <jvmfwk/plugins/sunmajor/pluginlib/sunversion.hxx>
34 class TestSunVersion
: public CppUnit::TestFixture
36 CPPUNIT_TEST_SUITE(TestSunVersion
);
37 CPPUNIT_TEST(testSunVersion
);
38 CPPUNIT_TEST_SUITE_END();
40 void testSunVersion();
43 void TestSunVersion::testSunVersion()
45 static char const * versions
[] = {"1.4.0", "1.4.1", "1.0.0", "10.0.0", "10.10.0",
46 "10.2.2", "10.10.0", "10.10.10", "111.0.999",
47 "1.4.1_01", "9.90.99_09", "1.4.1_99",
49 "1.4.1-ea", "1.4.1-beta", "1.4.1-rc1",
50 "1.5.0_01-ea", "1.5.0_01-rc2",
51 "10.0", "10.10", "1.5.0_010"};
52 static char const * badVersions
[] = {".4.0", "..1", "", "10.10.0.", "10.10.0-", "10.10.0.",
53 "10.2-2", "10_10.0", "10..10", "a.0.999",
54 "1.4b.1_01", "9.90.-99_09", "1.4.1_99-",
55 "1.4.1_00a2", "1.4.0_z01z", "1.4.1__99A",
56 "1.4.1-1ea", "1.5.0._01-", "1.5.0_01-eac"};
57 static char const * orderedVer
[] = { "1.3.1-ea", "1.3.1-beta", "1.3.1-rc1",
58 "1.3.1", "1.3.1_00a", "1.3.1_01", "1.3.1_01a",
59 "1.3.2", "1.4.0", "1.5.0_01-ea", "2.0.0"};
61 int num
= SAL_N_ELEMENTS (versions
);
62 int numBad
= SAL_N_ELEMENTS (badVersions
);
63 int numOrdered
= SAL_N_ELEMENTS (orderedVer
);
64 //parsing test (positive)
65 for (int i
= 0; i
< num
; i
++)
67 jfw_plugin::SunVersion
ver(versions
[i
]);
68 CPPUNIT_ASSERT_MESSAGE(
69 OString(OString::Concat("SunVersion(\"") + versions
[i
] + "\") good").getStr(), ver
);
71 //Parsing test (negative)
72 for ( int i
= 0; i
< numBad
; i
++)
74 jfw_plugin::SunVersion
ver(badVersions
[i
]);
75 CPPUNIT_ASSERT_MESSAGE(
76 OString(OString::Concat("SunVersion(\"") + badVersions
[i
] + "\") bad").getStr(), !ver
);
81 for (int i
= 0; i
< numOrdered
; i
++)
83 jfw_plugin::SunVersion
curVer(orderedVer
[i
]);
84 CPPUNIT_ASSERT_MESSAGE(
85 OString(OString::Concat("SunVersion(\"") + orderedVer
[i
] + "\") good").getStr(),
87 for (j
= 0; j
< numOrdered
; j
++)
89 jfw_plugin::SunVersion
compVer(orderedVer
[j
]);
92 CPPUNIT_ASSERT_MESSAGE(
93 OString(OString::Concat("\"") + orderedVer
[i
] + "\" < \"" + orderedVer
[j
])
99 CPPUNIT_ASSERT_MESSAGE(
100 OString(OString::Concat("\"") + orderedVer
[i
] + "\" == \"" + orderedVer
[j
])
102 curVer
.operator ==(compVer
));
103 CPPUNIT_ASSERT_MESSAGE(
104 OString(OString::Concat("not \"") + orderedVer
[i
] + "\" > \"" + orderedVer
[j
])
106 ! (curVer
> compVer
));
107 CPPUNIT_ASSERT_MESSAGE(
108 OString(OString::Concat("not \"") + orderedVer
[i
] + "\" < \"" + orderedVer
[j
])
110 ! (curVer
< compVer
));
114 CPPUNIT_ASSERT_MESSAGE(
115 OString(OString::Concat("\"") + orderedVer
[i
] + "\" > \"" + orderedVer
[j
])
123 CPPUNIT_TEST_SUITE_REGISTRATION(TestSunVersion
);
126 CPPUNIT_PLUGIN_IMPLEMENT();
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */