| 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 | 13 | void testSimpleValue(const std::string & testName){ | |
| 19 | 13 | T referenceValue(42); | |
| 20 |
2/2✓ Branch 0 (4→5) taken 13 times.
✓ Branch 2 (8→9) taken 13 times.
|
52 | std::string fileName("value_test.data"), unexistingFileName("someUnexisting/file/in/unexistingDir/file.data"); |
| 21 |
5/5✓ Branch 0 (12→13) taken 13 times.
✓ Branch 2 (15→16) taken 13 times.
✓ Branch 4 (18→19) taken 13 times.
✓ Branch 6 (19→20) taken 13 times.
✓ Branch 8 (20→21) taken 13 times.
|
78 | data_stream_assert(data_save(fileName, referenceValue)); |
| 22 | T value; | ||
| 23 |
5/5✓ Branch 0 (29→30) taken 13 times.
✓ Branch 2 (32→33) taken 13 times.
✓ Branch 4 (35→36) taken 13 times.
✓ Branch 6 (36→37) taken 13 times.
✓ Branch 8 (37→38) taken 13 times.
|
78 | data_stream_assert(data_load(fileName, value)); |
| 24 |
5/5✓ Branch 0 (46→47) taken 13 times.
✓ Branch 2 (49→50) taken 13 times.
✓ Branch 4 (52→53) taken 13 times.
✓ Branch 6 (53→54) taken 13 times.
✓ Branch 8 (54→55) taken 13 times.
|
78 | data_stream_assert(checkValue(testName, value, referenceValue)); |
| 25 |
5/5✓ Branch 0 (63→64) taken 13 times.
✓ Branch 2 (66→67) taken 13 times.
✓ Branch 4 (69→70) taken 13 times.
✓ Branch 6 (70→71) taken 13 times.
✓ Branch 8 (71→72) taken 13 times.
|
78 | data_stream_assert(!data_save(unexistingFileName, referenceValue)); |
| 26 |
5/5✓ Branch 0 (80→81) taken 13 times.
✓ Branch 2 (83→84) taken 13 times.
✓ Branch 4 (86→87) taken 13 times.
✓ Branch 6 (87→88) taken 13 times.
✓ Branch 8 (88→89) taken 13 times.
|
65 | data_stream_assert(!data_load(unexistingFileName, value)); |
| 27 | 13 | } | |
| 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 0 (4→5) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
|
4 | std::string fileName("value_test.data"), unexistingFileName("someUnexisting/file/in/unexistingDir/file.data"); |
| 36 |
5/5✓ Branch 0 (12→13) taken 1 times.
✓ Branch 2 (15→16) taken 1 times.
✓ Branch 4 (18→19) taken 1 times.
✓ Branch 6 (19→20) taken 1 times.
✓ Branch 8 (20→21) taken 1 times.
|
5 | data_stream_assert(data_save(fileName, referenceValue)); |
| 37 | 1 | T value; | |
| 38 |
5/5✓ Branch 0 (30→31) taken 1 times.
✓ Branch 2 (33→34) taken 1 times.
✓ Branch 4 (36→37) taken 1 times.
✓ Branch 6 (37→38) taken 1 times.
✓ Branch 8 (38→39) taken 1 times.
|
6 | data_stream_assert(data_load(fileName, value)); |
| 39 |
5/5✓ Branch 0 (47→48) taken 1 times.
✓ Branch 2 (50→51) taken 1 times.
✓ Branch 4 (53→54) taken 1 times.
✓ Branch 6 (54→55) taken 1 times.
✓ Branch 8 (55→56) taken 1 times.
|
6 | data_stream_assert(checkValue(testName, value, referenceValue)); |
| 40 |
5/5✓ Branch 0 (64→65) taken 1 times.
✓ Branch 2 (67→68) taken 1 times.
✓ Branch 4 (70→71) taken 1 times.
✓ Branch 6 (71→72) taken 1 times.
✓ Branch 8 (72→73) taken 1 times.
|
6 | data_stream_assert(!data_save(unexistingFileName, referenceValue)); |
| 41 |
5/5✓ Branch 0 (81→82) taken 1 times.
✓ Branch 2 (84→85) taken 1 times.
✓ Branch 4 (87→88) taken 1 times.
✓ Branch 6 (88→89) taken 1 times.
✓ Branch 8 (89→90) taken 1 times.
|
5 | 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 0 (4→5) taken 1 times.
✓ Branch 2 (5→6) taken 1 times.
|
2 | testSimpleValue<long unsigned int>("long unsigned int"); |
| 47 |
2/2✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
|
2 | testSimpleValue<unsigned int>("unsigned int"); |
| 48 |
2/2✓ Branch 0 (16→17) taken 1 times.
✓ Branch 2 (17→18) taken 1 times.
|
2 | testSimpleValue<unsigned short>("unsigned short"); |
| 49 |
2/2✓ Branch 0 (22→23) taken 1 times.
✓ Branch 2 (23→24) taken 1 times.
|
2 | testSimpleValue<unsigned char>("unsigned char"); |
| 50 | |||
| 51 |
2/2✓ Branch 0 (28→29) taken 1 times.
✓ Branch 2 (29→30) taken 1 times.
|
2 | testSimpleValue<long int>("long int"); |
| 52 |
2/2✓ Branch 0 (34→35) taken 1 times.
✓ Branch 2 (35→36) taken 1 times.
|
2 | testSimpleValue<long>("long"); |
| 53 |
2/2✓ Branch 0 (40→41) taken 1 times.
✓ Branch 2 (41→42) taken 1 times.
|
2 | testSimpleValue<int>("int"); |
| 54 |
2/2✓ Branch 0 (46→47) taken 1 times.
✓ Branch 2 (47→48) taken 1 times.
|
2 | testSimpleValue<short>("short"); |
| 55 |
2/2✓ Branch 0 (52→53) taken 1 times.
✓ Branch 2 (53→54) taken 1 times.
|
2 | testSimpleValue<char>("char"); |
| 56 |
2/2✓ Branch 0 (58→59) taken 1 times.
✓ Branch 2 (59→60) taken 1 times.
|
2 | testSimpleValue<int8_t>("int8_t"); |
| 57 | |||
| 58 |
2/2✓ Branch 0 (64→65) taken 1 times.
✓ Branch 2 (65→66) taken 1 times.
|
2 | testSimpleValue<float>("float"); |
| 59 |
2/2✓ Branch 0 (70→71) taken 1 times.
✓ Branch 2 (71→72) taken 1 times.
|
2 | testSimpleValue<double>("double"); |
| 60 |
2/2✓ Branch 0 (76→77) taken 1 times.
✓ Branch 2 (77→78) 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 0 (4→5) taken 1 times.
|
2 | std::string str("One thing to say"); |
| 66 |
2/2✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (9→10) 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 |