[clang][cli] CompilerInvocationTest: split enum test into two

Depends on D92826.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92827
This commit is contained in:
Jan Svoboda 2020-12-08 10:37:16 +01:00
parent f825ec86e1
commit 5afff86d26
1 changed files with 12 additions and 15 deletions

View File

@ -17,9 +17,7 @@ using namespace llvm;
using namespace clang;
using ::testing::Contains;
using ::testing::Each;
using ::testing::StrEq;
using ::testing::StrNe;
namespace {
class CommandLineTest : public ::testing::Test {
@ -117,27 +115,26 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str())));
}
TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnum) {
const char *RelocationModelCStr = "static";
const char *Args[] = {"clang", "-xc++", "-mrelocation-model",
RelocationModelCStr, "-"};
TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "static", "-"};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Non default relocation model
ASSERT_THAT(GeneratedArgs, Contains(StrEq(RelocationModelCStr)));
GeneratedArgs.clear();
// Non default relocation model.
ASSERT_THAT(GeneratedArgs, Contains(StrEq("static")));
}
RelocationModelCStr = "pic";
Args[3] = RelocationModelCStr;
TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "pic", "-"};
CompilerInvocation Invocation2;
CompilerInvocation::CreateFromArgs(Invocation2, Args, *Diags);
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
Invocation2.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Each(StrNe(RelocationModelCStr)));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Default relocation model.
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic"))));
}
TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {