summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2010-07-06 07:49:24 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2010-07-06 07:49:24 +0100
commitc0d2e13e5876a69ad8225614ee055923f6546ca6 (patch)
tree7fd2b9557c477de2a4ef477e34a1554613b5d28f
parentf4684e5de685ebd7344a48e5872c7ed74eb9d7ab (diff)
downloadrabbitmq-server-c0d2e13e5876a69ad8225614ee055923f6546ca6.tar.gz
make test_content_framing less dependent on codec internals
...and invert assertion, for clarity
-rw-r--r--src/rabbit_tests.erl38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 48f313f9..7fbbc1ea 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -355,42 +355,38 @@ test_field_values() ->
passed.
%% Test that content frames don't exceed frame-max
-test_content_framing(FrameMax, Fragments) ->
+test_content_framing(FrameMax, BodyBin) ->
[Header | Frames] =
rabbit_binary_generator:build_simple_content_frames(
1,
- #content{class_id = 60, properties = none, properties_bin = <<>>,
- payload_fragments_rev = Fragments},
+ rabbit_binary_generator:ensure_content_encoded(
+ rabbit_basic:build_content(#'P_basic'{}, BodyBin)),
FrameMax),
%% header is formatted correctly and the size is the total of the
%% fragments
<<_FrameHeader:7/binary, _ClassAndWeight:4/binary,
BodySize:64/unsigned, _Rest/binary>> = list_to_binary(Header),
- BodySize = size(list_to_binary(Fragments)),
- false = lists:any(
- fun (ContentFrame) ->
- FrameBinary = list_to_binary(ContentFrame),
- %% assert
- <<_TypeAndChannel:3/binary,
- Size:32/unsigned,
- _Payload:Size/binary,
- 16#CE>> = FrameBinary,
- size(FrameBinary) > FrameMax
- end,
- Frames),
+ BodySize = size(BodyBin),
+ true = lists:all(
+ fun (ContentFrame) ->
+ FrameBinary = list_to_binary(ContentFrame),
+ %% assert
+ <<_TypeAndChannel:3/binary,
+ Size:32/unsigned, _Payload:Size/binary, 16#CE>> =
+ FrameBinary,
+ size(FrameBinary) =< FrameMax
+ end, Frames),
passed.
test_content_framing() ->
%% no content
- passed = test_content_framing(4096, []),
- passed = test_content_framing(4096, [<<>>]),
+ passed = test_content_framing(4096, <<>>),
%% easily fit in one frame
- passed = test_content_framing(4096, [<<"Easy">>]),
+ passed = test_content_framing(4096, <<"Easy">>),
%% exactly one frame (empty frame = 8 bytes)
- passed = test_content_framing(11, [<<"One">>]),
+ passed = test_content_framing(11, <<"One">>),
%% more than one frame
- passed = test_content_framing(20, [<<"into more than one frame">>,
- <<"This will have to go">>]),
+ passed = test_content_framing(11, <<"More than one frame">>),
passed.
test_topic_match(P, R) ->