summaryrefslogtreecommitdiff
path: root/absl/flags/parse_test.cc
diff options
context:
space:
mode:
authorGravatar Gennadiy Rozental <rogeeff@google.com>2023-03-24 02:24:00 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-03-24 02:24:56 -0700
commit1bd60dca52b120a7b8e15b39ce86d19d87494a11 (patch)
tree1dac0120d5d165e1a6f1a7453f307cfe92c26349 /absl/flags/parse_test.cc
parentb6de7b80325514018d38de2c4dee1254258c4b31 (diff)
Add a call to handle usage flags in case of unrecognized flags
PiperOrigin-RevId: 519090305 Change-Id: Ic97a36da33e1e0681765a913f3c54c3d818eebdc
Diffstat (limited to 'absl/flags/parse_test.cc')
-rw-r--r--absl/flags/parse_test.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/absl/flags/parse_test.cc b/absl/flags/parse_test.cc
index 13606d14..f3987bb7 100644
--- a/absl/flags/parse_test.cc
+++ b/absl/flags/parse_test.cc
@@ -17,10 +17,8 @@
#include <stdlib.h>
-#include <cstddef>
#include <fstream>
#include <string>
-#include <utility>
#include <vector>
#include "gmock/gmock.h"
@@ -1061,4 +1059,17 @@ TEST_F(ParseTest, AllUndefOkFlagsAreIgnored) {
// --------------------------------------------------------------------
+TEST_F(ParseDeathTest, ExitOnUnrecognizedFlagPrintsHelp) {
+ const char* in_args[] = {
+ "testbin",
+ "--undef_flag1",
+ "--help=int_flag",
+ };
+
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args),
+ "Try --helpfull to get a list of all flags");
+}
+
+// --------------------------------------------------------------------
+
} // namespace