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 <vector>
10
#include "
phoenix_assert.h
"
11
#include "
string_system.h
"
12
14
void
testPoenixPOpen
(){
15
std::string resCmd1(
phoenix_popen
(
"echo \"test command\""
));
16
std::cout <<
"testPoenixPOpen : resCmd1 = '"
<< resCmd1 <<
"'"
<< std::endl;
17
phoenix_assert
(resCmd1 ==
"test command\n"
);
18
phoenix_assert
(
phoenix_popen
(
""
) ==
""
);
19
std::string resCmd3(
phoenix_popen
(
"someUnexistingCommad"
));
20
std::cout <<
"testPoenixPOpen : resCmd3 = '"
<< resCmd3 <<
"'"
<< std::endl;
21
phoenix_assert
(resCmd3 ==
"\0"
);
22
int
exitStatus1 =
phoenix_popen
(resCmd1,
"echo \"test command\""
);
23
phoenix_assert
(resCmd1 ==
"test command\n"
);
24
phoenix_assert
(exitStatus1 == 0);
25
std::string resEmptyCmd(
""
);
26
int
exitStatus2 =
phoenix_popen
(resEmptyCmd,
""
);
27
phoenix_assert
(resEmptyCmd ==
""
);
28
phoenix_assert
(exitStatus2 == -1);
29
std::string resUnexistingCmd(
""
);
30
int
exitStatus3 =
phoenix_popen
(resUnexistingCmd,
"someUnexistingCommad"
);
31
phoenix_assert
(resUnexistingCmd ==
""
);
32
phoenix_assert
(exitStatus3 == 32512);
33
phoenix_assert
(
phoenix_popen
(
"command.log"
,
"echo \"test command\""
,
true
));
34
phoenix_assert
(
phoenix_popen
(
"command.log"
,
"echo \"test command\""
,
false
));
35
phoenix_assert
(!
phoenix_popen
(
"command_unexistingCommand.log"
,
"someUnexistingCommand"
,
true
));
36
phoenix_assert
(!
phoenix_popen
(
"command_unexistingCommand.log"
,
"someUnexistingCommand"
,
false
));
37
}
38
39
int
main
(
int
argc,
char
** argv){
40
testPoenixPOpen
();
41
return
0;
42
}
43
44
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
testPoenixPOpen
void testPoenixPOpen()
Test the phoenix popen function.
Definition:
main.cpp:14
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
tmp_project
StringUtils
TESTS
TEST_PHOENIX_POPEN
main.cpp
Generated on Mon Dec 9 2024 15:33:41 for PhoenixMock by
1.8.17