1 #include "gtest/gtest.h"
3 #include "TestingSupport/MockTildeExpressionResolver.h"
4 #include "lldb/Utility/TildeExpressionResolver.h"
6 #include "llvm/ADT/SmallString.h"
9 using namespace lldb_private
;
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");
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
);
24 ASSERT_TRUE(Resolver
.ResolveFullPath("~James/bar/baz", Result
));
25 EXPECT_EQ("/james/bar/baz", Result
);
27 ASSERT_TRUE(Resolver
.ResolveFullPath("~Jason/", Result
));
28 EXPECT_EQ("/jason/", Result
);
30 ASSERT_TRUE(Resolver
.ResolveFullPath("~Lars", Result
));
31 EXPECT_EQ("/lars", Result
);
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
);