anchor.diff:      ?assertEqual([{xmlstreamend, <<"root">>}], collect_events(CallbackPid)),
       close(Stream6).
   
  +map_stream_test() ->
  +	parser_loop(infinity, [use_maps], [
  +		{<<"<a xmlns='ns1'><b/>">>,
  +			[#{'__struct__' => 'Elixir.FastXML.StreamStart',
  +                        attrs => #{},
  +                        name => <<"a">>},
  +                      #{'__struct__' => 'Elixir.FastXML.El',
  +                        attrs => #{},
  +                        children => [],
  +                        name => <<"b">>}]},
  +			reset,
  +			{<<"<a><b c='1'/></a>">>,
  +				[#{'__struct__' => 'Elixir.FastXML.StreamStart',
  +                        attrs => #{},
  +                        name => <<"a">>},
  +                      #{'__struct__' => 'Elixir.FastXML.El',
  +                        attrs => #{<<"c">> => <<"1">>},
  +                        children => [],
  +                        name => <<"b">>},
  +                      #{'__struct__' => 'Elixir.FastXML.StreamEnd',
  +                        name => <<"a">>}]}
  +	]).
  +
  +streaming_mismatched_tags_error_test() ->
  +    parser_loop([{<<"<root">>, []},
  +		 {<<"><a>">>, [{xmlstreamstart, <<"root">>, []}]},
  +		 {<<"</a><b/><c attr=">>,
  +		  [{xmlstreamelement, #xmlel{name = <<"a">>}},
  +		   {xmlstreamelement, #xmlel{name = <<"b">>}}]},
  +		 {<<"'1'></c>">>,
  +		  [{xmlstreamelement, #xmlel{name = <<"c">>,
  +					     attrs = [{<<"attr">>, <<"1">>}]}}]},
  +		 {<<"<z><a><b><d/></q><a/>">>,
  +		  [{xmlstreamerror,{7,<<"mismatched tag">>}}]}
  +		]).
  +
  +streaming_invalid_attribute_error_test() ->
  +	parser_loop([{<<"<root">>, []},
  +		{<<"><a>">>, [{xmlstreamstart, <<"root">>, []}]},
  +		{<<"</a><b/><c attr=">>,
  +			[{xmlstreamelement, #xmlel{name = <<"a">>}},
  +				{xmlstreamelement, #xmlel{name = <<"b">>}}]},
  +		{<<"'1><d/></c>">>,
  +			[{xmlstreamerror,{4,<<"not well-formed (invalid token)">>}}]}
  +	]).
  +
  +xmpp_stream_test() ->
  +    parser_loop([{<<"<?xml version='1.0'?>",
  +		    "<stream:stream to='server.com' ",
  +		    "version='1.0' xmlns:stream='http://etherx.jabber.org/streams' ",
  +		    "xml:lang='pl' >">>,
  +		  [{xmlstreamstart,<<"stream:stream">>,
  +		    [{<<"xmlns:stream">>,<<"http://etherx.jabber.org/streams">>},
  +		     {<<"to">>,<<"server.com">>},
  +		     {<<"version">>,<<"1.0">>},
  +		     {<<"xml:lang">>, <<"pl">>}]}]},
  +		 {<<"<stream:features>",
  +		    "<register xmlns='http://jabber.org/features/iq-register'/>",
  +		    "</stream:features>">>,
  +		  [{xmlstreamelement,
  +		    {xmlel,<<"stream:features">>,
  +		     [],
  +		     [{xmlel,<<"register">>,
  +		       [{<<"xmlns">>,<<"http://jabber.org/features/iq-register">>}],
  +		       []}]}}]},
  +		 {<<"<a:a xmlns:a='b'><a:c/></a:a>">>,
  +		  [{xmlstreamelement,
  +		    {xmlel,<<"a">>,
  +		     [{<<"xmlns">>,<<"b">>}, {<<"xmlns:a">>,<<"b">>}],
  +		     [{xmlel,<<"c">>,[], []}]}}]},
  +		 reset,
  +		 {<<"<?xml version='1.0'?>",
  +		    "<stream:stream xmlns='jabber:client' to='server.com' ",
  +		    "version='1.0' xmlns:stream='http://etherx.jabber.org/streams' ",
  +		    "xml:lang='pl' >">>,
  +		  [{xmlstreamstart,<<"stream:stream">>,
  +		    [{<<"xmlns">>,<<"jabber:client">>},
  +		     {<<"xmlns:stream">>,<<"http://etherx.jabber.org/streams">>},
  +		     {<<"to">>,<<"server.com">>},
  +		     {<<"version">>,<<"1.0">>},
  +		     {<<"xml:lang">>, <<"pl">>}]}]},
  +			reset,
  +			{<<"<?xml version='1.0'?>",
  +				"<stream:stream to='server.com' ",
  +				"version='1.0' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' ",
  +				"xml:lang='pl' >">>,
  +				[{xmlstreamstart, <<"stream:stream">>,
  +					[{<<"xmlns:stream">>, <<"http://etherx.jabber.org/streams">>},
  +						{<<"xmlns">>, <<"jabber:client">>},
  +						{<<"to">>, <<"server.com">>},
  +						{<<"version">>, <<"1.0">>},
  +						{<<"xml:lang">>, <<"pl">>}]}]}
  +		]).
  +
   too_big_test() ->
       CallbackPid = spawn_link(fun() -> receiver([]) end),
       Stream0 = new(CallbackPid, 5),
  
positive.code:     Stream1 = fxml_stream:parse(Stream0, Data),
      close(Stream1),
      ?assertMatch([{xmlstreamerror, _}], collect_events(CallbackPid)).
  
  element_to_binary_test() ->
      ?assertEqual(
  
negative.code: 	Events ->
  	    Events
      end.
  
  close_collector(Pid) ->
      Pid ! {close, self()},
      receive
  	closed ->
  	    closed
      end.
  
  parser_loop(TestData) ->
  		parser_loop(infinity, [], TestData).
  
  parser_loop(MaxSize, Options, TestData) ->
      CollectorPid = spawn_link(fun() -> receiver([]) end),
      parser_loop_int(TestData, fxml_stream:new(CollectorPid, MaxSize, Options), CollectorPid).
  
  parser_loop_int([reset | Tail], Handle, CollectorPid) ->
      parser_loop_int(Tail, fxml_stream:reset(Handle), CollectorPid);
  parser_loop_int([{Input, Output} | Tail], Handle, CollectorPid) ->
      NHandle = fxml_stream:parse(Handle, Input),
      ?assertEqual(Output, collect_events(CollectorPid)),
      parser_loop_int(Tail, NHandle, CollectorPid);
  parser_loop_int([], Handle, CollectorPid) ->
      close(Handle),
      close_collector(CollectorPid).
  
  stream_test() ->
      CallbackPid = spawn_link(fun() -> receiver([]) end),
  