Directory: | ./ |
---|---|
File: | tmp_project/PhoenixDataStream/TESTS/TEST_DATA_FILE/main_simple_type.cpp |
Date: | 2025-03-14 11:54:19 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 41 | 41 | 100.0% |
Branches: | 83 | 83 | 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 "data_stream_assert.h" | ||
8 | #include "data_stream_check_value.h" | ||
9 | |||
10 | #include "data_size.h" | ||
11 | #include "data_message.h" | ||
12 | #include "data_file.h" | ||
13 | |||
14 | ///Abstract check of a value stored in a file | ||
15 | /** @param testName : name of the test | ||
16 | */ | ||
17 | template<typename T> | ||
18 | 26 | void testSimpleValue(const std::string & testName){ | |
19 | 26 | T referenceValue(42); | |
20 |
2/2✓ Branch 2 taken 13 times.
✓ Branch 6 taken 13 times.
|
52 | std::string fileName("value_test.data"), unexistingFileName("someUnexisting/file/in/unexistingDir/file.data"); |
21 |
5/5✓ Branch 2 taken 13 times.
✓ Branch 6 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
✓ Branch 16 taken 13 times.
|
26 | data_stream_assert(data_save(fileName, referenceValue)); |
22 | T value; | ||
23 |
5/5✓ Branch 2 taken 13 times.
✓ Branch 6 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
✓ Branch 16 taken 13 times.
|
26 | data_stream_assert(data_load(fileName, value)); |
24 |
5/5✓ Branch 2 taken 13 times.
✓ Branch 6 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
✓ Branch 16 taken 13 times.
|
26 | data_stream_assert(checkValue(testName, value, referenceValue)); |
25 |
5/5✓ Branch 2 taken 13 times.
✓ Branch 6 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
✓ Branch 16 taken 13 times.
|
26 | data_stream_assert(!data_save(unexistingFileName, referenceValue)); |
26 |
5/5✓ Branch 2 taken 13 times.
✓ Branch 6 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
✓ Branch 16 taken 13 times.
|
26 | data_stream_assert(!data_load(unexistingFileName, value)); |
27 | 26 | } | |
28 | |||
29 | ///Abstract check of a value stored in a file | ||
30 | /** @param testName : name of the test | ||
31 | * @param referenceValue : reference value to be checked | ||
32 | */ | ||
33 | template<typename T> | ||
34 | 1 | void testSimpleValue(const std::string & testName, const T & referenceValue){ | |
35 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
|
2 | std::string fileName("value_test.data"), unexistingFileName("someUnexisting/file/in/unexistingDir/file.data"); |
36 |
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_save(fileName, referenceValue)); |
37 | 1 | T value; | |
38 |
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_load(fileName, value)); |
39 |
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(checkValue(testName, value, referenceValue)); |
40 |
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_save(unexistingFileName, referenceValue)); |
41 |
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_load(unexistingFileName, value)); |
42 | 1 | } | |
43 | |||
44 | ///Test if data size is Ok | ||
45 | 1 | void testSimpleDataFile(){ | |
46 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<long unsigned int>("long unsigned int"); |
47 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<unsigned int>("unsigned int"); |
48 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<unsigned short>("unsigned short"); |
49 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<unsigned char>("unsigned char"); |
50 | |||
51 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<long int>("long int"); |
52 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<long>("long"); |
53 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<int>("int"); |
54 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<short>("short"); |
55 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<char>("char"); |
56 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<int8_t>("int8_t"); |
57 | |||
58 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<float>("float"); |
59 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<double>("double"); |
60 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue<bool>("bool"); |
61 | 1 | } | |
62 | |||
63 | ///Test if data size is Ok | ||
64 | 1 | void testStringDataFile(){ | |
65 |
1/1✓ Branch 2 taken 1 times.
|
1 | std::string str("One thing to say"); |
66 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSimpleValue("std::string", str); |
67 | 1 | } | |
68 | |||
69 | 1 | int main(int argc, char** argv){ | |
70 | 1 | testSimpleDataFile(); | |
71 | 1 | testStringDataFile(); | |
72 | 1 | return 0; | |
73 | } | ||
74 | |||
75 | |||
76 |