From 50aae0b0e835ab46036bc15f380a3aa5b41b5f0f Mon Sep 17 00:00:00 2001 From: VaclavT Date: Sun, 26 Sep 2021 23:27:11 +0200 Subject: [PATCH] date test updated, but still wip because mlisps date epoch is in local time, which is temporary solution --- tests/test.lsp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/test.lsp b/tests/test.lsp index 7eb40ab..0c6fc09 100644 --- a/tests/test.lsp +++ b/tests/test.lsp @@ -88,9 +88,6 @@ (ut::define-test "result of (is-dir? \"/tmp/file_whichnotex_ists\")" '(ut::assert-false (is-dir? "/tmp/file_whichnotex_ists"))) (ut::define-test "result of (is-dir? \"/tmp\"" '(ut::assert-true (is-dir? "/tmp"))) -(ut::define-test "result of (str-to-date \"01.01.1970\" \"%d.%m.%Y\")" '(ut::assert-equal 0 (str-to-date "01.01.1970" "%d.%m.%Y"))) -(ut::define-test "result of (date-add (str-to-date \"01.01.1970\" \"%d.%m.%Y\") 1 \"day\")" '(ut::assert-equal 86400 (date-add (str-to-date "01.01.1970" "%d.%m.%Y") 1 "day"))) - (ut::define-test "result of (uniq '(1 2 2 2 3 4 5 4 4 1 2 2 2 3 4 5 4 4 61 2 2 2 3 4 5 4 4 66))" '(ut::assert-equal '(1 2 3 4 5 61 66) (uniq '(1 2 2 2 3 4 5 4 4 1 2 2 2 3 4 5 4 4 61 2 2 2 3 4 5 4 4 66)))) (ut::define-test "result of (flatten '(1 2 (3 3 (4)) 5 6))" '(ut::assert-equal '(1 2 3 3 4 5 6) (flatten (1 2 (3 3 (4)) 5 6)))) @@ -103,19 +100,26 @@ (ut::define-test "result of (!= nil nil)" '(ut::assert-false (!= nil nil))) -(ut::define-test "result of (start-of-day)" '(ut::assert-equal 1620864000 (start-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (end-of-day)" '(ut::assert-equal 1620950399 (end-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (start-of-month)" '(ut::assert-equal 1619827200 (start-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (end-of-month)" '(ut::assert-equal 1622505599 (end-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (start-of-next-month)" '(ut::assert-equal 1622505600 (start-of-next-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (end-of-next-month)" '(ut::assert-equal 1625097599 (end-of-next-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (start-of-prev-month)" '(ut::assert-equal 1617235200 (start-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (end-of-prev-month)" '(ut::assert-equal 1619827199 (end-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (start-of-year)" '(ut::assert-equal 1609459200 (start-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) -(ut::define-test "result of (end-of-year)" '(ut::assert-equal 1640995199 (end-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +; it is in local time +(ut::define-test "result of (str-to-date \"01.01.1970\" \"%d.%m.%Y\")" '(ut::assert-equal -7200 (str-to-date "01.01.1970" "%d.%m.%Y"))) +(ut::define-test "result of (date-add (str-to-date \"01.01.1970\" \"%d.%m.%Y\") 1 \"day\")" '(ut::assert-equal 79200 (date-add (str-to-date "01.01.1970" "%d.%m.%Y") 1 "day"))) + +(ut::define-test "result of (start-of-day)" '(ut::assert-equal 1620856800 (start-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (end-of-day)" '(ut::assert-equal 1620943199 (end-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (start-of-month)" '(ut::assert-equal 1619820000 (start-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (end-of-month)" '(ut::assert-equal 1622498399 (end-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (start-of-next-month)" '(ut::assert-equal 1622498400 (start-of-next-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (end-of-next-month)" '(ut::assert-equal 1625176799 (end-of-next-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (start-of-prev-month)" '(ut::assert-equal 1617228000 (start-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (end-of-prev-month)" '(ut::assert-equal 1619906399 (end-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (start-of-year)" '(ut::assert-equal 1609452000 (start-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) +(ut::define-test "result of (end-of-year)" '(ut::assert-equal 1640987999 (end-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")))) (ut::define-test "(read-file-lines \"/tmp/f.txt\" counter)" '(ut::assert-equal 3 (read-file-lines "/tmp/f.txt" counter))) + +(ut::define-test "result of create table" '(ut::assert-equal ((0 "table created" 0)) (usql "create table a (i integer not null, s varchar(64), f float null, d date null, b boolean)"))) + ;(ut::define-test "result of " '(ut::assert-true ) (ut::run-tests)