reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
#include "gtest/gtest.h"

#include "TestingSupport/MockTildeExpressionResolver.h"
#include "lldb/Utility/TildeExpressionResolver.h"

#include "llvm/ADT/SmallString.h"

using namespace llvm;
using namespace lldb_private;

TEST(TildeExpressionResolver, ResolveFullPath) {
  MockTildeExpressionResolver Resolver("James", "/james");
  Resolver.AddKnownUser("Kirk", "/kirk");
  Resolver.AddKnownUser("Lars", "/lars");
  Resolver.AddKnownUser("Jason", "/jason");
  Resolver.AddKnownUser("Larry", "/larry");

  SmallString<32> Result;
  ASSERT_TRUE(Resolver.ResolveFullPath("~", Result));
  EXPECT_EQ("/james", Result);
  ASSERT_TRUE(Resolver.ResolveFullPath("~/", Result));
  EXPECT_EQ("/james/", Result);

  ASSERT_TRUE(Resolver.ResolveFullPath("~James/bar/baz", Result));
  EXPECT_EQ("/james/bar/baz", Result);

  ASSERT_TRUE(Resolver.ResolveFullPath("~Jason/", Result));
  EXPECT_EQ("/jason/", Result);

  ASSERT_TRUE(Resolver.ResolveFullPath("~Lars", Result));
  EXPECT_EQ("/lars", Result);

  ASSERT_FALSE(Resolver.ResolveFullPath("~Jaso", Result));
  ASSERT_FALSE(Resolver.ResolveFullPath("", Result));
  ASSERT_FALSE(Resolver.ResolveFullPath("Jason", Result));
}