Directory: | ./ |
---|---|
File: | tests/tools/test_mailbox.cpp |
Date: | 2024-11-13 12:35:17 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 21 | 21 | 100.0% |
Branches: | 32 | 60 | 53.3% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright 2010, | ||
3 | * François Bleibel, | ||
4 | * Olivier Stasse, | ||
5 | * | ||
6 | * CNRS/AIST | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #include <iostream> | ||
11 | #include <sot/core/debug.hh> | ||
12 | |||
13 | #ifndef WIN32 | ||
14 | #include <unistd.h> | ||
15 | #endif | ||
16 | |||
17 | using namespace std; | ||
18 | |||
19 | #include <dynamic-graph/entity.h> | ||
20 | #include <dynamic-graph/factory.h> | ||
21 | |||
22 | #include <sot/core/feature-abstract.hh> | ||
23 | #include <sot/core/mailbox-vector.hh> | ||
24 | #include <sstream> | ||
25 | |||
26 | using namespace dynamicgraph; | ||
27 | using namespace dynamicgraph::sot; | ||
28 | |||
29 | #include <boost/thread.hpp> | ||
30 | |||
31 | sot::MailboxVector *mailbox = NULL; | ||
32 | |||
33 | 1 | void f(void) { | |
34 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Vector vect(25); |
35 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Vector vect2(25); |
36 |
2/2✓ Branch 0 taken 250 times.
✓ Branch 1 taken 1 times.
|
251 | for (int i = 0; i < 250; ++i) { |
37 |
3/6✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 250 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 250 times.
✗ Branch 8 not taken.
|
250 | std::cout << " iter " << i << std::endl; |
38 |
3/4✓ Branch 1 taken 6250 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6250 times.
✓ Branch 4 taken 250 times.
|
6500 | for (int j = 0; j < 25; ++j) vect(j) = j + i * 10; |
39 |
1/2✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
|
250 | mailbox->post(vect); |
40 |
2/4✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 250 times.
✗ Branch 5 not taken.
|
250 | Vector V = mailbox->getObject(vect2, 1); |
41 |
2/4✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 250 times.
✗ Branch 5 not taken.
|
250 | std::cout << vect2 << std::endl; |
42 |
4/8✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 250 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 250 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 250 times.
✗ Branch 11 not taken.
|
250 | std::cout << " getClassName " << mailbox->getClassName() << std::endl; |
43 |
3/6✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 250 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 250 times.
✗ Branch 9 not taken.
|
250 | std::cout << " getName " << mailbox->getName() << std::endl; |
44 |
4/8✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 250 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 250 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 250 times.
✗ Branch 11 not taken.
|
250 | std::cout << " hasBeenUpdated " << mailbox->hasBeenUpdated() << std::endl; |
45 |
1/2✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
|
250 | std::cout << std::endl; |
46 | 250 | } | |
47 | 1 | } | |
48 | |||
49 | 1 | int main(int, char **) { | |
50 |
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 | mailbox = new sot::MailboxVector("mail"); |
51 | |||
52 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | boost::thread th(f); |
53 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | th.join(); |
54 | |||
55 | 1 | return 0; | |
56 | 1 | } | |
57 |