1 |
|
|
|
2 |
|
|
/*************************************** |
3 |
|
|
Auteur : Pierre Aubert |
4 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
5 |
|
|
Licence : CeCILL-C |
6 |
|
|
****************************************/ |
7 |
|
|
|
8 |
|
|
#include "phoenix_check.h" |
9 |
|
|
#include "print_string.h" |
10 |
|
|
|
11 |
|
|
#include "Option.h" |
12 |
|
|
|
13 |
|
|
///Print value of Option |
14 |
|
|
/** @param opt : Option to be printed |
15 |
|
|
*/ |
16 |
|
3 |
void printValueOfOptConst(const Option & opt){ |
17 |
✓✓✓✓
|
3 |
phoenix_print(opt.getDocString(), "", "Docstring : "); |
18 |
✓✓✓✓
|
3 |
phoenix_print(opt.getLongName(), "", "LongName : "); |
19 |
✓✓✓✓
|
3 |
phoenix_print(opt.getShortName(), "", "ShortName : "); |
20 |
✓✓✓✓ ✓ |
3 |
phoenix_print(opt.getValue().getValue(), "", "Value : "); |
21 |
✓✓✓✓
|
3 |
phoenix_print(opt.isRequired(), "", "IsRequired : "); |
22 |
✓✓✓✓
|
3 |
phoenix_print(opt.isAllowEmpty(), "", "IsAllowEmpty : "); |
23 |
|
3 |
} |
24 |
|
|
|
25 |
|
|
///Print value of Option |
26 |
|
|
/** @param opt : Option to be printed |
27 |
|
|
*/ |
28 |
|
1 |
void printValueOfOpt(Option & opt){ |
29 |
✓✓✓✓
|
1 |
phoenix_print(opt.getDocString(), "", "Docstring : "); |
30 |
✓✓✓✓
|
1 |
phoenix_print(opt.getLongName(), "", "LongName : "); |
31 |
✓✓✓✓
|
1 |
phoenix_print(opt.getShortName(), "", "ShortName : "); |
32 |
✓✓✓✓ ✓ |
1 |
phoenix_print(opt.getValue().getValue(), "", "Value : "); |
33 |
✓✓✓✓
|
1 |
phoenix_print(opt.isRequired(), "", "IsRequired : "); |
34 |
✓✓✓✓
|
1 |
phoenix_print(opt.isAllowEmpty(), "", "IsAllowEmpty : "); |
35 |
|
1 |
} |
36 |
|
|
|
37 |
|
|
///Test the option type |
38 |
|
|
/** @return true on success, false otherwise |
39 |
|
|
*/ |
40 |
|
1 |
bool testOption(){ |
41 |
|
1 |
bool b(true); |
42 |
|
|
|
43 |
✓✓✓✓
|
3 |
Option opt("long", "short", "value", "some doc"); |
44 |
✓ |
1 |
printValueOfOpt(opt); |
45 |
✓ |
1 |
printValueOfOptConst(opt); |
46 |
|
|
|
47 |
✓✓✓✓
|
3 |
Option optReq("long", "short", true, "some doc"); |
48 |
✓ |
1 |
printValueOfOptConst(optReq); |
49 |
|
|
|
50 |
✓✓✓✓
|
2 |
Option optSet; |
51 |
✓✓ |
1 |
optSet.setDocString("Some doc"); |
52 |
✓✓ |
1 |
optSet.setLongName("long"); |
53 |
✓✓ |
1 |
optSet.setShortName("short"); |
54 |
✓✓✓ |
1 |
optSet.setValue(OptionValue("Value", OptionType::STRING)); |
55 |
✓ |
1 |
optSet.setIsRequired(true); |
56 |
✓ |
1 |
optSet.setIsAllowEmpty(true); |
57 |
✓ |
1 |
optSet.setIsParsed(false); |
58 |
✓ |
1 |
printValueOfOptConst(optSet); |
59 |
|
|
|
60 |
✓✓ |
1 |
phoenix_functionOk("testOption", b); |
61 |
|
2 |
return b; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
1 |
int main(int argc, char** argv){ |
65 |
|
1 |
bool b(testOption()); |
66 |
|
|
|
67 |
✓✓ |
1 |
phoenix_functionOk("final", b); |
68 |
|
1 |
return b - 1; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
|