llvm-project/clang-tools-extra/clangd/unittests/tweaks/ObjCLocalizeStringLiteralTests.cpp
Sam McCall 4d006520b8 [clangd] Clean up unused includes. NFCI
Add includes where needed to fix build.
Haven't systematically added used headers, so there is still accidental
dependency on transitive includes.
2022-02-26 12:00:16 +01:00

40 lines
1.2 KiB
C++

//===-- ObjCLocalizeStringLiteralTests.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "TweakTesting.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace clang {
namespace clangd {
namespace {
TWEAK_TEST(ObjCLocalizeStringLiteral);
TEST_F(ObjCLocalizeStringLiteralTest, Test) {
ExtraArgs.push_back("-x");
ExtraArgs.push_back("objective-c");
// Ensure the action can be initiated in the string literal.
EXPECT_AVAILABLE(R"(id x = ^[[@[[^"^t^est^"]]]];)");
// Ensure that the action can't be initiated in other places.
EXPECT_UNAVAILABLE(R"([[i^d ^[[x]] ^= @"test";^]])");
// Ensure that the action is not available for regular C strings.
EXPECT_UNAVAILABLE(R"(const char * x= "^test";)");
const char *Input = R"(id x = [[@"test"]];)";
const char *Output = R"(id x = NSLocalizedString(@"test", @"");)";
EXPECT_EQ(apply(Input), Output);
}
} // namespace
} // namespace clangd
} // namespace clang