From 295c54e10f587a56dfec95ca3a3aee0f9fd721a2 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 8 Jan 2011 18:19:55 -0500 Subject: Remove the assumption that circular_buffer's buffer has a power of two size It was not obvious how to make this implementation work when the unit size was not also a power of two, so for now just make the buffer size a multiple of the unit size so it can pass all the tests. --- src/test/run-pass/rt-circular-buffer.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/test') diff --git a/src/test/run-pass/rt-circular-buffer.rs b/src/test/run-pass/rt-circular-buffer.rs index d582a415..542846b4 100644 --- a/src/test/run-pass/rt-circular-buffer.rs +++ b/src/test/run-pass/rt-circular-buffer.rs @@ -67,6 +67,25 @@ impure fn test_rotate() { let port[record] myport = port(); auto mychan = chan(myport); + for each (uint i in _uint.range(0u, 100u)) { + auto val = rec(val1=i as u32, + val2=i as u32, + val3=i as u32); + mychan <| val; + + auto x <- myport; + check (x.val1 == i as u32); + check (x.val2 == i as u32); + check (x.val3 == i as u32); + } +} + +// Test rotating and growing the buffer when +// the unit size is not a power of two +impure fn test_rotate_grow() { + let port[record] myport = port(); + auto mychan = chan(myport); + for each (uint j in _uint.range(0u, 10u)) { for each (uint i in _uint.range(0u, 10u)) { let record val = rec(val1=i as u32, @@ -90,6 +109,7 @@ impure fn main() { test_shrink1(); test_shrink2(); test_rotate(); + test_rotate_grow(); } // Local Variables: -- cgit v1.2.3