added new test

This commit is contained in:
mes5k 2004-01-08 05:04:04 +00:00
parent dc50ceed2d
commit a29ce6ca74
2 changed files with 68 additions and 1 deletions

View File

@ -1,17 +1,19 @@
noinst_PROGRAMS = test1 test2 test3
noinst_PROGRAMS = test1 test2 test3 test4
test1_SOURCES = test1.cpp
test2_SOURCES = test2.cpp
test3_SOURCES = test3.cpp
test4_SOURCES = test4.cpp
test1_LDADD = $(top_builddir)/src/libtclap.a
test2_LDADD = $(top_builddir)/src/libtclap.a
test3_LDADD = $(top_builddir)/src/libtclap.a
test4_LDADD = $(top_builddir)/src/libtclap.a
INCLUDES = -I$(top_builddir)/include

65
examples/test4.cpp Normal file
View File

@ -0,0 +1,65 @@
#include <tclap/CmdLine.h>
#include <iostream>
#include <string>
using namespace TCLAP;
bool _boolTestB;
bool _boolTestA;
string _stringTest;
void parseOptions(int argc, char** argv);
int main(int argc, char** argv)
{
parseOptions(argc,argv);
cout << "for string we got : " << _stringTest<< endl
<< "for bool B we got : " << _boolTestB << endl
<< "for bool A we got : " << _boolTestA << endl;
}
void parseOptions(int argc, char** argv)
{
try {
CmdLine cmd("this is a message", ' ', "0.99" );
//
// Define arguments
//
SwitchArg btest("B","sB", "exist Test B", false);
SwitchArg atest("A","sA", "exist Test B", false);
ValueArg<string> stest("s", "Bs", "string test", true, "homer",
"string");
cmd.add( stest );
cmd.add( btest );
cmd.add( atest );
//
// Parse the command line.
//
cmd.parse(argc,argv);
//
// Set variables
//
_stringTest = stest.getValue();
_boolTestB = btest.getValue();
_boolTestA = atest.getValue();
} catch ( ArgException e )
{ cout << "ERROR: " << e.error() << " " << e.argId() << endl; }
}