• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "test/Test.h"
18 #include "util/Files.h"
19 
20 #include <sstream>
21 
22 namespace aapt {
23 namespace file {
24 
25 class FilesTest : public ::testing::Test {
26 public:
SetUp()27     void SetUp() override {
28         std::stringstream builder;
29         builder << "hello" << sDirSep << "there";
30         mExpectedPath = builder.str();
31     }
32 
33 protected:
34     std::string mExpectedPath;
35 };
36 
TEST_F(FilesTest,appendPath)37 TEST_F(FilesTest, appendPath) {
38     std::string base = "hello";
39     appendPath(&base, "there");
40     EXPECT_EQ(mExpectedPath, base);
41 }
42 
TEST_F(FilesTest,appendPathWithLeadingOrTrailingSeparators)43 TEST_F(FilesTest, appendPathWithLeadingOrTrailingSeparators) {
44     std::string base = "hello/";
45     appendPath(&base, "there");
46     EXPECT_EQ(mExpectedPath, base);
47 
48     base = "hello";
49     appendPath(&base, "/there");
50     EXPECT_EQ(mExpectedPath, base);
51 
52     base = "hello/";
53     appendPath(&base, "/there");
54     EXPECT_EQ(mExpectedPath, base);
55 }
56 
57 } // namespace files
58 } // namespace aapt
59