| //===---- ObjCModuleTest.cpp - clang-tidy ---------------------------------===// |
| // 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 "ClangTidyTest.h" |
| #include "objc/ForbiddenSubclassingCheck.h" |
| using namespace clang::tidy::objc; |
| TEST(ObjCForbiddenSubclassing, AllowedSubclass) { |
| std::vector<ClangTidyError> Errors; |
| runCheckOnCode<ForbiddenSubclassingCheck>( |
| EXPECT_EQ(0ul, Errors.size()); |
| TEST(ObjCForbiddenSubclassing, ForbiddenSubclass) { |
| std::vector<ClangTidyError> Errors; |
| runCheckOnCode<ForbiddenSubclassingCheck>( |
| "@interface UIImagePickerController\n" |
| "@interface Foo : UIImagePickerController\n" |
| EXPECT_EQ(1ul, Errors.size()); |
| "Objective-C interface 'Foo' subclasses 'UIImagePickerController', which is not intended to be subclassed", |
| Errors[0].Message.Message); |