blob: fae4f0aba59bf5e4f8e89bf9d9508d0f579dbee3 [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001/*
2 * Copyright 2007 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "rtc_base/pathutils.h"
12#include "rtc_base/gunit.h"
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000013
14TEST(Pathname, ReturnsDotForEmptyPathname) {
15 const std::string kCWD =
16 std::string(".") + rtc::Pathname::DefaultFolderDelimiter();
17
18 rtc::Pathname path("/", "");
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000019 EXPECT_TRUE (path.filename().empty());
20 EXPECT_FALSE(path.pathname().empty());
21 EXPECT_EQ(std::string("/"), path.pathname());
22
23 path.SetPathname("", "foo");
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000024 EXPECT_FALSE(path.filename().empty());
25 EXPECT_FALSE(path.pathname().empty());
26 EXPECT_EQ(std::string("foo"), path.pathname());
27
28 path.SetPathname("", "");
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000029 EXPECT_TRUE (path.filename().empty());
30 EXPECT_FALSE(path.pathname().empty());
31 EXPECT_EQ(kCWD, path.pathname());
32
33 path.SetPathname(kCWD, "");
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000034 EXPECT_TRUE (path.filename().empty());
35 EXPECT_FALSE(path.pathname().empty());
36 EXPECT_EQ(kCWD, path.pathname());
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000037}