blob: 39982bcc4fe95ae89dd6672888efa2bed4735fc6 [file] [log] [blame]
Christopher Wiley8decf952016-06-02 16:27:26 -07001/*
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 <string>
18
19#include <gtest/gtest.h>
20
21#include "io_delegate.h"
22
23using std::string;
24
25namespace android {
26namespace aidl {
27
28TEST(IoDelegateTest, CannotGetAbsolutePathFromEmptyString) {
29 string absolute_path;
30 EXPECT_FALSE(IoDelegate::GetAbsolutePath("", &absolute_path));
31 EXPECT_TRUE(absolute_path.empty());
32}
33
34TEST(IoDelegateTest, CurrentlyInfersLinuxAbsolutePath) {
35 string absolute_path;
36 EXPECT_TRUE(IoDelegate::GetAbsolutePath("foo", &absolute_path));
37 ASSERT_FALSE(absolute_path.empty());
38 // Should find our desired file at the end of |absolute_path|
39 // But we don't know the prefix, since it's the current working directory
40 EXPECT_TRUE(absolute_path.rfind("/foo") == absolute_path.length() - 4);
41 // Whatever our current working directory, the path is absolute.
42 EXPECT_EQ(absolute_path[0], '/');
43}
44
Christopher Wiley8decf952016-06-02 16:27:26 -070045} // namespace aidl
Steven Morelandf4c64df2019-07-29 19:54:04 -070046} // namespace android