1   /*
2    * Licensed under the Apache License, Version 2.0 (the "License"); 
3    * you may not use this file except in compliance with the License. 
4    * You may obtain a copy of the License at
5    *
6    *     http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software 
9    * distributed under the License is distributed on an 
10   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
11   * either express or implied. See the License for the specific language 
12   * governing permissions and limitations under the License.
13   */
14  package fuzzy.internal.functions;
15  
16  import static org.junit.Assert.assertEquals;
17  
18  import java.util.Arrays;
19  import java.util.Collection;
20  import java.util.Collections;
21  
22  import org.junit.Test;
23  
24  /**
25   * Tests for Max function.
26   * 
27   * @since 0.2
28   * @see Max
29   */
30  public class TestMax {
31  
32  	@Test
33  	public void testMax() {
34  		Collection<Double> list = Arrays.asList(-1.0, 1.0, 2.0, 3.5);
35  		Double r = Max.of(list, false);
36  		assertEquals(Double.valueOf(3.5), r);
37  	}
38  	
39  	@Test
40  	public void testMaxEmpty() {
41  		Double r = Max.of(Collections.<Double>emptyList(), false);
42  		assertEquals(Double.valueOf(0.0), r);
43  	}
44  
45  	@Test
46      public void testMaxAbs() {
47  	    Collection<Double> list = Arrays.asList(-10.0, -1.0, 1.0, 2.0, 3.5);
48          Double r = Max.of(list, true);
49          assertEquals(Double.valueOf(-10.0), r);
50      }
51  }