diff options
author | Sverker Eriksson <[email protected]> | 2017-08-30 20:55:08 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-08-30 20:55:08 +0200 |
commit | 7c67bbddb53c364086f66260701bc54a61c9659c (patch) | |
tree | 92ab0d4b91d5e2f6e7a3f9d61ea25089e8a71fe0 /lib/xmerl/test/xmerl_sax_SUITE.erl | |
parent | 97dc5e7f396129222419811c173edc7fa767b0f8 (diff) | |
parent | 3b7a6ffddc819bf305353a593904cea9e932e7dc (diff) | |
download | otp-7c67bbddb53c364086f66260701bc54a61c9659c.tar.gz otp-7c67bbddb53c364086f66260701bc54a61c9659c.tar.bz2 otp-7c67bbddb53c364086f66260701bc54a61c9659c.zip |
Merge tag 'OTP-19.0' into sverker/19/binary_to_atom-utf8-crash/ERL-474/OTP-14590
Diffstat (limited to 'lib/xmerl/test/xmerl_sax_SUITE.erl')
-rw-r--r-- | lib/xmerl/test/xmerl_sax_SUITE.erl | 117 |
1 files changed, 54 insertions, 63 deletions
diff --git a/lib/xmerl/test/xmerl_sax_SUITE.erl b/lib/xmerl/test/xmerl_sax_SUITE.erl index 563bbaaa06..f5c0a783c4 100644 --- a/lib/xmerl/test/xmerl_sax_SUITE.erl +++ b/lib/xmerl/test/xmerl_sax_SUITE.erl @@ -2,18 +2,19 @@ %%---------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010. All Rights Reserved. +%% Copyright Ericsson AB 2010-2016. All Rights Reserved. %% -%% The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. %% %% %CopyrightEnd% %%---------------------------------------------------------------------- @@ -26,7 +27,7 @@ %%---------------------------------------------------------------------- %% Include files %%---------------------------------------------------------------------- --include_lib("test_server/include/test_server.hrl"). +-include_lib("common_test/include/ct.hrl"). -include_lib("kernel/include/file.hrl"). %%====================================================================== @@ -37,25 +38,11 @@ %% Initializations %%---------------------------------------------------------------------- -init_per_suite(doc) -> - ["Starts the test suite"]; -init_per_suite(Config) -> - Config. - -end_per_suite(doc) -> - ["Stops the test suite"]; -end_per_suite(Config) -> - Config. - +all() -> + [{group, bugs}]. - -%% initialization before each testcase -init_per_testcase(_TestCase,Config) -> - Config. - -%% clean up after each testcase -end_per_testcase(_Func,_Config) -> - ok. +groups() -> + [{bugs, [], [ticket_8213, ticket_8214, ticket_11551]}]. %%---------------------------------------------------------------------- %% Tests @@ -65,46 +52,50 @@ end_per_testcase(_Func,_Config) -> %% Test Case %% ID: ticket_8213 %% Description: Checks that end of document is checked properly when continuation fun is missing. -ticket_8213(suite) -> []; ticket_8213(_Config) -> - ?line {ok,ok,[]} = xmerl_sax_parser:stream("<elem/>", [{event_fun, fun (_E,_,_) -> ok end}]). + {ok,ok,[]} = xmerl_sax_parser:stream("<elem/>", [{event_fun, fun (_E,_,_) -> ok end}]), + ok. %%---------------------------------------------------------------------- %% Test Case %% ID: ticket_8214 %% Description: Checks that attributes with default namespace don't get [] in NS field. -ticket_8214(suite) -> []; ticket_8214(_Config) -> - ?line {ok,ok,[]} = - xmerl_sax_parser:stream("<elem attr='123' x:attr='234' xmlns='http://lshift.net/d' " - "xmlns:x='http://lshift.net/x' />", - [{event_fun, fun ({startElement,"http://lshift.net/d","elem", - {[],"elem"}, - [{[],[],"attr","123"},{"http://lshift.net/x","x","attr","234"}]}, - _, _) ->ok; - ({startElement, _, "elem",_,_}, _,_) -> - throw({test, "Error in startElement tuple"}); - (_E,_,_) -> ok - end}]). - -%%---------------------------------------------------------------------- -%% Bug test cases -%% + Event = fun ({startElement,"http://lshift.net/d","elem", + {[],"elem"}, + [{[],[],"attr","123"},{"http://lshift.net/x","x","attr","234"}]}, + _, _) ->ok; + ({startElement, _, "elem",_,_}, _,_) -> + throw({test, "Error in startElement tuple"}); + (_E,_,_) -> ok + end, + + {ok,ok,[]} = xmerl_sax_parser:stream("<elem attr='123' x:attr='234' xmlns='http://lshift.net/d' " + "xmlns:x='http://lshift.net/x' />", + [{event_fun, Event}]), + ok. %%---------------------------------------------------------------------- -%% Test Suite -%% -all() -> - [{group, bugs}]. - -groups() -> - [{bugs, [], [ticket_8213, ticket_8214]}]. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - +%% Test Case +%% ID: ticket_8214 +%% Description: Checks that attributes with default namespace don't get [] in NS field. +ticket_11551(_Config) -> + Stream1 = <<"<?xml version=\"1.0\" encoding=\"utf-8\" ?> +<a>hej</a> +<?xml version=\"1.0\" encoding=\"utf-8\" ?> +<a>hej</a>">>, + {ok, undefined, <<"<?xml", _/binary>>} = xmerl_sax_parser:stream(Stream1, []), + Stream2= <<"<?xml version=\"1.0\" encoding=\"utf-8\" ?> +<a>hej</a> + + +<?xml version=\"1.0\" encoding=\"utf-8\" ?> +<a>hej</a>">>, + {ok, undefined, <<"<?xml", _/binary>>} = xmerl_sax_parser:stream(Stream2, []), + Stream3= <<"<a>hej</a> + +<?xml version=\"1.0\" encoding=\"utf-8\" ?> +<a>hej</a>">>, + {ok, undefined, <<"<?xml", _/binary>>} = xmerl_sax_parser:stream(Stream3, []), + ok. |