1e1b7b959SAlex Lorenz //===- unittests/Frontend/ParsedSourceLocationTest.cpp - ------------------===//
2e1b7b959SAlex Lorenz //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e1b7b959SAlex Lorenz //
7e1b7b959SAlex Lorenz //===----------------------------------------------------------------------===//
8e1b7b959SAlex Lorenz
9e1b7b959SAlex Lorenz #include "clang/Frontend/CommandLineSourceLoc.h"
10e1b7b959SAlex Lorenz #include "gtest/gtest.h"
11a1580d7bSKazu Hirata #include <optional>
12e1b7b959SAlex Lorenz
13e1b7b959SAlex Lorenz using namespace llvm;
14e1b7b959SAlex Lorenz using namespace clang;
15e1b7b959SAlex Lorenz
16e1b7b959SAlex Lorenz namespace {
17e1b7b959SAlex Lorenz
TEST(ParsedSourceRange,ParseTest)18e1b7b959SAlex Lorenz TEST(ParsedSourceRange, ParseTest) {
19e1b7b959SAlex Lorenz auto Check = [](StringRef Value, StringRef Filename, unsigned BeginLine,
20e1b7b959SAlex Lorenz unsigned BeginColumn, unsigned EndLine, unsigned EndColumn) {
21*6ad0788cSKazu Hirata std::optional<ParsedSourceRange> PSR = ParsedSourceRange::fromString(Value);
22e1b7b959SAlex Lorenz ASSERT_TRUE(PSR);
23e1b7b959SAlex Lorenz EXPECT_EQ(PSR->FileName, Filename);
24e1b7b959SAlex Lorenz EXPECT_EQ(PSR->Begin.first, BeginLine);
25e1b7b959SAlex Lorenz EXPECT_EQ(PSR->Begin.second, BeginColumn);
26e1b7b959SAlex Lorenz EXPECT_EQ(PSR->End.first, EndLine);
27e1b7b959SAlex Lorenz EXPECT_EQ(PSR->End.second, EndColumn);
28e1b7b959SAlex Lorenz };
29e1b7b959SAlex Lorenz
30e1b7b959SAlex Lorenz Check("/Users/test/a-b.cpp:1:2", "/Users/test/a-b.cpp", 1, 2, 1, 2);
31e1b7b959SAlex Lorenz Check("/Users/test/a-b.cpp:1:2-3:4", "/Users/test/a-b.cpp", 1, 2, 3, 4);
32e1b7b959SAlex Lorenz
33e1b7b959SAlex Lorenz Check("C:/Users/bob/a-b.cpp:1:2", "C:/Users/bob/a-b.cpp", 1, 2, 1, 2);
34e1b7b959SAlex Lorenz Check("C:/Users/bob/a-b.cpp:1:2-3:4", "C:/Users/bob/a-b.cpp", 1, 2, 3, 4);
35e1b7b959SAlex Lorenz }
36e1b7b959SAlex Lorenz
37e1b7b959SAlex Lorenz } // anonymous namespace
38