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