anchor.diff:        {"parse_packet content length mismatch",
          generator,
          fun() ->
  -               BadLength = [{<<"1|11\na_label:1|m">>,
  -                             {11, <<"a_label:1|m">>}},
  -                             
  -                            {<<"1|12\nx:1|m">>,
  -                             {12, <<"x:1|m">>}},
  -                            
  -                            {<<"1|11\na_label:1|m">>,
  -                            {11, <<"a_label:1|m">>}}
  +               BadLength = [{<<"1|11\na_label:1|m\n">>,
  +                             {11, <<"a_label:1|m\n">>}},
  +
  +                            {<<"1|12\nx:1|m\n">>,
  +                             {12, <<"x:1|m\n">>}}
                              ],
                  [ ?_assertEqual({bad_length, {L, R}}, parse_packet(P))
                    || {P, {L, R}} <- BadLength ]
  
positive.code:             error_logger:error_report({bad_metric,
                                         {Body, Why, erlang:get_stacktrace()}}),
              throw({bad_metric_body, Body})
      
      end.
  
  -spec parse_metric(binary()) -> #shp_metric{}.
  
negative.code:      [
        {"parse_packet valid packet",
         fun() ->
  
             Packet = <<"1|42\ndeploys.OpscodeAccount.application:1000|h\n">>,
             ?assertEqual([#shp_metric{key = <<"deploys.OpscodeAccount.application">>,
                                       value = 1000,
                                       type = h,
                                       sample_rate = undefined}],
                          parse_packet(Packet))
         end
        },
  
        {"parse_packet packet no trailing LF",
         fun() ->
  
             Packet = <<"1|41\ndeploys.OpscodeAccount.application:1000|h">>,
             ?assertEqual([#shp_metric{key = <<"deploys.OpscodeAccount.application">>,
                                       value = 1000,
                                       type = h,
                                       sample_rate = undefined}],
                          parse_packet(Packet))
         end
        },
  
        {"parse_packet multiple metrics",
         fun() ->
             NumMetrics = 20,
             IO = lists:map(fun(I) ->
                                C = integer_to_list(I),
                                ["metric-", C, ":", C, "|h\n"]
                            end, lists:seq(1, NumMetrics)),
             Body = iolist_to_binary(IO),
             Size = integer_to_list(size(Body)),
             Packet = iolist_to_binary(["1|", Size, "\n", Body]),
             Metrics = parse_packet(Packet),
             Expect = lists:map(fun(I) ->
                                    C = integer_to_list(I),
                                    #shp_metric{key = iolist_to_binary(["metric-", C]),
                                                value = I,
                                                type = h,
                                                sample_rate = undefined}
                                end, lists:seq(1, NumMetrics)),
             ?assertEqual(Expect, Metrics)
         end
        },
  
  