diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-08-19 16:28:42 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-08-19 16:28:42 +0100 |
| commit | e6df59a9e679ef0b60a287290e3dd8b33f1f799d (patch) | |
| tree | 334c39917b5e64219af0c782f277e770f28d61b6 /src | |
| parent | 8840378e20a541cfd86048f27aa3fdc6619711a6 (diff) | |
| download | rabbitmq-server-git-e6df59a9e679ef0b60a287290e3dd8b33f1f799d.tar.gz | |
100% code coverage of join. Also made in have 100% code coverage. The remaining out case I don't think can exist without manually constructing the necessary structure. I don't believe the API permits it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_tests.erl | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index e180b82c57..5e1cdfb18a 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -128,6 +128,35 @@ test_priority_queue() -> {true, false, 2, [{2, bar}, {1, foo}], [bar, foo]} = test_priority_queue(Q10), + %% merge 2 * 2-element multi-different-priority Qs + Q11 = priority_queue:join(Q6, Q5), + {true, false, 4, [{1, bar}, {0, foo}, {0, foo}, {0, bar}], + [bar, foo, foo, bar]} = test_priority_queue(Q11), + + %% and the other way around + Q12 = priority_queue:join(Q5, Q6), + {true, false, 4, [{1, bar}, {0, foo}, {0, bar}, {0, foo}], + [bar, foo, bar, foo]} = test_priority_queue(Q12), + + %% merge with negative priorities + Q13 = priority_queue:join(Q4, Q5), + {true, false, 3, [{0, foo}, {0, bar}, {-1, foo}], [foo, bar, foo]} = + test_priority_queue(Q13), + + %% and the other way around + Q14 = priority_queue:join(Q5, Q4), + {true, false, 3, [{0, foo}, {0, bar}, {-1, foo}], [foo, bar, foo]} = + test_priority_queue(Q14), + + %% joins with empty queues: + Q1 = priority_queue:join(Q, Q1), + Q1 = priority_queue:join(Q1, Q), + + %% insert with priority into non-empty zero-priority queue + Q15 = priority_queue:in(baz, 1, Q5), + {true, false, 3, [{1, baz}, {0, foo}, {0, bar}], [baz, foo, bar]} = + test_priority_queue(Q15), + passed. priority_queue_in_all(Q, L) -> |
