PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
main.cpp File Reference
#include <iostream>
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "string_system.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

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. More...
 
int main (int argc, char **argv)
 
void testCompletion ()
 Test the completion of the option. More...
 

Function Documentation

◆ 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.

Parameters
program: program to be tested
partialOption: partial typed option
cursorOption: option of the cursor
prevCursorOption: previous cursor option
expectedResult: expected completion result
Returns
true on success, false otherwise

Definition at line 21 of file main.cpp.

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 }

References phoenix_check(), and phoenix_popen().

Referenced by testCompletion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 43 of file main.cpp.

43  {
45  return 0;
46 }

References testCompletion().

+ Here is the call graph for this function:

◆ testCompletion()

void testCompletion ( )

Test the completion of the option.

Definition at line 32 of file main.cpp.

32  {
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 }

References checkOptionCompletion(), and phoenix_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:
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