From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id A21BD6EC55; Thu, 15 Jul 2021 11:20:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A21BD6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626337223; bh=2RMrHV0zk6oCYed7CMyucWuPeqiVGBYrzEn1ugz9iB4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=WkoKIWgJtm0D5Qp6UtZrqUEopBrULdgGn8PagamIi/kPcRc/Yu7Yb/mg+r4rz5//D TK5/DxOF8VcSrXFxIY4TcW09sp+gm8xuHhk8Qj79HvOmBYXVHgUjlRWe3Ms9Oz+wH7 guE1LrqHZbJKrsKa1JK8WA7mklH3IFHlglnRFlMs= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (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 D739F6EC57 for ; Thu, 15 Jul 2021 11:18:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D739F6EC57 Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1m3wa3-00070N-PQ; Thu, 15 Jul 2021 11:18:52 +0300 To: v.shpilevoy@tarantool.org Date: Thu, 15 Jul 2021 11:18:09 +0300 Message-Id: <5eab17762162a6ea36205586dc55a89702091e6c.1626335241.git.tsafin@tarantool.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD941C43E597735A9C30288BCF456A452ECBCD3030350682103182A05F53808504081243CAEFFC84A872DCD2DECEF5311642D21F5A2711ED34D1A225A5103AAED25 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE760302A529BCAAAFCEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063764FE777F378F21448638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D809A9D57B8FF5CB12B21D06E950597F71117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FC7A1B84289E8AD5C63AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F7900637EFEE248DCEC35FEAD81D268191BDAD3D698AB9A7B718F8C4D1B931868CE1C5781A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B262FEC7FBD7D1F5BB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CE68746B1F2AB10C6820F9F816B5A706CE0F61862939453F09C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF3033054805BDE987699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34DFB7A809FB537087E948CEC24F406048E02BDF9B50E54CC1E4D16FF7FF0D07A61359A92B5BAA7B791D7E09C32AA3244C90EAA78943FD5C3044A6734B2B472FF13FD9C8CA1B0515E083B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXjnYxxC9kpVb5rZXZs5rI6/ X-Mailru-Sender: B5B6A6EBBD94DAD8DA84A184D75F19DB2E7B7B20C3E75D0F138376BA797E063B571D99010C863CB81EC9E4A2C82A33BC8C24925A86E657CE0C70AEE3C9A96FBAB3D7EE8ED63280BE112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [RFC PATCH 03/13] test: datetime test X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Timur Safin via Tarantool-patches Reply-To: Timur Safin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" * created app-tap test fro newly created builtin module - `datetime.lua` --- test/app-tap/datetime.test.lua | 89 ++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 test/app-tap/datetime.test.lua diff --git a/test/app-tap/datetime.test.lua b/test/app-tap/datetime.test.lua new file mode 100755 index 000000000..bc66b3296 --- /dev/null +++ b/test/app-tap/datetime.test.lua @@ -0,0 +1,89 @@ +#!/usr/bin/env tarantool + +local tap = require('tap') +local test = tap.test("errno") +local date = require('datetime') + +test:plan(2) + +test:test("Simple tests for parser", function(test) + test:plan(2) + test:ok(date("1970-01-01T01:00:00Z") == + date {year=1970, month=1, day=1, hour=1, minute=0, second=0}) + test:ok(date("1970-01-01T02:00:00+02:00") == + date {year=1970, month=1, day=1, hour=2, minute=0, second=0, tz=120}) +end) + +test:test("Multiple tests for parser (with nanoseconds)", function(test) + test:plan(165) + -- borrowed from p5-time-moments/t/180_from_string.t + local tests = + { + { '1970-01-01T00:00:00Z', 0, 0, 0 }, + { '1970-01-01T02:00:00+02:00', 0, 0, 120 }, + { '1970-01-01T01:30:00+01:30', 0, 0, 90 }, + { '1970-01-01T01:00:00+01:00', 0, 0, 60 }, + { '1970-01-01T00:01:00+00:01', 0, 0, 1 }, + { '1970-01-01T00:00:00+00:00', 0, 0, 0 }, + { '1969-12-31T23:59:00-00:01', 0, 0, -1 }, + { '1969-12-31T23:00:00-01:00', 0, 0, -60 }, + { '1969-12-31T22:30:00-01:30', 0, 0, -90 }, + { '1969-12-31T22:00:00-02:00', 0, 0, -120 }, + { '1970-01-01T00:00:00.123456789Z', 0, 123456789, 0 }, + { '1970-01-01T00:00:00.12345678Z', 0, 123456780, 0 }, + { '1970-01-01T00:00:00.1234567Z', 0, 123456700, 0 }, + { '1970-01-01T00:00:00.123456Z', 0, 123456000, 0 }, + { '1970-01-01T00:00:00.12345Z', 0, 123450000, 0 }, + { '1970-01-01T00:00:00.1234Z', 0, 123400000, 0 }, + { '1970-01-01T00:00:00.123Z', 0, 123000000, 0 }, + { '1970-01-01T00:00:00.12Z', 0, 120000000, 0 }, + { '1970-01-01T00:00:00.1Z', 0, 100000000, 0 }, + { '1970-01-01T00:00:00.01Z', 0, 10000000, 0 }, + { '1970-01-01T00:00:00.001Z', 0, 1000000, 0 }, + { '1970-01-01T00:00:00.0001Z', 0, 100000, 0 }, + { '1970-01-01T00:00:00.00001Z', 0, 10000, 0 }, + { '1970-01-01T00:00:00.000001Z', 0, 1000, 0 }, + { '1970-01-01T00:00:00.0000001Z', 0, 100, 0 }, + { '1970-01-01T00:00:00.00000001Z', 0, 10, 0 }, + { '1970-01-01T00:00:00.000000001Z', 0, 1, 0 }, + { '1970-01-01T00:00:00.000000009Z', 0, 9, 0 }, + { '1970-01-01T00:00:00.00000009Z', 0, 90, 0 }, + { '1970-01-01T00:00:00.0000009Z', 0, 900, 0 }, + { '1970-01-01T00:00:00.000009Z', 0, 9000, 0 }, + { '1970-01-01T00:00:00.00009Z', 0, 90000, 0 }, + { '1970-01-01T00:00:00.0009Z', 0, 900000, 0 }, + { '1970-01-01T00:00:00.009Z', 0, 9000000, 0 }, + { '1970-01-01T00:00:00.09Z', 0, 90000000, 0 }, + { '1970-01-01T00:00:00.9Z', 0, 900000000, 0 }, + { '1970-01-01T00:00:00.99Z', 0, 990000000, 0 }, + { '1970-01-01T00:00:00.999Z', 0, 999000000, 0 }, + { '1970-01-01T00:00:00.9999Z', 0, 999900000, 0 }, + { '1970-01-01T00:00:00.99999Z', 0, 999990000, 0 }, + { '1970-01-01T00:00:00.999999Z', 0, 999999000, 0 }, + { '1970-01-01T00:00:00.9999999Z', 0, 999999900, 0 }, + { '1970-01-01T00:00:00.99999999Z', 0, 999999990, 0 }, + { '1970-01-01T00:00:00.999999999Z', 0, 999999999, 0 }, + { '1970-01-01T00:00:00.0Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.00Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.000Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.0000Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.00000Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.000000Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.0000000Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.00000000Z', 0, 0, 0 }, + { '1970-01-01T00:00:00.000000000Z', 0, 0, 0 }, + { '1973-11-29T21:33:09Z', 123456789, 0, 0 }, + { '2013-10-28T17:51:56Z', 1382982716, 0, 0 }, + -- { '9999-12-31T23:59:59Z', 253402300799, 0, 0 }, + } + for _, value in ipairs(tests) do + local str, epoch, nsec, offset + str, epoch, nsec, offset = unpack(value) + local dt = date(str) + test:ok(dt.secs == epoch, ('%s: dt.secs == %d'):format(str, epoch)) + test:ok(dt.nsec == nsec, ('%s: dt.nsec == %d'):format(str, nsec)) + test:ok(dt.offset == offset, ('%s: dt.offset == %d'):format(str, offset)) + end +end) + +os.exit(test:check() and 0 or 1) -- 2.29.2