From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 56A9C469719 for ; Tue, 13 Oct 2020 03:14:18 +0300 (MSK) Date: Tue, 13 Oct 2020 03:14:36 +0300 From: Alexander Turenko Message-ID: <20201013001436.3h5rkyf2t3giasx7@tkn_work_nb> References: <0b974732d5f63fcf820ae432d88ce349addea5ec.1602463103.git.tsafin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0b974732d5f63fcf820ae432d88ce349addea5ec.1602463103.git.tsafin@tarantool.org> 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: Timur Safin Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@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 + test_. I would borrow the name from the function we test: tuple_validate + test_tuple_validate.