Revize bb5636cc
Přidáno uživatelem Jan Jirman před téměř 6 roky(ů)
src/test/testBitmap.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import static org.junit.Assert.assertArrayEquals; |
4 | 4 |
import static org.junit.Assert.assertEquals; |
5 |
import static org.junit.Assert.assertTrue; |
|
5 | 6 |
|
6 | 7 |
import java.time.DayOfWeek; |
7 | 8 |
import java.time.LocalDate; |
... | ... | |
25 | 26 |
private static Bitmap bitmap; |
26 | 27 |
private static LocalDate dateFrom; |
27 | 28 |
private static LocalDate dateTo; |
29 |
private char[] hardCodesChar; |
|
28 | 30 |
|
29 | 31 |
@BeforeClass |
30 | 32 |
public static void setUpBeforeClass() { |
31 | 33 |
|
32 | 34 |
BasicConfigurator.configure(); |
33 | 35 |
Logger.getRootLogger().setLevel(Level.INFO); |
36 |
|
|
37 |
|
|
34 | 38 |
|
35 | 39 |
} |
36 | 40 |
|
... | ... | |
39 | 43 |
|
40 | 44 |
dateFrom = LocalDate.of(2019, 5, 1); |
41 | 45 |
dateTo = LocalDate.of(2019, 5, 31); |
46 |
|
|
47 |
|
|
42 | 48 |
|
43 | 49 |
bitmap = new Bitmap(dateFrom, dateTo, "143440","1","34", "5", "1"); |
50 |
hardCodesChar = bitmap.getHardCodes().toCharArray(); |
|
44 | 51 |
|
45 | 52 |
} |
46 | 53 |
|
... | ... | |
74 | 81 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1]")); |
75 | 82 |
} |
76 | 83 |
|
84 |
@Test |
|
85 |
public void testsetWorkdaysInRange(){ |
|
86 |
bitmap.setWorkdaysInRange(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 15), 1); |
|
87 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")); |
|
88 |
} |
|
89 |
|
|
77 | 90 |
@Test |
78 | 91 |
public void testsetSundaysAndHolidays() { |
79 | 92 |
bitmap.setSundaysAndHolidays(1); |
80 | 93 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]")); |
81 | 94 |
} |
82 | 95 |
|
96 |
@Test |
|
97 |
public void testsetSundaysAndHolidays2() { |
|
98 |
bitmap.setSundaysAndHolidays(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 15),1); |
|
99 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")); |
|
100 |
} |
|
101 |
|
|
83 | 102 |
|
84 | 103 |
@Test |
85 | 104 |
public void testsetOneDayOnly() { |
... | ... | |
98 | 117 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")); |
99 | 118 |
} |
100 | 119 |
|
120 |
@Test |
|
121 |
public void unsetDaysInRange() { |
|
122 |
bitmap.setWorkdays(1); |
|
123 |
bitmap.unsetDaysInRange(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 15)); |
|
124 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1]")); |
|
125 |
} |
|
126 |
|
|
101 | 127 |
@Test |
102 | 128 |
public void testsetDaysInWeek(){ |
103 | 129 |
bitmap.setDaysInWeek(DayOfWeek.MONDAY, 1); //kazde pondeli ... pondeli - 2 |
... | ... | |
105 | 131 |
|
106 | 132 |
} |
107 | 133 |
|
134 |
@Test |
|
135 |
public void testsetDaysInWeek2(){ |
|
136 |
bitmap.setDaysInWeek(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 15),DayOfWeek.MONDAY, 1); //kazde pondeli ... pondeli - 2 |
|
137 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")); |
|
138 |
} |
|
139 |
|
|
108 | 140 |
@Test |
109 | 141 |
public void testsetWeeks(){ |
110 | 142 |
bitmap.setWeeks(1, 1); |
... | ... | |
121 | 153 |
|
122 | 154 |
} |
123 | 155 |
|
156 |
@Test |
|
157 |
public void setHolidays() { |
|
158 |
bitmap.setHolidays(1); |
|
159 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")); |
|
160 |
} |
|
161 |
|
|
162 |
@Test |
|
163 |
public void setHardCodeDays() { |
|
164 |
bitmap.setHardCodeDays(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 15), 1); |
|
165 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")); |
|
166 |
|
|
167 |
} |
|
168 |
|
|
169 |
|
|
170 |
@Test |
|
171 |
public void setHardCodeWeeks() { |
|
172 |
bitmap.setHardCodeWeeks(1,1); |
|
173 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]")); |
|
174 |
|
|
175 |
} |
|
176 |
|
|
177 |
|
|
178 |
@Test |
|
179 |
public void setHardCodeWeeksInRange() { |
|
180 |
bitmap.setHardCodeWeeksInRange(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 15),1,1); |
|
181 |
assertEquals(0,bitmap.bitmapToString().compareToIgnoreCase("[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")); |
|
182 |
|
|
183 |
} |
|
184 |
|
|
185 |
@Test |
|
186 |
public void testisHardCodeDay(){ |
|
187 |
assertTrue(bitmap.isHardCodeDay(LocalDate.of(2019, 5, 10), hardCodesChar[0])); |
|
188 |
} |
|
189 |
|
|
190 |
@Test |
|
191 |
public void isBankHoliday() { |
|
192 |
assertTrue(bitmap.isBankHoliday(LocalDate.of(2019, 5, 1))); |
|
193 |
} |
|
194 |
|
|
195 |
/* @Test |
|
196 |
public void getEasterHolidays() { |
|
197 |
bitmap.getEasterHolidays(2019); |
|
198 |
bitmap.; |
|
199 |
} */ |
|
200 |
|
|
201 |
@Test |
|
202 |
public void getBitmapString() { |
|
203 |
bitmap.setWorkdays(1); |
|
204 |
assertEquals(0,bitmap.getBitmapString().compareToIgnoreCase("0110011011001111100111110011111")); |
|
205 |
} |
|
206 |
|
|
124 | 207 |
@Test |
125 | 208 |
public void testfillWithZeros(){ |
126 | 209 |
bitmap.fillWithZeros(); |
Také k dispozici: Unified diff
Testování třídy Bitmap (Re #7489)