From be511dd001a4640c5009b49160cddcf5f0d51888 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Fri, 24 Jan 2025 11:10:19 -0600 Subject: [PATCH] Avoid using more unexported constants in tests This commit avoids using maxInlineArrayElementSize in tests. --- array_benchmark_test.go | 10 +++++----- array_test.go | 36 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/array_benchmark_test.go b/array_benchmark_test.go index b5fec50..5bc89c6 100644 --- a/array_benchmark_test.go +++ b/array_benchmark_test.go @@ -88,7 +88,7 @@ func benchmarkArray(b *testing.B, initialArraySize, numberOfElements int) { // setup for i := 0; i < initialArraySize; i++ { v := RandomValue(r) - storable, err := v.Storable(storage, array.Address(), maxInlineArrayElementSize) + storable, err := v.Storable(storage, array.Address(), MaxInlineArrayElementSize()) require.NoError(b, err) totalRawDataSize += storable.ByteSize() err = array.Append(v) @@ -107,7 +107,7 @@ func benchmarkArray(b *testing.B, initialArraySize, numberOfElements int) { for i := 0; i < numberOfElements; i++ { v := RandomValue(r) - storable, err := v.Storable(storage, array.Address(), maxInlineArrayElementSize) + storable, err := v.Storable(storage, array.Address(), MaxInlineArrayElementSize()) require.NoError(b, err) totalRawDataSize += storable.ByteSize() @@ -143,7 +143,7 @@ func benchmarkArray(b *testing.B, initialArraySize, numberOfElements int) { ind := r.Intn(int(array.Count())) v := RandomValue(r) - storable, err := v.Storable(storage, array.Address(), maxInlineArrayElementSize) + storable, err := v.Storable(storage, array.Address(), MaxInlineArrayElementSize()) require.NoError(b, err) totalRawDataSize += storable.ByteSize() @@ -217,7 +217,7 @@ func benchmarkLongTermImpactOnMemory(b *testing.B, initialArraySize, numberOfOps for i := 0; i < initialArraySize; i++ { v := RandomValue(r) - storable, err := v.Storable(storage, array.Address(), maxInlineArrayElementSize) + storable, err := v.Storable(storage, array.Address(), MaxInlineArrayElementSize()) require.NoError(b, err) totalRawDataSize += storable.ByteSize() @@ -239,7 +239,7 @@ func benchmarkLongTermImpactOnMemory(b *testing.B, initialArraySize, numberOfOps case 1: // insert v := RandomValue(r) - storable, err := v.Storable(storage, array.Address(), maxInlineArrayElementSize) + storable, err := v.Storable(storage, array.Address(), MaxInlineArrayElementSize()) require.NoError(b, err) totalRawDataSize += storable.ByteSize() diff --git a/array_test.go b/array_test.go index 5524d57..d5ea175 100644 --- a/array_test.go +++ b/array_test.go @@ -2456,7 +2456,7 @@ func TestArraySetRandomValues(t *testing.T) { for i := uint64(0); i < arraySize; i++ { oldValue := values[i] - newValue := randomValue(r, int(maxInlineArrayElementSize)) + newValue := randomValue(r, int(MaxInlineArrayElementSize())) values[i] = newValue existingStorable, err := array.Set(i, newValue) @@ -2490,7 +2490,7 @@ func TestArrayInsertRandomValues(t *testing.T) { values := make([]Value, arraySize) for i := uint64(0); i < arraySize; i++ { - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) values[arraySize-i-1] = v err := array.Insert(0, v) @@ -2515,7 +2515,7 @@ func TestArrayInsertRandomValues(t *testing.T) { values := make([]Value, arraySize) for i := uint64(0); i < arraySize; i++ { - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) values[i] = v err := array.Insert(i, v) @@ -2541,7 +2541,7 @@ func TestArrayInsertRandomValues(t *testing.T) { values := make([]Value, arraySize) for i := uint64(0); i < arraySize; i++ { k := r.Intn(int(i) + 1) - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) copy(values[k+1:], values[k:]) values[k] = v @@ -2573,7 +2573,7 @@ func TestArrayRemoveRandomValues(t *testing.T) { values := make([]Value, arraySize) // Insert n random values into array for i := uint64(0); i < arraySize; i++ { - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) values[i] = v err := array.Insert(i, v) @@ -2640,7 +2640,7 @@ func testArrayAppendSetInsertRemoveRandomValues( switch nextOp { case ArrayAppendOp: - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) values = append(values, v) err := array.Append(v) @@ -2648,7 +2648,7 @@ func testArrayAppendSetInsertRemoveRandomValues( case ArraySetOp: k := r.Intn(int(array.Count())) - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) oldV := values[k] @@ -2668,7 +2668,7 @@ func testArrayAppendSetInsertRemoveRandomValues( case ArrayInsertOp: k := r.Intn(int(array.Count() + 1)) - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) if k == int(array.Count()) { values = append(values, v) @@ -4457,7 +4457,7 @@ func TestArrayStringElement(t *testing.T) { r := newRand(t) - stringSize := int(maxInlineArrayElementSize - 3) + stringSize := int(MaxInlineArrayElementSize() - 3) values := make([]Value, arraySize) for i := uint64(0); i < arraySize; i++ { @@ -4490,7 +4490,7 @@ func TestArrayStringElement(t *testing.T) { r := newRand(t) - stringSize := int(maxInlineArrayElementSize + 512) + stringSize := int(MaxInlineArrayElementSize() + 512) values := make([]Value, arraySize) for i := uint64(0); i < arraySize; i++ { @@ -4787,7 +4787,7 @@ func TestArrayFromBatchData(t *testing.T) { var values []Value var v Value - v = NewStringValue(strings.Repeat("a", int(maxInlineArrayElementSize-2))) + v = NewStringValue(strings.Repeat("a", int(MaxInlineArrayElementSize()-2))) values = append(values, v) err = array.Insert(0, v) @@ -4843,7 +4843,7 @@ func TestArrayFromBatchData(t *testing.T) { require.NoError(t, err) } - v = NewStringValue(strings.Repeat("a", int(maxInlineArrayElementSize-2))) + v = NewStringValue(strings.Repeat("a", int(MaxInlineArrayElementSize()-2))) values = append(values, nil) copy(values[25+1:], values[25:]) values[25] = v @@ -4890,7 +4890,7 @@ func TestArrayFromBatchData(t *testing.T) { values := make([]Value, arraySize) for i := uint64(0); i < arraySize; i++ { - v := randomValue(r, int(maxInlineArrayElementSize)) + v := randomValue(r, int(MaxInlineArrayElementSize())) values[i] = v err := array.Append(v) @@ -4939,17 +4939,17 @@ func TestArrayFromBatchData(t *testing.T) { var values []Value var v Value - v = NewStringValue(randStr(r, int(maxInlineArrayElementSize-2))) + v = NewStringValue(randStr(r, int(MaxInlineArrayElementSize()-2))) values = append(values, v) err = array.Append(v) require.NoError(t, err) - v = NewStringValue(randStr(r, int(maxInlineArrayElementSize-2))) + v = NewStringValue(randStr(r, int(MaxInlineArrayElementSize()-2))) values = append(values, v) err = array.Append(v) require.NoError(t, err) - v = NewStringValue(randStr(r, int(maxInlineArrayElementSize-2))) + v = NewStringValue(randStr(r, int(MaxInlineArrayElementSize()-2))) values = append(values, v) err = array.Append(v) require.NoError(t, err) @@ -5016,7 +5016,7 @@ func TestArrayMaxInlineElement(t *testing.T) { var values []Value for i := 0; i < 2; i++ { // String length is MaxInlineArrayElementSize - 3 to account for string encoding overhead. - v := NewStringValue(randStr(r, int(maxInlineArrayElementSize-3))) + v := NewStringValue(randStr(r, int(MaxInlineArrayElementSize()-3))) values = append(values, v) err = array.Append(v) @@ -5139,7 +5139,7 @@ func TestArraySlabDump(t *testing.T) { array, err := NewArray(storage, address, typeInfo) require.NoError(t, err) - err = array.Append(NewStringValue(strings.Repeat("a", int(maxInlineArrayElementSize)))) + err = array.Append(NewStringValue(strings.Repeat("a", int(MaxInlineArrayElementSize())))) require.NoError(t, err) want := []string{