anchor.diff:          end
       ).
   
  -deduplicate_qos1([Session,Packet]) ->
  +qos1_flow_double_append([Session,Packet]) ->
       {ok, NewSession, _PacketId} = mqtt_session:append_msg(Session,Packet,?QOS_1),
       ?_assertMatch(duplicate, mqtt_session:append_msg(NewSession,Packet,?QOS_1)).
   
  -deduplicate_qos2([Session,Packet]) ->
  +qo2_flow_double_append([Session,Packet]) ->
       {ok, NewSession, _PacketId} = mqtt_session:append_msg(Session,Packet,?QOS_2),
       ?_assertMatch(duplicate, mqtt_session:append_msg(NewSession,Packet,?QOS_2)).
   
  
positive.code:         ?assertMatch(duplicate,mqtt_session:message_pub_comp(S3 ,PacketId))
      end).
  
  
  
  
negative.code: 
  %% {_Topic,_Content,_Retain,_Dup,Ref},
  
  setup_msg() ->
      Session = mqtt_session:new(),
      Ref = make_ref(),
      Packet = {<<"Topic1">>, <<"Content">>, Ref},
      [Session,Packet].
  
  setup_sub() ->
      Session = mqtt_session:new(),
      NewSubs = [{<<"Filter1",1>>,<<"Filter2",2>>}],
      [Session,NewSubs].
  
  msg_test_() ->
      {
          foreach, fun setup_msg/0, fun(_) -> ok end,
          [
              fun msg_in_flight_qos0/1,
              fun msg_in_flight_qos1/1,
              fun msg_in_flight_qos1_flow_complete/1,
              fun msg_in_flight_qos2_phase1/1,
              fun msg_in_flight_qos2_phase2/1,
              fun msg_in_flight_qos2_flow_complete/1
          ]
      }.
  
  msg_in_flight_test_() ->
      {
          foreach, fun setup_msg/0, fun(_) -> ok end,
          [
              fun msg_in_flight_qos0/1,
              fun msg_in_flight_qos1/1,
              fun msg_in_flight_qos1_flow_complete/1,
              fun msg_in_flight_qos2_phase1/1,
              fun msg_in_flight_qos2_phase2/1,
              fun msg_in_flight_qos2_flow_complete/1
          ]
      }.
  
  sub_test_() ->
      {
          foreach, fun setup_sub/0, fun(_) -> ok end,
          [
              fun subscribe_new/1,
              fun subscribe_existing/1,
              fun unsubscribe_existing/1,
              fun unsubscribe_non_existing/1
          ]
      }.
  
  