mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
22 lines
500 B
Go
22 lines
500 B
Go
package bytesutil
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestResize(t *testing.T) {
|
|
for i := 0; i < 1000; i++ {
|
|
b := Resize(nil, i)
|
|
if len(b) != i {
|
|
t.Fatalf("invalid b size; got %d; expecting %d", len(b), i)
|
|
}
|
|
b1 := Resize(b, i)
|
|
if len(b1) != len(b) || (len(b) > 0 && &b1[0] != &b[0]) {
|
|
t.Fatalf("invalid b1; got %x; expecting %x", b1, b)
|
|
}
|
|
b2 := Resize(b[:0], i)
|
|
if len(b2) != len(b) || (len(b) > 0 && &b2[0] != &b[0]) {
|
|
t.Fatalf("invalid b2; got %x; expecting %x", b2, b)
|
|
}
|
|
}
|
|
}
|