TestStdBinDecoderErrorRecovery.h
Go to the documentation of this file.
1 #ifndef TEST_STD_BIN_DECODER_ERROR_RECOVERY_FEATURE_H
2 #define TEST_STD_BIN_DECODER_ERROR_RECOVERY_FEATURE_H
3 
4 #include <gtest/gtest.h>
6 
7 // add data for error recovery
8 #include "../datasets/errors/BadCheckSum.h"
9 #include "../datasets/errors/BadNavProtocolVersion.h"
10 #include "../datasets/errors/BadAnswerProtocolVersion.h"
11 
12 #include "../datasets/MinimalV2NavFrame.h"
13 #include "../datasets/MinimalV3AnsFrame.h"
14 
21  ASSERT_NO_THROW(parseNextFrame()) << "Error recovery don't work.";
22  ASSERT_EQ(this->internalBuffer.size(),0L);
23  }
24 
30  ASSERT_NO_THROW(parseNextFrame()) << "Error recovery don't work.";
31  ASSERT_EQ(this->internalBuffer.size(),0L);
32  }
33 public:
39  template<typename T> void addNewDataFrame(const T & frame){
40  this->addNewData(frame.data(),frame.size());
41  }
42 
46  void testIsErrorIsThrown(ssize_t cleaned_buffer_size){
47  ASSERT_THROW(parseNextFrame(),std::runtime_error) << "Exception must be thrown in miss formatted data frame.";
48  EXPECT_EQ(this->internalBuffer.size(),cleaned_buffer_size) << "Buffer must be cleaned.";
49  }
50 
59  }
60 
61 };
62 #endif //TEST_STD_BIN_DECODER_ERROR_RECOVERY_FEATURE_H
TestStdBinDecoderErrorRecovery::testNavFrameErrorRecovery
void testNavFrameErrorRecovery()
used to assert if error recovery was successfully applied
Definition: TestStdBinDecoderErrorRecovery.h:19
TestStdBinDecoderErrorRecovery::testAnswerFrameErrorRecovery
void testAnswerFrameErrorRecovery()
used to assert if error recovery was successfully applied
Definition: TestStdBinDecoderErrorRecovery.h:28
TestStdBinDecoderErrorRecovery::testIsErrorIsThrown
void testIsErrorIsThrown(ssize_t cleaned_buffer_size)
used to assert if is error is thrown
Definition: TestStdBinDecoderErrorRecovery.h:46
TestStdBinDecoderErrorRecovery
Definition: TestStdBinDecoderErrorRecovery.h:15
ixblue_stdbin_decoder::StdBinDecoder::addNewData
void addNewData(const uint8_t *data, std::size_t length)
Add new binary data to the parser internal buffer The new data can only be a part of a frame,...
Definition: stdbin_decoder.cpp:158
stdbin_decoder.h
ixblue_stdbin_decoder::StdBinDecoder::parseNextFrame
bool parseNextFrame()
Try to parse a frame from the parser internal buffer. Some binary data must have been added with the ...
Definition: stdbin_decoder.cpp:163
MINIMAL_V3_ANS_FRAME
constexpr std::array< uint8_t, 0x0d > MINIMAL_V3_ANS_FRAME
Definition: MinimalV3AnsFrame.h:5
MINIMAL_V2_NAV_FRAME
constexpr std::array< uint8_t, 0x25 > MINIMAL_V2_NAV_FRAME
Definition: MinimalV2NavFrame.h:5
TestStdBinDecoderErrorRecovery::addNewDataFrame
void addNewDataFrame(const T &frame)
Add data using dataset values.
Definition: TestStdBinDecoderErrorRecovery.h:39
ixblue_stdbin_decoder::StdBinDecoder
Parser of a STDBIN IXblue message. This is the entry point of the library. Usage of this class is as ...
Definition: stdbin_decoder.h:33
TestStdBinDecoderErrorRecovery::testFramesErrorRecovery
void testFramesErrorRecovery()
use multiple frame to test error recovery. Add Nav data frame and parse it. Add Answer data frame and...
Definition: TestStdBinDecoderErrorRecovery.h:56
ixblue_stdbin_decoder::StdBinDecoder::internalBuffer
boost::circular_buffer< uint8_t > internalBuffer
Definition: stdbin_decoder.h:119


ixblue_stdbin_decoder
Author(s): Adrien BARRAL , Laure LEBROTON
autogenerated on Wed Apr 6 2022 02:55:48