Skip to content

circular-buffer: Test overwrite on non-full buffer #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions circular-buffer/circular_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
"testing"
)

const testVersion = 1
const testVersion = 2

// Retired:
// (non-versioned) ea3c43868a02d8d899d3a99163380a3b7b3a0a18
// 1 38c982fc7e6861dfebec2a0023a85e53ea8c1b59

func TestTestVersion(t *testing.T) {
if TestVersion != testVersion {
Expand Down Expand Up @@ -150,7 +151,7 @@ func TestWriteFullBuffer(t *testing.T) {
tb.writeFail('A')
}

func TestOverwrite(t *testing.T) {
func TestOverwriteFull(t *testing.T) {
tb := nb(2, t)
tb.write('1')
tb.write('2')
Expand All @@ -160,6 +161,15 @@ func TestOverwrite(t *testing.T) {
tb.readFail()
}

func TestOverwriteNonFull(t *testing.T) {
tb := nb(2, t)
tb.write('1')
tb.overwrite('2')
tb.read('1')
tb.read('2')
tb.readFail()
}

func TestAlternateReadAndOverwrite(t *testing.T) {
tb := nb(5, t)
tb.write('1')
Expand Down
2 changes: 1 addition & 1 deletion circular-buffer/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"errors"
)

const TestVersion = 1
const TestVersion = 2

// Buffer implements a circular buffer supporting both overflow-checked writes
// and unconditional, possibly overwriting, writes.
Expand Down