1*5934a791SAdam Czachorowski //===-- ObjCLocalizeStringLiteralTests.cpp ----------------------*- C++ -*-===// 2*5934a791SAdam Czachorowski // 3*5934a791SAdam Czachorowski // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*5934a791SAdam Czachorowski // See https://llvm.org/LICENSE.txt for license information. 5*5934a791SAdam Czachorowski // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*5934a791SAdam Czachorowski // 7*5934a791SAdam Czachorowski //===----------------------------------------------------------------------===// 8*5934a791SAdam Czachorowski 9*5934a791SAdam Czachorowski #include "TweakTesting.h" 10*5934a791SAdam Czachorowski #include "gmock/gmock.h" 11*5934a791SAdam Czachorowski #include "gtest/gtest.h" 12*5934a791SAdam Czachorowski 13*5934a791SAdam Czachorowski namespace clang { 14*5934a791SAdam Czachorowski namespace clangd { 15*5934a791SAdam Czachorowski namespace { 16*5934a791SAdam Czachorowski 17*5934a791SAdam Czachorowski TWEAK_TEST(ObjCLocalizeStringLiteral); 18*5934a791SAdam Czachorowski TEST_F(ObjCLocalizeStringLiteralTest,Test)19*5934a791SAdam CzachorowskiTEST_F(ObjCLocalizeStringLiteralTest, Test) { 20*5934a791SAdam Czachorowski ExtraArgs.push_back("-x"); 21*5934a791SAdam Czachorowski ExtraArgs.push_back("objective-c"); 22*5934a791SAdam Czachorowski 23*5934a791SAdam Czachorowski // Ensure the action can be initiated in the string literal. 24*5934a791SAdam Czachorowski EXPECT_AVAILABLE(R"(id x = ^[[@[[^"^t^est^"]]]];)"); 25*5934a791SAdam Czachorowski 26*5934a791SAdam Czachorowski // Ensure that the action can't be initiated in other places. 27*5934a791SAdam Czachorowski EXPECT_UNAVAILABLE(R"([[i^d ^[[x]] ^= @"test";^]])"); 28*5934a791SAdam Czachorowski 29*5934a791SAdam Czachorowski // Ensure that the action is not available for regular C strings. 30*5934a791SAdam Czachorowski EXPECT_UNAVAILABLE(R"(const char * x= "^test";)"); 31*5934a791SAdam Czachorowski 32*5934a791SAdam Czachorowski const char *Input = R"(id x = [[@"test"]];)"; 33*5934a791SAdam Czachorowski const char *Output = R"(id x = NSLocalizedString(@"test", @"");)"; 34*5934a791SAdam Czachorowski EXPECT_EQ(apply(Input), Output); 35*5934a791SAdam Czachorowski } 36*5934a791SAdam Czachorowski 37*5934a791SAdam Czachorowski } // namespace 38*5934a791SAdam Czachorowski } // namespace clangd 39*5934a791SAdam Czachorowski } // namespace clang 40