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

feat(cbor): Add support for CBOR encoding #94

Merged
merged 5 commits into from
Oct 20, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore(lint): fix lint issues
imsk17 committed Oct 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 85e3dd9834de7fc276bd26eb3c4ef82e6306a647
13 changes: 8 additions & 5 deletions cbor_test.go
Original file line number Diff line number Diff line change
@@ -22,19 +22,22 @@ func Test_DefaultCBOREncoder(t *testing.T) {
raw, err := cborEncoder(ss)
require.NoError(t, err)

require.Equal(t, hex.EncodeToString([]byte(raw)), importantString)
require.Equal(t, hex.EncodeToString(raw), importantString)
}

func Test_DefaultCBORDecoder(t *testing.T) {
t.Parallel()

var (
ss sampleStructure
importantString, _ = hex.DecodeString("a170696d706f7274616e745f737472696e676b48656c6c6f20576f726c64")
cborDecoder CBORUnmarshal = cbor.Unmarshal
ss sampleStructure
importantString, err = hex.DecodeString("a170696d706f7274616e745f737472696e676b48656c6c6f20576f726c64")
cborDecoder CBORUnmarshal = cbor.Unmarshal
)
if err != nil {
t.Error("Failed to decode hex string")
}

err := cborDecoder(importantString, &ss)
err = cborDecoder(importantString, &ss)
require.NoError(t, err)
require.Equal(t, "Hello World", ss.ImportantString)
}