mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-12-29 19:05:26 +01:00
Repaired old unit tests. Added unit test for span buffers ... which currently fails. :-/
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const chunkSize = 1024
|
||||
|
||||
type Span struct {
|
||||
@@ -184,3 +189,31 @@ func (sp *SpanPool) Insert(s *Span, pos, value int32) *Span {
|
||||
|
||||
return head
|
||||
}
|
||||
|
||||
func (s *Span) Visit(v func(*Span)) {
|
||||
for ; s != nil; s = s.Next {
|
||||
v(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Span) Len() int {
|
||||
n := 0
|
||||
for ; s != nil; s = s.Next {
|
||||
n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (s *Span) String() string {
|
||||
var buf bytes.Buffer
|
||||
first := true
|
||||
s.Visit(func(s1 *Span) {
|
||||
if !first {
|
||||
buf.WriteString(", ")
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
buf.WriteString(fmt.Sprintf("(%d, %d)", s1.From, s1.To))
|
||||
})
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user