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 Sum function.
26 *
27 * @since 0.2
28 * @see Sum
29 */
30 public class TestSum {
31
32 @Test
33 public void testSum() {
34 Collection<Double> list = Arrays.asList(0.0, 1.0, 2.0, 3.5);
35 Double r = Sum.of(list);
36 assertEquals(Double.valueOf(6.5), r);
37 }
38
39 @Test
40 public void testSumEmpty() {
41 Double r = Sum.of(Collections.<Double>emptyList());
42 assertEquals(Double.valueOf(0.0), r);
43 }
44
45 }