Fix GNU C++ version check
[LibreOffice.git] / sal / qa / osl / file / osl_old_test_file.cxx
blob871e8913689e6fb9c5aa71c0a77a66aaa9cf2a8b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <osl/file.h>
21 #include <rtl/ustring.hxx>
23 #ifdef SAL_UNX
24 #define TEST_VOLUME ""
25 #elif defined _WIN32
26 #define TEST_VOLUME "Z:/"
27 #endif
29 #include <cppunit/TestFixture.h>
30 #include <cppunit/extensions/HelperMacros.h>
32 #include <utility>
34 namespace osl_test_file
37 class oldtestfile : public CppUnit::TestFixture
39 public:
40 void test_file_001();
41 void test_file_002();
42 void test_file_004();
44 CPPUNIT_TEST_SUITE( oldtestfile );
45 CPPUNIT_TEST( test_file_001 );
46 CPPUNIT_TEST( test_file_002 );
47 CPPUNIT_TEST( test_file_004 );
48 CPPUNIT_TEST_SUITE_END( );
51 const std::pair<OUString, OUString> aSource1[] = {
52 { u"a"_ustr, u"file:///" TEST_VOLUME "bla/a"_ustr },
53 ///TODO: check if last slash must be omitted in resolved path.
54 // { u"a/"_ustr, u"file:///" TEST_VOLUME "bla/a"_ustr },
55 { u"../a"_ustr, u"file:///" TEST_VOLUME "a"_ustr },
56 { u"a/.."_ustr, u"file:///" TEST_VOLUME "bla/"_ustr },
57 { u"a/../b"_ustr, u"file:///" TEST_VOLUME "bla/b"_ustr },
58 { u".."_ustr, u"file:///" TEST_VOLUME ""_ustr },
59 { u"a/b/c/d"_ustr, u"file:///" TEST_VOLUME "bla/a/b/c/d"_ustr },
60 { u"a/./c"_ustr, u"file:///" TEST_VOLUME "bla/a/c"_ustr },
61 { u"a/././c"_ustr, u"file:///" TEST_VOLUME "bla/a/c"_ustr },
62 { u"file:///" TEST_VOLUME "bla1/blub"_ustr, u"file:///" TEST_VOLUME "bla1/blub"_ustr },
65 const std::pair<OUString, OUString> aSource2[] = {
66 { u"a"_ustr, u"file:///" TEST_VOLUME "bla/blubs/schnubbel/a"_ustr },
67 ///TODO: check if last slash must be omitted in resolved path.
68 // { u"a/"_ustr, u"file:///" TEST_VOLUME "bla/blubs/schnubbel/a"_ustr },
69 { u"../a"_ustr, u"file:///" TEST_VOLUME "bla/blubs/a"_ustr },
70 { u"../../a"_ustr, u"file:///" TEST_VOLUME "bla/a"_ustr },
71 { u"../../../a"_ustr, u"file:///" TEST_VOLUME "a"_ustr },
72 { u"../../../a/b/c/d"_ustr, u"file:///" TEST_VOLUME "a/b/c/d"_ustr },
75 void oldtestfile::test_file_001()
77 OUString base1( u"file:///" TEST_VOLUME "bla"_ustr );
78 for (const auto& [rel, expected] : aSource1)
80 OUString target;
81 oslFileError e = osl_getAbsoluteFileURL( base1.pData, rel.pData , &target.pData );
82 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #1", osl_File_E_None, e );
83 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #1.1", expected, target);
87 void oldtestfile::test_file_002()
89 OUString base2( u"file:///" TEST_VOLUME "bla/blubs/schnubbel"_ustr );
90 for (const auto& [rel, expected] : aSource2)
92 OUString target;
93 oslFileError e = osl_getAbsoluteFileURL( base2.pData, rel.pData , &target.pData );
94 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #2", osl_File_E_None, e );
95 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #2.1", expected, target);
99 void oldtestfile::test_file_004()
101 OUString base4( u"file:///" TEST_VOLUME "bla/"_ustr );
102 for (const auto& [rel, expected] : aSource1)
104 OUString target;
105 oslFileError e = osl_getAbsoluteFileURL( base4.pData, rel.pData , &target.pData );
106 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #10", osl_File_E_None, e );
107 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #10.1", expected, target);
111 } // namespace osl_test_file
113 CPPUNIT_TEST_SUITE_REGISTRATION( osl_test_file::oldtestfile);
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */