• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- RawStringLiteralTests.cpp -------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "TestTU.h"
10 #include "TweakTesting.h"
11 #include "gmock/gmock-matchers.h"
12 #include "gmock/gmock.h"
13 #include "gtest/gtest.h"
14 
15 namespace clang {
16 namespace clangd {
17 namespace {
18 
19 TWEAK_TEST(RawStringLiteral);
20 
TEST_F(RawStringLiteralTest,Test)21 TEST_F(RawStringLiteralTest, Test) {
22   Context = Expression;
23   EXPECT_AVAILABLE(R"cpp(^"^f^o^o^\^n^")cpp");
24   EXPECT_AVAILABLE(R"cpp(R"(multi )" ^"token " "str\ning")cpp");
25   EXPECT_UNAVAILABLE(R"cpp(^"f^o^o^o")cpp"); // no chars need escaping
26   EXPECT_UNAVAILABLE(R"cpp(R"(multi )" ^"token " u8"str\ning")cpp"); // nonascii
27   EXPECT_UNAVAILABLE(R"cpp(^R^"^(^multi )" "token " "str\ning")cpp"); // raw
28   EXPECT_UNAVAILABLE(R"cpp(^"token\n" __FILE__)cpp"); // chunk is macro
29   EXPECT_UNAVAILABLE(R"cpp(^"a\r\n";)cpp");           // forbidden escape char
30 
31   const char *Input = R"cpp(R"(multi
32 token)" "\nst^ring\n" "literal")cpp";
33   const char *Output = R"cpp(R"(multi
34 token
35 string
36 literal)")cpp";
37   EXPECT_EQ(apply(Input), Output);
38 }
39 
40 } // namespace
41 } // namespace clangd
42 } // namespace clang
43