commit 7166fd659b3e557c8be1b04c95527add7a0f5f67
parent ca0442d6e33334128a2ee68f24c6c962de72ead3
Author: Francois Parquet <francois.parquet@gmail.com>
Date: Wed, 23 May 2018 22:10:04 +0800
Merge pull request #30 from m1ome/uint-tests
Added Uint64 tests & Int64 tests
Diffstat:
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/encode_number_test.go b/encode_number_test.go
@@ -5,6 +5,8 @@ import (
"testing"
"github.com/stretchr/testify/assert"
+ "math"
+ "fmt"
)
func TestEncoderNumberEncodeAPI(t *testing.T) {
@@ -22,11 +24,22 @@ func TestEncoderNumberEncodeAPI(t *testing.T) {
t.Run("encode-int64", func(t *testing.T) {
builder := &strings.Builder{}
enc := NewEncoder(builder)
- err := enc.EncodeInt64(int64(1))
+ err := enc.EncodeInt64(math.MaxInt64)
assert.Nil(t, err, "Error should be nil")
assert.Equal(
t,
- `1`,
+ fmt.Sprintf("%d", math.MaxInt64),
+ builder.String(),
+ "Result of marshalling is different as the one expected")
+ })
+ t.Run("encode-uint64", func(t *testing.T) {
+ builder := &strings.Builder{}
+ enc := NewEncoder(builder)
+ err := enc.EncodeUint64(uint64(math.MaxUint64))
+ assert.Nil(t, err, "Error should be nil")
+ assert.Equal(
+ t,
+ fmt.Sprintf("%d", uint64(math.MaxUint64)),
builder.String(),
"Result of marshalling is different as the one expected")
})