Skip to content

Commit

Permalink
[lldb] Make TestOptionValueFileColonLine work on Windows
Browse files Browse the repository at this point in the history
The colon in the file name is interpreted as a drive name and therefore
the path looks like foo:\\bar.c. Compare FileSpecs instead of their
string representation so we don't have to worry about that.
  • Loading branch information
JDevlieghere committed Jul 21, 2020
1 parent 7926143 commit cb59267
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lldb/unittests/Interpreter/TestOptionValueFileColonLine.cpp
Expand Up @@ -13,7 +13,7 @@

using namespace lldb_private;

void CheckSetting(const char *input, bool success, const char *path = nullptr,
void CheckSetting(const char *input, bool success, FileSpec path = {},
uint32_t line_number = LLDB_INVALID_LINE_NUMBER,
uint32_t column_number = LLDB_INVALID_COLUMN_NUMBER) {

Expand All @@ -29,8 +29,7 @@ void CheckSetting(const char *input, bool success, const char *path = nullptr,

ASSERT_EQ(value.GetLineNumber(), line_number);
ASSERT_EQ(value.GetColumnNumber(), column_number);
std::string value_path = value.GetFileSpec().GetPath();
ASSERT_STREQ(value_path.c_str(), path);
ASSERT_EQ(value.GetFileSpec(), path);
}

TEST(OptionValueFileColonLine, setFromString) {
Expand All @@ -48,11 +47,11 @@ TEST(OptionValueFileColonLine, setFromString) {
CheckSetting("foo.c", false);

// Now try with just a file & line:
CheckSetting("foo.c:12", true, "foo.c", 12);
CheckSetting("foo.c:12:20", true, "foo.c", 12, 20);
CheckSetting("foo.c:12", true, FileSpec("foo.c"), 12);
CheckSetting("foo.c:12:20", true, FileSpec("foo.c"), 12, 20);
// Make sure a colon doesn't mess us up:
CheckSetting("foo:bar.c:12", true, "foo:bar.c", 12);
CheckSetting("foo:bar.c:12:20", true, "foo:bar.c", 12, 20);
CheckSetting("foo:bar.c:12", true, FileSpec("foo:bar.c"), 12);
CheckSetting("foo:bar.c:12:20", true, FileSpec("foo:bar.c"), 12, 20);
// Try errors in the line number:
CheckSetting("foo.c:12c", false);
CheckSetting("foo.c:12:20c", false);
Expand Down

0 comments on commit cb59267

Please sign in to comment.