Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #353

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3188,7 +3188,7 @@ func TestStructKeyAsIntError(t *testing.T) {
func TestUnmarshalToNotNilInterface(t *testing.T) {
cborData := hexDecode("83010203") // []uint64{1, 2, 3}
s := "hello" //nolint:goconst
var v interface{} = s // Unmarshal() sees v as type inteface{} and sets CBOR data as default Go type. s is unmodified. Same behavior as encoding/json.
var v interface{} = s // Unmarshal() sees v as type interface{} and sets CBOR data as default Go type. s is unmodified. Same behavior as encoding/json.
wantV := []interface{}{uint64(1), uint64(2), uint64(3)}
if err := Unmarshal(cborData, &v); err != nil {
t.Errorf("Unmarshal(0x%x) returned error %v", cborData, err)
Expand Down Expand Up @@ -4630,7 +4630,7 @@ func TestDecModeInvalidExtraError(t *testing.T) {
}
}

func TestExtraErrorCondUnknowField(t *testing.T) {
func TestExtraErrorCondUnknownField(t *testing.T) {
type s struct {
A string
B string
Expand Down Expand Up @@ -4715,7 +4715,7 @@ func TestInvalidUTF8Mode(t *testing.T) {
}
}

func TestStreamExtraErrorCondUnknowField(t *testing.T) {
func TestStreamExtraErrorCondUnknownField(t *testing.T) {
type s struct {
A string
B string
Expand Down Expand Up @@ -5398,63 +5398,63 @@ func TestUnmarshalToInterface(t *testing.T) {
}{
{
name: "uint",
data: hexDecode("a2016b736f6d65206d657373676502187b"), // {1: "some messge", 2: 123}
data: hexDecode("a2016c736f6d65206d65737361676502187b"), // {1: "some message", 2: 123}
v: &TestExample{
Message: "some messge",
Message: "some message",
Foo: &uintFoo123,
},
unmarshalToObj: &TestExample{Foo: &uintFoo},
},
{
name: "int",
data: hexDecode("a2016b736f6d65206d65737367650220"), // {1: "some messge", 2: -1}
data: hexDecode("a2016c736f6d65206d6573736167650220"), // {1: "some message", 2: -1}
v: &TestExample{
Message: "some messge",
Message: "some message",
Foo: &intFooNeg1,
},
unmarshalToObj: &TestExample{Foo: &intFoo},
},
{
name: "bytes",
data: hexDecode("a2016b736f6d65206d65737367650243010203"), // {1: "some messge", 2: [1,2,3]}
data: hexDecode("a2016c736f6d65206d6573736167650243010203"), // {1: "some message", 2: [1,2,3]}
v: &TestExample{
Message: "some messge",
Message: "some message",
Foo: &byteFoo123,
},
unmarshalToObj: &TestExample{Foo: &byteFoo},
},
{
name: "string",
data: hexDecode("a2016b736f6d65206d65737367650263313233"), // {1: "some messge", 2: "123"}
data: hexDecode("a2016c736f6d65206d6573736167650263313233"), // {1: "some message", 2: "123"}
v: &TestExample{
Message: "some messge",
Message: "some message",
Foo: &stringFoo123,
},
unmarshalToObj: &TestExample{Foo: &stringFoo},
},
{
name: "array",
data: hexDecode("a2016b736f6d65206d65737367650283010203"), // {1: "some messge", 2: []int{1,2,3}}
data: hexDecode("a2016c736f6d65206d6573736167650283010203"), // {1: "some message", 2: []int{1,2,3}}
v: &TestExample{
Message: "some messge",
Message: "some message",
Foo: &arrayFoo123,
},
unmarshalToObj: &TestExample{Foo: &arrayFoo},
},
{
name: "map",
data: hexDecode("a2016b736f6d65206d657373676502a3010102020303"), // {1: "some messge", 2: map[int]int{1:1,2:2,3:3}}
data: hexDecode("a2016c736f6d65206d65737361676502a3010102020303"), // {1: "some message", 2: map[int]int{1:1,2:2,3:3}}
v: &TestExample{
Message: "some messge",
Message: "some message",
Foo: &mapFoo123,
},
unmarshalToObj: &TestExample{Foo: &mapFoo},
},
{
name: "struct",
data: hexDecode("a2016b736f6d65206d657373676502a1011901c8"), // {1: "some messge", 2: {1: 456}}
data: hexDecode("a2016c736f6d65206d65737361676502a1011901c8"), // {1: "some message", 2: {1: 456}}
v: &TestExample{
Message: "some messge",
Message: "some message",
Foo: &StructFoo{Value: 456},
},
unmarshalToObj: &TestExample{Foo: &StructFoo{}},
Expand Down
2 changes: 1 addition & 1 deletion encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ type BigIntConvertMode int
const (
// BigIntConvertShortest makes big.Int encode to CBOR integer if value fits.
// E.g. if big.Int value can be converted to CBOR integer while preserving
// value, encoder will encode it to CBOR interger (major type 0 or 1).
// value, encoder will encode it to CBOR integer (major type 0 or 1).
BigIntConvertShortest BigIntConvertMode = iota

// BigIntConvertNone makes big.Int encode to CBOR bignum (tag 2 or 3) without
Expand Down
4 changes: 2 additions & 2 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ func (enc *Encoder) Encode(v interface{}) error {

// StartIndefiniteByteString starts byte string encoding of indefinite length.
// Subsequent calls of (*Encoder).Encode() encodes definite length byte strings
// ("chunks") as one continguous string until EndIndefinite is called.
// ("chunks") as one contiguous string until EndIndefinite is called.
func (enc *Encoder) StartIndefiniteByteString() error {
return enc.startIndefinite(cborTypeByteString)
}

// StartIndefiniteTextString starts text string encoding of indefinite length.
// Subsequent calls of (*Encoder).Encode() encodes definite length text strings
// ("chunks") as one continguous string until EndIndefinite is called.
// ("chunks") as one contiguous string until EndIndefinite is called.
func (enc *Encoder) StartIndefiniteTextString() error {
return enc.startIndefinite(cborTypeTextString)
}
Expand Down