forked from OSchip/llvm-project
Rename unit test argument and add argument comments for clarity.
NFC llvm-svn: 217947
This commit is contained in:
parent
351b2feeb3
commit
31a1024b93
|
@ -89,11 +89,11 @@ TEST(NamespaceCommentCheckTest, FixWrongComments) {
|
|||
// FIXME: It seems this might be incompatible to dos path. Investigating.
|
||||
#if !defined(_WIN32)
|
||||
static std::string runHeaderGuardCheck(StringRef Code, const Twine &Filename,
|
||||
unsigned NumWarnings = 1) {
|
||||
unsigned ExpectedWarnings) {
|
||||
std::vector<ClangTidyError> Errors;
|
||||
std::string Result = test::runCheckOnCode<LLVMHeaderGuardCheck>(
|
||||
Code, &Errors, Filename, std::string("-xc++-header"));
|
||||
return Errors.size() == NumWarnings ? Result : "invalid error count";
|
||||
return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -106,92 +106,101 @@ struct WithEndifComment : public LLVMHeaderGuardCheck {
|
|||
|
||||
static std::string runHeaderGuardCheckWithEndif(StringRef Code,
|
||||
const Twine &Filename,
|
||||
unsigned NumWarnings = 1) {
|
||||
unsigned ExpectedWarnings) {
|
||||
std::vector<ClangTidyError> Errors;
|
||||
std::string Result = test::runCheckOnCode<WithEndifComment>(
|
||||
Code, &Errors, Filename, std::string("-xc++-header"));
|
||||
return Errors.size() == NumWarnings ? Result : "invalid error count";
|
||||
return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
|
||||
}
|
||||
|
||||
TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) {
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif\n",
|
||||
runHeaderGuardCheck("#ifndef FOO\n#define FOO\n#endif\n",
|
||||
"include/llvm/ADT/foo.h"));
|
||||
"include/llvm/ADT/foo.h",
|
||||
/*ExpectedWarnings=*/1));
|
||||
|
||||
// Allow trailing underscores.
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H_\n#define LLVM_ADT_FOO_H_\n#endif\n",
|
||||
runHeaderGuardCheck(
|
||||
"#ifndef LLVM_ADT_FOO_H_\n#define LLVM_ADT_FOO_H_\n#endif\n",
|
||||
"include/llvm/ADT/foo.h", 0));
|
||||
"include/llvm/ADT/foo.h", /*ExpectedWarnings=*/0));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_CLANG_C_BAR_H\n#define LLVM_CLANG_C_BAR_H\n\n\n#endif\n",
|
||||
runHeaderGuardCheck("", "./include/clang-c/bar.h"));
|
||||
EXPECT_EQ(
|
||||
"#ifndef LLVM_CLANG_C_BAR_H\n#define LLVM_CLANG_C_BAR_H\n\n\n#endif\n",
|
||||
runHeaderGuardCheck("", "./include/clang-c/bar.h",
|
||||
/*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_CLANG_LIB_CODEGEN_C_H\n#define "
|
||||
"LLVM_CLANG_LIB_CODEGEN_C_H\n\n\n#endif\n",
|
||||
runHeaderGuardCheck("", "tools/clang/lib/CodeGen/c.h"));
|
||||
runHeaderGuardCheck("", "tools/clang/lib/CodeGen/c.h",
|
||||
/*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_X_H\n#define "
|
||||
"LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_X_H\n\n\n#endif\n",
|
||||
runHeaderGuardCheck("", "tools/clang/tools/extra/clang-tidy/x.h"));
|
||||
runHeaderGuardCheck("", "tools/clang/tools/extra/clang-tidy/x.h",
|
||||
/*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ(
|
||||
"int foo;\n#ifndef LLVM_CLANG_BAR_H\n#define LLVM_CLANG_BAR_H\n#endif\n",
|
||||
runHeaderGuardCheck("int foo;\n#ifndef LLVM_CLANG_BAR_H\n"
|
||||
"#define LLVM_CLANG_BAR_H\n#endif\n",
|
||||
"include/clang/bar.h"));
|
||||
"include/clang/bar.h", /*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_CLANG_BAR_H\n#define LLVM_CLANG_BAR_H\n\n"
|
||||
"int foo;\n#ifndef FOOLOLO\n#define FOOLOLO\n#endif\n\n#endif\n",
|
||||
runHeaderGuardCheck(
|
||||
"int foo;\n#ifndef FOOLOLO\n#define FOOLOLO\n#endif\n",
|
||||
"include/clang/bar.h"));
|
||||
"include/clang/bar.h", /*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif "
|
||||
" // LLVM_ADT_FOO_H\n",
|
||||
runHeaderGuardCheckWithEndif("#ifndef FOO\n#define FOO\n#endif\n",
|
||||
"include/llvm/ADT/foo.h"));
|
||||
"include/llvm/ADT/foo.h",
|
||||
/*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif "
|
||||
" // LLVM_ADT_FOO_H\n",
|
||||
runHeaderGuardCheckWithEndif("#ifndef LLVM_ADT_FOO_H\n#define "
|
||||
"LLVM_ADT_FOO_H\n#endif // LLVM_H\n",
|
||||
"include/llvm/ADT/foo.h"));
|
||||
"include/llvm/ADT/foo.h",
|
||||
/*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif"
|
||||
" /* LLVM_ADT_FOO_H */\n",
|
||||
runHeaderGuardCheckWithEndif("#ifndef LLVM_ADT_FOO_H\n#define "
|
||||
"LLVM_ADT_FOO_H\n"
|
||||
"#endif /* LLVM_ADT_FOO_H */\n",
|
||||
"include/llvm/ADT/foo.h", 0));
|
||||
"include/llvm/ADT/foo.h",
|
||||
/*ExpectedWarnings=*/0));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H_\n#define LLVM_ADT_FOO_H_\n#endif "
|
||||
"// LLVM_ADT_FOO_H_\n",
|
||||
runHeaderGuardCheckWithEndif(
|
||||
"#ifndef LLVM_ADT_FOO_H_\n#define "
|
||||
"LLVM_ADT_FOO_H_\n#endif // LLVM_ADT_FOO_H_\n",
|
||||
"include/llvm/ADT/foo.h", 0));
|
||||
"include/llvm/ADT/foo.h", /*ExpectedWarnings=*/0));
|
||||
|
||||
EXPECT_EQ(
|
||||
"#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif // "
|
||||
"LLVM_ADT_FOO_H\n",
|
||||
runHeaderGuardCheckWithEndif(
|
||||
"#ifndef LLVM_ADT_FOO_H_\n#define LLVM_ADT_FOO_H_\n#endif // LLVM\n",
|
||||
"include/llvm/ADT/foo.h"));
|
||||
"include/llvm/ADT/foo.h", /*ExpectedWarnings=*/1));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif \\ \n// "
|
||||
"LLVM_ADT_FOO_H\n",
|
||||
runHeaderGuardCheckWithEndif("#ifndef LLVM_ADT_FOO_H\n#define "
|
||||
"LLVM_ADT_FOO_H\n#endif \\ \n// "
|
||||
"LLVM_ADT_FOO_H\n",
|
||||
"include/llvm/ADT/foo.h", 0));
|
||||
"include/llvm/ADT/foo.h",
|
||||
/*ExpectedWarnings=*/0));
|
||||
|
||||
EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif /* "
|
||||
"LLVM_ADT_FOO_H\\ \n FOO */",
|
||||
runHeaderGuardCheckWithEndif(
|
||||
"#ifndef LLVM_ADT_FOO_H\n#define LLVM_ADT_FOO_H\n#endif /* "
|
||||
"LLVM_ADT_FOO_H\\ \n FOO */",
|
||||
"include/llvm/ADT/foo.h", 0));
|
||||
"include/llvm/ADT/foo.h", /*ExpectedWarnings=*/0));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue