diff options
| author | Brian Anderson <[email protected]> | 2011-01-08 18:19:55 -0500 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-01-10 11:31:33 -0800 |
| commit | 295c54e10f587a56dfec95ca3a3aee0f9fd721a2 (patch) | |
| tree | 74f9f227ed056f8132424989106019f534c3e0da /src/test | |
| parent | Remove unused variable in circular_buffer tests (diff) | |
| download | rust-295c54e10f587a56dfec95ca3a3aee0f9fd721a2.tar.xz rust-295c54e10f587a56dfec95ca3a3aee0f9fd721a2.zip | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/rt-circular-buffer.rs | 20 |
1 files changed, 20 insertions, 0 deletions
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: |