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.util;
15  
16  import static org.junit.Assert.assertTrue;
17  
18  import java.util.Collection;
19  import java.util.Map;
20  
21  import org.apache.commons.functor.generator.range.DoubleRange;
22  import org.junit.Test;
23  
24  import fuzzy.mf.MembershipFunction;
25  import fuzzy.mf.TrapezoidalMembershipFunction;
26  
27  /**
28   * Tests for Max Membership Function.
29   * 
30   * @since 0.2
31   * @see MaxMF
32   */
33  public class TestMaxMF {
34  
35  	@Test
36  	public void testMaxMF() {
37  		Collection<Double> values = new DoubleRange(-10.0, 30.0, 0.1).toCollection();
38  		MembershipFunction<Double> mf = new TrapezoidalMembershipFunction(-5.0,  -2.0, 10.0, 20.0);
39  		Map<Double, Double> r = MaxMF.of(values, mf);
40  		
41  		assertTrue(r.containsValue(Double.valueOf(1.0)));
42  	}
43  	
44  }