From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Timur Safin <tsafin@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 2.X v3 1/3] module api: export box_tuple_validate
Date: Tue, 13 Oct 2020 03:14:36 +0300 [thread overview]
Message-ID: <20201013001436.3h5rkyf2t3giasx7@tkn_work_nb> (raw)
In-Reply-To: <0b974732d5f63fcf820ae432d88ce349addea5ec.1602463103.git.tsafin@tarantool.org>
> +int
> +box_tuple_validate(box_tuple_t *tuple, box_tuple_format_t *format)
> +{
> + return tuple_validate_raw(format, tuple_data(tuple));
> +}
> +
I would invoke tuple_validate() here.
> +static int
> +test_tuple_validate(lua_State *L)
> +{
> + int valid = 0;
> + box_tuple_t *tuple = luaT_istuple(L, -1);
> +
> + if (tuple != NULL) {
> + box_tuple_format_t *format = box_tuple_format_default();
> + valid = box_tuple_validate(tuple, format) == 0;
> + }
Tab / spaces mix.
All tuples are valid against the runtime (default) format. For the sake
of minimal testing I would create a format with at least one specified
field and check a tuple that is valid and one that is invalid. You can
use box_tuple_format_new() to create a format, see example in
test_key_def_api().
> +local function test_tuples(test, module)
> + test:plan(8)
> +
> + local nottuple1 = {}
> + local nottuple2 = {1, 2}
> + local nottuple3 = {1, nil, 2}
> + local nottuple4 = {1, box.NULL, 2, 3}
What is the purpose? You test your test_tuple_validate() wrapper here.
> @@ -199,6 +221,7 @@ local test = require('tap').test("module_api", function(test)
> test:test("pushcdata", test_pushcdata, module)
> test:test("iscallable", test_iscallable, module)
> test:test("iscdata", test_iscdata, module)
> + test:test("validate", test_tuples, module)
Nit: Feels a bit inconsistent: either validate + test_validate or
tuples + test_tuples or any other <foo> + test_<foo>. I would borrow the
name from the function we test: tuple_validate + test_tuple_validate.
next prev parent reply other threads:[~2020-10-13 0:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 0:44 [Tarantool-patches] [PATCH 2.X v3 0/3] module api: extend for external merger Lua module Timur Safin
2020-10-12 0:44 ` [Tarantool-patches] [PATCH 2.X v3 1/3] module api: export box_tuple_validate Timur Safin
2020-10-13 0:14 ` Alexander Turenko [this message]
2020-10-13 0:35 ` Timur Safin
2020-10-12 0:44 ` [Tarantool-patches] [PATCH 2.X v3 2/3] module api: export box_key_def_dup Timur Safin
2020-10-13 0:46 ` Alexander Turenko
2020-10-12 0:44 ` [Tarantool-patches] [PATCH 2.X v3 3/3] module api: luaL_checkibuf Timur Safin
2020-10-13 11:47 ` Alexander Turenko
2020-10-13 19:26 ` Igor Munkin
2020-10-13 16:30 ` [Tarantool-patches] [PATCH 2.X v3] module api: box_ibuf_* wrappers Timur Safin
2020-10-13 18:21 ` Alexander Turenko
2020-10-13 19:02 ` Timur Safin
2020-10-13 19:58 ` Alexander Turenko
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=20201013001436.3h5rkyf2t3giasx7@tkn_work_nb \
--to=alexander.turenko@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=tsafin@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 2.X v3 1/3] module api: export box_tuple_validate' \
/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