mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
add tests for Mutex (#925)
* std/lib: add tests for Mutex Signed-off-by: Pierre Curto <pierre.curto@gmail.com> * lib/collections: add missing import Signed-off-by: Pierre Curto <pierre.curto@gmail.com> * std/collections: add RingBuffer Signed-off-by: Pierre Curto <pierre.curto@gmail.com> --------- Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
26
test/unit/stdlib/collections/ringbuffer.c3
Normal file
26
test/unit/stdlib/collections/ringbuffer.c3
Normal file
@@ -0,0 +1,26 @@
|
||||
module ringbuffer_test @test;
|
||||
import collections::ringbuffer;
|
||||
import std::io;
|
||||
|
||||
def Buffer = RingBuffer(<char, 4>);
|
||||
|
||||
fn void putc_getc()
|
||||
{
|
||||
Buffer rb;
|
||||
rb.init();
|
||||
rb.putc(1);
|
||||
rb.putc(2);
|
||||
rb.putc(3);
|
||||
rb.putc(4);
|
||||
|
||||
assert(rb.getc(0) == 1);
|
||||
assert(rb.getc(1) == 2);
|
||||
assert(rb.getc(2) == 3);
|
||||
assert(rb.getc(3) == 4);
|
||||
|
||||
rb.putc(5);
|
||||
assert(rb.getc(0) == 2);
|
||||
assert(rb.getc(1) == 3);
|
||||
assert(rb.getc(2) == 4);
|
||||
assert(rb.getc(3) == 5);
|
||||
}
|
||||
Reference in New Issue
Block a user