merge the formfield patch from ooo-build
[ooovba.git] / tools / qa / test_pathutils.cxx
blob097c2ceb942a82f4ab20ce71d0346d4df6f42b1d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: test_pathutils.cxx,v $
10 * $Revision: 1.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "precompiled_tools.hxx"
32 #include "sal/config.h"
34 #include <cwchar>
36 #include "cppunit/simpleheader.hxx"
37 #include "tools/pathutils.hxx"
39 namespace {
41 void buildPath(
42 wchar_t const * front, wchar_t const * back, wchar_t const * path)
44 #if defined WNT
45 wchar_t p[MAX_PATH];
46 wchar_t * e = tools::buildPath(
47 p, front, front + std::wcslen(front), back, std::wcslen(back));
48 CPPUNIT_ASSERT_EQUAL(p + std::wcslen(path), e);
49 CPPUNIT_ASSERT_EQUAL(0, std::wcscmp(path, p));
50 #else
51 (void) front;
52 (void) back;
53 (void) path;
54 #endif
57 class Test: public CppUnit::TestFixture {
58 public:
59 void testBuildPath();
61 CPPUNIT_TEST_SUITE(Test);
62 CPPUNIT_TEST(testBuildPath);
63 CPPUNIT_TEST_SUITE_END();
66 void Test::testBuildPath() {
67 buildPath(L"a:\\b\\", L"..", L"a:\\");
68 buildPath(L"a:\\b\\", L"..\\", L"a:\\");
69 buildPath(L"a:\\b\\c\\", L"..\\..\\..\\d", L"a:\\..\\d");
70 buildPath(L"\\\\a\\b\\", L"..\\..\\..\\c", L"\\\\..\\c");
71 buildPath(L"\\", L"..\\a", L"\\..\\a");
72 buildPath(L"", L"..\\a", L"..\\a");
75 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
79 NOADDITIONAL;