meowlib/buffer_test.go

25 lines
582 B
Go
Raw Normal View History

2022-11-29 22:19:54 +01:00
package meowlib
import (
"log"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBufferSplit(t *testing.T) {
source := []byte("Hello World, I need to slice you, but in equal parts, not the capitalist way")
packets, err := BufferSplit(source, 3)
if err != nil {
log.Fatalln("Failed to encode address book:", err)
}
println(len(packets))
destination, err := BufferMerge(packets)
if err != nil {
log.Fatalln("Failed to encode address book:", err)
}
println(string(destination))
assert.Equal(t, source, destination, "The two buffers should be the same.")
}