TEST(TcpHealthCheckMatcher, match) {
  Protobuf::RepeatedPtrField<envoy::config::core::v3::HealthCheck::Payload> repeated_payload;
  repeated_payload.Add()->set_text("01");
  repeated_payload.Add()->set_text("02");

  TcpHealthCheckMatcher::MatchSegments segments =
      TcpHealthCheckMatcher::loadProtoBytes(repeated_payload);

  Buffer::OwnedImpl buffer;
  EXPECT_FALSE(TcpHealthCheckMatcher::match(segments, buffer));
  addUint8(buffer, 1);
  EXPECT_FALSE(TcpHealthCheckMatcher::match(segments, buffer));
  addUint8(buffer, 2);
  EXPECT_TRUE(TcpHealthCheckMatcher::match(segments, buffer));

  buffer.drain(2);
  addUint8(buffer, 1);
  addUint8(buffer, 3);
  addUint8(buffer, 2);
  EXPECT_TRUE(TcpHealthCheckMatcher::match(segments, buffer));

  buffer.drain(3);
  addUint8(buffer, 0);
  addUint8(buffer, 3);
  addUint8(buffer, 1);
  addUint8(buffer, 2);
  EXPECT_TRUE(TcpHealthCheckMatcher::match(segments, buffer));
}
TEST(TcpHealthCheckMatcher, match) {
  Protobuf::RepeatedPtrField<envoy::config::core::v3::HealthCheck::Payload> repeated_payload;
  repeated_payload.Add()->set_text("01");
  repeated_payload.Add()->set_text("02");

  TcpHealthCheckMatcher::MatchSegments segments =
      TcpHealthCheckMatcher::loadProtoBytes(repeated_payload);

  Buffer::OwnedImpl buffer;
  EXPECT_FALSE(TcpHealthCheckMatcher::match(segments, buffer));
  addUint8(buffer, 1);
  EXPECT_FALSE(TcpHealthCheckMatcher::match(segments, buffer));
  addUint8(buffer, 2);
  EXPECT_TRUE(TcpHealthCheckMatcher::match(segments, buffer));

  buffer.drain(2);
  addUint8(buffer, 1);
  addUint8(buffer, 3);
  addUint8(buffer, 2);
  EXPECT_TRUE(TcpHealthCheckMatcher::match(segments, buffer));

  buffer.drain(3);
  addUint8(buffer, 0);
  addUint8(buffer, 3);
  addUint8(buffer, 1);
  addUint8(buffer, 2);
  EXPECT_TRUE(TcpHealthCheckMatcher::match(segments, buffer));
}