From 8233556d44d6d296130887d5065bff1c44ed1e1c Mon Sep 17 00:00:00 2001 From: Craig Silverstein Date: Thu, 4 Aug 2011 00:02:39 +0000 Subject: Add a new unittest case, that tests the --help output for a really long helpstring. Opensource gflags had a bug where we were cutting off the output too soon; this test should protect against such a thing. R=nilton DELTA=16 (16 added, 0 deleted, 0 changed) Revision created by MOE tool push_codebase. MOE_MIGRATION=2885 git-svn-id: https://gflags.googlecode.com/svn/trunk@58 6586e3c6-dcc4-952a-343f-ff74eb82781d --- src/gflags_unittest.cc | 13 +++++++++++++ src/gflags_unittest.sh | 3 +++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/gflags_unittest.cc b/src/gflags_unittest.cc index d64febb..890e157 100644 --- a/src/gflags_unittest.cc +++ b/src/gflags_unittest.cc @@ -127,6 +127,19 @@ DEFINE_string(unused_string, "unused", ""); // These flags are used by gflags_unittest.sh DEFINE_bool(changed_bool1, false, "changed"); DEFINE_bool(changed_bool2, false, "changed"); +DEFINE_bool(long_helpstring, false, + "This helpstring goes on forever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever and ever and ever and ever and ever and ever and ever and " + "ever. This is the end of a long helpstring"); + static bool AlwaysFail(const char* flag, bool value) { return value == false; } DEFINE_bool(always_fail, false, "will fail to validate when you set it"); diff --git a/src/gflags_unittest.sh b/src/gflags_unittest.sh index 39b03c5..c81e41e 100755 --- a/src/gflags_unittest.sh +++ b/src/gflags_unittest.sh @@ -111,6 +111,9 @@ Expect $LINENO 0 "PASS" "" # --help should show all flags, including flags from gflags_reporting Expect $LINENO 1 "/gflags_reporting.cc" "" --help +# Make sure that --help prints even very long helpstrings. +Expect $LINENO 1 "end of a long helpstring" "" --help + # Make sure --help reflects flag changes made before flag-parsing Expect $LINENO 1 \ "-changed_bool1 (changed) type: bool default: true" "" --help -- cgit v1.2.3