tests/test_serial.cpp
//TODO: not sure how can I test flushOutput
not sure how can I test flushOutput
not sure how can I test flushOutput
TEST_F(SerialFixture, readWriteCorrectly)
{
  ASSERT_TRUE(sut0_->setBaudrate(115200));
  ASSERT_TRUE(sut0_->setTimeout(std::chrono::milliseconds(100)));
  ASSERT_TRUE(sut0_->setParity(ISerial::parity_t::parity_even));
  ASSERT_TRUE(sut0_->setStopbits(ISerial::stopbits_t::stopbits_two));
  ASSERT_TRUE(sut0_->setFlowcontrol(ISerial::flowcontrol_t::flowcontrol_software));
  ASSERT_TRUE(sut1_->setBaudrate(115200));
  ASSERT_TRUE(sut1_->setTimeout(std::chrono::milliseconds(100)));
  ASSERT_TRUE(sut1_->setParity(ISerial::parity_t::parity_even));
  ASSERT_TRUE(sut1_->setStopbits(ISerial::stopbits_t::stopbits_two));
  ASSERT_TRUE(sut1_->setFlowcontrol(ISerial::flowcontrol_t::flowcontrol_software));
  uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x05};
  size_t num_bytes = sizeof(data);
  uint8_t received_data[5] = {0, 0, 0, 0, 0};
  ASSERT_TRUE(sut0_->open());
  ASSERT_TRUE(sut1_->open());
  ASSERT_EQ(num_bytes, sut0_->write(data, num_bytes));
  ASSERT_EQ(num_bytes, sut1_->read(received_data, num_bytes));
  for (size_t i = 0; i < num_bytes; i++)
  {
    ASSERT_EQ(data[i], received_data[i]);
  }
}
TEST_F ( SerialFixture , readWriteCorrectly ) { ASSERT_TRUE ( sut0_ -> setBaudrate ( 115200 ) ) ; ASSERT_TRUE ( sut0_ -> setTimeout ( std :: chrono :: milliseconds ( 100 ) ) ) ; ASSERT_TRUE ( sut0_ -> setParity ( ISerial :: parity_t :: parity_even ) ) ; ASSERT_TRUE ( sut0_ -> setStopbits ( ISerial :: stopbits_t :: stopbits_two ) ) ; ASSERT_TRUE ( sut0_ -> setFlowcontrol ( ISerial :: flowcontrol_t :: flowcontrol_software ) ) ; ASSERT_TRUE ( sut1_ -> setBaudrate ( 115200 ) ) ; ASSERT_TRUE ( sut1_ -> setTimeout ( std :: chrono :: milliseconds ( 100 ) ) ) ; ASSERT_TRUE ( sut1_ -> setParity ( ISerial :: parity_t :: parity_even ) ) ; ASSERT_TRUE ( sut1_ -> setStopbits ( ISerial :: stopbits_t :: stopbits_two ) ) ; ASSERT_TRUE ( sut1_ -> setFlowcontrol ( ISerial :: flowcontrol_t :: flowcontrol_software ) ) ; uint8_t data [ ] = { 0x01 , 0x02 , 0x03 , 0x04 , 0x05 } ; size_t num_bytes = sizeof ( data ) ; uint8_t received_data [ 5 ] = { 0 , 0 , 0 , 0 , 0 } ; ASSERT_TRUE ( sut0_ -> open ( ) ) ; ASSERT_TRUE ( sut1_ -> open ( ) ) ; ASSERT_EQ ( num_bytes , sut0_ -> write ( data , num_bytes ) ) ; ASSERT_EQ ( num_bytes , sut1_ -> read ( received_data , num_bytes ) ) ; for ( size_t i = 0 ; i < num_bytes ; i ++ ) { ASSERT_EQ ( data [ i ] , received_data [ i ] ) ; } }
TODO: not sure how can I test flushOutput
TODO : not sure how can I test flushOutput