Bump version to 6.4-15
[LibreOffice.git] / sal / qa / osl / file / osl_old_test_file.cxx
blobee89b836d78b31312a3f4fd0c64b9c5e04ede9ed
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 <osl/process.h>
22 #include <rtl/ustring.hxx>
23 #ifdef SAL_UNX
24 #include <unistd.h>
25 #include <limits.h>
26 #include <string.h>
27 #include <sys/stat.h>
28 #define TEST_VOLUME ""
29 #endif
31 #include <cppunit/TestFixture.h>
32 #include <cppunit/extensions/HelperMacros.h>
33 #include <cppunit/plugin/TestPlugIn.h>
35 namespace osl_test_file
38 class oldtestfile : public CppUnit::TestFixture
40 public:
41 void test_file_001();
42 void test_file_002();
43 void test_file_004();
45 CPPUNIT_TEST_SUITE( oldtestfile );
46 CPPUNIT_TEST( test_file_001 );
47 CPPUNIT_TEST( test_file_002 );
48 CPPUNIT_TEST( test_file_004 );
49 CPPUNIT_TEST_SUITE_END( );
52 #ifndef _WIN32
53 const char * const aSource1[] =
55 "a" , "file:///" TEST_VOLUME "bla/a",
56 ///TODO: check if last slash must be omitted in resolved path.
57 // "a/" , "file:///" TEST_VOLUME "bla/a",
58 "../a" , "file:///" TEST_VOLUME "a" ,
59 "a/.." , "file:///" TEST_VOLUME "bla/",
60 "a/../b" , "file:///" TEST_VOLUME "bla/b",
61 ".." , "file:///" TEST_VOLUME "",
62 "a/b/c/d" , "file:///" TEST_VOLUME "bla/a/b/c/d",
63 "a/./c" , "file:///" TEST_VOLUME "bla/a/c",
64 "file:///bla/blub", "file:///" "bla/blub",
65 nullptr , nullptr
68 const char * const aSource2[ ] =
70 "a" , "file:///" TEST_VOLUME "bla/blubs/schnubbel/a",
71 ///TODO: check if last slash must be omitted in resolved path.
72 // "a/", "file:///" TEST_VOLUME "bla/blubs/schnubbel/a",
73 "../a", "file:///" TEST_VOLUME "bla/blubs/a",
74 "../../a", "file:///" TEST_VOLUME "bla/a",
75 "../../../a", "file:///" TEST_VOLUME "a",
76 "../../../a/b/c/d", "file:///" TEST_VOLUME "a/b/c/d",
77 nullptr,nullptr
79 #endif
81 void oldtestfile::test_file_001()
83 #ifndef _WIN32
84 OUString base1( "file:///" TEST_VOLUME "bla" );
85 int i;
86 for( i = 0 ; aSource1[i] ; i +=2 )
88 OUString target;
89 OUString rel = OUString::createFromAscii( aSource1[i] );
90 oslFileError e = osl_getAbsoluteFileURL( base1.pData, rel.pData , &target.pData );
91 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #1", osl_File_E_None, e );
92 if( e == osl_File_E_None )
94 CPPUNIT_ASSERT_MESSAGE("failure #1.1", target.equalsAscii( aSource1[i+1] ) );
97 #endif
100 void oldtestfile::test_file_002()
102 #ifndef _WIN32
103 OUString base2( "file:///" TEST_VOLUME "bla/blubs/schnubbel" );
104 int i;
105 for( i = 0 ; aSource2[i] ; i +=2 )
107 OUString target;
108 OUString rel = OUString::createFromAscii( aSource2[i] );
109 oslFileError e = osl_getAbsoluteFileURL( base2.pData, rel.pData , &target.pData );
110 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #2", osl_File_E_None, e );
111 if( e == osl_File_E_None )
113 CPPUNIT_ASSERT_MESSAGE("failure #2.1", target.equalsAscii( aSource2[i+1] ) );
116 #endif
119 void oldtestfile::test_file_004()
121 #ifndef _WIN32
122 OUString base4( "file:///" TEST_VOLUME "bla/" );
123 int i;
124 for( i = 0 ; aSource1[i] ; i +=2 )
126 OUString target;
127 OUString rel = OUString::createFromAscii( aSource1[i] );
128 oslFileError e = osl_getAbsoluteFileURL( base4.pData, rel.pData , &target.pData );
129 CPPUNIT_ASSERT_EQUAL_MESSAGE("failure #10", osl_File_E_None, e );
130 if( e == osl_File_E_None )
132 CPPUNIT_ASSERT_MESSAGE("failure #10.1", target.equalsAscii( aSource1[i+1] ) );
135 #endif
138 } // namespace osl_test_file
140 CPPUNIT_TEST_SUITE_REGISTRATION( osl_test_file::oldtestfile);
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */