diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go index 4295b92..1a3addd 100644 --- a/internal/testutil/testutil.go +++ b/internal/testutil/testutil.go @@ -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"