GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixDataStream/TESTS/TEST_ENUM_MACRO/main.cpp
Date: 2025-03-14 12:18:05
Exec Total Coverage
Lines: 27 27 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 1 taken 6 times.
20 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 1 taken 1 times.
1 size_t shadokSize(data_size(type));
23
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 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 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 DataStreamMsg messageIn(data_size(type));
31 1 DataStreamIter iter = (DataStreamIter)messageIn.data();
32
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 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 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 data_stream_assert(data_message_load(iterOut, out));
38
39
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 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 2 taken 1 times.
1 std::string fileName("ShadokType.data");
46
1/1
✓ Branch 1 taken 1 times.
1 data_save(fileName, type);
47
48 ///Load shadok from message
49 ShadokType::ShadokType out;
50
1/1
✓ Branch 1 taken 1 times.
1 data_load(fileName, out);
51
52
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 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