2020-03-21 00:37:09 +00:00
|
|
|
package de.wwwu.awolf.presenter.util;
|
2017-10-23 15:48:36 +00:00
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
2020-03-21 00:37:09 +00:00
|
|
|
import java.util.Collections;
|
2017-10-23 15:48:36 +00:00
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
|
|
*
|
|
|
|
* @Author: Armin Wolf
|
|
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
|
|
* @Date: 23.10.2017.
|
|
|
|
*/
|
|
|
|
public class FastElementSelectorTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void randomizedSelect() throws Exception {
|
|
|
|
Double[] array = {1d, 2d, 3d, 4d};
|
|
|
|
ArrayList<Double> list = new ArrayList<>(Arrays.asList(array));
|
|
|
|
assertEquals(FastElementSelector.randomizedSelect(list, 0), 1d, 0.00001);
|
|
|
|
assertEquals(FastElementSelector.randomizedSelect(list, 2), 2d, 0.00001);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = IndexOutOfBoundsException.class)
|
|
|
|
public void testIndexOutOfBoundsException() {
|
2020-03-21 00:37:09 +00:00
|
|
|
FastElementSelector.randomizedSelect(Collections.emptyList(), 42);
|
2017-10-23 15:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|