@@ -24,6 +24,8 @@ public:
2424 void test2();
2525 void test3();
2626 void test4();
27+ void test5();
28+ void test6();
2729
2830private:
2931
@@ -200,3 +202,43 @@ void SyncSuffixLayerTestSuite::test4()
200202 TS_ASSERT_EQUALS(std::get<0>(msg11.fields()).value(), "he@@==llo");
201203}
202204
205+ void SyncSuffixLayerTestSuite::test5()
206+ {
207+ // Double esc field should be ignored
208+ static const char Buf[] = {
209+ MessageType11, 'h', 'e', 'l', 'l', 'o', '@', '@', '@', '@', '=', '=', static_cast<char>(0x3f)
210+ };
211+
212+ static const std::size_t BufSize = std::extent<decltype(Buf)>::value;
213+
214+ SeekFieldWithEscFrame frame;
215+ SeekFieldWithEscFrame::MsgPtr msg;
216+ auto readIter = comms::readIteratorFor(msg, Buf);
217+ auto es = frame.read(msg, readIter, BufSize);
218+ TS_ASSERT_EQUALS(es, comms::ErrorStatus::Success);
219+ TS_ASSERT(msg);
220+ TS_ASSERT_EQUALS(msg->getId(), MessageType11);
221+ auto& msg11 = dynamic_cast<BeMsg11&>(*msg);
222+ TS_ASSERT_EQUALS(std::get<0>(msg11.fields()).value(), "hello@@@@");
223+ }
224+
225+ void SyncSuffixLayerTestSuite::test6()
226+ {
227+ // Triple escape should still count as escape
228+ static const char Buf[] = {
229+ MessageType11, 'h', 'e', '@', '@', '@', '@', '@', '@', '=', '=', 'l', 'l', 'o', '=', '=', static_cast<char>(0x3f)
230+ };
231+
232+ static const std::size_t BufSize = std::extent<decltype(Buf)>::value;
233+
234+ SeekFieldWithEscFrame frame;
235+ SeekFieldWithEscFrame::MsgPtr msg;
236+ auto readIter = comms::readIteratorFor(msg, Buf);
237+ auto es = frame.read(msg, readIter, BufSize);
238+ TS_ASSERT_EQUALS(es, comms::ErrorStatus::Success);
239+ TS_ASSERT(msg);
240+ TS_ASSERT_EQUALS(msg->getId(), MessageType11);
241+ auto& msg11 = dynamic_cast<BeMsg11&>(*msg);
242+ TS_ASSERT_EQUALS(std::get<0>(msg11.fields()).value(), "he@@@@@@==llo");
243+ }
244+
0 commit comments