Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Георгий Кириченко" <georgy@tarantool.org>
To: Serge Petrenko <sergepetrenko@tarantool.org>
Cc: vdavydov.dev@gmail.com, tarantool-patches@freelists.org,
	kostja@tarantool.org
Subject: Re: [PATCH v3 4/4] decimal: add MessagePack encoding/decoding support
Date: Wed, 05 Jun 2019 11:20:02 +0300	[thread overview]
Message-ID: <1950115.Z54sOVnjKB@localhost> (raw)
In-Reply-To: <eecbfaa3676f0e63200e53bb5be69341133f53b4.1559663794.git.sergepetrenko@tarantool.org>

[-- Attachment #1: Type: text/plain, Size: 22671 bytes --]

LGTM, but I would like to postpone this commit until we would be able to 
process decimals in lua. I'm not sure what would happen if lua faced this in a 
msgpuck/tuple.

Thanks!

On Tuesday, June 4, 2019 7:04:19 PM MSK Serge Petrenko wrote:
> Add methods to encode/decode decimals as msgpack.
> 
> Part of #692
> ---
>  cmake/BuildDecNumber.cmake   |   1 +
>  src/lib/core/decimal.c       |  64 +++++++++++
>  src/lib/core/decimal.h       |  38 +++++++
>  src/lib/core/mp_user_types.h |  38 +++++++
>  test/unit/decimal.c          |  73 ++++++++++++-
>  test/unit/decimal.result     | 204 ++++++++++++++++++++++++++++++++++-
>  6 files changed, 416 insertions(+), 2 deletions(-)
>  create mode 100644 src/lib/core/mp_user_types.h
> 
> diff --git a/cmake/BuildDecNumber.cmake b/cmake/BuildDecNumber.cmake
> index 80942fe05..abc6c64c4 100644
> --- a/cmake/BuildDecNumber.cmake
> +++ b/cmake/BuildDecNumber.cmake
> @@ -4,6 +4,7 @@ macro(decnumber_build)
>      set(decnumber_src
>  	${PROJECT_SOURCE_DIR}/third_party/decNumber/decNumber.c
>  	${PROJECT_SOURCE_DIR}/third_party/decNumber/decContext.c
> +	${PROJECT_SOURCE_DIR}/third_party/decNumber/decPacked.c
>      )
> 
>      add_library(decNumber STATIC ${decnumber_src})
> diff --git a/src/lib/core/decimal.c b/src/lib/core/decimal.c
> index 12250da95..7b3b1d8c9 100644
> --- a/src/lib/core/decimal.c
> +++ b/src/lib/core/decimal.c
> @@ -30,7 +30,10 @@
>   */
> 
>  #include "decimal.h"
> +#include "mp_user_types.h"
> +#include "src/lib/msgpuck/msgpuck.h"
>  #include "third_party/decNumber/decContext.h"
> +#include "third_party/decNumber/decPacked.h"
>  #include <stdlib.h>
>  #include <assert.h>
> 
> @@ -291,3 +294,64 @@ decimal_sqrt(decimal *res, const decimal *lhs, uint32_t
> precision)
> 
>  	return decimal_finalize(res, &op_context);
>  }
> +
> +static inline uint32_t
> +decimal_len(decimal *dec)
> +{
> +	       /* 1 + ceil((digits + 1) / 2) */
> +	return 2 + dec->digits / 2;
> +}
> +
> +uint32_t
> +mp_sizeof_decimal(decimal *dec) {
> +	uint32_t l = decimal_len(dec);
> +	return mp_sizeof_extl(l) + l;
> +}
> +
> +char *
> +mp_encode_decimal(char *data, decimal *dec)
> +{
> +	uint32_t len = decimal_len(dec);
> +	data = mp_encode_extl(data, MP_DECIMAL, len);
> +	data = mp_store_u8(data, decimal_scale(dec));
> +	len--;
> +	int32_t scale;
> +	char *tmp = (char *)decPackedFromNumber((uint8_t *)data, len, 
&scale,
> dec); +	assert(tmp == data);
> +	assert(scale == (int32_t)decimal_scale(dec));
> +	data += len;
> +	return data;
> +}
> +
> +decimal *
> +mp_decode_decimal_raw(const char **data, decimal *dec, uint32_t len)
> +{
> +	int32_t scale = mp_load_u8(data);
> +	len--;
> +	decimal *res = decPackedToNumber((uint8_t *)*data, len, &scale, 
dec);
> +	if (res)
> +		*data += len;
> +	else
> +		(*data)--;
> +	return res;
> +}
> +
> +decimal *
> +mp_decode_decimal(const char **data, decimal *dec)
> +{
> +	int8_t type;
> +	uint32_t len;
> +
> +	if (mp_typeof(**data) != MP_EXT)
> +		return NULL;
> +	const char *const svp = *data;
> +	len = mp_decode_extl(data, &type);
> +
> +	if (type != MP_DECIMAL || len == 0)
> +		return NULL;
> +	decimal *res = mp_decode_decimal_raw(data, dec, len);
> +	if (!res) {
> +		*data = svp;
> +	}
> +	return res;
> +}
> diff --git a/src/lib/core/decimal.h b/src/lib/core/decimal.h
> index f2812f500..cfcc98073 100644
> --- a/src/lib/core/decimal.h
> +++ b/src/lib/core/decimal.h
> @@ -156,4 +156,42 @@ decimal_exp(decimal *res, const decimal *lhs, uint32_t
> precision); decimal *
>  decimal_sqrt(decimal *res, const decimal *lhs, uint32_t precision);
> 
> +
> +/**
> + * Return length of message pack encoded decimal with extension header.
> + * Equivalent to mp_sizeof_ext(decimal representation length)
> + */
> +uint32_t
> +mp_sizeof_decimal(decimal *dec);
> +
> +/**
> + * Encode a decimal value to msgpack.
> + *
> + * @return data + mp_sizeof_decimal(dec)
> + */
> +char *
> +mp_encode_decimal(char *data, decimal *dec);
> +
> +/**
> + * Decode a decimal value as though msgpack
> + * ext header was already decoded.
> + *
> + * \post *data = *data + value representation length
> + * @return NULL if value encoding is incorrect
> + *	    dec  otherwise.
> + */
> +decimal *
> +mp_decode_decimal_raw(const char **data, decimal *dec, uint32_t len);
> +
> +/**
> + * Decode a decimal encoded as msgpack with ext header.
> + *
> + * \post *data = *data + mp_sizeof_decimal(dec)
> + * @return NULL if mp_typeof(**data) != MP_EXT
> + *		   or value encoding is incorrect
> + *	   dec  otherwise.
> + */
> +decimal *
> +mp_decode_decimal(const char **data, decimal *dec);
> +
>  #endif /* TARANTOOL_LIB_CORE_DECIMAL_H_INCLUDED */
> diff --git a/src/lib/core/mp_user_types.h b/src/lib/core/mp_user_types.h
> new file mode 100644
> index 000000000..d5694a386
> --- /dev/null
> +++ b/src/lib/core/mp_user_types.h
> @@ -0,0 +1,38 @@
> +#ifndef TARANTOOL_LIB_CORE_MP_USER_TYPES_H_INCLUDED
> +#define TARANTOOL_LIB_CORE_MP_USER_TYPES_H_INCLUDED
> +/*
> + * Copyright 2019, Tarantool AUTHORS, please see AUTHORS file.
> + *
> + * Redistribution and use in source and binary forms, with or
> + * without modification, are permitted provided that the following
> + * conditions are met:
> + *
> + * 1. Redistributions of source code must retain the above
> + *    copyright notice, this list of conditions and the
> + *    following disclaimer.
> + *
> + * 2. Redistributions in binary form must reproduce the above
> + *    copyright notice, this list of conditions and the following
> + *    disclaimer in the documentation and/or other materials
> + *    provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
> + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
> + * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
> + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +enum mp_user_type {
> +    MP_DECIMAL = 0
> +};
> +
> +#endif /* TARANTOOL_LIB_CORE_MP_USER_TYPES_H_INCLUDED */
> diff --git a/test/unit/decimal.c b/test/unit/decimal.c
> index adfbead91..1f4c9f385 100644
> --- a/test/unit/decimal.c
> +++ b/test/unit/decimal.c
> @@ -1,12 +1,81 @@
>  #include "unit.h"
>  #include "decimal.h"
> +#include "msgpuck.h"
> +#include "mp_user_types.h"
> +
>  #include <limits.h>
>  #include <string.h>
> 
> +char buf[32];
> +char buf2[TARANTOOL_MAX_DECIMAL_DIGITS + 3];
> +
> +#define test_mpdec(_str) ({  \
> +	decimal dec;\
> +	decimal_from_string(&dec, _str);\
> +	uint32_t l1 = mp_sizeof_decimal(&dec);\
> +	ok(l1 <= 25 && l1 >= 4, "mp_sizeof_decimal(%s)", _str);\
> +	char *b1 = mp_encode_decimal(buf, &dec);\
> +	is(b1, buf + l1, "mp_sizeof_decimal(%s) == 
len(mp_encode_decimal(%s)))",
> _str, _str);\ +	const char *b2 = buf;\
> +	const char *b3 = buf;\
> +	decimal d2;\
> +	mp_next(&b3);\
> +	is(b3, b1, "mp_next(mp_encode(%s))", _str);\
> +	mp_decode_decimal(&b2, &d2);\
> +	is(b1, b2, "mp_decode(mp_encode(%s)) len", _str);\
> +	is(decimal_compare(&dec, &d2), 0, "mp_decode(mp_encode(%s)) value",
> _str);\ +	is(decimal_scale(&dec), decimal_scale(&d2),
> "mp_decode(mp_encode(%s)) scale", _str);\ +	decimal_to_string(&d2, 
buf2);\
> +	is(strcmp(buf2, _str), 0, "str(mp_decode(mp_encode())) == %s", 
_str);\
> +	b2 = buf;\
> +	int8_t type;\
> +	uint32_t l2 = mp_decode_extl(&b2, &type);\
> +	is(type, MP_DECIMAL, "mp_ext_type is MP_DECIMAL");\
> +	ok(&d2 == mp_decode_decimal_raw(&b2, &d2, l2),
> "mp_decode_decimal_raw()");\ +	is(decimal_compare(&dec, &d2), 0,
> "mp_decode_decimal_raw() is correct");\ +	is(b2, buf + l1, 
"mp_decode_extl
> + mp_decode_decimal_raw len");\ +})
> +
> +static int
> +test_encode_decode(void)
> +{
> +	plan(200);
> +	test_mpdec("0");
> +	test_mpdec("-0");
> +	test_mpdec("1");
> +	test_mpdec("-1");
> +	test_mpdec("0.1");
> +	test_mpdec("-0.1");
> +	test_mpdec("2.718281828459045");
> +	test_mpdec("-2.718281828459045");
> +	test_mpdec("3.141592653589793");
> +	test_mpdec("-3.141592653589793");
> +	test_mpdec("1234567891234567890.0987654321987654321");
> +	test_mpdec("-1234567891234567890.0987654321987654321");
> +	test_mpdec("0.0000000000000000000000000000000000001");
> +	test_mpdec("-0.0000000000000000000000000000000000001");
> +	test_mpdec("0.00000000000000000000000000000000000001");
> +	test_mpdec("-0.00000000000000000000000000000000000001");
> +	test_mpdec("99999999999999999999999999999999999999");
> +	test_mpdec("-99999999999999999999999999999999999999");
> +
> +	/* Encode an invalid decimal. */
> +	char *b = mp_encode_extl(buf, MP_DECIMAL, 2);
> +	b = mp_store_u8(b, 1);
> +	*b++ = '\xab';
> +	*b++ = '\xcd';
> +	const char *bb = buf;
> +	decimal dec;
> +	is(mp_decode_decimal(&bb, &dec), NULL, "decode malformed decimal 
fails");
> +	is (bb, buf, "decode malformed decimal saves buffer position");
> +
> +	return check_plan();
> +}
> +
>  int
>  main(void)
>  {
> -	plan(50);
> +	plan(51);
> 
>  	char buf[TARANTOOL_MAX_DECIMAL_DIGITS + 3];
>  	char buf2[TARANTOOL_MAX_DECIMAL_DIGITS + 3];
> @@ -164,5 +233,7 @@ main(void)
>  	is(decimal_precision(&s), 38, "Correct precision");
>  	is(decimal_scale(&s), 38, "Correct scale");
> 
> +	test_encode_decode();
> +
>  	check_plan();
>  }
> diff --git a/test/unit/decimal.result b/test/unit/decimal.result
> index 02bee118a..da34aa0fd 100644
> --- a/test/unit/decimal.result
> +++ b/test/unit/decimal.result
> @@ -1,4 +1,4 @@
> -1..50
> +1..51
>  ok 1 - Basic construction from string.
>  ok 2 - Correct construction and to_string conversion.
>  ok 3 - Correct construction from INT_MAX.
> @@ -49,3 +49,205 @@ ok 47 - Rounding too small number to zero
>  ok 48 - Rounding is correct
>  ok 49 - Correct precision
>  ok 50 - Correct scale
> +    1..200
> +    ok 1 - mp_sizeof_decimal(0)
> +    ok 2 - mp_sizeof_decimal(0) == len(mp_encode_decimal(0)))
> +    ok 3 - mp_next(mp_encode(0))
> +    ok 4 - mp_decode(mp_encode(0)) len
> +    ok 5 - mp_decode(mp_encode(0)) value
> +    ok 6 - mp_decode(mp_encode(0)) scale
> +    ok 7 - str(mp_decode(mp_encode())) == 0
> +    ok 8 - mp_ext_type is MP_DECIMAL
> +    ok 9 - mp_decode_decimal_raw()
> +    ok 10 - mp_decode_decimal_raw() is correct
> +    ok 11 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 12 - mp_sizeof_decimal(-0)
> +    ok 13 - mp_sizeof_decimal(-0) == len(mp_encode_decimal(-0)))
> +    ok 14 - mp_next(mp_encode(-0))
> +    ok 15 - mp_decode(mp_encode(-0)) len
> +    ok 16 - mp_decode(mp_encode(-0)) value
> +    ok 17 - mp_decode(mp_encode(-0)) scale
> +    ok 18 - str(mp_decode(mp_encode())) == -0
> +    ok 19 - mp_ext_type is MP_DECIMAL
> +    ok 20 - mp_decode_decimal_raw()
> +    ok 21 - mp_decode_decimal_raw() is correct
> +    ok 22 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 23 - mp_sizeof_decimal(1)
> +    ok 24 - mp_sizeof_decimal(1) == len(mp_encode_decimal(1)))
> +    ok 25 - mp_next(mp_encode(1))
> +    ok 26 - mp_decode(mp_encode(1)) len
> +    ok 27 - mp_decode(mp_encode(1)) value
> +    ok 28 - mp_decode(mp_encode(1)) scale
> +    ok 29 - str(mp_decode(mp_encode())) == 1
> +    ok 30 - mp_ext_type is MP_DECIMAL
> +    ok 31 - mp_decode_decimal_raw()
> +    ok 32 - mp_decode_decimal_raw() is correct
> +    ok 33 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 34 - mp_sizeof_decimal(-1)
> +    ok 35 - mp_sizeof_decimal(-1) == len(mp_encode_decimal(-1)))
> +    ok 36 - mp_next(mp_encode(-1))
> +    ok 37 - mp_decode(mp_encode(-1)) len
> +    ok 38 - mp_decode(mp_encode(-1)) value
> +    ok 39 - mp_decode(mp_encode(-1)) scale
> +    ok 40 - str(mp_decode(mp_encode())) == -1
> +    ok 41 - mp_ext_type is MP_DECIMAL
> +    ok 42 - mp_decode_decimal_raw()
> +    ok 43 - mp_decode_decimal_raw() is correct
> +    ok 44 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 45 - mp_sizeof_decimal(0.1)
> +    ok 46 - mp_sizeof_decimal(0.1) == len(mp_encode_decimal(0.1)))
> +    ok 47 - mp_next(mp_encode(0.1))
> +    ok 48 - mp_decode(mp_encode(0.1)) len
> +    ok 49 - mp_decode(mp_encode(0.1)) value
> +    ok 50 - mp_decode(mp_encode(0.1)) scale
> +    ok 51 - str(mp_decode(mp_encode())) == 0.1
> +    ok 52 - mp_ext_type is MP_DECIMAL
> +    ok 53 - mp_decode_decimal_raw()
> +    ok 54 - mp_decode_decimal_raw() is correct
> +    ok 55 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 56 - mp_sizeof_decimal(-0.1)
> +    ok 57 - mp_sizeof_decimal(-0.1) == len(mp_encode_decimal(-0.1)))
> +    ok 58 - mp_next(mp_encode(-0.1))
> +    ok 59 - mp_decode(mp_encode(-0.1)) len
> +    ok 60 - mp_decode(mp_encode(-0.1)) value
> +    ok 61 - mp_decode(mp_encode(-0.1)) scale
> +    ok 62 - str(mp_decode(mp_encode())) == -0.1
> +    ok 63 - mp_ext_type is MP_DECIMAL
> +    ok 64 - mp_decode_decimal_raw()
> +    ok 65 - mp_decode_decimal_raw() is correct
> +    ok 66 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 67 - mp_sizeof_decimal(2.718281828459045)
> +    ok 68 - mp_sizeof_decimal(2.718281828459045) ==
> len(mp_encode_decimal(2.718281828459045))) +    ok 69 -
> mp_next(mp_encode(2.718281828459045))
> +    ok 70 - mp_decode(mp_encode(2.718281828459045)) len
> +    ok 71 - mp_decode(mp_encode(2.718281828459045)) value
> +    ok 72 - mp_decode(mp_encode(2.718281828459045)) scale
> +    ok 73 - str(mp_decode(mp_encode())) == 2.718281828459045
> +    ok 74 - mp_ext_type is MP_DECIMAL
> +    ok 75 - mp_decode_decimal_raw()
> +    ok 76 - mp_decode_decimal_raw() is correct
> +    ok 77 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 78 - mp_sizeof_decimal(-2.718281828459045)
> +    ok 79 - mp_sizeof_decimal(-2.718281828459045) ==
> len(mp_encode_decimal(-2.718281828459045))) +    ok 80 -
> mp_next(mp_encode(-2.718281828459045))
> +    ok 81 - mp_decode(mp_encode(-2.718281828459045)) len
> +    ok 82 - mp_decode(mp_encode(-2.718281828459045)) value
> +    ok 83 - mp_decode(mp_encode(-2.718281828459045)) scale
> +    ok 84 - str(mp_decode(mp_encode())) == -2.718281828459045
> +    ok 85 - mp_ext_type is MP_DECIMAL
> +    ok 86 - mp_decode_decimal_raw()
> +    ok 87 - mp_decode_decimal_raw() is correct
> +    ok 88 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 89 - mp_sizeof_decimal(3.141592653589793)
> +    ok 90 - mp_sizeof_decimal(3.141592653589793) ==
> len(mp_encode_decimal(3.141592653589793))) +    ok 91 -
> mp_next(mp_encode(3.141592653589793))
> +    ok 92 - mp_decode(mp_encode(3.141592653589793)) len
> +    ok 93 - mp_decode(mp_encode(3.141592653589793)) value
> +    ok 94 - mp_decode(mp_encode(3.141592653589793)) scale
> +    ok 95 - str(mp_decode(mp_encode())) == 3.141592653589793
> +    ok 96 - mp_ext_type is MP_DECIMAL
> +    ok 97 - mp_decode_decimal_raw()
> +    ok 98 - mp_decode_decimal_raw() is correct
> +    ok 99 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 100 - mp_sizeof_decimal(-3.141592653589793)
> +    ok 101 - mp_sizeof_decimal(-3.141592653589793) ==
> len(mp_encode_decimal(-3.141592653589793))) +    ok 102 -
> mp_next(mp_encode(-3.141592653589793))
> +    ok 103 - mp_decode(mp_encode(-3.141592653589793)) len
> +    ok 104 - mp_decode(mp_encode(-3.141592653589793)) value
> +    ok 105 - mp_decode(mp_encode(-3.141592653589793)) scale
> +    ok 106 - str(mp_decode(mp_encode())) == -3.141592653589793
> +    ok 107 - mp_ext_type is MP_DECIMAL
> +    ok 108 - mp_decode_decimal_raw()
> +    ok 109 - mp_decode_decimal_raw() is correct
> +    ok 110 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 111 - mp_sizeof_decimal(1234567891234567890.0987654321987654321)
> +    ok 112 - mp_sizeof_decimal(1234567891234567890.0987654321987654321) ==
> len(mp_encode_decimal(1234567891234567890.0987654321987654321))) +    ok
> 113 - mp_next(mp_encode(1234567891234567890.0987654321987654321)) +    ok
> 114 - mp_decode(mp_encode(1234567891234567890.0987654321987654321)) len +  
>  ok 115 - mp_decode(mp_encode(1234567891234567890.0987654321987654321))
> value +    ok 116 -
> mp_decode(mp_encode(1234567891234567890.0987654321987654321)) scale +    ok
> 117 - str(mp_decode(mp_encode())) ==
> 1234567891234567890.0987654321987654321 +    ok 118 - mp_ext_type is
> MP_DECIMAL
> +    ok 119 - mp_decode_decimal_raw()
> +    ok 120 - mp_decode_decimal_raw() is correct
> +    ok 121 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 122 - mp_sizeof_decimal(-1234567891234567890.0987654321987654321)
> +    ok 123 - mp_sizeof_decimal(-1234567891234567890.0987654321987654321) ==
> len(mp_encode_decimal(-1234567891234567890.0987654321987654321))) +    ok
> 124 - mp_next(mp_encode(-1234567891234567890.0987654321987654321)) +    ok
> 125 - mp_decode(mp_encode(-1234567891234567890.0987654321987654321)) len + 
>   ok 126 - mp_decode(mp_encode(-1234567891234567890.0987654321987654321))
> value +    ok 127 -
> mp_decode(mp_encode(-1234567891234567890.0987654321987654321)) scale +   
> ok 128 - str(mp_decode(mp_encode())) ==
> -1234567891234567890.0987654321987654321 +    ok 129 - mp_ext_type is
> MP_DECIMAL
> +    ok 130 - mp_decode_decimal_raw()
> +    ok 131 - mp_decode_decimal_raw() is correct
> +    ok 132 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 133 - mp_sizeof_decimal(0.0000000000000000000000000000000000001)
> +    ok 134 - mp_sizeof_decimal(0.0000000000000000000000000000000000001) ==
> len(mp_encode_decimal(0.0000000000000000000000000000000000001))) +    ok
> 135 - mp_next(mp_encode(0.0000000000000000000000000000000000001)) +    ok
> 136 - mp_decode(mp_encode(0.0000000000000000000000000000000000001)) len +  
>  ok 137 - mp_decode(mp_encode(0.0000000000000000000000000000000000001))
> value +    ok 138 -
> mp_decode(mp_encode(0.0000000000000000000000000000000000001)) scale +    ok
> 139 - str(mp_decode(mp_encode())) ==
> 0.0000000000000000000000000000000000001 +    ok 140 - mp_ext_type is
> MP_DECIMAL
> +    ok 141 - mp_decode_decimal_raw()
> +    ok 142 - mp_decode_decimal_raw() is correct
> +    ok 143 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 144 - mp_sizeof_decimal(-0.0000000000000000000000000000000000001)
> +    ok 145 - mp_sizeof_decimal(-0.0000000000000000000000000000000000001) ==
> len(mp_encode_decimal(-0.0000000000000000000000000000000000001))) +    ok
> 146 - mp_next(mp_encode(-0.0000000000000000000000000000000000001)) +    ok
> 147 - mp_decode(mp_encode(-0.0000000000000000000000000000000000001)) len + 
>   ok 148 - mp_decode(mp_encode(-0.0000000000000000000000000000000000001))
> value +    ok 149 -
> mp_decode(mp_encode(-0.0000000000000000000000000000000000001)) scale +   
> ok 150 - str(mp_decode(mp_encode())) ==
> -0.0000000000000000000000000000000000001 +    ok 151 - mp_ext_type is
> MP_DECIMAL
> +    ok 152 - mp_decode_decimal_raw()
> +    ok 153 - mp_decode_decimal_raw() is correct
> +    ok 154 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 155 - mp_sizeof_decimal(0.00000000000000000000000000000000000001)
> +    ok 156 - mp_sizeof_decimal(0.00000000000000000000000000000000000001) ==
> len(mp_encode_decimal(0.00000000000000000000000000000000000001))) +    ok
> 157 - mp_next(mp_encode(0.00000000000000000000000000000000000001)) +    ok
> 158 - mp_decode(mp_encode(0.00000000000000000000000000000000000001)) len + 
>   ok 159 - mp_decode(mp_encode(0.00000000000000000000000000000000000001))
> value +    ok 160 -
> mp_decode(mp_encode(0.00000000000000000000000000000000000001)) scale +   
> ok 161 - str(mp_decode(mp_encode())) ==
> 0.00000000000000000000000000000000000001 +    ok 162 - mp_ext_type is
> MP_DECIMAL
> +    ok 163 - mp_decode_decimal_raw()
> +    ok 164 - mp_decode_decimal_raw() is correct
> +    ok 165 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 166 - mp_sizeof_decimal(-0.00000000000000000000000000000000000001)
> +    ok 167 - mp_sizeof_decimal(-0.00000000000000000000000000000000000001)
> == len(mp_encode_decimal(-0.00000000000000000000000000000000000001))) +   
> ok 168 - mp_next(mp_encode(-0.00000000000000000000000000000000000001)) +   
> ok 169 - mp_decode(mp_encode(-0.00000000000000000000000000000000000001))
> len +    ok 170 -
> mp_decode(mp_encode(-0.00000000000000000000000000000000000001)) value +   
> ok 171 - mp_decode(mp_encode(-0.00000000000000000000000000000000000001))
> scale +    ok 172 - str(mp_decode(mp_encode())) ==
> -0.00000000000000000000000000000000000001 +    ok 173 - mp_ext_type is
> MP_DECIMAL
> +    ok 174 - mp_decode_decimal_raw()
> +    ok 175 - mp_decode_decimal_raw() is correct
> +    ok 176 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 177 - mp_sizeof_decimal(99999999999999999999999999999999999999)
> +    ok 178 - mp_sizeof_decimal(99999999999999999999999999999999999999) ==
> len(mp_encode_decimal(99999999999999999999999999999999999999))) +    ok 179
> - mp_next(mp_encode(99999999999999999999999999999999999999)) +    ok 180 -
> mp_decode(mp_encode(99999999999999999999999999999999999999)) len +    ok
> 181 - mp_decode(mp_encode(99999999999999999999999999999999999999)) value + 
>   ok 182 - mp_decode(mp_encode(99999999999999999999999999999999999999))
> scale +    ok 183 - str(mp_decode(mp_encode())) ==
> 99999999999999999999999999999999999999 +    ok 184 - mp_ext_type is
> MP_DECIMAL
> +    ok 185 - mp_decode_decimal_raw()
> +    ok 186 - mp_decode_decimal_raw() is correct
> +    ok 187 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 188 - mp_sizeof_decimal(-99999999999999999999999999999999999999)
> +    ok 189 - mp_sizeof_decimal(-99999999999999999999999999999999999999) ==
> len(mp_encode_decimal(-99999999999999999999999999999999999999))) +    ok
> 190 - mp_next(mp_encode(-99999999999999999999999999999999999999)) +    ok
> 191 - mp_decode(mp_encode(-99999999999999999999999999999999999999)) len +  
>  ok 192 - mp_decode(mp_encode(-99999999999999999999999999999999999999))
> value +    ok 193 -
> mp_decode(mp_encode(-99999999999999999999999999999999999999)) scale +    ok
> 194 - str(mp_decode(mp_encode())) ==
> -99999999999999999999999999999999999999 +    ok 195 - mp_ext_type is
> MP_DECIMAL
> +    ok 196 - mp_decode_decimal_raw()
> +    ok 197 - mp_decode_decimal_raw() is correct
> +    ok 198 - mp_decode_extl + mp_decode_decimal_raw len
> +    ok 199 - decode malformed decimal fails
> +    ok 200 - decode malformed decimal saves buffer position
> +ok 51 - subtests


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-06-05  8:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 16:04 [PATCH v3 0/4] Introduce decimal type to tarantool core Serge Petrenko
2019-06-04 16:04 ` [PATCH v3 1/4] third-party: add decNumber library Serge Petrenko
2019-06-05  8:04   ` Георгий Кириченко
2019-06-04 16:04 ` [PATCH v3 2/4] lib/core: introduce decimal type to tarantool Serge Petrenko
2019-06-05  8:11   ` Георгий Кириченко
2019-06-05 10:03     ` Serge Petrenko
2019-06-05 12:19   ` Vladimir Davydov
2019-06-11 16:14     ` [tarantool-patches] " Serge Petrenko
2019-06-04 16:04 ` [PATCH v3 3/4] lib: update msgpuck library Serge Petrenko
2019-06-04 16:04 ` [PATCH v3 4/4] decimal: add MessagePack encoding/decoding support Serge Petrenko
2019-06-05  8:20   ` Георгий Кириченко [this message]
2019-06-05 12:40   ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1950115.Z54sOVnjKB@localhost \
    --to=georgy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH v3 4/4] decimal: add MessagePack encoding/decoding support' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox