mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-11 04:30:22 +01:00
37 lines
687 B
Go
37 lines
687 B
Go
// Copyright 2014 by Sascha L. Teichmann
|
|
// Use of this source code is governed by the MIT license
|
|
// that can be found in the LICENSE file.
|
|
|
|
package common
|
|
|
|
import (
|
|
"math/rand"
|
|
"testing"
|
|
)
|
|
|
|
func TestSpans(t *testing.T) {
|
|
|
|
inp := make([]int32, 3000)
|
|
for i, n := 0, len(inp); i < n; i++ {
|
|
inp[i] = int32(i)
|
|
}
|
|
for i, n := 0, len(inp); i < n; i++ {
|
|
i1 := rand.Int31n(int32(n))
|
|
i2 := rand.Int31n(int32(n))
|
|
inp[i1], inp[i2] = inp[i2], inp[i1]
|
|
}
|
|
|
|
sp := NewSpanPool()
|
|
var s *Span
|
|
for i, n := 0, len(inp); i < n; i++ {
|
|
s = sp.Insert(s, inp[i], 42)
|
|
}
|
|
|
|
if n := s.Len(); n != 1 {
|
|
t.Errorf("Span length %d expected 1\n", n)
|
|
t.Errorf("spans: %s\n", s)
|
|
}
|
|
|
|
sp.FreeAll(s)
|
|
}
|