[Tarantool-patches] [PATCH 2.X v3 1/3] module api: export box_tuple_validate
Timur Safin
tsafin at tarantool.org
Tue Oct 13 03:35:31 MSK 2020
: From: Alexander Turenko <alexander.turenko at tarantool.org>
: Subject: Re: [PATCH 2.X v3 1/3] module api: export box_tuple_validate
:
: > +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.
Yup, indeed. Good point.
:
: > +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.
Indeed. I have found it later during further ibuf tests additions.
Will fix.
:
: 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().
Will add some format there.
:
: > +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.
:) at least it distinguish Tarantool tuple objects from generic Lua tables.
:
: > @@ -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.
Will streamline name. Thanks
Timur
More information about the Tarantool-patches
mailing list