brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · af0498d Raw
40 lines · cpp
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-exception6//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");21  ExtraArgs.push_back("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} // namespace38} // namespace clangd39} // namespace clang40