1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.hipparchus.optim;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.junit.Assert;
23 import org.junit.Test;
24
25 public class ConvergenceCheckerOrMultiplexerTest {
26
27 @Test
28 public void testFalseFalse() {
29 Assert.assertFalse(new ConvergenceCheckerOrMultiplexer<>(buildCheckers(false, false)).converged(0, null, null));
30 }
31
32 @Test
33 public void testFalseTrue() {
34 Assert.assertTrue(new ConvergenceCheckerOrMultiplexer<>(buildCheckers(false, true)).converged(0, null, null));
35 }
36
37 @Test
38 public void testTrueFalse() {
39 Assert.assertTrue(new ConvergenceCheckerOrMultiplexer<>(buildCheckers(true, false)).converged(0, null, null));
40 }
41
42 @Test
43 public void testTrueTrue() {
44 Assert.assertTrue(new ConvergenceCheckerOrMultiplexer<>(buildCheckers(true, true)).converged(0, null, null));
45 }
46
47 private List<ConvergenceChecker<Object>> buildCheckers(final boolean result1, final boolean result2) {
48 final List<ConvergenceChecker<Object>> checkers = new ArrayList<>();
49 checkers.add((iteration, previous, current) -> result1);
50 checkers.add((iteration, previous, current) -> result2);
51 return checkers;
52 }
53
54 }