Directory: | ./ |
---|---|
File: | TESTS/TEST_DATA_PROCESSING/main.cpp |
Date: | 2025-03-14 12:18:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 36 | 36 | 100.0% |
Branches: | 66 | 66 | 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 <iostream> | ||
9 | #include <functional> | ||
10 | #include "phoenix_assert.h" | ||
11 | #include "phoenix_check.h" | ||
12 | |||
13 | #include "Shadok.h" | ||
14 | #include "ProcessClass.h" | ||
15 | #include "ProcessClassSort.h" | ||
16 | #include "Daemon.h" | ||
17 | |||
18 | #include "DaemonEmptyBackend.h" | ||
19 | |||
20 | typedef Daemon<DaemonEmptyBackend> TestDaemon; | ||
21 | |||
22 | ///Process a Shadok | ||
23 | /** @param shadok : Shadok to be processed | ||
24 | * @return true on success, false otherwise | ||
25 | */ | ||
26 | 1 | bool testShadokProcessing(const Shadok & shadok){ | |
27 | //Let's do something | ||
28 | 1 | std::cout << "testShadokProcessing : we are processing a Shadok" << std::endl; | |
29 | //I do not know what it was, but is was OK | ||
30 | 1 | return true; | |
31 | } | ||
32 | |||
33 | ///Process a Shadok | ||
34 | /** @param shadok : Shadok to be processed | ||
35 | * @return true on success, false otherwise | ||
36 | */ | ||
37 | 1 | bool testIntProcessing(const int & value){ | |
38 | //Let's do something | ||
39 | 1 | std::cout << "testIntProcessing : we are processing an int" << std::endl; | |
40 | //I do not know what it was, but is was OK | ||
41 | 1 | return true; | |
42 | } | ||
43 | |||
44 | ///Test the load configuration of a Daemon | ||
45 | /** @param fileName : name of the configuration toml file | ||
46 | */ | ||
47 | 1 | void testBaseDaemonLoadConfig(const PPath & fileName){ | |
48 |
1/1✓ Branch 1 taken 1 times.
|
1 | TestDaemon daemon; |
49 |
1/1✓ Branch 1 taken 1 times.
|
1 | daemon.setSocketMode(PSocketMode::MOCK); |
50 |
1/1✓ Branch 1 taken 1 times.
|
1 | daemon.setClockMode(PClockMode::MOCK); |
51 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | daemon.getLog().setLogLevel(PLog::DEBUG); |
52 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | daemon.getLog().setFileName(PPath("Daemon.log")); |
53 |
6/6✓ 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.
✓ Branch 19 taken 1 times.
|
1 | phoenix_assert(daemon.getLog().open()); |
54 |
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(daemon.addDataCallableMethod(testShadokProcessing)); |
55 |
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(daemon.addDataCallableMethod(testIntProcessing)); |
56 | //Add a non static method | ||
57 |
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(daemon.addDataCallableMethod(ProcessClass::fillLong)); |
58 | //Add a non-static method | ||
59 |
1/1✓ Branch 1 taken 1 times.
|
1 | ProcessClass processClass; |
60 |
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(daemon.addDataCallableMethod(sortFillShort, processClass)); |
61 | //The function is added already | ||
62 | // phoenix_assert(!daemon.addCallableMethod(testCallFunction, "testCallFunction")); | ||
63 | |||
64 | 1 | int value(42); | |
65 |
1/1✓ Branch 1 taken 1 times.
|
1 | Data dataInt(phoenix_createData(value)); |
66 |
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(daemon.processData(dataInt)); |
67 | |||
68 |
1/1✓ Branch 1 taken 1 times.
|
1 | Shadok shadok; |
69 |
1/1✓ Branch 1 taken 1 times.
|
1 | shadok.setAge(42); |
70 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | shadok.setName("Shadoko"); |
71 |
1/1✓ Branch 1 taken 1 times.
|
1 | Data data(phoenix_createData(shadok)); |
72 |
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(daemon.processData(data)); |
73 | |||
74 | 1 | long longValue(42); | |
75 |
1/1✓ Branch 1 taken 1 times.
|
1 | Data dataLong(phoenix_createData(longValue)); |
76 |
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(daemon.processData(dataLong)); |
77 | |||
78 | 1 | short shortValue(42); | |
79 |
1/1✓ Branch 1 taken 1 times.
|
1 | Data dataShort(phoenix_createData(shortValue)); |
80 |
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(daemon.processData(dataShort)); |
81 | 1 | } | |
82 | |||
83 | 1 | int main(int argc, char** argv){ | |
84 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testBaseDaemonLoadConfig(PPath(DAEMON_CONFIG_OK)); |
85 | 1 | return 0; | |
86 | } | ||
87 | |||
88 | |||
89 |