Directory: | ./ |
---|---|
File: | tests/task/test_flags.cpp |
Date: | 2024-11-13 12:35:17 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 39 | 41 | 95.1% |
Branches: | 107 | 214 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright 2010, | ||
3 | * François Bleibel, | ||
4 | * Olivier Stasse, | ||
5 | * | ||
6 | * CNRS/AIST | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | /* -------------------------------------------------------------------------- */ | ||
11 | /* --- INCLUDES ------------------------------------------------------------- */ | ||
12 | /* -------------------------------------------------------------------------- */ | ||
13 | #include <iostream> | ||
14 | #include <sot/core/flags.hh> | ||
15 | #include <sstream> | ||
16 | |||
17 | using namespace std; | ||
18 | using namespace dynamicgraph::sot; | ||
19 | |||
20 | 1 | int main(void) { | |
21 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | cout << "Entering test" << endl; |
22 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Flags f1(128 * 112 + 84); |
23 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Flags f2(198); |
24 | cout << "f1 " | ||
25 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | << "\t" << f1 << endl; |
26 | cout << "f2 " | ||
27 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | << "\t" << f2 << endl; |
28 | |||
29 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
30 | cout << "1|2 " | ||
31 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | << "\t" << (f1 | f2) << endl; |
32 | cout << "1&2 " | ||
33 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | << "\t" << (f1 & f2) << endl; |
34 | cout << "TRUE " | ||
35 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | << "\t" << (Flags(true)) << endl; |
36 | cout << "1&TRUE" | ||
37 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
1 | << "\t" << (f1 & Flags(true)) << endl; |
38 | cout << "1&!2 " | ||
39 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
1 | << "\t" << ((!f2) & f1) << endl; |
40 | cout << "1XOR2 " | ||
41 |
9/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
|
1 | << "\t" << (((!f2) & f1) | ((!f1) & f2)) << endl; |
42 | |||
43 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
44 | cout << "f1 " | ||
45 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | << "\t" << f1 << endl; |
46 | cout << "!2 " | ||
47 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | << "\t" << !f2 << endl; |
48 | cout << "1|!2 " | ||
49 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
1 | << "\t" << (f1 | (!f2)) << endl; |
50 | |||
51 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
52 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | if (f1 & f2) |
53 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << "TRUE"; |
54 | else | ||
55 | ✗ | cout << "FALSE"; | |
56 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
57 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
|
1 | if (f1 & Flags()) |
58 | ✗ | cout << "TRUE"; | |
59 | else | ||
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << "FALSE"; |
61 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
62 | |||
63 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
64 | cout << "f1>>3 " | ||
65 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
1 | << "\t" << Flags(f1 >> 3) << endl; |
66 | cout << "f1>>5 " | ||
67 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
1 | << "\t" << Flags(f1 >> 5) << endl; |
68 | |||
69 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << "f1 byte per byte:"; |
70 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
|
17 | for (int i = 0; i < 16; ++i) { |
71 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
16 | if (!(i % 8)) cout << " "; |
72 |
2/4✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
|
16 | cout << f1(i); |
73 | } | ||
74 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
75 | |||
76 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | cout << endl; |
77 | |||
78 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
2 | istringstream iss("00101"); |
79 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Flags flread; |
80 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | iss >> flread; |
81 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | cout << flread << endl << endl; |
82 | |||
83 | 1 | return 0; | |
84 | 1 | } | |
85 |