summaryrefslogtreecommitdiffstats
path: root/tests/ts/cal
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
commit30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 (patch)
tree9b788335f92174baf7ee18f03ca8330b8c19ce2b /tests/ts/cal
parentInitial commit. (diff)
downloadutil-linux-upstream.tar.xz
util-linux-upstream.zip
Adding upstream version 2.36.1.upstream/2.36.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/cal')
-rwxr-xr-xtests/ts/cal/bigyear83
-rwxr-xr-xtests/ts/cal/color76
-rwxr-xr-xtests/ts/cal/colorw76
-rwxr-xr-xtests/ts/cal/jan175345
-rwxr-xr-xtests/ts/cal/month72
-rwxr-xr-xtests/ts/cal/sep175286
-rwxr-xr-xtests/ts/cal/vertical72
-rwxr-xr-xtests/ts/cal/weekarg98
-rwxr-xr-xtests/ts/cal/weeknum57
-rwxr-xr-xtests/ts/cal/year54
10 files changed, 719 insertions, 0 deletions
diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear
new file mode 100755
index 0000000..34139fd
--- /dev/null
+++ b/tests/ts/cal/bigyear
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="Year 2147483646"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_CAL"
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+MYMONTH="12 2147483646"
+MYYEAR="2147483646"
+
+
+CAL_TEST_TIME=1516562739 # 21st January 2018
+export CAL_TEST_TIME
+
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g')
+
+ if [ "$3" == "$MYYEAR" ]; then
+ testname="${testname}-year"
+ else
+ testname="${testname}-month"
+ fi
+
+ ts_init_subtest "$testname"
+ ts_log "$1"
+ shift
+ if [ "$USETERM" == "yes" ]; then
+ $TS_HELPER_CAL "$@"
+ fi
+ $TS_HELPER_CAL "$@" >> $TS_OUTPUT
+ ts_finalize_subtest
+}
+
+call_cal "Gregorian - Monday-based month" -1m $MYMONTH
+call_cal "Gregorian - Sunday-based month" -1s $MYMONTH
+call_cal "Julian - Monday-based month" -1mj $MYMONTH
+call_cal "Julian - Sunday-based month" -1sj $MYMONTH
+
+call_cal "Gregorian - Monday-based 3 months" -3m $MYMONTH
+call_cal "Gregorian - Sunday-based 3 months" -3s $MYMONTH
+call_cal "Julian - Monday-based 3 months" -3mj $MYMONTH
+call_cal "Julian - Sunday-based 3 months" -3sj $MYMONTH
+
+call_cal "Gregorian - Monday-based year" -1m $MYYEAR
+call_cal "Gregorian - Sunday-based year" -1s $MYYEAR
+call_cal "Julian - Monday-based year" -1mj $MYYEAR
+call_cal "Julian - Sunday-based year" -1sj $MYYEAR
+
+
+call_cal "Gregorian - Monday-based month with weeks" -1mw $MYMONTH
+call_cal "Gregorian - Sunday-based month with weeks" -1sw $MYMONTH
+call_cal "Julian - Monday-based month with weeks" -1mjw $MYMONTH
+call_cal "Julian - Sunday-based month with weeks" -1sjw $MYMONTH
+
+call_cal "Gregorian - Monday-based 3 months with weeks" -3mw $MYMONTH
+call_cal "Gregorian - Sunday-based 3 months with weeks" -3sw $MYMONTH
+call_cal "Julian - Monday-based 3 months with weeks" -3mjw $MYMONTH
+call_cal "Julian - Sunday-based 3 months with weeks" -3sjw $MYMONTH
+
+call_cal "Gregorian - Monday-based year with weeks" -1mw $MYYEAR
+call_cal "Gregorian - Sunday-based year with weeks" -1sw $MYYEAR
+call_cal "Julian - Monday-based year with weeks" -1mjw $MYYEAR
+call_cal "Julian - Sunday-based year with weeks" -1sjw $MYYEAR
+
+ts_finalize
diff --git a/tests/ts/cal/color b/tests/ts/cal/color
new file mode 100755
index 0000000..8a6dfb6
--- /dev/null
+++ b/tests/ts/cal/color
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="color"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+has_ncurses=$( ts_has_ncurses_support )
+if [ "$has_ncurses" != "yes" ]; then
+ ts_skip "without-ncurses"
+fi
+
+# --color output depends on terminal type
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+
+[ "$USETERM" == "yes" ] && TS_VERBOSE="yes"
+ts_log ""
+
+ts_log "First day"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL --color=always 1 1 1
+fi
+$TS_CMD_CAL --color=always 1 1 1 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 1"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL --color=always 2 9 1752
+fi
+$TS_CMD_CAL --color=always 2 9 1752 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 2"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL --color=always 3 9 1752
+fi
+$TS_CMD_CAL --color=always 3 9 1752 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 3"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL --color=always 13 9 1752
+fi
+$TS_CMD_CAL --color=always 13 9 1752 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 4"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL --color=always 14 9 1752
+fi
+$TS_CMD_CAL --color=always 14 9 1752 >> $TS_OUTPUT
+
+ts_log "Last day"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL --color=always 31 12 9999
+fi
+$TS_CMD_CAL --color=always -3 31 12 9999 >> $TS_OUTPUT
+
+
+ts_finalize
+
diff --git a/tests/ts/cal/colorw b/tests/ts/cal/colorw
new file mode 100755
index 0000000..493dd2c
--- /dev/null
+++ b/tests/ts/cal/colorw
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="color with week numbers"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+has_ncurses=$( ts_has_ncurses_support )
+if [ "$has_ncurses" != "yes" ]; then
+ ts_skip "without-ncurses"
+fi
+
+# --color output depends on terminal type
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+
+[ "$USETERM" == "yes" ] && TS_VERBOSE="yes"
+ts_log ""
+
+ts_log "First day with week numbers"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL -w --color=always 1 1 1
+fi
+$TS_CMD_CAL -w --color=always 1 1 1 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 1 with week numbers"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL -w --color=always 2 9 1752
+fi
+$TS_CMD_CAL -w --color=always 2 9 1752 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 2 with week numbers"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL -w --color=always 3 9 1752
+fi
+$TS_CMD_CAL -w --color=always 3 9 1752 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 3 with week numbers"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL -w --color=always 13 9 1752
+fi
+$TS_CMD_CAL -w --color=always 13 9 1752 >> $TS_OUTPUT
+
+ts_log "Reformation corner cases 4 with week numbers"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL -w --color=always 14 9 1752
+fi
+$TS_CMD_CAL -w --color=always 14 9 1752 >> $TS_OUTPUT
+
+ts_log "Last day with week numbers"
+if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL -w --color=always 31 12 9999
+fi
+$TS_CMD_CAL -w --color=always -3 31 12 9999 >> $TS_OUTPUT
+
+
+ts_finalize
+
diff --git a/tests/ts/cal/jan1753 b/tests/ts/cal/jan1753
new file mode 100755
index 0000000..1be3db3
--- /dev/null
+++ b/tests/ts/cal/jan1753
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="January 1753"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+MYMONTH="1 1753"
+
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g')
+
+ ts_init_subtest "$testname"
+ ts_log "$1"
+ shift
+ if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL "$@"
+ fi
+ $TS_CMD_CAL "$@" >> $TS_OUTPUT
+
+ ts_finalize_subtest
+}
+
+call_cal "Monday-based 1753 week numbers" -m3w $MYMONTH
+call_cal "Sunday-based 1753 week numbers" -3w $MYMONTH
+
+ts_finalize
diff --git a/tests/ts/cal/month b/tests/ts/cal/month
new file mode 100755
index 0000000..62fd1f9
--- /dev/null
+++ b/tests/ts/cal/month
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007-2018 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="month"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_CAL"
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+MYTIME="27 09 2006"
+
+CAL_TEST_TIME=1516562739 # 21st January 2018
+export CAL_TEST_TIME
+
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g; s/ //g')
+
+ ts_init_subtest "$testname"
+ ts_log "$1"
+ shift
+ if [ "$USETERM" == "yes" ]; then
+ $TS_HELPER_CAL "$@"
+ fi
+ $TS_HELPER_CAL "$@" >> $TS_OUTPUT
+
+ ts_finalize_subtest
+}
+
+call_cal "Gregorian - Monday-based week" -1m $MYTIME
+call_cal "Gregorian - Sunday-based week" -1s $MYTIME
+call_cal "Julian - Monday-based week" -1mj $MYTIME
+call_cal "Julian - Sunday-based week" -1sj $MYTIME
+call_cal "Gregorian - Monday-based week with week numbers" -1mw $MYTIME
+call_cal "Gregorian - Sunday-based week with week numbers" -1sw $MYTIME
+call_cal "Julian - Monday-based week with week numbers" -1mjw $MYTIME
+call_cal "Julian - Sunday-based week with week numbers" -1sjw $MYTIME
+call_cal "Gregorian - Monday-based week" -3m $MYTIME
+call_cal "Gregorian - Sunday-based week" -3s $MYTIME
+call_cal "Julian - Monday-based week" -3mj $MYTIMET
+call_cal "Julian - Sunday-based week" -3sj $MYTIME
+call_cal "Gregorian - Monday-based week with week numbers" -3mw $MYTIME
+call_cal "Gregorian - Sunday-based week with week numbers" -3sw $MYTIME
+call_cal "Julian - Monday-based week with week numbers" -3mjw $MYTIME
+call_cal "Julian - Sunday-based week with week numbers" -3sjw $MYTIME
+
+call_cal "Normal span" "-Sn 3" $MYTIME
+call_cal "Large span" "-Sn 21" $MYTIME
+call_cal "Very Large span" "-Sn 51" $MYTIME
+call_cal "Extreme span" "-Sn 201" $MYTIME
+
+ts_finalize
+
diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752
new file mode 100755
index 0000000..41c30d4
--- /dev/null
+++ b/tests/ts/cal/sep1752
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="September 1752"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_CAL"
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+MYMONTH="09 1752"
+MYYEAR="1752"
+
+CAL_TEST_TIME=1516562739 # 21st January 2018
+export CAL_TEST_TIME
+
+function call_cal_simple {
+ ts_log "$1"
+ shift
+ if [ "$USETERM" == "yes" ]; then
+ $TS_HELPER_CAL "$@"
+ fi
+ $TS_HELPER_CAL "$@" >> $TS_OUTPUT
+}
+
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g')
+
+ if [ "$3" == "$MYYEAR" ]; then
+ testname="${testname}-year"
+ else
+ testname="${testname}-month"
+ fi
+
+ ts_init_subtest "$testname"
+ call_cal_simple "$@"
+ ts_finalize_subtest
+}
+
+
+call_cal "Gregorian - Monday-based month with week numbers" -1mw $MYMONTH
+call_cal "Gregorian - Sunday-based month with week numbers" -1sw $MYMONTH
+call_cal "Julian - Monday-based month with week numbers" -1mjw $MYMONTH
+call_cal "Julian - Sunday-based month with week numbers" -1sjw $MYMONTH
+call_cal "Gregorian - Monday-based three months with week numbers" -3mw $MYMONTH
+call_cal "Gregorian - Sunday-based three months with week numbers" -3sw $MYMONTH
+call_cal "Julian - Monday-based three months with week numbers" -3mjw $MYMONTH
+call_cal "Julian - Sunday-based three months with week numbers" -3sjw $MYMONTH
+call_cal "Gregorian - Monday-based year with week numbers" -1mw $MYYEAR
+call_cal "Gregorian - Sunday-based year with week numbers" -1sw $MYYEAR
+call_cal "Julian - Monday-based year with week numbers" -1mjw $MYYEAR
+call_cal "Julian - Sunday-based year with week numbers" -1sjw $MYYEAR
+
+ts_init_subtest "week-iso"
+call_cal_simple "Gregorian - address by week number" --week=40 --iso $MYYEAR
+ts_finalize_subtest
+
+call_cal "Gregorian - Monday-based month" -1m $MYMONTH
+call_cal "Gregorian - Sunday-based month" -1s $MYMONTH
+call_cal "Julian - Monday-based month" -1mj $MYMONTH
+call_cal "Julian - Sunday-based month" -1sj $MYMONTH
+call_cal "Gregorian - Monday-based three months" -3m $MYMONTH
+call_cal "Gregorian - Sunday-based three months" -3s $MYMONTH
+call_cal "Julian - Monday-based three months" -3mj $MYMONTH
+call_cal "Julian - Sunday-based three months" -3sj $MYMONTH
+call_cal "Gregorian - Monday-based year" -1m $MYYEAR
+call_cal "Gregorian - Sunday-based year" -1s $MYYEAR
+call_cal "Julian - Monday-based year" -1mj $MYYEAR
+call_cal "Julian - Sunday-based year" -1sj $MYYEAR
+
+ts_finalize
diff --git a/tests/ts/cal/vertical b/tests/ts/cal/vertical
new file mode 100755
index 0000000..f92f042
--- /dev/null
+++ b/tests/ts/cal/vertical
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007-2018 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="vertical"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_CAL"
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+MYTIME="27 09 2006"
+
+CAL_TEST_TIME=1516562739 # 21st January 2018
+export CAL_TEST_TIME
+
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g; s/ //g')
+
+ ts_init_subtest "$testname"
+ ts_log "$1"
+ shift
+ if [ "$USETERM" == "yes" ]; then
+ $TS_HELPER_CAL "$@"
+ fi
+ $TS_HELPER_CAL "$@" >> $TS_OUTPUT
+
+ ts_finalize_subtest
+}
+
+call_cal "Gregorian - Monday-based week" -1mv $MYTIME
+call_cal "Gregorian - Sunday-based week" -1sv $MYTIME
+call_cal "Julian - Monday-based week" -1mjv $MYTIME
+call_cal "Julian - Sunday-based week" -1sjv $MYTIME
+call_cal "Gregorian - Monday-based week with week numbers" -1mwv $MYTIME
+call_cal "Gregorian - Sunday-based week with week numbers" -1swv $MYTIME
+call_cal "Julian - Monday-based week with week numbers" -1mjwv $MYTIME
+call_cal "Julian - Sunday-based week with week numbers" -1sjwv $MYTIME
+call_cal "Gregorian - Monday-based week" -3mv $MYTIME
+call_cal "Gregorian - Sunday-based week" -3sv $MYTIME
+call_cal "Julian - Monday-based week" -3mjv $MYTIMET
+call_cal "Julian - Sunday-based week" -3sjv $MYTIME
+call_cal "Gregorian - Monday-based week with week numbers" -3mwv $MYTIME
+call_cal "Gregorian - Sunday-based week with week numbers" -3swv $MYTIME
+call_cal "Julian - Monday-based week with week numbers" -3mjwv $MYTIME
+call_cal "Julian - Sunday-based week with week numbers" -3sjwv $MYTIME
+
+call_cal "Normal span" "-vSn 3" $MYTIME
+call_cal "Large span" "-vSn 21" $MYTIME
+call_cal "Very Large span" "-vSn 51" $MYTIME
+call_cal "Extreme span" "-vSn 201" $MYTIME
+
+ts_finalize
+
diff --git a/tests/ts/cal/weekarg b/tests/ts/cal/weekarg
new file mode 100755
index 0000000..f51644a
--- /dev/null
+++ b/tests/ts/cal/weekarg
@@ -0,0 +1,98 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="week number given as argument"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+has_ncurses=$( ts_has_ncurses_support )
+if [ "$has_ncurses" != "yes" ]; then
+ ts_skip "without-ncurses"
+fi
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+
+function call_cal_simple {
+ ts_log "$1"
+ shift
+ if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL "$@"
+ fi
+ $TS_CMD_CAL "$@" >> $TS_OUTPUT
+}
+
+function call_cal {
+ local testname=$(echo "${2}" | sed 's/-//g')
+ testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')"
+
+ ts_init_subtest "$testname"
+ call_cal_simple "$@"
+ ts_finalize_subtest
+}
+
+function call_cal_color {
+ local testname=$(echo "${2}" | sed 's/-//g')
+ testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')-color"
+
+ ts_init_subtest "$testname"
+ call_cal_simple "$@" --color=always
+ ts_finalize_subtest
+}
+
+MYTIME="7 10 2013"
+PWEEK="week 40"
+WEEK="--week=40"
+call_cal "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
+call_cal "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME
+call_cal "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME
+call_cal "Julian - Sunday-based, $PWEEK, 3 month" -3sj $WEEK $MYTIME
+call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -m $WEEK $MYTIME
+call_cal "Gregorian - Sunday-based, $PWEEK, 1 month" -s $WEEK $MYTIME
+call_cal "Julian - Monday-based, $PWEEK, 1 month" -mj $WEEK $MYTIME
+call_cal "Julian - Sunday-based, $PWEEK, 1 month" -sj $WEEK $MYTIME
+
+call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
+call_cal_color "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME
+
+# tricky year, starts with a bit of 53 yet ends during 52
+MYTIME="2010"
+PWEEK="week 53"
+WEEK="--week=53"
+call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME
+call_cal "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME
+call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
+call_cal_color "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME
+call_cal_color "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME
+
+MYTIME="31 12 2000"
+PWEEK="week 54"
+WEEK="--week=54"
+call_cal_color "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME
+
+MYTIME="31 12 2000"
+PWEEK="week 52"
+WEEK="--week=52"
+call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
+
+ts_finalize
+
diff --git a/tests/ts/cal/weeknum b/tests/ts/cal/weeknum
new file mode 100755
index 0000000..f2aec94
--- /dev/null
+++ b/tests/ts/cal/weeknum
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="week number corner cases"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+
+[ "$USETERM" == "yes" ] && TS_VERBOSE="yes"
+
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g')
+
+ ts_init_subtest "$testname"
+ ts_log "$1"
+ shift
+ for x in 2001 2002 2003 2009 2010 2011 2012 ; do
+ if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL "$@" 1 $x
+ fi
+ $TS_CMD_CAL "$@" 1 $x >> $TS_OUTPUT
+ done
+ ts_finalize_subtest
+}
+
+call_cal "Gregorian - Monday-based week with week numbers" -ymw
+call_cal "Gregorian - Sunday-based week with week numbers" -ysw
+call_cal "Julian - Monday-based week with week numbers" -ymjw
+call_cal "Julian - Sunday-based week with week numbers" -ysjw
+call_cal "Gregorian - Monday-based week with week number" -3mw
+call_cal "Gregorian - Sunday-based week with week numbers - 3 month" -3sw
+call_cal "Julian - Monday-based week with week numbers - 3 month" -3mjw
+call_cal "Julian - Sunday-based week with week numbers - 3 month" -3sjw
+
+ts_finalize
+
diff --git a/tests/ts/cal/year b/tests/ts/cal/year
new file mode 100755
index 0000000..6a8c42e
--- /dev/null
+++ b/tests/ts/cal/year
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007-2018 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="year"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CAL"
+
+export TERM=linux
+
+USETERM=$( ts_has_option "useterm" "$*" )
+MYTIME="29 11 2006"
+
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g')
+
+ ts_init_subtest "$testname"
+ ts_log "$1"
+ shift
+ if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL "$@"
+ fi
+ $TS_CMD_CAL "$@" >> $TS_OUTPUT
+ ts_finalize_subtest
+}
+
+call_cal "Gregorian - Monday-based week" -ym $MYTIME
+call_cal "Gregorian - Sunday-based week" -ys $MYTIME
+call_cal "Julian - Monday-based week" -ymj $MYTIME
+call_cal "Julian - Sunday-based week" -ysj $MYTIME
+call_cal "Gregorian - Monday-based week with week numbers" -ymw $MYTIME
+call_cal "Gregorian - Sunday-based week with week numbers" -ysw $MYTIME
+call_cal "Julian - Monday-based week with week numbers" -ymjw $MYTIME
+call_cal "Julian - Sunday-based week with week numbers" -ysjw $MYTIME
+
+ts_finalize
+