I’ve implemented concurrent circullar buffer on C# and now want to test its work. I have pretty simple API – void Write(T element) and T Read(). I’m looking for a good example how to test all possible use-cases and detect all possible bugs, including race condition.Simple alternate writing and reading from 2 threads does not seem to be a good idea because we can’t control the order of API calls from different threads.
I’ve implemented concurrent circullar buffer on C# and now want to test its work.
Share
One of the use case should include writing to the buffer (without reading from it) until the buffer is full.
If your test case implements reading and writing from the same thread, then you can control the sequence of read/writes.
I like it when the implementation of thread-safety in multi-threaded code is simple enough to verify “by inspection”, i.e. via a code review (and not just via testing).