llvm.org GIT mirror llvm / 486e8bb
OptionParsingTest.cpp: reorder EXPECT_EQs to put expectation on the left. NFC. This provides for better error messages from the framework when the expected and actual values don't match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266393 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 3 years ago
1 changed file(s) with 26 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
7878 EXPECT_TRUE(AL.hasArg(OPT_G));
7979
8080 // Check the values.
81 EXPECT_EQ(AL.getLastArgValue(OPT_B), "hi");
82 EXPECT_EQ(AL.getLastArgValue(OPT_C), "bye");
83 EXPECT_EQ(AL.getLastArgValue(OPT_D), "adena");
81 EXPECT_EQ("hi", AL.getLastArgValue(OPT_B));
82 EXPECT_EQ("bye", AL.getLastArgValue(OPT_C));
83 EXPECT_EQ("adena", AL.getLastArgValue(OPT_D));
8484 std::vector Es = AL.getAllArgValues(OPT_E);
85 EXPECT_EQ(Es[0], "apple");
86 EXPECT_EQ(Es[1], "bloom");
87 EXPECT_EQ(AL.getLastArgValue(OPT_F), "42");
85 EXPECT_EQ("apple", Es[0]);
86 EXPECT_EQ("bloom", Es[1]);
87 EXPECT_EQ("42", AL.getLastArgValue(OPT_F));
8888 std::vector Gs = AL.getAllArgValues(OPT_G);
89 EXPECT_EQ(Gs[0], "chuu");
90 EXPECT_EQ(Gs[1], "2");
89 EXPECT_EQ("chuu", Gs[0]);
90 EXPECT_EQ("2", Gs[1]);
9191
9292 // Check the help text.
9393 std::string Help;
9494 raw_string_ostream RSO(Help);
9595 T.PrintHelp(RSO, "test", "title!");
96 EXPECT_NE(Help.find("-A"), std::string::npos);
96 EXPECT_NE(std::string::npos, Help.find("-A"));
9797
9898 // Test aliases.
9999 arg_iterator Cs = AL.filtered_begin(OPT_C);
100 ASSERT_NE(Cs, AL.filtered_end());
101 EXPECT_EQ(StringRef((*Cs)->getValue()), "desu");
100 ASSERT_NE(AL.filtered_end(), Cs);
101 EXPECT_EQ("desu", StringRef((*Cs)->getValue()));
102102 ArgStringList ASL;
103103 (*Cs)->render(AL, ASL);
104 ASSERT_EQ(ASL.size(), 2u);
105 EXPECT_EQ(StringRef(ASL[0]), "-C");
106 EXPECT_EQ(StringRef(ASL[1]), "desu");
104 ASSERT_EQ(2u, ASL.size());
105 EXPECT_EQ("-C", StringRef(ASL[0]));
106 EXPECT_EQ("desu", StringRef(ASL[1]));
107107 }
108108
109109 TEST(Option, ParseWithFlagExclusions) {
130130 AL = T.ParseArgs(NewArgs, MAI, MAC);
131131 EXPECT_TRUE(AL.hasArg(OPT_SLASH_C));
132132 EXPECT_TRUE(AL.hasArg(OPT_C));
133 EXPECT_EQ(AL.getLastArgValue(OPT_SLASH_C), "foo");
134 EXPECT_EQ(AL.getLastArgValue(OPT_C), "bar");
133 EXPECT_EQ("foo", AL.getLastArgValue(OPT_SLASH_C));
134 EXPECT_EQ("bar", AL.getLastArgValue(OPT_C));
135135 }
136136
137137 TEST(Option, ParseAliasInGroup) {
150150 const char *MyArgs[] = { "-J", "-Joo" };
151151 InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);
152152 EXPECT_TRUE(AL.hasArg(OPT_B));
153 EXPECT_EQ(AL.getAllArgValues(OPT_B)[0], "foo");
154 EXPECT_EQ(AL.getAllArgValues(OPT_B)[1], "bar");
153 EXPECT_EQ("foo", AL.getAllArgValues(OPT_B)[0]);
154 EXPECT_EQ("bar", AL.getAllArgValues(OPT_B)[1]);
155155 }
156156
157157 TEST(Option, IgnoreCase) {
182182 InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);
183183 EXPECT_TRUE(AL.hasArg(OPT_A));
184184 EXPECT_TRUE(AL.hasArg(OPT_Slurp));
185 EXPECT_EQ(AL.getAllArgValues(OPT_Slurp).size(), 0U);
185 EXPECT_EQ(0U, AL.getAllArgValues(OPT_Slurp).size());
186186 }
187187
188188 TEST(Option, Slurp) {
195195 EXPECT_TRUE(AL.hasArg(OPT_A));
196196 EXPECT_FALSE(AL.hasArg(OPT_B));
197197 EXPECT_TRUE(AL.hasArg(OPT_Slurp));
198 EXPECT_EQ(AL.getAllArgValues(OPT_Slurp).size(), 3U);
199 EXPECT_EQ(AL.getAllArgValues(OPT_Slurp)[0], "-B");
200 EXPECT_EQ(AL.getAllArgValues(OPT_Slurp)[1], "--");
201 EXPECT_EQ(AL.getAllArgValues(OPT_Slurp)[2], "foo");
198 EXPECT_EQ(3U, AL.getAllArgValues(OPT_Slurp).size());
199 EXPECT_EQ("-B", AL.getAllArgValues(OPT_Slurp)[0]);
200 EXPECT_EQ("--", AL.getAllArgValues(OPT_Slurp)[1]);
201 EXPECT_EQ("foo", AL.getAllArgValues(OPT_Slurp)[2]);
202202 }
203203
204204 TEST(Option, FlagAliasToJoined) {
210210 InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);
211211 EXPECT_EQ(AL.size(), 1U);
212212 EXPECT_TRUE(AL.hasArg(OPT_B));
213 EXPECT_EQ(AL.getAllArgValues(OPT_B).size(), 1U);
214 EXPECT_EQ(AL.getAllArgValues(OPT_B)[0], "");
215 }
213 EXPECT_EQ(1U, AL.getAllArgValues(OPT_B).size());
214 EXPECT_EQ("", AL.getAllArgValues(OPT_B)[0]);
215 }