1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_desktop.hxx"
26
27 #include "sal/config.h"
28
29 #include <cstddef>
30
31 #include "gtest/gtest.h"
32 #include "rtl/ustring.h"
33 #include "rtl/ustring.hxx"
34
35 #include "../../source/deployment/inc/dp_version.hxx"
36
37 namespace {
38
39 class Test: public ::testing::Test {
40 public:
41 };
42
TEST_F(Test,test)43 TEST_F(Test, test) {
44 struct Data {
45 rtl::OUString version1;
46 rtl::OUString version2;
47 ::dp_misc::Order order;
48 };
49 static Data const data[] = {
50 { rtl::OUString(),
51 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0.0000.00.0")),
52 ::dp_misc::EQUAL },
53 { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".01")),
54 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0.1")),
55 ::dp_misc::EQUAL },
56 { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10")),
57 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("2")),
58 ::dp_misc::GREATER },
59 { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("9223372036854775808")),
60 // 2^63
61 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("9223372036854775807")),
62 ::dp_misc::GREATER }
63 };
64 for (::std::size_t i = 0; i < sizeof data / sizeof (Data); ++i) {
65 ASSERT_EQ(
66 data[i].order,
67 ::dp_misc::compareVersions(data[i].version1, data[i].version2));
68 static ::dp_misc::Order const reverse[3] = {
69 ::dp_misc::GREATER, ::dp_misc::EQUAL, ::dp_misc::LESS
70 };
71 ASSERT_EQ(
72 reverse[data[i].order],
73 ::dp_misc::compareVersions(data[i].version2, data[i].version1));
74 }
75 }
76
77
78 }
79