Skip to content

Commit d102b1f

Browse files
author
Richard Artoul
committed
Add tests
1 parent d3e6e67 commit d102b1f

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

go/arrow/array/string_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,26 @@ func TestStringBuilder_Empty(t *testing.T) {
158158
assert.Equal(t, want, stringValues(a))
159159
a.Release()
160160
}
161+
162+
// TestStringReset tests the Reset() method on the String type by creating two different Strings and then
163+
// reseting the contents of string2 with the values from string1.
164+
func TestStringReset(t *testing.T) {
165+
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
166+
sb1 := array.NewStringBuilder(mem)
167+
sb2 := array.NewStringBuilder(mem)
168+
defer sb1.Release()
169+
defer sb2.Release()
170+
171+
sb1.Append("string1")
172+
sb1.AppendNull()
173+
174+
var (
175+
string1 = sb1.NewStringArray()
176+
string2 = sb2.NewStringArray()
177+
178+
string1Data = string1.Data()
179+
)
180+
string2.Reset(string1Data)
181+
182+
assert.Equal(t, "string1", string2.Value(0))
183+
}

go/arrow/memory/buffer_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,15 @@ func TestNewResizableBuffer(t *testing.T) {
4343
assert.Nil(t, buf.Bytes())
4444
assert.Zero(t, buf.Len())
4545
}
46+
47+
func TestBufferReset(t *testing.T) {
48+
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
49+
defer mem.AssertSize(t, 0)
50+
51+
buf := memory.NewResizableBuffer(mem)
52+
53+
newBytes := []byte("some-new-bytes")
54+
buf.Reset(newBytes)
55+
assert.Equal(t, newBytes, buf.Bytes())
56+
assert.Equal(t, len(newBytes), buf.Len())
57+
}

0 commit comments

Comments
 (0)