Update coders with error return values
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user