PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp
Go to the documentation of this file.
1 
2 /***************************************
3  Auteur : Pierre Aubert
4  Mail : pierre.aubert@lapp.in2p3.fr
5  Licence : CeCILL-C
6 ****************************************/
7 
8 #include "phoenix_assert.h"
9 #include "phoenix_check.h"
10 
11 #include "Option.h"
12 
14 
22 void printValueOfOptConst(const Option & opt, const PString & expectedLongOption, const PString & expectedShortOption, size_t expectedNbValue,
23  bool expectedIsRequired, bool expectedAllowEmpty, const PString & expectedDocString)
24 {
25  phoenix_assert(phoenix_check("printValueOfOptConst : docstring", opt.getDocString(), expectedDocString));
26  phoenix_assert(phoenix_check("printValueOfOptConst : long name", opt.getLongName(), expectedLongOption));
27  phoenix_assert(phoenix_check("printValueOfOptConst : short name", opt.getShortName(), expectedShortOption));
28  phoenix_assert(phoenix_check("printValueOfOptConst : value", opt.getValue().getValue().size(), expectedNbValue));
29  phoenix_assert(phoenix_check("printValueOfOptConst : isRequired", opt.isRequired(), expectedIsRequired));
30  phoenix_assert(phoenix_check("printValueOfOptConst : isAllowEmpty", opt.isAllowEmpty(), expectedAllowEmpty));
31 }
32 
34 
42 void printValueOfOpt(Option & opt, const PString & expectedLongOption, const PString & expectedShortOption, size_t expectedNbValue,
43  bool expectedIsRequired, bool expectedAllowEmpty, const PString & expectedDocString)
44 {
45  phoenix_assert(phoenix_check("printValueOfOpt : docstring", opt.getDocString(), expectedDocString));
46  phoenix_assert(phoenix_check("printValueOfOpt : long name", opt.getLongName(), expectedLongOption));
47  phoenix_assert(phoenix_check("printValueOfOpt : short name", opt.getShortName(), expectedShortOption));
48  phoenix_assert(phoenix_check("printValueOfOpt : value", opt.getValue().getValue().size(), expectedNbValue));
49  phoenix_assert(phoenix_check("printValueOfOpt : isRequired", opt.isRequired(), expectedIsRequired));
50  phoenix_assert(phoenix_check("printValueOfOpt : isAllowEmpty", opt.isAllowEmpty(), expectedAllowEmpty));
51 }
52 
54 void testOption(){
55  Option opt("long", "short", false, "some doc");
56  printValueOfOpt(opt, "long", "short", 0lu, false, false, "some doc");
57  printValueOfOptConst(opt, "long", "short", 0lu, false, false, "some doc");
58 
59  Option optReq("long", "short", true, "some doc");
60  printValueOfOptConst(optReq, "long", "short", 0lu, true, false, "some doc");
61 
62  Option optSet;
63  optSet.setDocString("Some doc");
64  optSet.setLongName("long");
65  optSet.setShortName("short");
66  optSet.setValue(OptionValue("Value", OptionType::STRING));
67  optSet.setIsRequired(true);
68  optSet.setIsAllowEmpty(true);
69  optSet.setIsParsed(false);
70  printValueOfOptConst(optSet, "long", "short", 1lu, true, true, "Some doc");
71 }
72 
73 int main(int argc, char** argv){
74  testOption();
75  return 0;
76 }
77 
78 
int main(int argc, char **argv)
Definition: main.cpp:228
void printValueOfOpt(Option &opt, const PString &expectedLongOption, const PString &expectedShortOption, size_t expectedNbValue, bool expectedIsRequired, bool expectedAllowEmpty, const PString &expectedDocString)
Print value of Option.
Definition: main.cpp:42
void testOption()
Test the option type.
Definition: main.cpp:54
void printValueOfOptConst(const Option &opt, const PString &expectedLongOption, const PString &expectedShortOption, size_t expectedNbValue, bool expectedIsRequired, bool expectedAllowEmpty, const PString &expectedDocString)
Print value of Option.
Definition: main.cpp:22
Describe the value of an option passed to a program.
Definition: OptionValue.h:16
const PVecString & getValue() const
Get the vector of values.
Describes an option passed to a program.
Definition: Option.h:14
void setIsParsed(bool isParsed)
Say if the Option has been parsed or not.
Definition: Option.cpp:179
void setIsAllowEmpty(bool isAllowEmpty)
Say if the option can be empty or not.
Definition: Option.cpp:184
const PString & getLongName() const
Get the long name of the Option.
Definition: Option.cpp:189
void setLongName(const PString &longName)
Set the long name of the option.
Definition: Option.cpp:154
const OptionValue & getValue() const
Get the value of the Option.
Definition: Option.cpp:209
const PString & getDocString() const
Get the documentation string of the Option.
Definition: Option.cpp:239
void setShortName(const PString &shortName)
Set the short name of the option.
Definition: Option.cpp:159
void setIsRequired(bool isRequired)
Set if the option is required.
Definition: Option.cpp:169
const PString & getShortName() const
Get the short name of the Option.
Definition: Option.cpp:199
void setValue(const OptionValue &value)
Set the value of the option.
Definition: Option.cpp:164
bool isAllowEmpty() const
Get if the option value can be empty.
Definition: Option.cpp:229
void setDocString(const PString &docString)
Set the documentation string of the Option.
Definition: Option.cpp:174
bool isRequired() const
Get if the option is required.
Definition: Option.cpp:219
Extends the std::string.
Definition: PString.h:16
#define phoenix_assert(isOk)
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.