Covered tests for rjreader

This commit is contained in:
porosnicuadrian
2020-11-17 15:55:11 +02:00
committed by Dan Christian Bogos
parent 921d1d2023
commit 880dfe48dc

View File

@@ -20,6 +20,7 @@ package config
import (
"encoding/json"
"fmt"
"io"
"os"
"reflect"
"testing"
@@ -324,6 +325,16 @@ func TestHandleJSONErrorInvalidUnmarshalError(t *testing.T) {
}
}
func TestHandleJSONErrorDefaultError(t *testing.T) {
rjr := NewRjReaderFromBytes([]byte("{}"))
rjr.indx = 10
if _, err := rjr.ReadByteWC(); err == nil || err != io.EOF {
t.Errorf("Expected %+v, received %+v", io.EOF, err)
} else if newErr := rjr.HandleJSONError(err); newErr == nil || newErr != io.EOF {
t.Errorf("Expected %+v, received %+v", io.EOF, err)
}
}
func TestHandleJSONErrorUnmarshalTypeError(t *testing.T) {
rjr := NewRjReaderFromBytes([]byte("{}"))
err := &json.UnmarshalTypeError{