Fix wxCmdLineParser::Found(name) for options with values.

Calling Found() without providing the second "value" argument started
generating an assert since introduction of the negated options as it reused
FoundSwitch() which can only be used for switches, i.e. options without
values.

Fix this to revert a regression since 2.8 and also add unit tests for the
different Found() overloads.

Closes #15986, #16001.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75943 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-02-20 00:32:47 +00:00
parent 3d20f8e534
commit 41d5ebc86f
2 changed files with 64 additions and 1 deletions

View File

@@ -709,7 +709,9 @@ void wxCmdLineParser::AddUsageText(const wxString& text)
bool wxCmdLineParser::Found(const wxString& name) const
{
return FoundSwitch(name) != wxCMD_SWITCH_NOT_FOUND;
const wxCmdLineOption* const opt = m_data->FindOptionByAnyName(name);
return opt && opt->HasValue();
}
wxCmdLineSwitchState wxCmdLineParser::FoundSwitch(const wxString& name) const