GCC Code Coverage Report


Directory: ./
File: tests/task/test_gain.cpp
Date: 2024-11-13 12:35:17
Exec Total Coverage
Lines: 17 17 100.0%
Branches: 22 44 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
14 #include <dynamic-graph/linear-algebra.h>
15 #include <dynamic-graph/signal.h>
16
17 #include <iostream>
18 #include <sot/core/gain-adaptive.hh>
19 using namespace std;
20 using namespace dynamicgraph::sot;
21 using namespace dynamicgraph;
22
23 class DummyClass {
24 public:
25 dynamicgraph::Vector err;
26
27 2 dynamicgraph::Vector &getError(dynamicgraph::Vector &res, int t) {
28 2 cout << "Dummy::getError [" << t << "] " << endl;
29 2 return res = err;
30 }
31 };
32
33 DummyClass dummy;
34
35 /* -------------------------------------------------------------------------- */
36 /* --- INCLUDES ------------------------------------------------------------- */
37 /* -------------------------------------------------------------------------- */
38
39 1 int main(void) {
40
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 dummy.err.resize(3);
41
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 dummy.err.fill(3);
42
43
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 GainAdaptive *gain = new GainAdaptive("gain", 4, 1, 5);
44
45
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
2 Signal<dynamicgraph::Vector, int> errSig("test");
46
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 errSig.setFunction(boost::bind(&DummyClass::getError, dummy, _1, _2));
47
48
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gain->errorSIN.plug(&errSig);
49
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 cout << "Appel of errSig and display of the result." << endl;
50
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 << errSig(0) << endl;
51
52 1 Signal<double, int> &gainSig = gain->gainSOUT;
53
54
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 cout << "Compute gain from Gain Signal and display." << endl;
55
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 << gainSig(0) << endl;
56
57 1 return 0;
58 1 }
59