File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -310,3 +310,35 @@ func TestGetByIndex(t *testing.T) {
310310 require .Equal (t , pair .Value , v )
311311 }
312312}
313+
314+ func TestGetCacheReturnsCopiesDisableZeroCopy (t * testing.T ) {
315+ tree := New (8 )
316+ tree .SetZeroCopy (false )
317+
318+ key := []byte ("key1" )
319+ val := []byte ("val1" )
320+ changeSet := ChangeSet {
321+ Pairs : []* KVPair {
322+ {Key : key , Value : val },
323+ },
324+ }
325+
326+ tree .ApplyChangeSet (changeSet )
327+ _ , _ , err := tree .SaveVersion (true )
328+ require .NoError (t , err )
329+
330+ first := tree .Get (key )
331+ require .Equal (t , val , first )
332+
333+ first [0 ] = 'x'
334+ second := tree .Get (key )
335+ require .Equal (t , val , second )
336+
337+ second [1 ] = 'y'
338+ third := tree .Get (key )
339+ require .Equal (t , val , third )
340+
341+ require .Equal (t , byte ('x' ), first [0 ])
342+ require .Equal (t , byte ('y' ), second [1 ])
343+
344+ }
You can’t perform that action at this time.
0 commit comments