@@ -63,10 +63,10 @@ func (t *TupleDecimal) DecodeMsgpack(d *msgpack.Decoder) error {
6363 return err
6464 }
6565
66- if dec , ok := res .(* Decimal ); ! ok {
66+ if dec , ok := res .(Decimal ); ! ok {
6767 return fmt .Errorf ("decimal doesn't match" )
6868 } else {
69- t .number = * dec
69+ t .number = dec
7070 }
7171 return nil
7272}
@@ -143,12 +143,12 @@ var decimalSamples = []struct {
143143func TestMPEncodeDecode (t * testing.T ) {
144144 for _ , testcase := range benchmarkSamples {
145145 t .Run (testcase .numString , func (t * testing.T ) {
146- decNum , err := NewDecimalFromString (testcase .numString )
146+ decNum , err := MakeDecimalFromString (testcase .numString )
147147 if err != nil {
148148 t .Fatal (err )
149149 }
150150 var buf []byte
151- tuple := TupleDecimal {number : * decNum }
151+ tuple := TupleDecimal {number : decNum }
152152 if buf , err = msgpack .Marshal (& tuple ); err != nil {
153153 t .Fatalf ("Failed to msgpack.Encoder decimal number '%s' to a MessagePack buffer: %s" , testcase .numString , err )
154154 }
@@ -251,7 +251,7 @@ func TestEncodeStringToBCDIncorrectNumber(t *testing.T) {
251251func TestEncodeMaxNumber (t * testing.T ) {
252252 referenceErrMsg := "msgpack: decimal number is bigger than maximum supported number (10^38 - 1)"
253253 decNum := decimal .New (1 , DecimalPrecision ) // // 10^DecimalPrecision
254- tuple := TupleDecimal {number : * NewDecimal (decNum )}
254+ tuple := TupleDecimal {number : MakeDecimal (decNum )}
255255 _ , err := msgpack .Marshal (& tuple )
256256 if err == nil {
257257 t .Fatalf ("It is possible to msgpack.Encoder a number unsupported by Tarantool" )
@@ -265,7 +265,7 @@ func TestEncodeMinNumber(t *testing.T) {
265265 referenceErrMsg := "msgpack: decimal number is lesser than minimum supported number (-10^38 - 1)"
266266 two := decimal .NewFromInt (2 )
267267 decNum := decimal .New (1 , DecimalPrecision ).Neg ().Sub (two ) // -10^DecimalPrecision - 2
268- tuple := TupleDecimal {number : * NewDecimal (decNum )}
268+ tuple := TupleDecimal {number : MakeDecimal (decNum )}
269269 _ , err := msgpack .Marshal (& tuple )
270270 if err == nil {
271271 t .Fatalf ("It is possible to msgpack.Encoder a number unsupported by Tarantool" )
@@ -284,7 +284,7 @@ func benchmarkMPEncodeDecode(b *testing.B, src decimal.Decimal, dst interface{})
284284 var buf []byte
285285 var err error
286286 for i := 0 ; i < b .N ; i ++ {
287- tuple := TupleDecimal {number : * NewDecimal (src )}
287+ tuple := TupleDecimal {number : MakeDecimal (src )}
288288 if buf , err = msgpack .Marshal (& tuple ); err != nil {
289289 b .Fatal (err )
290290 }
@@ -309,13 +309,15 @@ func BenchmarkMPEncodeDecodeDecimal(b *testing.B) {
309309func BenchmarkMPEncodeDecimal (b * testing.B ) {
310310 for _ , testcase := range benchmarkSamples {
311311 b .Run (testcase .numString , func (b * testing.B ) {
312- decNum , err := NewDecimalFromString (testcase .numString )
312+ decNum , err := MakeDecimalFromString (testcase .numString )
313313 if err != nil {
314314 b .Fatal (err )
315315 }
316316 b .ResetTimer ()
317317 for i := 0 ; i < b .N ; i ++ {
318- msgpack .Marshal (decNum )
318+ if _ , err := msgpack .Marshal (decNum ); err != nil {
319+ b .Fatal (err )
320+ }
319321 }
320322 })
321323 }
@@ -324,20 +326,20 @@ func BenchmarkMPEncodeDecimal(b *testing.B) {
324326func BenchmarkMPDecodeDecimal (b * testing.B ) {
325327 for _ , testcase := range benchmarkSamples {
326328 b .Run (testcase .numString , func (b * testing.B ) {
327- decNum , err := NewDecimalFromString (testcase .numString )
329+ decNum , err := MakeDecimalFromString (testcase .numString )
328330 if err != nil {
329331 b .Fatal (err )
330332 }
331- var buf [] byte
332- if buf , err = msgpack . Marshal ( decNum ); err != nil {
333+ buf , err := msgpack . Marshal ( decNum )
334+ if err != nil {
333335 b .Fatal (err )
334336 }
335337 b .ResetTimer ()
336- var v TupleDecimal
337338 for i := 0 ; i < b .N ; i ++ {
338- msgpack .Unmarshal (buf , & v )
339+ if err := msgpack .Unmarshal (buf , & decNum ); err != nil {
340+ b .Fatal (err )
341+ }
339342 }
340-
341343 })
342344 }
343345}
@@ -353,7 +355,7 @@ func tupleValueIsDecimal(t *testing.T, tuples []interface{}, number decimal.Deci
353355 if len (tpl ) != 1 {
354356 t .Fatalf ("Unexpected return value body (tuple len)" )
355357 }
356- if val , ok := tpl [0 ].(* Decimal ); ! ok || ! val .Equal (number ) {
358+ if val , ok := tpl [0 ].(Decimal ); ! ok || ! val .Equal (number ) {
357359 t .Fatalf ("Unexpected return value body (tuple 0 field)" )
358360 }
359361 }
@@ -418,9 +420,9 @@ func TestMPEncode(t *testing.T) {
418420 samples = append (samples , benchmarkSamples ... )
419421 for _ , testcase := range samples {
420422 t .Run (testcase .numString , func (t * testing.T ) {
421- dec , err := NewDecimalFromString (testcase .numString )
423+ dec , err := MakeDecimalFromString (testcase .numString )
422424 if err != nil {
423- t .Fatalf ("NewDecimalFromString () failed: %s" , err .Error ())
425+ t .Fatalf ("MakeDecimalFromString () failed: %s" , err .Error ())
424426 }
425427 buf , err := msgpack .Marshal (dec )
426428 if err != nil {
@@ -451,7 +453,7 @@ func TestMPDecode(t *testing.T) {
451453 if err != nil {
452454 t .Fatalf ("Unmsgpack.Marshalling failed: %s" , err .Error ())
453455 }
454- decActual , ok := v .(* Decimal )
456+ decActual , ok := v .(Decimal )
455457 if ! ok {
456458 t .Fatalf ("Unable to convert to Decimal" )
457459 }
@@ -502,7 +504,7 @@ func TestSelect(t *testing.T) {
502504 t .Fatalf ("Failed to prepare test decimal: %s" , err )
503505 }
504506
505- ins := NewInsertRequest (space ).Tuple ([]interface {}{NewDecimal (number )})
507+ ins := NewInsertRequest (space ).Tuple ([]interface {}{MakeDecimal (number )})
506508 resp , err := conn .Do (ins ).Get ()
507509 if err != nil {
508510 t .Fatalf ("Decimal insert failed: %s" , err )
@@ -519,7 +521,7 @@ func TestSelect(t *testing.T) {
519521 Offset (offset ).
520522 Limit (limit ).
521523 Iterator (IterEq ).
522- Key ([]interface {}{NewDecimal (number )})
524+ Key ([]interface {}{MakeDecimal (number )})
523525 resp , err = conn .Do (sel ).Get ()
524526 if err != nil {
525527 t .Fatalf ("Decimal select failed: %s" , err .Error ())
@@ -529,7 +531,7 @@ func TestSelect(t *testing.T) {
529531 }
530532 tupleValueIsDecimal (t , resp .Data , number )
531533
532- del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{NewDecimal (number )})
534+ del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{MakeDecimal (number )})
533535 resp , err = conn .Do (del ).Get ()
534536 if err != nil {
535537 t .Fatalf ("Decimal delete failed: %s" , err )
@@ -543,7 +545,7 @@ func assertInsert(t *testing.T, conn *Connection, numString string) {
543545 t .Fatalf ("Failed to prepare test decimal: %s" , err )
544546 }
545547
546- ins := NewInsertRequest (space ).Tuple ([]interface {}{NewDecimal (number )})
548+ ins := NewInsertRequest (space ).Tuple ([]interface {}{MakeDecimal (number )})
547549 resp , err := conn .Do (ins ).Get ()
548550 if err != nil {
549551 t .Fatalf ("Decimal insert failed: %s" , err )
@@ -553,7 +555,7 @@ func assertInsert(t *testing.T, conn *Connection, numString string) {
553555 }
554556 tupleValueIsDecimal (t , resp .Data , number )
555557
556- del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{NewDecimal (number )})
558+ del := NewDeleteRequest (space ).Index (index ).Key ([]interface {}{MakeDecimal (number )})
557559 resp , err = conn .Do (del ).Get ()
558560 if err != nil {
559561 t .Fatalf ("Decimal delete failed: %s" , err )
@@ -586,7 +588,7 @@ func TestReplace(t *testing.T) {
586588 t .Fatalf ("Failed to prepare test decimal: %s" , err )
587589 }
588590
589- rep := NewReplaceRequest (space ).Tuple ([]interface {}{NewDecimal (number )})
591+ rep := NewReplaceRequest (space ).Tuple ([]interface {}{MakeDecimal (number )})
590592 respRep , errRep := conn .Do (rep ).Get ()
591593 if errRep != nil {
592594 t .Fatalf ("Decimal replace failed: %s" , errRep )
@@ -600,7 +602,7 @@ func TestReplace(t *testing.T) {
600602 Index (index ).
601603 Limit (1 ).
602604 Iterator (IterEq ).
603- Key ([]interface {}{NewDecimal (number )})
605+ Key ([]interface {}{MakeDecimal (number )})
604606 respSel , errSel := conn .Do (sel ).Get ()
605607 if errSel != nil {
606608 t .Fatalf ("Decimal select failed: %s" , errSel )
0 commit comments