1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 11:44:53 +08:00
serial/tests/serial_tests.cc

65 lines
1.1 KiB
C++
Raw Normal View History

2012-01-23 14:28:14 -06:00
/* To run these tests you need to change the define below to the serial port
* 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());
}
}
*/
#define SERIAL_PORT_NAME "/dev/tty.usbserial"
#include "gtest/gtest.h"
#include <boost/bind.hpp>
// OMG this is so nasty...
#define private public
#define protected public
#include "serial/serial.h"
2012-01-23 14:28:14 -06:00
using namespace serial;
2012-01-23 14:28:14 -06:00
namespace {
2012-01-23 14:28:14 -06:00
class SerialTests : public ::testing::Test {
protected:
virtual void SetUp() {
port1 = new Serial(SERIAL_PORT_NAME, 115200, 250);
}
2012-01-23 14:28:14 -06:00
virtual void TearDown() {
port1->close();
delete port1;
}
2012-01-23 14:28:14 -06:00
Serial * port1;
};
// TEST_F(SerialTests, throwsOnInvalidPort) {
//
// }
} // namespace
int main(int argc, char **argv) {
try {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} catch (std::exception &e) {
std::cerr << "Unhandled Exception: " << e.what() << std::endl;
}
2012-01-23 14:28:14 -06:00
return 1;
}