2424-include_lib (" proper/include/proper.hrl" ).
2525
2626all () ->
27- % % The test should run on OTP < 20 (erts < 9)
28- case erts_gt_8 () of
29- true ->
30- [];
31- false ->
32- [queue_name_to_binary ]
33- end .
27+ [
28+ pre_3_6_11_works ,
29+ term_to_binary_latin_atom ,
30+ queue_name_to_binary
31+ ].
3432
3533erts_gt_8 () ->
3634 Vsn = erlang :system_info (version ),
@@ -47,16 +45,51 @@ end_per_suite(Config) ->
4745init_per_testcase (Testcase , Config ) ->
4846 rabbit_ct_helpers :testcase_started (Config , Testcase ).
4947
48+ % % If this test fails - the erlang version is not supported in
49+ % % RabbitMQ-3.6.10 and earlier.
50+ pre_3_6_11_works (Config ) ->
51+ Fun = fun () -> prop_pre_3_6_11_works (Config ) end ,
52+ rabbit_ct_proper_helpers :run_proper (Fun , [], 50000 ).
53+
54+ prop_pre_3_6_11_works (_Config ) ->
55+ ? FORALL (Term , any (),
56+ begin
57+ Current = term_to_binary (Term ),
58+ Compat = term_to_binary_compat :term_to_binary_1 (Term ),
59+ Current =:= Compat
60+ end ).
61+
62+ term_to_binary_latin_atom (Config ) ->
63+ Fun = fun () -> prop_term_to_binary_latin_atom (Config ) end ,
64+ rabbit_ct_proper_helpers :run_proper (Fun , [], 10000 ).
65+
66+ prop_term_to_binary_latin_atom (_Config ) ->
67+ ? FORALL (LatinString , list (integer (0 , 255 )),
68+ begin
69+ Length = length (LatinString ),
70+ Atom = list_to_atom (LatinString ),
71+ Binary = list_to_binary (LatinString ),
72+ <<131 ,100 , Length :16 , Binary /binary >> =:= term_to_binary_compat :term_to_binary_1 (Atom )
73+ end ).
74+
5075queue_name_to_binary (Config ) ->
5176 Fun = fun () -> prop_queue_name_to_binary (Config ) end ,
5277 rabbit_ct_proper_helpers :run_proper (Fun , [], 10000 ).
5378
5479
5580prop_queue_name_to_binary (_Config ) ->
56- ? FORALL ({Vhost , QName }, {binary (), binary ()},
81+ ? FORALL ({VHost , QName }, {binary (), binary ()},
5782 begin
58- Resource = rabbit_misc :r (Vhost , queue , QName ),
59- Legacy = term_to_binary_compat :queue_name_to_binary (Resource ),
60- Current = term_to_binary (Resource ),
61- Current =:= Legacy
62- end ).
83+ VHostBSize = byte_size (VHost ),
84+ NameBSize = byte_size (QName ),
85+ Expected =
86+ <<131 , % % Binary format "version"
87+ 104 , 4 , % % 4-element tuple
88+ 100 , 0 , 8 , " resource" , % % `resource` atom
89+ 109 , VHostBSize :32 , VHost /binary , % % Vhost binary
90+ 100 , 0 , 5 , " queue" , % % `queue` atom
91+ 109 , NameBSize :32 , QName /binary >>, % % Name binary
92+ Resource = rabbit_misc :r (VHost , queue , QName ),
93+ Current = term_to_binary_compat :term_to_binary_1 (Resource ),
94+ Current =:= Expected
95+ end ).
0 commit comments