diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-08 14:24:20 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-08 14:24:20 +0100 |
commit | 3be6c57dde28f1a2e0a2fae7bbf74307cd2a5cc9 (patch) | |
tree | 2554fc4829125b9a70721550ac45bed9c3c03270 | |
parent | ca8abd076c06189a18ff58d6ae51886c18a0d98d (diff) | |
download | rabbitmq-server-bug23091.tar.gz |
expand and rewrite testsbug23091
make it more obvious what we are testing and handle more cases
-rw-r--r-- | src/rabbit_tests.erl | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index e6a43120..c07055af 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -538,6 +538,9 @@ test_content_framing() -> passed. test_content_transcoding() -> + %% there are no guarantees provided by 'clear' - it's just a hint + ClearDecoded = fun rabbit_binary_parser:clear_decoded_content/1, + ClearEncoded = fun rabbit_binary_generator:clear_encoded_content/1, EnsureDecoded = fun (C0) -> C1 = rabbit_binary_parser:ensure_content_decoded(C0), @@ -553,17 +556,32 @@ test_content_transcoding() -> C1 end end, - EnsureEncoded1 = EnsureEncoded(rabbit_framing_amqp_0_9_1), - EnsureEncoded2 = EnsureEncoded(rabbit_framing_amqp_0_8), - ClearEncoded = fun rabbit_binary_generator:clear_encoded_content/1, - ClearDecoded = fun rabbit_binary_parser:clear_decoded_content/1, - lists:foldl(fun (F, V) -> F(F(V)) end, - rabbit_basic:build_content(#'P_basic'{}, <<>>), - [EnsureDecoded, ClearEncoded, ClearDecoded, - EnsureEncoded1, ClearDecoded, ClearEncoded, - EnsureEncoded2, EnsureDecoded, ClearEncoded, EnsureEncoded1]), + %% Beyond the assertions in Ensure*, the only testable guarantee + %% is that the operations should never fail. + %% + %% If we were using quickcheck we'd simply stuff all the above + %% into a generator for sequences of operations. In the absence of + %% quickcheck we pick particularly interesting sequences that: + %% + %% - execute every op twice since they are idempotent + %% - invoke clear_decoded, clear_encoded, decode and transcode + %% with one or both of decoded and encoded content present + [begin + sequence_with_content([Op]), + sequence_with_content([ClearEncoded, Op]), + sequence_with_content([ClearDecoded, Op]) + end || Op <- [ClearDecoded, ClearEncoded, EnsureDecoded, + EnsureEncoded(rabbit_framing_amqp_0_9_1), + EnsureEncoded(rabbit_framing_amqp_0_8)]], passed. +sequence_with_content(Sequence) -> + lists:foldl(fun (F, V) -> F(F(V)) end, + rabbit_binary_generator:ensure_content_encoded( + rabbit_basic:build_content(#'P_basic'{}, <<>>), + rabbit_framing_amqp_0_9_1), + Sequence). + test_topic_match(P, R) -> test_topic_match(P, R, true). |