Skip to content

Commit

Permalink
[YARP_OS] Add some unit tests for issue robotology#442 (for now disab…
Browse files Browse the repository at this point in the history
…led)
  • Loading branch information
drdanz committed Mar 13, 2015
1 parent 6ed9415 commit 3d4c0c1
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/libYARP_OS/harness/PortReaderBufferTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PortReaderBufferTestHelper : public BufferedPort<Bottle> {
class PortReaderBufferTest : public UnitTest {
public:
virtual String getName() { return "PortReaderBufferTest"; }


void checkAccept() {
report(0, "checking direct object accept...");
Expand All @@ -47,7 +47,7 @@ class PortReaderBufferTest : public UnitTest {
Bottle data2("there");

buffer.acceptObject(&data, &dummy);

Bottle *bot = buffer.read();
checkTrue(bot!=NULL,"Inserted message received");
if (bot!=NULL) {
Expand All @@ -61,7 +61,7 @@ class PortReaderBufferTest : public UnitTest {
if (bot!=NULL) {
checkEqual(bot->toString().c_str(),"there","value ok");
}

buffer.read(false);
}

Expand Down Expand Up @@ -143,6 +143,24 @@ class PortReaderBufferTest : public UnitTest {
}
checkEqual(in.count,5,"got message #3");
}

void checkCallbackNoOpen() {
report(0, "checking callback part without open...");
#if 0
{
report(1, "test 1");
PortReaderBufferTestHelper in;
in.useCallback();
}
{
report(1, "test 2");
PortReaderBufferTestHelper in;
in.useCallback();
in.close();
}
#endif
}

virtual void runTests() {
Network::setLocalMode(true);

Expand All @@ -151,6 +169,7 @@ class PortReaderBufferTest : public UnitTest {

checkAccept();
checkCallback();
checkCallbackNoOpen();
Network::setLocalMode(false);
}
};
Expand Down
77 changes: 77 additions & 0 deletions src/libYARP_OS/harness/PortTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,51 @@ class PortTest : public UnitTest {
in.disableCallback();
}

virtual void testReaderHandlerNoOpen() {
report(0,"check reader handler without open...");
#if 0
{
report(1, "test 1");
Port in;
DelegatedCallback callback;
PortReaderBuffer<Bottle> reader;
reader.setStrict();
reader.attach(in);
reader.useCallback(callback);
reader.disableCallback();
in.close();
}
{
report(1, "test 2");
Port in;
DelegatedCallback callback;
PortReaderBuffer<Bottle> reader;
reader.setStrict();
reader.attach(in);
reader.useCallback(callback);
reader.disableCallback();
}
{
report(1, "test 3");
Port in;
DelegatedCallback callback;
PortReaderBuffer<Bottle> reader;
reader.setStrict();
reader.attach(in);
reader.useCallback(callback);
in.close();
}
{
report(1, "test 4");
Port in;
DelegatedCallback callback;
PortReaderBuffer<Bottle> reader;
reader.setStrict();
reader.attach(in);
reader.useCallback(callback);
}
#endif
}

virtual void testStrictWriter() {
report(0,"check strict writer...");
Expand Down Expand Up @@ -1294,6 +1339,36 @@ class PortTest : public UnitTest {
checkEqual(pin.ct,1,"callback happened");
}

virtual void testBufferedPortCallbackNoOpen() {
report(0,"checking BufferedPort callback without open...");
#if 0
{
report(1, "test 1");
DataPort pin;
pin.useCallback();
pin.disableCallback();
}
{
report(1, "test 2");
DataPort pin;
pin.useCallback();
pin.disableCallback();
pin.close();
}
{
report(1, "test 3");
DataPort pin;
pin.useCallback();
}
{
report(1, "test 4");
DataPort pin;
pin.useCallback();
pin.close();
}
#endif
}

void testAdminReader() {
report(0,"checking user-level admin message reads");
Port pin;
Expand Down Expand Up @@ -1354,6 +1429,7 @@ class PortTest : public UnitTest {
testDelegatedReadReply();
testReaderHandler();
testReaderHandler2();
testReaderHandlerNoOpen();
testStrictWriter();
testRecentReader();

Expand Down Expand Up @@ -1387,6 +1463,7 @@ class PortTest : public UnitTest {
testInterruptWithBadReader();

testBufferedPortCallback();
testBufferedPortCallbackNoOpen();

testAdminReader();

Expand Down

0 comments on commit 3d4c0c1

Please sign in to comment.