Debian Codegraph @

tests/ts/cal/weekarg

raw
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2007 Karel Zak <[email protected]>
5 #
6 # This file is part of util-linux.
7 #
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 TS_TOPDIR="${0%/*}/../.."
19 TS_DESC="week number given as argument"
20
21 . "$TS_TOPDIR"/functions.sh
22 ts_init "$*"
23
24 ts_check_test_command "$TS_CMD_CAL"
25 ts_inhibit_custom_colorscheme
26
27 ts_skip_ncurses
28
29 export TERM=linux
30
31 USETERM=$( ts_has_option "useterm" "$*" )
32
33 function call_cal_simple {
34 ts_log "$1"
35 shift
36 if [ "$USETERM" == "yes" ]; then
37 $TS_CMD_CAL "$@"
38 fi
39 $TS_CMD_CAL "$@" >> $TS_OUTPUT
40 }
41
42 function call_cal {
43 local testname=$(echo "${2}" | sed 's/-//g')
44 testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')"
45
46 ts_init_subtest "$testname"
47 call_cal_simple "$@"
48 ts_finalize_subtest
49 }
50
51 function call_cal_color {
52 local testname=$(echo "${2}" | sed 's/-//g')
53 testname="${testname}-$(echo "${3}" | sed 's/=//g;s/-//g')-color"
54
55 ts_init_subtest "$testname"
56 call_cal_simple "$@" --color=always
57 ts_finalize_subtest
58 }
59
60 MYTIME="7 10 2013"
61 PWEEK="week 40"
62 WEEK="--week=40"
63 call_cal "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
64 call_cal "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME
65 call_cal "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME
66 call_cal "Julian - Sunday-based, $PWEEK, 3 month" -3sj $WEEK $MYTIME
67 call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -m $WEEK $MYTIME
68 call_cal "Gregorian - Sunday-based, $PWEEK, 1 month" -s $WEEK $MYTIME
69 call_cal "Julian - Monday-based, $PWEEK, 1 month" -mj $WEEK $MYTIME
70 call_cal "Julian - Sunday-based, $PWEEK, 1 month" -sj $WEEK $MYTIME
71
72 call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
73 call_cal_color "Julian - Monday-based, $PWEEK, 3 month" -3mj $WEEK $MYTIME
74
75 # tricky year, starts with a bit of 53 yet ends during 52
76 MYTIME="2010"
77 PWEEK="week 53"
78 WEEK="--week=53"
79 call_cal "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME
80 call_cal "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME
81 call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
82 call_cal_color "Gregorian - Monday-based, $PWEEK, 1 month" -1m $WEEK $MYTIME
83 call_cal_color "Julian - Monday-based, $PWEEK, 1 month" -1mj $WEEK $MYTIME
84
85 MYTIME="31 12 2000"
86 PWEEK="week 54"
87 WEEK="--week=54"
88 call_cal_color "Gregorian - Sunday-based, $PWEEK, 3 month" -3s $WEEK $MYTIME
89
90 MYTIME="31 12 2000"
91 PWEEK="week 52"
92 WEEK="--week=52"
93 call_cal_color "Gregorian - Monday-based, $PWEEK, 3 month" -3m $WEEK $MYTIME
94
95 ts_finalize
96