Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Artoul committed Feb 22, 2020
1 parent d3e6e67 commit d102b1f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions go/arrow/array/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,26 @@ func TestStringBuilder_Empty(t *testing.T) {
assert.Equal(t, want, stringValues(a))
a.Release()
}

// TestStringReset tests the Reset() method on the String type by creating two different Strings and then
// reseting the contents of string2 with the values from string1.
func TestStringReset(t *testing.T) {
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
sb1 := array.NewStringBuilder(mem)
sb2 := array.NewStringBuilder(mem)
defer sb1.Release()
defer sb2.Release()

sb1.Append("string1")
sb1.AppendNull()

var (
string1 = sb1.NewStringArray()
string2 = sb2.NewStringArray()

string1Data = string1.Data()
)
string2.Reset(string1Data)

assert.Equal(t, "string1", string2.Value(0))
}
12 changes: 12 additions & 0 deletions go/arrow/memory/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,15 @@ func TestNewResizableBuffer(t *testing.T) {
assert.Nil(t, buf.Bytes())
assert.Zero(t, buf.Len())
}

func TestBufferReset(t *testing.T) {
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
defer mem.AssertSize(t, 0)

buf := memory.NewResizableBuffer(mem)

newBytes := []byte("some-new-bytes")
buf.Reset(newBytes)
assert.Equal(t, newBytes, buf.Bytes())
assert.Equal(t, len(newBytes), buf.Len())
}

0 comments on commit d102b1f

Please sign in to comment.