1//===-- ObjCLocalizeStringLiteralTests.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 "TweakTesting.h"
10#include "gmock/gmock.h"
11#include "gtest/gtest.h"
12
13namespace clang {
14namespace clangd {
15namespace {
16
17TWEAK_TEST(ObjCLocalizeStringLiteral);
18
19TEST_F(ObjCLocalizeStringLiteralTest, Test) {
20 ExtraArgs.push_back(x: "-x");
21 ExtraArgs.push_back(x: "objective-c");
22
23 // Ensure the action can be initiated in the string literal.
24 EXPECT_AVAILABLE(R"(id x = ^[[@[[^"^t^est^"]]]];)");
25
26 // Ensure that the action can't be initiated in other places.
27 EXPECT_UNAVAILABLE(R"([[i^d ^[[x]] ^= @"test";^]])");
28
29 // Ensure that the action is not available for regular C strings.
30 EXPECT_UNAVAILABLE(R"(const char * x= "^test";)");
31
32 const char *Input = R"(id x = [[@"test"]];)";
33 const char *Output = R"(id x = NSLocalizedString(@"test", @"");)";
34 EXPECT_EQ(apply(Input), Output);
35}
36
37} // namespace
38} // namespace clangd
39} // namespace clang
40

source code of clang-tools-extra/clangd/unittests/tweaks/ObjCLocalizeStringLiteralTests.cpp