anchor.diff:      catch 
           _:_ -> undefined
       end.
  +
  +%%
  +%% Tests
  +%%
  +
  +-ifdef(TEST).
  +
  +-include_lib("eunit/include/eunit.hrl").
  +
  +simple_partial_metadata_test() ->
  +    Url = "http://example.org",
  +    Headers = [{"content-type", "text/html"}],
  +    Data = <<"<html><head><title>Example</title><body></body></html>">>,
  +
  +    MD = partial_metadata(Url, Headers, Data),
  +    
  +    ?assertEqual(<<"http://example.org">>, MD#url_metadata.final_url),
  +    ?assertEqual(<<"text/html">>, MD#url_metadata.content_type),
  +    ?assertEqual([{title, <<"Example">>}], MD#url_metadata.metadata),
  +    
  +    ok.
  +    
  +simple_html_meta_test() ->
  +    Data = <<"<html><head><title>Example</title><body></body></html>">>,
  +    ?assertEqual([{title, <<"Example">>}], html_meta(Data)),
  +    ok.
  +    
  +partial_unbalanced_tags_html_meta_test() ->
  +    Data = <<"<head><meta name=\"description\" content=\"Example Content\"><title>Example</title>">>,
  +    ?assertEqual([{description, <<"Example Content">>},
  +        {title, <<"Example">>}], html_meta(Data)),
  +    ok.
  +
  +partial_no_surrounding_tags_html_meta_test() ->
  +    Data = <<"<meta name=\"description\" content=\"Example Content\"><title>Example</title>">>,
  +    ?assertEqual([{description, <<"Example Content">>},
  +        {title, <<"Example">>}], html_meta(Data)),
  +    ok.
  +    
  +partial_ampersant_in_html_meta_test() ->
  +    Data = <<"<meta name=\"description\" content=\"Example & Stuff\"><title>Foo &amp; Co</title>">>,
  +    ?assertEqual([{description, <<"Example & Stuff">>},
  +        {title, <<"Foo & Co">>}], html_meta(Data)),
  +    ok.
  +
  +-endif.
positive.code:         _ ->
              false
      end.
  
  html_meta(true, PartialData) ->
      Parsed = mochiweb_html:parse(PartialData),
      lists:reverse(html(Parsed, [], #ps{}));
  html_meta(false, _PartialData) ->
      [].
  
  html([], MD, _P) ->
      MD;
  
negative.code: 
  -export([
      fetch/1,
      html_meta/1,
      p/2,
      filename/2
      ]).
  