brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 2681b8c Raw
56 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "TweakTesting.h"10#include "gmock/gmock-matchers.h"11#include "gmock/gmock.h"12#include "gtest/gtest.h"13 14namespace clang {15namespace clangd {16namespace {17 18TWEAK_TEST(RawStringLiteral);19 20TEST_F(RawStringLiteralTest, Test) {21  Context = Expression;22  EXPECT_AVAILABLE(R"cpp(^"^f^o^o^\^n^")cpp");23  EXPECT_AVAILABLE(R"cpp(R"(multi )" ^"token " "str\ning")cpp");24  EXPECT_UNAVAILABLE(R"cpp(^"f^o^o^o")cpp"); // no chars need escaping25  EXPECT_UNAVAILABLE(R"cpp(R"(multi )" ^"token " u8"str\ning")cpp"); // nonascii26  EXPECT_UNAVAILABLE(R"cpp(^R^"^(^multi )" "token " "str\ning")cpp"); // raw27  EXPECT_UNAVAILABLE(R"cpp(^"token\n" __FILE__)cpp"); // chunk is macro28  EXPECT_UNAVAILABLE(R"cpp(^"a\r\n";)cpp");           // forbidden escape char29 30  const char *Input = R"cpp(R"(multi31token)" "\nst^ring\n" "literal")cpp";32  const char *Output = R"cpp(R"(multi33token34string35literal)")cpp";36  EXPECT_EQ(apply(Input), Output);37}38 39TEST_F(RawStringLiteralTest, TestC) {40  Context = File;41  FileName = "TestTU.c";42  ExtraArgs = {"-xc"}; // raw strings are unavailable in C43  EXPECT_UNAVAILABLE(R"c(const char *a = ^"^f^o^o^\^n^";)c");44}45 46TEST_F(RawStringLiteralTest, TestCpp98) {47  Context = File;48  ExtraArgs = {"-std=c++98"}; // raw strings are unavailable49                              // in versions prior to C++1150  EXPECT_UNAVAILABLE(R"cpp(const char *a = ^"^f^o^o^\^n^";)cpp");51}52 53} // namespace54} // namespace clangd55} // namespace clang56