testutil: Add Flatten method to Snake
This commit is contained in:
parent
9278bdcb43
commit
423f547da3
@ -64,6 +64,18 @@ func (sn Snake) Check(data []byte) (ok bool, n int) {
|
||||
return true, n
|
||||
}
|
||||
|
||||
// Flatten returns the snake flattened to a byte array. The result of this
|
||||
// function always satisfies the snake.
|
||||
func (sn Snake) Flatten() []byte {
|
||||
flat := []byte { }
|
||||
for _, sector := range sn {
|
||||
for _, variation := range sector {
|
||||
flat = append(flat, variation...)
|
||||
}
|
||||
}
|
||||
return flat
|
||||
}
|
||||
|
||||
func (sn Snake) String() string {
|
||||
if len(sn) == 0 || len(sn[0]) == 0 || len(sn[0][0]) == 0 {
|
||||
return "EMPTY"
|
||||
|
Loading…
x
Reference in New Issue
Block a user