Skip to content

Commit

Permalink
add encoding main, ext tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shamaton committed Aug 23, 2024
1 parent e6c3a73 commit bf52e78
Show file tree
Hide file tree
Showing 8 changed files with 820 additions and 10 deletions.
1 change: 1 addition & 0 deletions def/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ var (
ErrTooShortBytes = errors.New("too short bytes")
ErrLackDataLengthToSlice = errors.New("data length lacks to create slice")
ErrLackDataLengthToMap = errors.New("data length lacks to create map")
ErrUnsupported = errors.New("unsupported")
)
2 changes: 1 addition & 1 deletion internal/decoding/decoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (d *decoder) decode(rv reflect.Value, offset int) (int, error) {
}

default:
return 0, fmt.Errorf("type(%v) is unsupported", rv.Kind())
return 0, fmt.Errorf("%v is %w type", rv.Kind(), def.ErrUnsupported)
}
return offset, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (e *encoder) calcSize(rv reflect.Value) (int, error) {
// do nothing (return nil)

default:
return 0, fmt.Errorf("type(%v) is unsupported", rv.Kind())
return 0, fmt.Errorf("%v is %w type", rv.Kind(), def.ErrUnsupported)
}

return ret, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/stream/decoding/decoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (d *decoder) decodeWithCode(code byte, rv reflect.Value) error {
}

default:
return fmt.Errorf("type(%v) is unsupported", rv.Kind())
return fmt.Errorf("%v is %w type", rv.Kind(), def.ErrUnsupported)
}
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion internal/stream/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"reflect"

"github.com/shamaton/msgpack/v2/def"
"github.com/shamaton/msgpack/v2/internal/common"
)

Expand Down Expand Up @@ -188,7 +189,7 @@ func (e *encoder) create(rv reflect.Value) error {
case reflect.Invalid:
return e.writeNil()
default:
return fmt.Errorf("type(%v) is unsupported", rv.Kind())
return fmt.Errorf("%v is %w type", rv.Kind(), def.ErrUnsupported)
}
return nil
}
Loading

0 comments on commit bf52e78

Please sign in to comment.