GCC Code Coverage Report


Directory: ./
File: TESTS/TEST_ENUM_MACRO/main.cpp
Date: 2026-01-15 15:51:44
Exec Total Coverage
Lines: 27 27 100.0%
Functions: 9 9 100.0%
Branches: 35 35 100.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "phoenix_data_stream.h"
8
9 namespace ShadokType{
10 ///Type of the Shadok we want to serialized
11 enum ShadokType{
12 NONE = 0, //Nothing to do
13 HAUT = 1, //Shadok from the top of the planet
14 BAS = 2 //Shadok from the bottom of the planet
15 };
16 }
17
1/1
✓ Branch 0 (2→3) taken 6 times.
12 PHOENIX_DATA_STREAM_ENUM(ShadokType::ShadokType)
18
19 ///Test the Shadok size
20 1 void testShadokTypeSize(){
21 1 ShadokType::ShadokType type(ShadokType::HAUT);
22
1/1
✓ Branch 0 (2→3) taken 1 times.
1 size_t shadokSize(data_size(type));
23
6/6
✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (11→12) taken 1 times.
✓ Branch 6 (14→15) taken 1 times.
✓ Branch 8 (15→16) taken 1 times.
✓ Branch 10 (16→17) taken 1 times.
7 data_stream_assert(checkValue("testShadokTypeSize", shadokSize, 4lu));
24 1 }
25
26 ///Test the Shadok message
27 1 void testShadokTypeMessage(){
28 1 ShadokType::ShadokType type(ShadokType::BAS);
29
30
2/2
✓ Branch 0 (4→5) taken 1 times.
✓ Branch 2 (5→6) taken 1 times.
1 DataStreamMsg messageIn(data_size(type));
31 1 DataStreamIter iter = (DataStreamIter)messageIn.data();
32
5/5
✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (13→14) taken 1 times.
✓ Branch 4 (16→17) taken 1 times.
✓ Branch 6 (17→18) taken 1 times.
✓ Branch 8 (18→19) taken 1 times.
5 data_stream_assert(data_message_save(iter, type));
33
34 ///Load shadok from message
35 ShadokType::ShadokType out;
36 1 DataStreamIter iterOut = (DataStreamIter)messageIn.data();
37
5/5
✓ Branch 0 (28→29) taken 1 times.
✓ Branch 2 (31→32) taken 1 times.
✓ Branch 4 (34→35) taken 1 times.
✓ Branch 6 (35→36) taken 1 times.
✓ Branch 8 (36→37) taken 1 times.
6 data_stream_assert(data_message_load(iterOut, out));
38
39
6/6
✓ Branch 0 (45→46) taken 1 times.
✓ Branch 2 (48→49) taken 1 times.
✓ Branch 4 (51→52) taken 1 times.
✓ Branch 6 (54→55) taken 1 times.
✓ Branch 8 (55→56) taken 1 times.
✓ Branch 10 (56→57) taken 1 times.
7 data_stream_assert(checkValue("testShadokMessage", out, type));
40 1 }
41
42 ///Test the Shadok message
43 1 void testShadokTypeFile(){
44 1 ShadokType::ShadokType type(ShadokType::BAS);
45
1/1
✓ Branch 0 (4→5) taken 1 times.
1 std::string fileName("ShadokType.data");
46
1/1
✓ Branch 0 (6→7) taken 1 times.
1 data_save(fileName, type);
47
48 ///Load shadok from message
49 ShadokType::ShadokType out;
50
1/1
✓ Branch 0 (7→8) taken 1 times.
1 data_load(fileName, out);
51
52
6/6
✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (13→14) taken 1 times.
✓ Branch 4 (16→17) taken 1 times.
✓ Branch 6 (19→20) taken 1 times.
✓ Branch 8 (20→21) taken 1 times.
✓ Branch 10 (21→22) taken 1 times.
7 data_stream_assert(checkValue("testShadokFile", out, type));
53 1 }
54
55
56 1 int main(int argc, char** argv){
57 1 testShadokTypeSize();
58 1 testShadokTypeMessage();
59 1 testShadokTypeFile();
60 1 return 0;
61 }
62
63