-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from bloder/take-drop
Add Take and Drop function
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.jmonad.seq; | ||
|
||
import org.junit.Test; | ||
|
||
public class SeqDropTest { | ||
|
||
private Integer[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | ||
private Seq<Integer> elements = new Seq<>(numbers); | ||
|
||
@Test public void dropListElementsTest() { | ||
assert elements.drop(5).toArrayList().toString().equals("[6, 7, 8, 9, 10]"); | ||
} | ||
|
||
@Test public void dropElementsWithNoAmountTest() { | ||
assert elements.drop(0).toArrayList().toString().equals("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"); | ||
} | ||
|
||
@Test public void dropElementsWithNegativeAmountTest() { | ||
assert elements.drop(-1).toArrayList().toString().equals("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"); | ||
} | ||
|
||
@Test public void dropElementsWithAmountHigherThanListSizeTest() { | ||
assert elements.drop(20).toArrayList().toString().equals("[]"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.jmonad.seq; | ||
|
||
import org.junit.Test; | ||
|
||
public class SeqTakeTest { | ||
|
||
private Integer[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | ||
private Seq<Integer> elements = new Seq<>(numbers); | ||
|
||
@Test public void takeListElementsTest() { | ||
assert elements.take(5).toArrayList().toString().equals("[1, 2, 3, 4, 5]"); | ||
} | ||
|
||
@Test public void takeElementsWithNoAmountTest() { | ||
assert elements.take(0).toArrayList().toString().equals("[]"); | ||
} | ||
|
||
@Test public void takeElementsWithNegativeAmountTest() { | ||
assert elements.take(-1).toArrayList().toString().equals("[]"); | ||
} | ||
|
||
@Test public void takeElementsWithAmountHigherThanListSizeTest() { | ||
assert elements.take(20).toArrayList().toString().equals("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"); | ||
} | ||
} |