Debian Codegraph @

tests/ts/cal/sep1752

raw
1 #!/bin/bash
2
3 # This file is part of util-linux.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 TS_TOPDIR="${0%/*}/../.."
16 TS_DESC="September 1752"
17
18 . "$TS_TOPDIR"/functions.sh
19 ts_init "$*"
20
21 ts_check_test_command "$TS_HELPER_CAL"
22
23 export TERM=linux
24
25 USETERM=$( ts_has_option "useterm" "$*" )
26 MYMONTH="09 1752"
27 MYYEAR="1752"
28
29 CAL_TEST_TIME=1516562739 # 21st January 2018
30 export CAL_TEST_TIME
31
32 function call_cal_simple {
33 ts_log "$1"
34 shift
35 if [ "$USETERM" == "yes" ]; then
36 $TS_HELPER_CAL "$@"
37 fi
38 $TS_HELPER_CAL "$@" >> $TS_OUTPUT
39 }
40
41 function call_cal {
42 local testname=$(echo "$2" | sed 's/-//g')
43
44 if [ "$3" == "$MYYEAR" ]; then
45 testname="${testname}-year"
46 else
47 testname="${testname}-month"
48 fi
49
50 ts_init_subtest "$testname"
51 call_cal_simple "$@"
52 ts_finalize_subtest
53 }
54
55
56 call_cal "Gregorian - Monday-based month with week numbers" -1mw $MYMONTH
57 call_cal "Gregorian - Sunday-based month with week numbers" -1sw $MYMONTH
58 call_cal "Julian - Monday-based month with week numbers" -1mjw $MYMONTH
59 call_cal "Julian - Sunday-based month with week numbers" -1sjw $MYMONTH
60 call_cal "Gregorian - Monday-based three months with week numbers" -3mw $MYMONTH
61 call_cal "Gregorian - Sunday-based three months with week numbers" -3sw $MYMONTH
62 call_cal "Julian - Monday-based three months with week numbers" -3mjw $MYMONTH
63 call_cal "Julian - Sunday-based three months with week numbers" -3sjw $MYMONTH
64 call_cal "Gregorian - Monday-based year with week numbers" -1mw $MYYEAR
65 call_cal "Gregorian - Sunday-based year with week numbers" -1sw $MYYEAR
66 call_cal "Julian - Monday-based year with week numbers" -1mjw $MYYEAR
67 call_cal "Julian - Sunday-based year with week numbers" -1sjw $MYYEAR
68
69 ts_init_subtest "week-iso"
70 call_cal_simple "Gregorian - address by week number" --week=40 --iso $MYYEAR
71 ts_finalize_subtest
72
73 call_cal "Gregorian - Monday-based month" -1m $MYMONTH
74 call_cal "Gregorian - Sunday-based month" -1s $MYMONTH
75 call_cal "Julian - Monday-based month" -1mj $MYMONTH
76 call_cal "Julian - Sunday-based month" -1sj $MYMONTH
77 call_cal "Gregorian - Monday-based three months" -3m $MYMONTH
78 call_cal "Gregorian - Sunday-based three months" -3s $MYMONTH
79 call_cal "Julian - Monday-based three months" -3mj $MYMONTH
80 call_cal "Julian - Sunday-based three months" -3sj $MYMONTH
81 call_cal "Gregorian - Monday-based year" -1m $MYYEAR
82 call_cal "Gregorian - Sunday-based year" -1s $MYYEAR
83 call_cal "Julian - Monday-based year" -1mj $MYYEAR
84 call_cal "Julian - Sunday-based year" -1sj $MYYEAR
85
86 ts_finalize