1 //===-- ObjCLocalizeStringLiteralTests.cpp ----------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "TweakTesting.h"
10 #include "gmock/gmock.h"
11 #include "gtest/gtest.h"
17 TWEAK_TEST(ObjCLocalizeStringLiteral
);
19 TEST_F(ObjCLocalizeStringLiteralTest
, Test
) {
20 ExtraArgs
.push_back("-x");
21 ExtraArgs
.push_back("objective-c");
23 // Ensure the action can be initiated in the string literal.
24 EXPECT_AVAILABLE(R
"(id x = ^[[@[[^"^t
^est
^"]]]];)");
26 // Ensure that the action can't be initiated in other places.
27 EXPECT_UNAVAILABLE(R
"([[i^d ^[[x]] ^= @"test
";^]])");
29 // Ensure that the action is not available for regular C strings.
30 EXPECT_UNAVAILABLE(R
"(const char * x= "^test
";)");
32 const char *Input
= R
"(id x = [[@"test
"]];)";
33 const char *Output
= R
"(id x = NSLocalizedString(@"test
", @"");)";
34 EXPECT_EQ(apply(Input
), Output
);