mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 14:16:14 +01:00
36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
////////////////////////////////////////
|
|
// Programming project code
|
|
// UniBw M, 2022, 2023, 2024
|
|
// www.unibw.de/inf2
|
|
// (c) Mark Minas (mark.minas@unibw.de)
|
|
////////////////////////////////////////
|
|
|
|
package pp.util;
|
|
|
|
import org.junit.Test;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
public class RandomPositionIteratorTest {
|
|
public static final int WIDTH = 15;
|
|
public static final int HEIGHT = 25;
|
|
|
|
@Test
|
|
public void permutation() {
|
|
for (int i = 0; i < 10; i++) {
|
|
final List<Position> permutation = new ArrayList<>();
|
|
RandomPositionIterator.floatPoints(WIDTH, HEIGHT).forEachRemaining(permutation::add);
|
|
assertEquals(WIDTH * HEIGHT, permutation.size());
|
|
assertEquals(permutation.size(), new HashSet<>(permutation).size());
|
|
for (Position w : permutation) {
|
|
assertTrue(w.toString(), 0 <= w.getX() && w.getX() < WIDTH);
|
|
assertTrue(w.toString(), 0 <= w.getY() && w.getY() < HEIGHT);
|
|
}
|
|
}
|
|
}
|
|
} |