1 |
|
|
|
2 |
|
|
/*************************************** |
3 |
|
|
Auteur : Pierre Aubert |
4 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
5 |
|
|
Licence : CeCILL-C |
6 |
|
|
****************************************/ |
7 |
|
|
|
8 |
|
|
#include <iostream> |
9 |
|
|
#include <vector> |
10 |
|
|
|
11 |
|
|
#include "print_string.h" |
12 |
|
|
#include "phoenix_vector_split.h" |
13 |
|
|
|
14 |
|
|
///Test the string filename function |
15 |
|
|
/** @return true on success, false otherwise |
16 |
|
|
*/ |
17 |
|
1 |
bool testVectorSplit(){ |
18 |
|
2 |
std::vector<int> vecInt; |
19 |
✓✓ |
11 |
for(size_t i(0lu); i < 10lu; ++i){ |
20 |
✓ |
10 |
vecInt.push_back((int)i); |
21 |
|
|
} |
22 |
|
|
|
23 |
|
1 |
std::vector<std::vector<int> > vecVecInt; |
24 |
|
|
|
25 |
✓ |
1 |
phoenix_vector_split(vecVecInt, vecInt, 2lu); |
26 |
✓✓ |
1 |
std::cout << "testVectorSplit : vecInt :" << std::endl; |
27 |
✓✓✓ |
1 |
phoenix_print(vecInt); |
28 |
✓✓ |
1 |
std::cout << "testVectorSplit : vecVecInt :" << std::endl; |
29 |
✓✓✓ |
1 |
phoenix_print(vecVecInt); |
30 |
|
|
|
31 |
|
1 |
bool b(true); |
32 |
✓✓ |
6 |
for(int i(0); i < 5; ++i){ |
33 |
|
5 |
b &= vecVecInt[0][i] == 2*i; |
34 |
|
5 |
b &= vecVecInt[1][i] == 2*i + 1; |
35 |
|
|
} |
36 |
|
|
|
37 |
✓✓✓ |
1 |
std::cout << "testVectorSplit : b = " << b << std::endl; |
38 |
|
2 |
return b; |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
///Test the string filename function |
42 |
|
|
/** @return true on success, false otherwise |
43 |
|
|
*/ |
44 |
|
1 |
bool testVectorSplit2(){ |
45 |
|
2 |
std::vector<int> vecInt; |
46 |
✓✓ |
3 |
for(size_t i(0lu); i < 2lu; ++i){ |
47 |
✓ |
2 |
vecInt.push_back((int)i); |
48 |
|
|
} |
49 |
|
|
|
50 |
|
1 |
std::vector<std::vector<int> > vecVecInt; |
51 |
|
|
|
52 |
✓ |
1 |
phoenix_vector_split(vecVecInt, vecInt, 6lu); |
53 |
✓✓ |
1 |
std::cout << "testVectorSplit2 : vecInt :" << std::endl; |
54 |
✓✓✓ |
1 |
phoenix_print(vecInt); |
55 |
✓✓ |
1 |
std::cout << "testVectorSplit2 : vecVecInt :" << std::endl; |
56 |
✓✓✓ |
1 |
phoenix_print(vecVecInt); |
57 |
|
|
|
58 |
|
1 |
bool b(true); |
59 |
✓✓ |
2 |
for(int i(0); i < 1; ++i){ |
60 |
|
1 |
b &= vecVecInt[0][i] == 2*i; |
61 |
|
1 |
b &= vecVecInt[1][i] == 2*i + 1; |
62 |
|
|
} |
63 |
|
|
|
64 |
✓✓✓ |
1 |
std::cout << "testVectorSplit2 : b = " << b << std::endl; |
65 |
|
2 |
return b; |
66 |
|
|
} |
67 |
|
|
|
68 |
|
1 |
int main(int argc, char** argv){ |
69 |
|
1 |
bool b(true); |
70 |
|
1 |
b &= testVectorSplit(); |
71 |
|
1 |
b &= testVectorSplit2(); |
72 |
|
1 |
std::cout << "final : b = " << b << std::endl; |
73 |
|
1 |
return b - 1; |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
|