Directory: | ./ |
---|---|
File: | TESTS/TEST_ARGPARSER/main.cpp |
Date: | 2024-07-27 10:53:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 31 | 31 | 100.0% |
Branches: | 35 | 35 | 100.0% |
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 "phoenix_assert.h" | ||
9 | #include "phoenix_check.h" | ||
10 | #include "ArgParser.h" | ||
11 | |||
12 | ///Test the ArgParser | ||
13 | 1 | void testArgParser(){ | |
14 |
1/1✓ Branch 1 taken 1 times.
|
1 | ArgParser arg; |
15 |
1/1✓ Branch 1 taken 1 times.
|
1 | ArgParser arg2(arg); |
16 |
1/1✓ Branch 1 taken 1 times.
|
1 | ArgParser arg3; |
17 |
1/1✓ Branch 1 taken 1 times.
|
1 | arg3 = arg; |
18 | |||
19 |
1/1✓ Branch 1 taken 1 times.
|
1 | arg.print(); |
20 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(arg.getNbArgument() == 0lu); |
21 |
1/1✓ Branch 1 taken 1 times.
|
1 | arg.rewind(); |
22 | 1 | } | |
23 | |||
24 | ///Test the ArgParser | ||
25 | /** @param arg : constant ArgParser to be tested | ||
26 | * @return true on success, false otherwise | ||
27 | */ | ||
28 | 1 | bool testConstGetCurrentOption(const ArgParser & arg){ | |
29 | 1 | return arg.getCurrentOption() != ""; | |
30 | } | ||
31 | |||
32 | ///Test the ArgParser | ||
33 | /** @return true on success, false otherwise | ||
34 | */ | ||
35 | 2 | bool testArgParserArg(int argc, char** argv){ | |
36 | 2 | bool b(true); | |
37 | |||
38 |
1/1✓ Branch 1 taken 2 times.
|
2 | ArgParser arg(argc, argv); |
39 |
1/1✓ Branch 1 taken 2 times.
|
2 | ArgParser arg2(arg); |
40 |
1/1✓ Branch 1 taken 2 times.
|
2 | ArgParser arg3; |
41 |
1/1✓ Branch 1 taken 2 times.
|
2 | arg3 = arg; |
42 | |||
43 |
1/1✓ Branch 1 taken 2 times.
|
2 | arg.print(); |
44 |
1/1✓ Branch 1 taken 2 times.
|
2 | b &= arg.getNbArgument() != 0lu; |
45 | |||
46 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
|
2 | if(arg.getNbArgument() != 0lu){ |
47 |
1/1✓ Branch 1 taken 1 times.
|
1 | arg.print(); |
48 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | b &= arg.getCurrentOption() != ""; |
49 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= testConstGetCurrentOption(arg); |
50 | } | ||
51 | |||
52 |
1/1✓ Branch 1 taken 2 times.
|
2 | arg.rewind(); |
53 | 2 | return b; | |
54 | 2 | } | |
55 | |||
56 | 1 | int main(int argc, char** argv){ | |
57 | 1 | testArgParser(); | |
58 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(testArgParserArg(argc, argv)); |
59 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(!testArgParserArg(0, argv)); |
60 | 1 | return 0; | |
61 | } | ||
62 | |||
63 | |||
64 |