PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
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 <iostream>
9 #include "phoenix_assert.h"
10 #include "phoenix_check.h"
11 #include "string_system.h"
12 
14 
21 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  std::string command(program + " __bashcompletionmode=\""+cursorOption+"\" __bashcompletionmodeprev=\""+prevCursorOption+"\" prgName " + partialOption);
25  std::string resultCmd(phoenix_popen(command));
26 
27  bool b(phoenix_check("checkOptionCompletion cmd("+command+")", resultCmd, expectedResult));
28  return b;
29 }
30 
33  phoenix_assert(checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "", "", "", "--value -n --help -h --version -v \n"));
34  phoenix_assert(checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "-", "", "-", "--value -n --help -h --version -v \n"));
35  //Here we expect mostly '--value --help --version'
36  phoenix_assert(checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--", "", "--", "--value --help --version \n"));
37  //Here we expect mostly '--value --version'
38  phoenix_assert(checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--v", "", "--v", "--value --version \n"));
39  phoenix_assert(checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--value", "--value", "", "INT\n"));
40  phoenix_assert(checkOptionCompletion(PROGRAM_OPTION_COMPLETION_INT, "--value=42", "", "", "--help -h --version -v \n"));
41 }
42 
43 int main(int argc, char** argv){
45  return 0;
46 }
47 
48 
checkOptionCompletion
bool checkOptionCompletion(const std::string &program, const std::string &partialOption, const std::string &prevCursorOption, const std::string &cursorOption, const std::string &expectedResult)
Check the option completion of a program.
Definition: main.cpp:21
phoenix_check
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.
Definition: phoenix_check.cpp:17
phoenix_popen
std::string phoenix_popen(const std::string &command)
Execute the given command and returns the output of this command.
Definition: string_system.cpp:341
testCompletion
void testCompletion()
Test the completion of the option.
Definition: main.cpp:32
phoenix_assert
#define phoenix_assert(isOk)
Definition: phoenix_assert.h:19
string_system.h
phoenix_assert.h
main
int main(int argc, char **argv)
Definition: main.cpp:85
phoenix_check.h