25 lines
582 B
Go
25 lines
582 B
Go
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.")
|
|
}
|