Commits

Bogdan Mart committed d5004e5

testFold

  • Participants
  • Parent commits 9c612d7

Comments (0)

Files changed (1)

src/test/java/com/innahema/collections/query/queriables/QueryableTest.java

     }
 
     @Test
+    public void testFold()
+    {
+        Queryable<Integer> q = Queryable.from(1,2,3,4,5,6);
+
+        int res = q.fold((a,x)->{
+            assertEquals(x-1,(int)a);
+            return x;
+        });
+        assertEquals(6,res);
+
+
+        res = q.fold(
+                1,
+                (a,x)->{
+                    assertEquals(x, a);
+                    return x+1;
+                }
+        );
+        assertEquals(7,res);
+
+
+        String res2 = q.fold(
+                1,
+                (a,x)->{
+                    assertEquals(x, a);
+                    return x+1;
+                },
+                x -> x.toString()
+        );
+        assertEquals("7",res2);
+    }
+
+    @Test
     public void testMinMax()
     {
         Queryable<Integer> ints  = Queryable.from(1,2,0,5,6,3,4);