From 35c93caf42cdccaefcf5e60d9d6ffd8a6bc9c8a0 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Mon, 23 Jan 2012 15:28:01 -0600 Subject: [PATCH] Still working on the tests --- include/serial/serial.h | 2 +- tests/serial_listener_tests.cc | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/serial/serial.h b/include/serial/serial.h index e924abc..3b4c20d 100644 --- a/include/serial/serial.h +++ b/include/serial/serial.h @@ -240,7 +240,7 @@ public: * \return A std::string containing the line. */ std::string - readline(size_t size = std::numeric_limits::max(), + readline(size_t size = std::numeric_limits::max(), std::string eol = "\n"); /*! Reads in multiple lines until the serail port times out. diff --git a/tests/serial_listener_tests.cc b/tests/serial_listener_tests.cc index ee84c9c..e6197ed 100644 --- a/tests/serial_listener_tests.cc +++ b/tests/serial_listener_tests.cc @@ -2,22 +2,22 @@ * with a loop back device attached. * * Alternatively you could use an Arduino: - - void setup() - { - Serial.begin(115200); - } - - void loop() - { - while (Serial.available() > 0) { - Serial.write(Serial.read()); - } - } - + * + * void setup() + * { + * Serial.begin(115200); + * } + * + * void loop() + * { + * while (Serial.available() > 0) { + * Serial.write(Serial.read()); + * } + * } + * */ -#define SERIAL_PORT_NAME "/dev/tty.usbserial-A900cfJA" +#define SERIAL_PORT_NAME "/dev/tty.usbserial" #include "gtest/gtest.h" @@ -50,7 +50,7 @@ protected: port1 = new Serial(SERIAL_PORT_NAME, 115200, 250); // Need to wait a bit for the Arduino to come up - my_sleep(1000); + // my_sleep(1000); listener.setDefaultHandler(default_handler); listener.startListening((*port1)); @@ -71,10 +71,10 @@ TEST_F(SerialListenerTests, handlesPartialMessage) { global_count = 0; std::string input_str = "?$1E\r$1E=Robo"; - port1->write(input_str); + ASSERT_EQ(input_str.length(), port1->write(input_str)); // give some time for the callback thread to finish - my_sleep(1000); + my_sleep(2000); ASSERT_EQ(1, global_count); }