xref: /aoo42x/main/tools/qa/test_pathutils.cxx (revision 58a353a3)
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 #include "precompiled_tools.hxx"
25 #include "sal/config.h"
26 
27 #include <cwchar>
28 
29 #include "gtest/gtest.h"
30 #include "tools/pathutils.hxx"
31 
32 namespace {
33 
buildPath(wchar_t const * front,wchar_t const * back,wchar_t const * path)34 void buildPath(
35     wchar_t const * front, wchar_t const * back, wchar_t const * path)
36 {
37 #if defined WNT
38     wchar_t p[MAX_PATH];
39     wchar_t * e = tools::buildPath(
40         p, front, front + std::wcslen(front), back, std::wcslen(back));
41     ASSERT_EQ(p + std::wcslen(path), e);
42     ASSERT_EQ(0, std::wcscmp(path, p));
43 #else
44     (void) front;
45     (void) back;
46     (void) path;
47 #endif
48 }
49 
50 class Test: public ::testing::Test {
51 public:
SetUp()52     void SetUp()
53     {
54     }
55 
TearDown()56     void TearDown()
57     {
58     }
59 };
60 
TEST_F(Test,testBuildPath)61 TEST_F(Test, testBuildPath) {
62     buildPath(L"a:\\b\\", L"..", L"a:\\");
63     buildPath(L"a:\\b\\", L"..\\", L"a:\\");
64     buildPath(L"a:\\b\\c\\", L"..\\..\\..\\d", L"a:\\..\\d");
65     buildPath(L"\\\\a\\b\\", L"..\\..\\..\\c", L"\\\\..\\c");
66     buildPath(L"\\", L"..\\a", L"\\..\\a");
67     buildPath(L"", L"..\\a", L"..\\a");
68 }
69 
70 }
71 
main(int argc,char ** argv)72 int main(int argc, char **argv)
73 {
74     ::testing::InitGoogleTest(&argc, argv);
75     return RUN_ALL_TESTS();
76 }
77 
78