mirror of
https://github.com/cuberite/TCLAP.git
synced 2025-08-04 02:06:29 -04:00

User is not allowed to provide a NULL constraint to the various ARG constructors. This patch makes sure the Constraint is not NULL before dereferencing and raises a logic_error if it is NULL. Also included the two new tests test88 and test89 in runtests script.
36 lines
976 B
C++
36 lines
976 B
C++
#include <iostream>
|
|
|
|
#include "tclap/CmdLine.h"
|
|
|
|
using namespace TCLAP;
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
try {
|
|
CmdLine cmd("test constraint bug");
|
|
ValueArg<int> arg("i","int", "tests int arg", false, 4711, NULL, cmd);
|
|
cout << "Expected exception" << endl;
|
|
} catch(std::logic_error &e) { /* expected */ }
|
|
|
|
try {
|
|
CmdLine cmd("test constraint bug");
|
|
ValueArg<int> arg1("i","int", "tests int arg", false, 4711, NULL, NULL);
|
|
cout << "Expected exception" << endl;
|
|
} catch(std::logic_error &e) { /* expected */ }
|
|
|
|
try {
|
|
CmdLine cmd("test constraint bug");
|
|
MultiArg<int> arg1("i","int", "tests int arg", false, NULL, NULL);
|
|
cout << "Expected exception" << endl;
|
|
} catch(std::logic_error &e) { /* expected */ }
|
|
|
|
try {
|
|
CmdLine cmd("test constraint bug");
|
|
MultiArg<int> arg1("i","int", "tests int arg", false, NULL, cmd);
|
|
cout << "Expected exception" << endl;
|
|
} catch(std::logic_error &e) { /* expected */ }
|
|
|
|
cout << "Passed" << endl;
|
|
}
|