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 |
|
|
#include "print_string.h" |
11 |
|
|
|
12 |
|
|
#include "Option.h" |
13 |
|
|
|
14 |
|
|
///Print value of Option |
15 |
|
|
/** @param opt : Option to be printed |
16 |
|
|
*/ |
17 |
|
3 |
void printValueOfOptConst(const Option & opt){ |
18 |
✓✓✓✓
|
3 |
phoenix_print(opt.getDocString(), "", "Docstring : "); |
19 |
✓✓✓✓
|
3 |
phoenix_print(opt.getLongName(), "", "LongName : "); |
20 |
✓✓✓✓
|
3 |
phoenix_print(opt.getShortName(), "", "ShortName : "); |
21 |
✓✓✓✓ ✓ |
3 |
phoenix_print(opt.getValue().getValue(), "", "Value : "); |
22 |
✓✓✓✓
|
3 |
phoenix_print(opt.isRequired(), "", "IsRequired : "); |
23 |
✓✓✓✓
|
3 |
phoenix_print(opt.isAllowEmpty(), "", "IsAllowEmpty : "); |
24 |
|
3 |
} |
25 |
|
|
|
26 |
|
|
///Print value of Option |
27 |
|
|
/** @param opt : Option to be printed |
28 |
|
|
*/ |
29 |
|
1 |
void printValueOfOpt(Option & opt){ |
30 |
✓✓✓✓
|
1 |
phoenix_print(opt.getDocString(), "", "Docstring : "); |
31 |
✓✓✓✓
|
1 |
phoenix_print(opt.getLongName(), "", "LongName : "); |
32 |
✓✓✓✓
|
1 |
phoenix_print(opt.getShortName(), "", "ShortName : "); |
33 |
✓✓✓✓ ✓ |
1 |
phoenix_print(opt.getValue().getValue(), "", "Value : "); |
34 |
✓✓✓✓
|
1 |
phoenix_print(opt.isRequired(), "", "IsRequired : "); |
35 |
✓✓✓✓
|
1 |
phoenix_print(opt.isAllowEmpty(), "", "IsAllowEmpty : "); |
36 |
|
1 |
} |
37 |
|
|
|
38 |
|
|
///Test the option type |
39 |
|
1 |
void testOption(){ |
40 |
✓✓✓✓
|
3 |
Option opt("long", "short", "value", "some doc"); |
41 |
✓ |
1 |
printValueOfOpt(opt); |
42 |
✓ |
1 |
printValueOfOptConst(opt); |
43 |
|
|
|
44 |
✓✓✓✓
|
3 |
Option optReq("long", "short", true, "some doc"); |
45 |
✓ |
1 |
printValueOfOptConst(optReq); |
46 |
|
|
|
47 |
✓✓✓✓
|
3 |
Option optSet; |
48 |
✓✓ |
1 |
optSet.setDocString("Some doc"); |
49 |
✓✓ |
1 |
optSet.setLongName("long"); |
50 |
✓✓ |
1 |
optSet.setShortName("short"); |
51 |
✓✓✓ |
1 |
optSet.setValue(OptionValue("Value", OptionType::STRING)); |
52 |
✓ |
1 |
optSet.setIsRequired(true); |
53 |
✓ |
1 |
optSet.setIsAllowEmpty(true); |
54 |
✓ |
1 |
optSet.setIsParsed(false); |
55 |
✓ |
1 |
printValueOfOptConst(optSet); |
56 |
|
1 |
} |
57 |
|
|
|
58 |
|
1 |
int main(int argc, char** argv){ |
59 |
|
1 |
testOption(); |
60 |
|
1 |
return 0; |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
|