GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tests/task/test_flags.cpp Lines: 38 40 95.0 %
Date: 2023-03-13 12:09:37 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

1
  cout << "Entering test" << endl;
22
2
  Flags f1(128 * 112 + 84);
23
2
  Flags f2(198);
24
  cout << "f1    "
25


1
       << "\t" << f1 << endl;
26
  cout << "f2    "
27


1
       << "\t" << f2 << endl;
28
29
1
  cout << endl;
30
  cout << "1|2   "
31


1
       << "\t" << (f1 | f2) << endl;
32
  cout << "1&2   "
33


1
       << "\t" << (f1 & f2) << endl;
34
  cout << "TRUE  "
35


1
       << "\t" << (Flags(true)) << endl;
36
  cout << "1&TRUE"
37



1
       << "\t" << (f1 & Flags(true)) << endl;
38
  cout << "1&!2 "
39



1
       << "\t" << ((!f2) & f1) << endl;
40
  cout << "1XOR2 "
41




1
       << "\t" << (((!f2) & f1) | ((!f1) & f2)) << endl;
42
43
1
  cout << endl;
44
  cout << "f1    "
45


1
       << "\t" << f1 << endl;
46
  cout << "!2    "
47


1
       << "\t" << !f2 << endl;
48
  cout << "1|!2 "
49



1
       << "\t" << (f1 | (!f2)) << endl;
50
51
1
  cout << endl;
52

1
  if (f1 & f2)
53
1
    cout << "TRUE";
54
  else
55
    cout << "FALSE";
56
1
  cout << endl;
57


1
  if (f1 & Flags())
58
    cout << "TRUE";
59
  else
60
1
    cout << "FALSE";
61
1
  cout << endl;
62
63
1
  cout << endl;
64
  cout << "f1>>3 "
65



1
       << "\t" << Flags(f1 >> 3) << endl;
66
  cout << "f1>>5 "
67



1
       << "\t" << Flags(f1 >> 5) << endl;
68
69
1
  cout << "f1 byte per byte:";
70
17
  for (int i = 0; i < 16; ++i) {
71

16
    if (!(i % 8)) cout << " ";
72

16
    cout << f1(i);
73
  }
74
1
  cout << endl;
75
76
1
  cout << endl;
77
78

3
  istringstream iss("00101");
79
1
  Flags flread;
80
1
  iss >> flread;
81

1
  cout << flread << endl << endl;
82
83
1
  return 0;
84
}