@@ -63,10 +63,10 @@ func (t *TupleDecimal) DecodeMsgpack(d *msgpack.Decoder) error {
63
63
return err
64
64
}
65
65
66
- if dec , ok := res .(* Decimal ); ! ok {
66
+ if dec , ok := res .(Decimal ); ! ok {
67
67
return fmt .Errorf ("decimal doesn't match" )
68
68
} else {
69
- t .number = * dec
69
+ t .number = dec
70
70
}
71
71
return nil
72
72
}
@@ -160,12 +160,12 @@ var decimalSamples = []struct {
160
160
func TestMPEncodeDecode (t * testing.T ) {
161
161
for _ , testcase := range benchmarkSamples {
162
162
t .Run (testcase .numString , func (t * testing.T ) {
163
- decNum , err := NewDecimalFromString (testcase .numString )
163
+ decNum , err := MakeDecimalFromString (testcase .numString )
164
164
if err != nil {
165
165
t .Fatal (err )
166
166
}
167
167
var buf []byte
168
- tuple := TupleDecimal {number : * decNum }
168
+ tuple := TupleDecimal {number : decNum }
169
169
if buf , err = msgpack .Marshal (& tuple ); err != nil {
170
170
t .Fatalf (
171
171
"Failed to msgpack.Encoder decimal number '%s' to a MessagePack buffer: %s" ,
@@ -270,7 +270,7 @@ func TestEncodeMaxNumber(t *testing.T) {
270
270
referenceErrMsg := "msgpack: decimal number is bigger than maximum " +
271
271
"supported number (10^38 - 1)"
272
272
decNum := decimal .New (1 , DecimalPrecision ) // // 10^DecimalPrecision
273
- tuple := TupleDecimal {number : * NewDecimal (decNum )}
273
+ tuple := TupleDecimal {number : MakeDecimal (decNum )}
274
274
_ , err := msgpack .Marshal (& tuple )
275
275
if err == nil {
276
276
t .Fatalf ("It is possible to msgpack.Encoder a number unsupported by Tarantool" )
@@ -285,7 +285,7 @@ func TestEncodeMinNumber(t *testing.T) {
285
285
"supported number (-10^38 - 1)"
286
286
two := decimal .NewFromInt (2 )
287
287
decNum := decimal .New (1 , DecimalPrecision ).Neg ().Sub (two ) // -10^DecimalPrecision - 2
288
- tuple := TupleDecimal {number : * NewDecimal (decNum )}
288
+ tuple := TupleDecimal {number : MakeDecimal (decNum )}
289
289
_ , err := msgpack .Marshal (& tuple )
290
290
if err == nil {
291
291
t .Fatalf ("It is possible to msgpack.Encoder a number unsupported by Tarantool" )
@@ -302,7 +302,7 @@ func benchmarkMPEncodeDecode(b *testing.B, src decimal.Decimal, dst interface{})
302
302
var buf []byte
303
303
var err error
304
304
for i := 0 ; i < b .N ; i ++ {
305
- tuple := TupleDecimal {number : * NewDecimal (src )}
305
+ tuple := TupleDecimal {number : MakeDecimal (src )}
306
306
if buf , err = msgpack .Marshal (& tuple ); err != nil {
307
307
b .Fatal (err )
308
308
}
@@ -327,13 +327,15 @@ func BenchmarkMPEncodeDecodeDecimal(b *testing.B) {
327
327
func BenchmarkMPEncodeDecimal (b * testing.B ) {
328
328
for _ , testcase := range benchmarkSamples {
329
329
b .Run (testcase .numString , func (b * testing.B ) {
330
- decNum , err := NewDecimalFromString (testcase .numString )
330
+ decNum , err := MakeDecimalFromString (testcase .numString )
331
331
if err != nil {
332
332
b .Fatal (err )
333
333
}
334
334
b .ResetTimer ()
335
335
for i := 0 ; i < b .N ; i ++ {
336
- msgpack .Marshal (decNum )
336
+ if _ , err := msgpack .Marshal (decNum ); err != nil {
337
+ b .Fatal (err )
338
+ }
337
339
}
338
340
})
339
341
}
@@ -342,20 +344,20 @@ func BenchmarkMPEncodeDecimal(b *testing.B) {
342
344
func BenchmarkMPDecodeDecimal (b * testing.B ) {
343
345
for _ , testcase := range benchmarkSamples {
344
346
b .Run (testcase .numString , func (b * testing.B ) {
345
- decNum , err := NewDecimalFromString (testcase .numString )
347
+ decNum , err := MakeDecimalFromString (testcase .numString )
346
348
if err != nil {
347
349
b .Fatal (err )
348
350
}
349
- var buf [] byte
350
- if buf , err = msgpack . Marshal ( decNum ); err != nil {
351
+ buf , err := msgpack . Marshal ( decNum )
352
+ if err != nil {
351
353
b .Fatal (err )
352
354
}
353
355
b .ResetTimer ()
354
- var v TupleDecimal
355
356
for i := 0 ; i < b .N ; i ++ {
356
- msgpack .Unmarshal (buf , & v )
357
+ if err := msgpack .Unmarshal (buf , & decNum ); err != nil {
358
+ b .Fatal (err )
359
+ }
357
360
}
358
-
359
361
})
360
362
}
361
363
}
@@ -371,7 +373,7 @@ func tupleValueIsDecimal(t *testing.T, tuples []interface{}, number decimal.Deci
371
373
if len (tpl ) != 1 {
372
374
t .Fatalf ("Unexpected return value body (tuple len)" )
373
375
}
374
- if val , ok := tpl [0 ].(* Decimal ); ! ok || ! val .Equal (number ) {
376
+ if val , ok := tpl [0 ].(Decimal ); ! ok || ! val .Equal (number ) {
375
377
t .Fatalf ("Unexpected return value body (tuple 0 field)" )
376
378
}
377
379
}
@@ -447,9 +449,9 @@ func TestMPEncode(t *testing.T) {
447
449
samples = append (samples , benchmarkSamples ... )
448
450
for _ , testcase := range samples {
449
451
t .Run (testcase .numString , func (t * testing.T ) {
450
- dec , err := NewDecimalFromString (testcase .numString )
452
+ dec , err := MakeDecimalFromString (testcase .numString )
451
453
if err != nil {
452
- t .Fatalf ("NewDecimalFromString () failed: %s" , err .Error ())
454
+ t .Fatalf ("MakeDecimalFromString () failed: %s" , err .Error ())
453
455
}
454
456
buf , err := msgpack .Marshal (dec )
455
457
if err != nil {
@@ -481,7 +483,7 @@ func TestMPDecode(t *testing.T) {
481
483
if err != nil {
482
484
t .Fatalf ("Unmsgpack.Marshalling failed: %s" , err .Error ())
483
485
}
484
- decActual , ok := v .(* Decimal )
486
+ decActual , ok := v .(Decimal )
485
487
if ! ok {
486
488
t .Fatalf ("Unable to convert to Decimal" )
487
489
}
@@ -532,7 +534,7 @@ func TestSelect(t *testing.T) {
532
534
t .Fatalf ("Failed to prepare test decimal: %s" , err )
533
535
}
534
536
535
- ins := NewInsertRequest (space ).Tuple ([]interface {}{NewDecimal (number )})
537
+ ins := NewInsertRequest (space ).Tuple ([]interface {}{MakeDecimal (number )})
536
538
resp , err := conn .Do (ins ).Get ()
537
539
if err != nil {
538
540
t .Fatalf ("Decimal insert failed: %s" , err )
@@ -549,7 +551,7 @@ func TestSelect(t *testing.T) {
549
551
Offset (offset ).
550
552
Limit (limit ).
551
553
Iterator (IterEq ).
552
- Key ([]interface {}{NewDecimal (number )})
554
+ Key ([]interface {}{MakeDecimal (number )})
553
555
resp , err = conn .Do (sel ).Get ()
554
556
if err != nil {
555
557
t .Fatalf ("Decimal select failed: %s" , err .Error ())
@@ -559,7 +561,7 @@ func TestSelect(t *testing.T) {
559
561
}
560
562
tupleValueIsDecimal (t , resp .Data , number )
561
563
562
- del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{NewDecimal (number )})
564
+ del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{MakeDecimal (number )})
563
565
resp , err = conn .Do (del ).Get ()
564
566
if err != nil {
565
567
t .Fatalf ("Decimal delete failed: %s" , err )
@@ -604,7 +606,7 @@ func assertInsert(t *testing.T, conn *Connection, numString string) {
604
606
t .Fatalf ("Failed to prepare test decimal: %s" , err )
605
607
}
606
608
607
- ins := NewInsertRequest (space ).Tuple ([]interface {}{NewDecimal (number )})
609
+ ins := NewInsertRequest (space ).Tuple ([]interface {}{MakeDecimal (number )})
608
610
resp , err := conn .Do (ins ).Get ()
609
611
if err != nil {
610
612
t .Fatalf ("Decimal insert failed: %s" , err )
@@ -614,7 +616,7 @@ func assertInsert(t *testing.T, conn *Connection, numString string) {
614
616
}
615
617
tupleValueIsDecimal (t , resp .Data , number )
616
618
617
- del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{NewDecimal (number )})
619
+ del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{MakeDecimal (number )})
618
620
resp , err = conn .Do (del ).Get ()
619
621
if err != nil {
620
622
t .Fatalf ("Decimal delete failed: %s" , err )
@@ -648,7 +650,7 @@ func TestReplace(t *testing.T) {
648
650
t .Fatalf ("Failed to prepare test decimal: %s" , err )
649
651
}
650
652
651
- rep := NewReplaceRequest (space ).Tuple ([]interface {}{NewDecimal (number )})
653
+ rep := NewReplaceRequest (space ).Tuple ([]interface {}{MakeDecimal (number )})
652
654
respRep , errRep := conn .Do (rep ).Get ()
653
655
if errRep != nil {
654
656
t .Fatalf ("Decimal replace failed: %s" , errRep )
@@ -662,7 +664,7 @@ func TestReplace(t *testing.T) {
662
664
Index (index ).
663
665
Limit (1 ).
664
666
Iterator (IterEq ).
665
- Key ([]interface {}{NewDecimal (number )})
667
+ Key ([]interface {}{MakeDecimal (number )})
666
668
respSel , errSel := conn .Do (sel ).Get ()
667
669
if errSel != nil {
668
670
t .Fatalf ("Decimal select failed: %s" , errSel )
0 commit comments