1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "util/Files.h"
18
19#include <sstream>
20
21#include "test/Test.h"
22
23namespace aapt {
24namespace file {
25
26class FilesTest : public ::testing::Test {
27 public:
28  void SetUp() override {
29    std::stringstream builder;
30    builder << "hello" << sDirSep << "there";
31    expected_path_ = builder.str();
32  }
33
34 protected:
35  std::string expected_path_;
36};
37
38TEST_F(FilesTest, AppendPath) {
39  std::string base = "hello";
40  AppendPath(&base, "there");
41  EXPECT_EQ(expected_path_, base);
42}
43
44TEST_F(FilesTest, AppendPathWithLeadingOrTrailingSeparators) {
45  std::string base = "hello/";
46  AppendPath(&base, "there");
47  EXPECT_EQ(expected_path_, base);
48
49  base = "hello";
50  AppendPath(&base, "/there");
51  EXPECT_EQ(expected_path_, base);
52
53  base = "hello/";
54  AppendPath(&base, "/there");
55  EXPECT_EQ(expected_path_, base);
56}
57
58}  // namespace files
59}  // namespace aapt
60