1#include "gtest/gtest.h"
2
3#include "TestingSupport/MockTildeExpressionResolver.h"
4#include "lldb/Utility/TildeExpressionResolver.h"
5
6#include "llvm/ADT/SmallString.h"
7
8using namespace llvm;
9using namespace lldb_private;
10
11TEST(TildeExpressionResolver, ResolveFullPath) {
12 MockTildeExpressionResolver Resolver("James", "/james");
13 Resolver.AddKnownUser(User: "Kirk", HomeDir: "/kirk");
14 Resolver.AddKnownUser(User: "Lars", HomeDir: "/lars");
15 Resolver.AddKnownUser(User: "Jason", HomeDir: "/jason");
16 Resolver.AddKnownUser(User: "Larry", HomeDir: "/larry");
17
18 SmallString<32> Result;
19 ASSERT_TRUE(Resolver.ResolveFullPath("~", Result));
20 EXPECT_EQ("/james", Result);
21 ASSERT_TRUE(Resolver.ResolveFullPath("~/", Result));
22 EXPECT_EQ("/james/", Result);
23
24 ASSERT_TRUE(Resolver.ResolveFullPath("~James/bar/baz", Result));
25 EXPECT_EQ("/james/bar/baz", Result);
26
27 ASSERT_TRUE(Resolver.ResolveFullPath("~Jason/", Result));
28 EXPECT_EQ("/jason/", Result);
29
30 ASSERT_TRUE(Resolver.ResolveFullPath("~Lars", Result));
31 EXPECT_EQ("/lars", Result);
32
33 ASSERT_FALSE(Resolver.ResolveFullPath("~Jaso", Result));
34 EXPECT_EQ("~Jaso", Result);
35 ASSERT_FALSE(Resolver.ResolveFullPath("", Result));
36 EXPECT_EQ("", Result);
37 ASSERT_FALSE(Resolver.ResolveFullPath("Jason", Result));
38 EXPECT_EQ("Jason", Result);
39}
40

source code of lldb/unittests/Utility/TildeExpressionResolverTest.cpp