From 378c18e5f024ac5a8aef4cb40d7c9aa9633d144c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:30:35 +0200 Subject: Adding upstream version 2.38.1. Signed-off-by: Daniel Baumann --- tests/ts/cal/bigyear | 83 +++++++++++++++++++++++++++++++++++++++++++ tests/ts/cal/color | 80 +++++++++++++++++++++++++++++++++++++++++ tests/ts/cal/colorw | 79 +++++++++++++++++++++++++++++++++++++++++ tests/ts/cal/jan1753 | 45 +++++++++++++++++++++++ tests/ts/cal/month | 72 +++++++++++++++++++++++++++++++++++++ tests/ts/cal/sep1752 | 86 ++++++++++++++++++++++++++++++++++++++++++++ tests/ts/cal/vertical | 72 +++++++++++++++++++++++++++++++++++++ tests/ts/cal/weekarg | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ts/cal/weeknum | 57 ++++++++++++++++++++++++++++++ tests/ts/cal/year | 54 ++++++++++++++++++++++++++++ 10 files changed, 726 insertions(+) create mode 100755 tests/ts/cal/bigyear create mode 100755 tests/ts/cal/color create mode 100755 tests/ts/cal/colorw create mode 100755 tests/ts/cal/jan1753 create mode 100755 tests/ts/cal/month create mode 100755 tests/ts/cal/sep1752 create mode 100755 tests/ts/cal/vertical create mode 100755 tests/ts/cal/weekarg create mode 100755 tests/ts/cal/weeknum create mode 100755 tests/ts/cal/year (limited to 'tests/ts/cal') 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..2e89412 --- /dev/null +++ b/tests/ts/cal/color @@ -0,0 +1,80 @@ +#!/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_init_subtest "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_finalize_subtest + +ts_init_subtest "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_finalize_subtest + +ts_init_subtest "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_finalize_subtest + +ts_init_subtest "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_finalize_subtest + +ts_init_subtest "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_finalize_subtest + +ts_init_subtest "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_subtest + + +ts_finalize diff --git a/tests/ts/cal/colorw b/tests/ts/cal/colorw new file mode 100755 index 0000000..9be3998 --- /dev/null +++ b/tests/ts/cal/colorw @@ -0,0 +1,79 @@ +#!/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_init_subtest "first-day-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_finalize_subtest + +ts_init_subtest "reformation-corner-cases-1-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_finalize_subtest + +ts_init_subtest "reformation-corner-cases-2-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_finalize_subtest + +ts_init_subtest "reformation-corner-cases-3-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_finalize_subtest + +ts_init_subtest "reformation-corner-cases-4-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_finalize_subtest + +ts_init_subtest "last-day-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_subtest + +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 +# +# 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 +# +# 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 +# +# 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 +# +# 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 +# +# 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 + -- cgit v1.2.3