Directory: | ./ |
---|---|
File: | tmp_project/PhoenixDataStream/TESTS/TEST_DATA_FILE/main_vector_pair.cpp |
Date: | 2025-03-14 12:18:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 41 | 41 | 100.0% |
Branches: | 67 | 67 | 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 | ///Abstract check of values stored in a file | ||
10 | /** @param testName : name of the test | ||
11 | * @param nbValue : number of values to put in the reference vector | ||
12 | */ | ||
13 | template<typename T, typename U> | ||
14 | 288 | void testSimpleVectorPairValue(const std::string & testName, size_t nbValue){ | |
15 |
1/1✓ Branch 2 taken 144 times.
|
288 | std::string fileName("value_test_vector_pair.data"); |
16 | |||
17 | 288 | std::vector<std::pair<T, U> > vecRef; | |
18 |
3/3✓ Branch 2 taken 1440 times.
✓ Branch 4 taken 1440 times.
✓ Branch 5 taken 144 times.
|
3168 | for(size_t i(0lu); i < nbValue; ++i){vecRef.push_back(std::pair<T, U>(i,2lu*i));} |
19 |
5/5✓ Branch 2 taken 144 times.
✓ Branch 6 taken 144 times.
✓ Branch 10 taken 144 times.
✓ Branch 13 taken 144 times.
✓ Branch 16 taken 144 times.
|
288 | data_stream_assert(data_save(fileName, vecRef)); |
20 | 288 | std::vector<std::pair<T, U> > vecValue; | |
21 |
5/5✓ Branch 2 taken 144 times.
✓ Branch 6 taken 144 times.
✓ Branch 10 taken 144 times.
✓ Branch 13 taken 144 times.
✓ Branch 16 taken 144 times.
|
288 | data_stream_assert(data_load(fileName, vecValue)); |
22 |
5/5✓ Branch 2 taken 144 times.
✓ Branch 6 taken 144 times.
✓ Branch 10 taken 144 times.
✓ Branch 13 taken 144 times.
✓ Branch 16 taken 144 times.
|
288 | data_stream_assert(checkValue(testName, vecValue, vecRef)); |
23 | 288 | } | |
24 | |||
25 | ///Abstract check of values stored in a file | ||
26 | /** @param firstTypeName : name of the first type | ||
27 | * @param nbValue : number of values to put in the reference vector | ||
28 | */ | ||
29 | template<typename T> | ||
30 | 24 | void testSetVectorPairValue(const std::string & firstTypeName, size_t nbValue){ | |
31 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, long unsigned int>("std::vector<std::pair<"+firstTypeName+", long unsigned int> >", nbValue); |
32 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, unsigned int>("std::vector<std::pair<"+firstTypeName+", unsigned int> >", nbValue); |
33 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, unsigned short>("std::vector<std::pair<"+firstTypeName+", unsigned short> >", nbValue); |
34 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, unsigned char>("std::vector<std::pair<"+firstTypeName+", unsigned char> >", nbValue); |
35 | |||
36 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, long int>("std::vector<std::pair<"+firstTypeName+", long int> >", nbValue); |
37 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, int>("std::vector<std::pair<"+firstTypeName+", int> >", nbValue); |
38 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, short>("std::vector<std::pair<"+firstTypeName+", short> >", nbValue); |
39 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, char>("std::vector<std::pair<"+firstTypeName+", char> >", nbValue); |
40 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, int8_t>("std::vector<std::pair<"+firstTypeName+", int8_t> >", nbValue); |
41 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, float>("std::vector<std::pair<"+firstTypeName+", float> >", nbValue); |
42 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, double>("std::vector<std::pair<"+firstTypeName+", double> >", nbValue); |
43 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
24 | testSimpleVectorPairValue<T, bool>("std::vector<std::pair<"+firstTypeName+", bool> >", nbValue); |
44 | 24 | } | |
45 | |||
46 | ///Test if data size is Ok | ||
47 | 1 | void testVectorPairDataFile(){ | |
48 | 1 | size_t nbValue(10lu); | |
49 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<long unsigned int>("long unsigned int", nbValue); |
50 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<unsigned int>("unsigned int", nbValue); |
51 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<unsigned short>("unsigned short", nbValue); |
52 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<unsigned char>("unsigned char", nbValue); |
53 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<long int>("long int", nbValue); |
54 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<int>("int", nbValue); |
55 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<short>("short", nbValue); |
56 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<char>("char", nbValue); |
57 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<int8_t>("int8_t", nbValue); |
58 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<float>("float", nbValue); |
59 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<double>("double", nbValue); |
60 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testSetVectorPairValue<bool>("bool", nbValue); |
61 | 1 | } | |
62 | |||
63 | |||
64 | 1 | int main(int argc, char** argv){ | |
65 | 1 | testVectorPairDataFile(); | |
66 | 1 | return 0; | |
67 | } | ||
68 | |||
69 | |||
70 |