From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.mail.ru (smtp1.mail.ru [94.100.179.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 87E9D469719 for ; Tue, 13 Oct 2020 03:35:37 +0300 (MSK) From: "Timur Safin" References: <0b974732d5f63fcf820ae432d88ce349addea5ec.1602463103.git.tsafin@tarantool.org> <20201013001436.3h5rkyf2t3giasx7@tkn_work_nb> In-Reply-To: <20201013001436.3h5rkyf2t3giasx7@tkn_work_nb> Date: Tue, 13 Oct 2020 03:35:31 +0300 Message-ID: <1cf301d6a0f8$c1b66ce0$452346a0$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: ru Subject: Re: [Tarantool-patches] [PATCH 2.X v3 1/3] module api: export box_tuple_validate List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Alexander Turenko' Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org : From: Alexander Turenko : 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 + test_. I would borrow the : name from the function we test: tuple_validate + test_tuple_validate. Will streamline name. Thanks Timur