GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
|||
2 |
/*************************************** |
||
3 |
Auteur : Pierre Aubert |
||
4 |
Mail : pierre.aubert@lapp.in2p3.fr |
||
5 |
Licence : CeCILL-C |
||
6 |
****************************************/ |
||
7 |
|||
8 |
#include <iostream> |
||
9 |
|||
10 |
#include "phoenix_check.h" |
||
11 |
#include "string_system.h" |
||
12 |
|||
13 |
///Check the option completion of a program |
||
14 |
/** @param program : program to be tested |
||
15 |
* @param partialOption : partial typed option |
||
16 |
* @param cursorOption : option of the cursor |
||
17 |
* @param prevCursorOption : previous cursor option |
||
18 |
* @param expectedResult : expected completion result |
||
19 |
* @return true on success, false otherwise |
||
20 |
*/ |
||
21 |
6 |
bool checkOptionCompletion(const std::string & program, const std::string & partialOption, const std::string & prevCursorOption, |
|
22 |
const std::string & cursorOption, const std::string & expectedResult) |
||
23 |
{ |
||
24 |
✓✓✓✓ ✓✓ |
18 |
std::string command(program + " __bashcompletionmode=\""+cursorOption+"\" __bashcompletionmodeprev=\""+prevCursorOption+"\" prgName " + partialOption); |
25 |
✓ | 6 |
std::string resultCmd(phoenix_popen(command)); |
26 |
|||
27 |
✓✓✓ | 6 |
bool b(phoenix_check("checkOptionCompletion cmd("+command+")", resultCmd, expectedResult)); |
28 |
12 |
return b; |
|
29 |
} |
||
30 |
|||
31 |
///Test the completion of the option |
||
32 |
/** @return true on success, false otherwise |
||
33 |
*/ |
||
34 |
1 |
bool testCompletion(){ |
|
35 |
1 |
bool b(true); |
|
36 |
|||
37 |
✓✓✓✓ ✓✓ |
1 |
b &= checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "", "", "", "--value -n --help -h --version -v \n"); |
38 |
|||
39 |
✓✓✓✓ ✓✓ |
1 |
b &= checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "-", "", "-", "--value -n --help -h --version -v \n"); |
40 |
|||
41 |
//Here we expect mostly '--value --help --version' |
||
42 |
✓✓✓✓ ✓✓ |
1 |
b &= checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--", "", "--", "--value --help --version \n"); |
43 |
|||
44 |
//Here we expect mostly '--value --version' |
||
45 |
✓✓✓✓ ✓✓ |
1 |
b &= checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--v", "", "--v", "--value --version \n"); |
46 |
|||
47 |
✓✓✓✓ ✓✓ |
1 |
b &= checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--value", "--value", "", "INT\n"); |
48 |
|||
49 |
✓✓✓✓ ✓✓ |
1 |
b &= checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--value=42", "", "", "--help -h --version -v \n"); |
50 |
|||
51 |
✓✓ | 1 |
phoenix_functionOk("testCompletion", b); |
52 |
1 |
return b; |
|
53 |
} |
||
54 |
|||
55 |
1 |
int main(int argc, char** argv){ |
|
56 |
1 |
bool b(testCompletion()); |
|
57 |
✓✓ | 1 |
phoenix_functionOk("final", b); |
58 |
|||
59 |
1 |
return b - 1; |
|
60 |
} |
||
61 |
|||
62 |
Generated by: GCOVR (Version 4.2) |