From 08a4ba91ef4c11c9b78cc84b3ab18d184892ddf6 Mon Sep 17 00:00:00 2001 From: Andrey Mironov Date: Wed, 24 Sep 2014 15:32:47 +0400 Subject: [PATCH] add tests for date arithmetic. --- .../00069_date_arithmetic.reference | 18 ++++++++++++++++ .../0_stateless/00069_date_arithmetic.sql | 21 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00069_date_arithmetic.reference create mode 100644 dbms/tests/queries/0_stateless/00069_date_arithmetic.sql diff --git a/dbms/tests/queries/0_stateless/00069_date_arithmetic.reference b/dbms/tests/queries/0_stateless/00069_date_arithmetic.reference new file mode 100644 index 00000000000..da7b788b157 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00069_date_arithmetic.reference @@ -0,0 +1,18 @@ +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 diff --git a/dbms/tests/queries/0_stateless/00069_date_arithmetic.sql b/dbms/tests/queries/0_stateless/00069_date_arithmetic.sql new file mode 100644 index 00000000000..0ae3984ac28 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00069_date_arithmetic.sql @@ -0,0 +1,21 @@ +SELECT toTypeName(now() - now()) = 'Int32'; +SELECT toTypeName(now() + 1) = 'DateTime'; +SELECT toTypeName(1 + now()) = 'DateTime'; +SELECT toTypeName(now() - 1) = 'DateTime'; +SELECT toDateTime(1) + 1 = toDateTime(2); +SELECT 1 + toDateTime(1) = toDateTime(2); +SELECT toDateTime(1) - 1 = toDateTime(0); + +SELECT toTypeName(today()) = 'Date'; +SELECT today() = toDate(now()); + +SELECT toTypeName(yesterday()) = 'Date'; +SELECT yesterday() = toDate(now() - 24*60*60); + +SELECT toTypeName(today() - today()) = 'Int32'; +SELECT toTypeName(today() + 1) = 'Date'; +SELECT toTypeName(1 + today()) = 'Date'; +SELECT toTypeName(today() - 1) = 'Date'; +SELECT yesterday() + 1 = today(); +SELECT 1 + yesterday() = today(); +SELECT today() - 1 = yesterday();