MCPcopy
hub / github.com/shopspring/decimal / TestGobEncode

Function TestGobEncode

decimal_test.go:3363–3405  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3361}
3362
3363func TestGobEncode(t *testing.T) {
3364 for _, y := range testTable {
3365 x := y.float
3366 d1 := NewFromFloat(x)
3367
3368 b1, err := d1.GobEncode()
3369 if err != nil {
3370 t.Errorf("error encoding %v to binary: %v", d1, err)
3371 }
3372
3373 d2 := NewFromFloat(x)
3374
3375 b2, err := d2.GobEncode()
3376 if err != nil {
3377 t.Errorf("error encoding %v to binary: %v", d2, err)
3378 }
3379
3380 if !slicesEqual(b1, b2) {
3381 t.Errorf("something about the gobencode is not working properly \n%v\n%v", b1, b2)
3382 }
3383
3384 var d3 Decimal
3385 err = d3.GobDecode(b1)
3386 if err != nil {
3387 t.Errorf("Error gobdecoding %v, got %v", b1, d3)
3388 }
3389 var d4 Decimal
3390 err = d4.GobDecode(b2)
3391 if err != nil {
3392 t.Errorf("Error gobdecoding %v, got %v", b2, d4)
3393 }
3394
3395 eq := d3.Equal(d4)
3396 if eq != true {
3397 t.Errorf("Encoding then decoding mutated Decimal")
3398 }
3399
3400 eq = d1.Equal(d3)
3401 if eq != true {
3402 t.Errorf("Error gobencoding/decoding %v, got %v", d1, d3)
3403 }
3404 }
3405}
3406
3407func TestSum(t *testing.T) {
3408 vals := make([]Decimal, 10)

Callers

nothing calls this directly

Calls 5

GobDecodeMethod · 0.95
EqualMethod · 0.95
NewFromFloatFunction · 0.85
slicesEqualFunction · 0.85
GobEncodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…