github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekatime/weekday_test.go (about) 1 // Copyright © 2020-2021. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekatime_test 7 8 import ( 9 "testing" 10 11 "github.com/qioalice/ekago/v3/ekatime" 12 13 "github.com/stretchr/testify/require" 14 ) 15 16 func TestWeekday_To06(t *testing.T) { 17 for _, n := range []struct { 18 wd ekatime.Weekday 19 expected06 int8 20 }{ 21 {ekatime.WEEKDAY_MONDAY, 1}, 22 {ekatime.WEEKDAY_TUESDAY, 2}, 23 {ekatime.WEEKDAY_WEDNESDAY, 3}, 24 {ekatime.WEEKDAY_THURSDAY, 4}, 25 {ekatime.WEEKDAY_FRIDAY, 5}, 26 {ekatime.WEEKDAY_SATURDAY, 6}, 27 {ekatime.WEEKDAY_SUNDAY, 0}, 28 } { 29 require.Equal(t, n.expected06, n.wd.To06()) 30 } 31 } 32 33 func TestWeekday_From06(t *testing.T) { 34 for _, n := range []struct { 35 _06 int8 36 expectedWeekday ekatime.Weekday 37 }{ 38 {1, ekatime.WEEKDAY_MONDAY}, 39 {2, ekatime.WEEKDAY_TUESDAY}, 40 {3, ekatime.WEEKDAY_WEDNESDAY}, 41 {4, ekatime.WEEKDAY_THURSDAY}, 42 {5, ekatime.WEEKDAY_FRIDAY}, 43 {6, ekatime.WEEKDAY_SATURDAY}, 44 {0, ekatime.WEEKDAY_SUNDAY}, 45 } { 46 require.Equal(t, n.expectedWeekday, *new(ekatime.Weekday).From06(n._06)) 47 } 48 } 49 50 func TestWeekdayJan1(t *testing.T) { 51 for _, n := range []struct { 52 y ekatime.Year 53 expectedWeekday ekatime.Weekday 54 }{ 55 {1500, ekatime.WEEKDAY_MONDAY}, 56 {1600, ekatime.WEEKDAY_SATURDAY}, 57 {1700, ekatime.WEEKDAY_FRIDAY}, 58 {1800, ekatime.WEEKDAY_WEDNESDAY}, 59 {1900, ekatime.WEEKDAY_MONDAY}, 60 {2000, ekatime.WEEKDAY_SATURDAY}, 61 {2100, ekatime.WEEKDAY_FRIDAY}, 62 {2200, ekatime.WEEKDAY_WEDNESDAY}, 63 {2300, ekatime.WEEKDAY_MONDAY}, 64 {2400, ekatime.WEEKDAY_SATURDAY}, 65 {2500, ekatime.WEEKDAY_FRIDAY}, 66 {2600, ekatime.WEEKDAY_WEDNESDAY}, 67 {2700, ekatime.WEEKDAY_MONDAY}, 68 {2800, ekatime.WEEKDAY_SATURDAY}, 69 {2900, ekatime.WEEKDAY_FRIDAY}, 70 {1926, ekatime.WEEKDAY_FRIDAY}, 71 {1927, ekatime.WEEKDAY_SATURDAY}, 72 {1928, ekatime.WEEKDAY_SUNDAY}, 73 {1929, ekatime.WEEKDAY_TUESDAY}, 74 {1930, ekatime.WEEKDAY_WEDNESDAY}, 75 {1931, ekatime.WEEKDAY_THURSDAY}, 76 {1932, ekatime.WEEKDAY_FRIDAY}, 77 {1933, ekatime.WEEKDAY_SUNDAY}, 78 {1934, ekatime.WEEKDAY_MONDAY}, 79 {1935, ekatime.WEEKDAY_TUESDAY}, 80 {1936, ekatime.WEEKDAY_WEDNESDAY}, 81 {1937, ekatime.WEEKDAY_FRIDAY}, 82 {1938, ekatime.WEEKDAY_SATURDAY}, 83 {1939, ekatime.WEEKDAY_SUNDAY}, 84 {1940, ekatime.WEEKDAY_MONDAY}, 85 {1941, ekatime.WEEKDAY_WEDNESDAY}, 86 {1942, ekatime.WEEKDAY_THURSDAY}, 87 {1943, ekatime.WEEKDAY_FRIDAY}, 88 {1944, ekatime.WEEKDAY_SATURDAY}, 89 {1945, ekatime.WEEKDAY_MONDAY}, 90 {1946, ekatime.WEEKDAY_TUESDAY}, 91 {1947, ekatime.WEEKDAY_WEDNESDAY}, 92 {1948, ekatime.WEEKDAY_THURSDAY}, 93 {1949, ekatime.WEEKDAY_SATURDAY}, 94 {1950, ekatime.WEEKDAY_SUNDAY}, 95 {1951, ekatime.WEEKDAY_MONDAY}, 96 {1952, ekatime.WEEKDAY_TUESDAY}, 97 {1953, ekatime.WEEKDAY_THURSDAY}, 98 {1954, ekatime.WEEKDAY_FRIDAY}, 99 {1955, ekatime.WEEKDAY_SATURDAY}, 100 {1956, ekatime.WEEKDAY_SUNDAY}, 101 {1957, ekatime.WEEKDAY_TUESDAY}, 102 {1958, ekatime.WEEKDAY_WEDNESDAY}, 103 {1959, ekatime.WEEKDAY_THURSDAY}, 104 {1960, ekatime.WEEKDAY_FRIDAY}, 105 {1961, ekatime.WEEKDAY_SUNDAY}, 106 {1962, ekatime.WEEKDAY_MONDAY}, 107 {1963, ekatime.WEEKDAY_TUESDAY}, 108 {1964, ekatime.WEEKDAY_WEDNESDAY}, 109 {1965, ekatime.WEEKDAY_FRIDAY}, 110 {1966, ekatime.WEEKDAY_SATURDAY}, 111 {1967, ekatime.WEEKDAY_SUNDAY}, 112 {1968, ekatime.WEEKDAY_MONDAY}, 113 {1969, ekatime.WEEKDAY_WEDNESDAY}, 114 {1970, ekatime.WEEKDAY_THURSDAY}, 115 {1971, ekatime.WEEKDAY_FRIDAY}, 116 {1972, ekatime.WEEKDAY_SATURDAY}, 117 {1973, ekatime.WEEKDAY_MONDAY}, 118 {1974, ekatime.WEEKDAY_TUESDAY}, 119 {1975, ekatime.WEEKDAY_WEDNESDAY}, 120 {1976, ekatime.WEEKDAY_THURSDAY}, 121 {1977, ekatime.WEEKDAY_SATURDAY}, 122 {1978, ekatime.WEEKDAY_SUNDAY}, 123 {1979, ekatime.WEEKDAY_MONDAY}, 124 {1980, ekatime.WEEKDAY_TUESDAY}, 125 {1981, ekatime.WEEKDAY_THURSDAY}, 126 {1982, ekatime.WEEKDAY_FRIDAY}, 127 {1983, ekatime.WEEKDAY_SATURDAY}, 128 {1984, ekatime.WEEKDAY_SUNDAY}, 129 {1985, ekatime.WEEKDAY_TUESDAY}, 130 {1986, ekatime.WEEKDAY_WEDNESDAY}, 131 {1987, ekatime.WEEKDAY_THURSDAY}, 132 {1988, ekatime.WEEKDAY_FRIDAY}, 133 {1989, ekatime.WEEKDAY_SUNDAY}, 134 {1990, ekatime.WEEKDAY_MONDAY}, 135 {1991, ekatime.WEEKDAY_TUESDAY}, 136 {1992, ekatime.WEEKDAY_WEDNESDAY}, 137 {1993, ekatime.WEEKDAY_FRIDAY}, 138 {1994, ekatime.WEEKDAY_SATURDAY}, 139 {1995, ekatime.WEEKDAY_SUNDAY}, 140 {1996, ekatime.WEEKDAY_MONDAY}, 141 {1997, ekatime.WEEKDAY_WEDNESDAY}, 142 {1998, ekatime.WEEKDAY_THURSDAY}, 143 {1999, ekatime.WEEKDAY_FRIDAY}, 144 {2000, ekatime.WEEKDAY_SATURDAY}, 145 {2001, ekatime.WEEKDAY_MONDAY}, 146 {2002, ekatime.WEEKDAY_TUESDAY}, 147 {2003, ekatime.WEEKDAY_WEDNESDAY}, 148 {2004, ekatime.WEEKDAY_THURSDAY}, 149 {2005, ekatime.WEEKDAY_SATURDAY}, 150 {2006, ekatime.WEEKDAY_SUNDAY}, 151 {2007, ekatime.WEEKDAY_MONDAY}, 152 {2008, ekatime.WEEKDAY_TUESDAY}, 153 {2009, ekatime.WEEKDAY_THURSDAY}, 154 {2010, ekatime.WEEKDAY_FRIDAY}, 155 {2011, ekatime.WEEKDAY_SATURDAY}, 156 {2012, ekatime.WEEKDAY_SUNDAY}, 157 {2013, ekatime.WEEKDAY_TUESDAY}, 158 {2014, ekatime.WEEKDAY_WEDNESDAY}, 159 {2015, ekatime.WEEKDAY_THURSDAY}, 160 {2016, ekatime.WEEKDAY_FRIDAY}, 161 {2017, ekatime.WEEKDAY_SUNDAY}, 162 {2018, ekatime.WEEKDAY_MONDAY}, 163 {2019, ekatime.WEEKDAY_TUESDAY}, 164 {2020, ekatime.WEEKDAY_WEDNESDAY}, 165 {2021, ekatime.WEEKDAY_FRIDAY}, 166 {2022, ekatime.WEEKDAY_SATURDAY}, 167 {2023, ekatime.WEEKDAY_SUNDAY}, 168 {2024, ekatime.WEEKDAY_MONDAY}, 169 {2025, ekatime.WEEKDAY_WEDNESDAY}, 170 {2026, ekatime.WEEKDAY_THURSDAY}, 171 } { 172 require.Equal(t, n.expectedWeekday, ekatime.WeekdayJan1(n.y)) 173 } 174 }