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
8 using namespace llvm;
9 using namespace lldb_private;
10
TEST(TildeExpressionResolver,ResolveFullPath)11 TEST(TildeExpressionResolver, ResolveFullPath) {
12 MockTildeExpressionResolver Resolver("James", "/james");
13 Resolver.AddKnownUser("Kirk", "/kirk");
14 Resolver.AddKnownUser("Lars", "/lars");
15 Resolver.AddKnownUser("Jason", "/jason");
16 Resolver.AddKnownUser("Larry", "/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