libNbiotCore/test/serial_test.cpp
// Tests ReadRaw timeout when trying to read a character from buffer but buffer is empty
Tests ReadRaw timeout when trying to read a character from buffer but buffer is empty
Tests ReadRaw timeout when trying to read a character from buffer but buffer is empty
TEST(SerialTest, ReadRawTimeoutRxEmpty) {
    RepeatedTimer tick_timer(1, tick);
    tick_timer.start();
    Serial s;
    pSerCom = new MockSerialCom();
    s.configSetWriteStatus(writeStatus);
    s.configSetReadStatus(readStatus);
    s.configSetReadByte(readByte);
    s.configSetPutChar(writeByte);
    EXPECT_CALL(*pSerCom, readStatus())
            .WillRepeatedly(Return(rx_empty));
    unsigned char buffer;
    size_t result = s.readRaw(&buffer, 10);
    EXPECT_EQ((int) Serial::ReadTimeout, s.getError());
    EXPECT_EQ(0, result);
    tick_timer.stop();
    delete (pSerCom);
}
TEST ( SerialTest , ReadRawTimeoutRxEmpty ) { RepeatedTimer tick_timer ( 1 , tick ) ; tick_timer . start ( ) ; Serial s ; pSerCom = new MockSerialCom ( ) ; s . configSetWriteStatus ( writeStatus ) ; s . configSetReadStatus ( readStatus ) ; s . configSetReadByte ( readByte ) ; s . configSetPutChar ( writeByte ) ; EXPECT_CALL ( * pSerCom , readStatus ( ) ) . WillRepeatedly ( Return ( rx_empty ) ) ; unsigned char buffer ; size_t result = s . readRaw ( & buffer , 10 ) ; EXPECT_EQ ( ( int ) Serial :: ReadTimeout , s . getError ( ) ) ; EXPECT_EQ ( 0 , result ) ; tick_timer . stop ( ) ; delete ( pSerCom ) ; }
Tests ReadRaw timeout when trying to read a character from buffer but buffer is empty
Tests ReadRaw timeout when trying to read a character from buffer but buffer is empty
//    EXPECT_CALL(*pSerCom, readByte()) //            .WillRepeatedly(Return('c'));