Skip to content

Commit

Permalink
test: Add tcp client reconnect test.
Browse files Browse the repository at this point in the history
Issue #72.
  • Loading branch information
vooon committed Aug 4, 2014
1 parent 292276e commit 2e86463
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/test_mavconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,28 @@ TEST_F(TCP, send_message)
ASSERT_EQ(message_id, MAVLINK_MSG_ID_HEARTBEAT);
}

TEST_F(TCP, client_reconnect)
{
std::unique_ptr<MAVConnInterface> echo_server;
std::unique_ptr<MAVConnInterface> client1, client2;

// create echo server
echo_server.reset(new MAVConnTCPServer(42, 200, "0.0.0.0", 57600));
echo_server->message_received.connect(boost::bind(&MAVConnInterface::send_message, echo_server.get(), _1, _2, _3));

EXPECT_NO_THROW({
client1.reset(new MAVConnTCPClient(44, 200, "localhost", 57600));
});

EXPECT_NO_THROW({
client2.reset(new MAVConnTCPClient(45, 200, "localhost", 57600));
});

EXPECT_NO_THROW({
client1.reset(new MAVConnTCPClient(46, 200, "localhost", 57600));
});
}

TEST(SERIAL, open_error)
{
std::unique_ptr<MAVConnInterface> serial;
Expand Down

0 comments on commit 2e86463

Please sign in to comment.