-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathFilterTest.java
More file actions
42 lines (33 loc) · 1.16 KB
/
FilterTest.java
File metadata and controls
42 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package bwapi;
import org.junit.*;
import java.util.*;
import static bwapi.UnitFilter.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
public class FilterTest {
List<Unit> units;
@Before
public void setup() {
Unit u = mock(Unit.class);
when(u.getHitPoints()).thenReturn(20);
when(u.getType()).thenReturn(UnitType.Resource_Mineral_Field);
units = Arrays.asList(u);
}
@Test
public void testBasicFilters() {
assertTrue(units.stream().anyMatch(IsMineralField));
assertTrue(units.stream().noneMatch(IsRefinery));
}
@Test
public void testVariableFilters() {
assertTrue(units.stream().anyMatch(GetType(t -> t == UnitType.Resource_Mineral_Field)));
assertTrue(units.stream().anyMatch(HP(x -> x > 10)));
assertTrue(units.stream().noneMatch(HP(x -> x == 10)));
}
@Test
public void testFilterCombinations() {
assertTrue(units.stream().anyMatch(IsMineralField.or(IsRefinery)));
assertTrue(units.stream().noneMatch(IsMineralField.and(IsRefinery)));
assertTrue(units.stream().noneMatch(IsMineralField.negate()));
}
}