diff options
author | Daniil Fedotov <fedotov.danil@gmail.com> | 2017-06-16 12:28:07 +0100 |
---|---|---|
committer | Daniil Fedotov <fedotov.danil@gmail.com> | 2017-06-16 12:28:07 +0100 |
commit | a5aac7736361e8841b8b6938f372c3876c51518f (patch) | |
tree | 5c1395f8f4c933d235c53eeda4a90f26f7ab7604 /test/term_to_binary_compat_prop_SUITE.erl | |
parent | 66b831d3ab635d111841fb6b07cc284974e028e4 (diff) | |
download | rabbitmq-server-git-a5aac7736361e8841b8b6938f372c3876c51518f.tar.gz |
Make term_to_binary_compat generate binaries using minor_version 1.
term_to_binary now has `minor_version:2` to always generate utf-8 atoms,
while default is `1`, so binaries generated in OTP-20 should be
the same as in OTP-19 for non-unicode atoms.
Diffstat (limited to 'test/term_to_binary_compat_prop_SUITE.erl')
-rw-r--r-- | test/term_to_binary_compat_prop_SUITE.erl | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/test/term_to_binary_compat_prop_SUITE.erl b/test/term_to_binary_compat_prop_SUITE.erl index d09b23c9ea..6c8a92a29f 100644 --- a/test/term_to_binary_compat_prop_SUITE.erl +++ b/test/term_to_binary_compat_prop_SUITE.erl @@ -24,13 +24,11 @@ -include_lib("proper/include/proper.hrl"). all() -> - %% The test should run on OTP < 20 (erts < 9) - case erts_gt_8() of - true -> - []; - false -> - [queue_name_to_binary] - end. + [ + pre_3_6_11_works, + term_to_binary_latin_atom, + queue_name_to_binary + ]. erts_gt_8() -> Vsn = erlang:system_info(version), @@ -47,16 +45,51 @@ end_per_suite(Config) -> init_per_testcase(Testcase, Config) -> rabbit_ct_helpers:testcase_started(Config, Testcase). +%% If this test fails - the erlang version is not supported in +%% RabbitMQ-3.6.10 and earlier. +pre_3_6_11_works(Config) -> + Fun = fun () -> prop_pre_3_6_11_works(Config) end, + rabbit_ct_proper_helpers:run_proper(Fun, [], 50000). + +prop_pre_3_6_11_works(_Config) -> + ?FORALL(Term, any(), + begin + Current = term_to_binary(Term), + Compat = term_to_binary_compat:term_to_binary_1(Term), + Current =:= Compat + end). + +term_to_binary_latin_atom(Config) -> + Fun = fun () -> prop_term_to_binary_latin_atom(Config) end, + rabbit_ct_proper_helpers:run_proper(Fun, [], 10000). + +prop_term_to_binary_latin_atom(_Config) -> + ?FORALL(LatinString, list(integer(0, 255)), + begin + Length = length(LatinString), + Atom = list_to_atom(LatinString), + Binary = list_to_binary(LatinString), + <<131,100, Length:16, Binary/binary>> =:= term_to_binary_compat:term_to_binary_1(Atom) + end). + queue_name_to_binary(Config) -> Fun = fun () -> prop_queue_name_to_binary(Config) end, rabbit_ct_proper_helpers:run_proper(Fun, [], 10000). prop_queue_name_to_binary(_Config) -> - ?FORALL({Vhost, QName}, {binary(), binary()}, + ?FORALL({VHost, QName}, {binary(), binary()}, begin - Resource = rabbit_misc:r(Vhost, queue, QName), - Legacy = term_to_binary_compat:queue_name_to_binary(Resource), - Current = term_to_binary(Resource), - Current =:= Legacy - end).
\ No newline at end of file + VHostBSize = byte_size(VHost), + NameBSize = byte_size(QName), + Expected = + <<131, %% Binary format "version" + 104, 4, %% 4-element tuple + 100, 0, 8, "resource", %% `resource` atom + 109, VHostBSize:32, VHost/binary, %% Vhost binary + 100, 0, 5, "queue", %% `queue` atom + 109, NameBSize:32, QName/binary>>, %% Name binary + Resource = rabbit_misc:r(VHost, queue, QName), + Current = term_to_binary_compat:term_to_binary_1(Resource), + Current =:= Expected + end). |