diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2017-06-19 22:21:05 +0300 |
|---|---|---|
| committer | Michael Klishin <mklishin@pivotal.io> | 2017-06-19 22:21:05 +0300 |
| commit | 72415b1c9446db5ad38b7d70a45fec6942682ec0 (patch) | |
| tree | 2d5ffab41df6d0f98529885f4e67cfe73e2dc725 /test | |
| parent | bc5048b89ddda79fd12e68247bda58a5691f7f28 (diff) | |
| parent | d81736602e67eca0b83bcb72b8fce805b328a2e0 (diff) | |
| download | rabbitmq-server-git-72415b1c9446db5ad38b7d70a45fec6942682ec0.tar.gz | |
Merge branch 'stable'
Conflicts:
src/rabbit_vm.erl
src/term_to_binary_compat.erl
Diffstat (limited to 'test')
| -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). |
