libNbiotCore/test/serial_test.cpp
// Tests that ReadRaw can read a character from buffer, when buffer has a character
Tests that ReadRaw can read a character from buffer, when buffer has a character
Tests that ReadRaw can read a character from buffer when buffer has a character
TEST(SerialTest, ReadRawByteWithRxAvailable) {
    Serial s;
    pSerCom = new MockSerialCom();
    s.configSetWriteStatus(writeStatus);
    s.configSetReadStatus(readStatus);
    s.configSetReadByte(readByte);
    s.configSetPutChar(writeByte);
    EXPECT_CALL(*pSerCom, readByte())
            .WillRepeatedly(Return('c'));
    EXPECT_CALL(*pSerCom, readStatus())
            .WillRepeatedly(Return(rx_avail));
    unsigned char buffer;
    size_t result = s.readRaw(&buffer, 10);
    EXPECT_EQ('c', buffer);
    EXPECT_EQ((int) Serial::NoError, s.getError());
    EXPECT_EQ(1, result);
    delete (pSerCom);
}
TEST ( SerialTest , ReadRawByteWithRxAvailable ) { Serial s ; pSerCom = new MockSerialCom ( ) ; s . configSetWriteStatus ( writeStatus ) ; s . configSetReadStatus ( readStatus ) ; s . configSetReadByte ( readByte ) ; s . configSetPutChar ( writeByte ) ; EXPECT_CALL ( * pSerCom , readByte ( ) ) . WillRepeatedly ( Return ( ' ' ) ) ; EXPECT_CALL ( * pSerCom , readStatus ( ) ) . WillRepeatedly ( Return ( rx_avail ) ) ; unsigned char buffer ; size_t result = s . readRaw ( & buffer , 10 ) ; EXPECT_EQ ( ' ' , buffer ) ; EXPECT_EQ ( ( int ) Serial :: NoError , s . getError ( ) ) ; EXPECT_EQ ( 1 , result ) ; delete ( pSerCom ) ; }
Tests that ReadRaw can read a character from buffer, when buffer has a character
Tests that ReadRaw can read a character from buffer when buffer has a character