test_pathutils.cxx (89b56da7) test_pathutils.cxx (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

--- 12 unchanged lines hidden (view full) ---

21
22
23
24#include "precompiled_tools.hxx"
25#include "sal/config.h"
26
27#include <cwchar>
28
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

--- 12 unchanged lines hidden (view full) ---

21
22
23
24#include "precompiled_tools.hxx"
25#include "sal/config.h"
26
27#include <cwchar>
28
29#include "testshl/simpleheader.hxx"
29#include "gtest/gtest.h"
30#include "tools/pathutils.hxx"
31
32namespace {
33
34void 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));
30#include "tools/pathutils.hxx"
31
32namespace {
33
34void 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 CPPUNIT_ASSERT_EQUAL(p + std::wcslen(path), e);
42 CPPUNIT_ASSERT_EQUAL(0, std::wcscmp(path, p));
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
43#else
44 (void) front;
45 (void) back;
46 (void) path;
47#endif
48}
49
50class Test: public CppUnit::TestFixture {
50class Test: public ::testing::Test {
51public:
51public:
52 void testBuildPath();
52 void SetUp()
53 {
54 }
53
55
54 CPPUNIT_TEST_SUITE(Test);
55 CPPUNIT_TEST(testBuildPath);
56 CPPUNIT_TEST_SUITE_END();
56 void TearDown()
57 {
58 }
57};
58
59};
60
59void Test::testBuildPath() {
61TEST_F(Test, testBuildPath) {
60 buildPath(L"a:\\b\\", L"..", L"a:\\");
61 buildPath(L"a:\\b\\", L"..\\", L"a:\\");
62 buildPath(L"a:\\b\\c\\", L"..\\..\\..\\d", L"a:\\..\\d");
63 buildPath(L"\\\\a\\b\\", L"..\\..\\..\\c", L"\\\\..\\c");
64 buildPath(L"\\", L"..\\a", L"\\..\\a");
65 buildPath(L"", L"..\\a", L"..\\a");
66}
67
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
68CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
70}
69
71
72int main(int argc, char **argv)
73{
74 ::testing::InitGoogleTest(&argc, argv);
75 return RUN_ALL_TESTS();
70}
71
76}
77
72NOADDITIONAL;