⬥ ID3 encoding/decoding library in Go ⬥
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.3 KiB

package util
import (
"bytes"
"testing"
)
func TestRead(t *testing.T) {
testBuffer := new(bytes.Buffer)
_, err := testBuffer.WriteString("Writing some data here. ᗜˬᗜ")
if err != nil {
t.Errorf("%s", err)
}
buffLen := testBuffer.Len()
buffBytes := testBuffer.Bytes()
read, err := Read(testBuffer, uint64(buffLen))
if err != nil {
t.Errorf("Read failed: %s", err)
}
if int(len(read)) != int(buffLen) {
t.Errorf("Read failed: expected length %d; got %d", buffLen, len(read))
}
for index, b := range read {
if buffBytes[index] != b {
t.Errorf("Read failed: expected byte %v; got %v at index %d", buffBytes[index], b, index)
}
}
}
func TestReadToString(t *testing.T) {
testBuffer := new(bytes.Buffer)
_, err := testBuffer.WriteString("This is literally the same as before. ᗜˬᗜ")
if err != nil {
t.Errorf("%s", err)
}
buffLen := testBuffer.Len()
buffBytes := testBuffer.Bytes()
read, err := Read(testBuffer, uint64(buffLen))
if err != nil {
t.Errorf("Read failed: %s", err)
}
if int(len(read)) != int(buffLen) {
t.Errorf("Read failed: expected length %d; got %d", buffLen, len(read))
}
for index, b := range read {
if buffBytes[index] != b {
t.Errorf("Read failed: expected byte %v; got %v at index %d", buffBytes[index], b, index)
}
}
}