• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "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(ObjCLocalizeStringLiteral);
20 
TEST_F(ObjCLocalizeStringLiteralTest,Test)21 TEST_F(ObjCLocalizeStringLiteralTest, Test) {
22   ExtraArgs.push_back("-x");
23   ExtraArgs.push_back("objective-c");
24 
25   // Ensure the action can be initiated in the string literal.
26   EXPECT_AVAILABLE(R"(id x = ^[[@[[^"^t^est^"]]]];)");
27 
28   // Ensure that the action can't be initiated in other places.
29   EXPECT_UNAVAILABLE(R"([[i^d ^[[x]] ^= @"test";^]])");
30 
31   // Ensure that the action is not available for regular C strings.
32   EXPECT_UNAVAILABLE(R"(const char * x= "^test";)");
33 
34   const char *Input = R"(id x = [[@"test"]];)";
35   const char *Output = R"(id x = NSLocalizedString(@"test", @"");)";
36   EXPECT_EQ(apply(Input), Output);
37 }
38 
39 } // namespace
40 } // namespace clangd
41 } // namespace clang
42