-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_test.go
More file actions
40 lines (32 loc) · 946 Bytes
/
json_test.go
File metadata and controls
40 lines (32 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package jsoff
import (
"encoding/json"
"github.com/stretchr/testify/assert"
"testing"
)
func TestMarshalBigint(t *testing.T) {
assert := assert.New(t)
type vwrap struct {
V *Bigint `json:"v"`
}
a := vwrap{
V: &Bigint{},
}
a.V.Load("1234498219282917838937829383759200002030081000698")
data, err := json.Marshal(&a)
assert.Nil(err)
assert.Equal(`{"v":"1234498219282917838937829383759200002030081000698"}`, string(data))
var b vwrap
err = json.Unmarshal(data, &b)
assert.Nil(err)
assert.Equal(a.V.Value(), b.V.Value())
assert.Equal(a.V, b.V)
assert.Equal("1234498219282917838937829383759200002030081000698", b.V.String())
strnoquote := `{"v": 1234498219282917838937829383759200002030081000698}`
var c vwrap
err = json.Unmarshal([]byte(strnoquote), &c)
assert.Nil(err)
assert.Equal(a.V.Value(), c.V.Value())
assert.Equal(a.V, c.V)
assert.Equal("1234498219282917838937829383759200002030081000698", c.V.String())
}