Bump version to 19.1.0git
[llvm-project.git] / clang-tools-extra / unittests / clang-tidy / ObjCModuleTest.cpp
blob826978b0f3b69e018e65218f9e9d5d1223c7a2e8
1 //===---- ObjCModuleTest.cpp - clang-tidy ---------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "ClangTidyTest.h"
10 #include "gtest/gtest.h"
11 #include "objc/ForbiddenSubclassingCheck.h"
13 using namespace clang::tidy::objc;
15 namespace clang {
16 namespace tidy {
17 namespace test {
19 TEST(ObjCForbiddenSubclassing, AllowedSubclass) {
20 std::vector<ClangTidyError> Errors;
21 runCheckOnCode<ForbiddenSubclassingCheck>(
22 "@interface Foo\n"
23 "@end\n"
24 "@interface Bar : Foo\n"
25 "@end\n",
26 &Errors,
27 "input.m");
28 EXPECT_EQ(0ul, Errors.size());
31 TEST(ObjCForbiddenSubclassing, ForbiddenSubclass) {
32 std::vector<ClangTidyError> Errors;
33 runCheckOnCode<ForbiddenSubclassingCheck>(
34 "@interface UIImagePickerController\n"
35 "@end\n"
36 "@interface Foo : UIImagePickerController\n"
37 "@end\n",
38 &Errors,
39 "input.m");
40 EXPECT_EQ(1ul, Errors.size());
41 EXPECT_EQ(
42 "Objective-C interface 'Foo' subclasses 'UIImagePickerController', which is not intended to be subclassed",
43 Errors[0].Message.Message);
46 } // namespace test
47 } // namespace tidy
48 } // namespace clang