| Alex Lorenz | e1b7b95 | 2017-10-16 17:31:16 +0000 | [diff] [blame] | 1 | //===- unittests/Frontend/ParsedSourceLocationTest.cpp - ------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "clang/Frontend/CommandLineSourceLoc.h" |
| 11 | #include "gtest/gtest.h" |
| 12 | |
| 13 | using namespace llvm; |
| 14 | using namespace clang; |
| 15 | |
| 16 | namespace { |
| 17 | |
| 18 | TEST(ParsedSourceRange, ParseTest) { |
| 19 | auto Check = [](StringRef Value, StringRef Filename, unsigned BeginLine, |
| 20 | unsigned BeginColumn, unsigned EndLine, unsigned EndColumn) { |
| 21 | Optional<ParsedSourceRange> PSR = ParsedSourceRange::fromString(Value); |
| 22 | ASSERT_TRUE(PSR); |
| 23 | EXPECT_EQ(PSR->FileName, Filename); |
| 24 | EXPECT_EQ(PSR->Begin.first, BeginLine); |
| 25 | EXPECT_EQ(PSR->Begin.second, BeginColumn); |
| 26 | EXPECT_EQ(PSR->End.first, EndLine); |
| 27 | EXPECT_EQ(PSR->End.second, EndColumn); |
| 28 | }; |
| 29 | |
| 30 | Check("/Users/test/a-b.cpp:1:2", "/Users/test/a-b.cpp", 1, 2, 1, 2); |
| 31 | Check("/Users/test/a-b.cpp:1:2-3:4", "/Users/test/a-b.cpp", 1, 2, 3, 4); |
| 32 | |
| 33 | Check("C:/Users/bob/a-b.cpp:1:2", "C:/Users/bob/a-b.cpp", 1, 2, 1, 2); |
| 34 | Check("C:/Users/bob/a-b.cpp:1:2-3:4", "C:/Users/bob/a-b.cpp", 1, 2, 3, 4); |
| 35 | } |
| 36 | |
| 37 | } // anonymous namespace |