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:                    {Line, Expect} <- Tests ]
         end
        }
        
       ]}.
               
  
  % TODO:
  % - put record def into header
  
negative.code:       {"parse_metric valid metric tests",
         generator,
         fun() ->
             Tests = [{<<"label:1|m">>,
                       #shp_metric{key = <<"label">>, value = 1, type = 'm'}},
  
                      {<<"label:123|h">>,
                       #shp_metric{key = <<"label">>, value = 123,
                                   type = 'h'}},
  
                      {<<"x:-123|g">>,
                       #shp_metric{key = <<"x">>, value = -123, type = 'g'}},
  
  
                      {<<"x:123|h">>,
                       #shp_metric{key = <<"x">>, value = 123, type = 'h'}},
  
                      % sample rate
                      {<<"x:123|h|@0.43">>,
                       #shp_metric{key = <<"x">>, value = 123, type = 'h',
                                   sample_rate = 0.43}}
                     ],
             [ ?_assertEqual(Expect, parse_metric(In)) || {In, Expect} <- Tests ]
         end
        },
  
        {"gzip compressed body",
         fun() ->
                 Body = <<"a_label:1|m\n">>,
                 GZBody = zlib:gzip(Body),
                 % we add one for the '\n'.  Not sure the \n should be
                 % included in the length.
                 BodySize = integer_to_list(size(GZBody)),
                 Packet = iolist_to_binary(["1|", BodySize, "\n",
                                            GZBody]),
                 ?assertEqual([#shp_metric{key = <<"a_label">>,
  