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.assertEquals;
17  import static org.junit.Assert.assertTrue;
18  
19  import java.util.Collection;
20  
21  import org.apache.commons.functor.generator.range.DoubleRange;
22  import org.junit.Test;
23  
24  import fuzzy.mf.GeneralizedBellShapedMembershipFunction;
25  import fuzzy.mf.MembershipFunction;
26  
27  /**
28   * Tests for Crisp Fuzzy Product.
29   * 
30   * @since 0.2
31   * @see CrispFuzzyProduct
32   */
33  public class TestCrispFuzzyProduct {
34  
35  	@Test
36  	public void testCrispFuzzyProduct() {
37  		Collection<Double> col = new DoubleRange(0.0, 1.0, 0.1).toCollection(); // crisp
38  		MembershipFunction<Double> mf = new GeneralizedBellShapedMembershipFunction(0.2, 0.5, 0.8); // fuzzy
39  		Collection<Double> r = CrispFuzzyProduct.of(col, mf);
40  		assertTrue(r.size() == 11);
41  		assertEquals(Double.valueOf(0.0), r.iterator().next()); // 0.0 * n = 0.0
42  	}
43  	
44  }