Skip to content

Commit

Permalink
test: Add BenchmarkEncodeDecode
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhellberg committed Aug 24, 2023
1 parent addde54 commit 9fdaa7e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ import (
"testing"
)

func BenchmarkEncodeDecode(b *testing.B) {
numbers := []uint64{1, 2, 3, 4, 5}

s, err := New()
if err != nil {
b.Fatal(err)
}

for i := 0; i < b.N; i++ {
id, err := s.Encode(numbers)
if err != nil {
b.Fatal(err)
}

decodedNumbers := s.Decode(id)
if !reflect.DeepEqual(numbers, decodedNumbers) {
b.Errorf("Could not encode/decode `%v`", numbers)
}
}
}

func TestEncodingSimple(t *testing.T) {
numbers := []uint64{1, 2, 3}

Expand Down

0 comments on commit 9fdaa7e

Please sign in to comment.