Update coders with error return values
Some checks failed
Benchmark BufferPool / RunBenchmarks (push) Failing after 25s
Run Tests / Test (push) Failing after 23s

This commit is contained in:
2024-07-25 16:53:14 +02:00
parent 0eb0f5d773
commit 92c0e83e73
3 changed files with 26 additions and 9 deletions

View File

@@ -11,7 +11,11 @@ func TestASCIIEncodeSimpleASCIIString(t *testing.T) {
input := "Hello, World!"
expected := []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
coder.Encode(input, &buf)
err := coder.Encode(input, &buf)
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if !bytes.Equal(buf.Bytes(), expected) {
t.Errorf("Expected %v, but got %v", expected, buf.Bytes())
@@ -25,7 +29,11 @@ func TestASCIIDecodeSimpleASCIIString(t *testing.T) {
expected := "Hello, World!"
buf.Write(input)
output := coder.Decode(&buf)
output, err := coder.Decode(&buf)
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if output != expected {
t.Errorf("Expected %v, but got %v", expected, output)
@@ -38,7 +46,11 @@ func TestASCIIEncodeEmptyString(t *testing.T) {
input := ""
expected := []byte{}
coder.Encode(input, &buf)
err := coder.Encode(input, &buf)
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if !bytes.Equal(buf.Bytes(), expected) {
t.Errorf("Expected %v, but got %v", expected, buf.Bytes())
@@ -50,7 +62,11 @@ func TestASCIIDecodeEmptyString(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
expected := ""
output := coder.Decode(buf)
output, err := coder.Decode(buf)
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if output != expected {
t.Errorf("Expected %v, but got %v", expected, output)