1 //===- unittests/Frontend/ParsedSourceLocationTest.cpp - ------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "clang/Frontend/CommandLineSourceLoc.h"
10 #include "gtest/gtest.h"
13 using namespace clang
;
17 TEST(ParsedSourceRange
, ParseTest
) {
18 auto Check
= [](StringRef Value
, StringRef Filename
, unsigned BeginLine
,
19 unsigned BeginColumn
, unsigned EndLine
, unsigned EndColumn
) {
20 Optional
<ParsedSourceRange
> PSR
= ParsedSourceRange::fromString(Value
);
22 EXPECT_EQ(PSR
->FileName
, Filename
);
23 EXPECT_EQ(PSR
->Begin
.first
, BeginLine
);
24 EXPECT_EQ(PSR
->Begin
.second
, BeginColumn
);
25 EXPECT_EQ(PSR
->End
.first
, EndLine
);
26 EXPECT_EQ(PSR
->End
.second
, EndColumn
);
29 Check("/Users/test/a-b.cpp:1:2", "/Users/test/a-b.cpp", 1, 2, 1, 2);
30 Check("/Users/test/a-b.cpp:1:2-3:4", "/Users/test/a-b.cpp", 1, 2, 3, 4);
32 Check("C:/Users/bob/a-b.cpp:1:2", "C:/Users/bob/a-b.cpp", 1, 2, 1, 2);
33 Check("C:/Users/bob/a-b.cpp:1:2-3:4", "C:/Users/bob/a-b.cpp", 1, 2, 3, 4);
36 } // anonymous namespace