|
15 | 15 | import static net.danielhildebrandt.JArray.numberOf;
|
16 | 16 | import static net.danielhildebrandt.JArray.remove;
|
17 | 17 | import static net.danielhildebrandt.JArray.removeFirst;
|
| 18 | +import static net.danielhildebrandt.JArray.removeLast; |
18 | 19 | import static net.danielhildebrandt.JArray.removeRange;
|
19 | 20 | import static net.danielhildebrandt.JArray.toPrimitiveArray;
|
20 | 21 | import static net.danielhildebrandt.JArray.toWrapperArray;
|
@@ -599,43 +600,62 @@ public static final class RemoveLastTest
|
599 | 600 | @Test
|
600 | 601 | public final void removeLast_NullEmptyElement()
|
601 | 602 | {
|
| 603 | + String[] before = {"Lorkhan", "Doom-Drum", "Doom-Drum", "Shor", "Shezarr", null, null}; |
| 604 | + String[] after = {"Lorkhan", "Doom-Drum", "Shor", "Shezarr", null, null, null}; |
602 | 605 |
|
| 606 | + removeLast(before, null, "Doom-Drum"); |
| 607 | + assertThat(before, is(equalTo(after))); |
603 | 608 | }
|
604 | 609 |
|
605 | 610 | @Test
|
606 | 611 | public final void removeLast_NonNullEmptyElement()
|
607 | 612 | {
|
| 613 | + Object[] before = {"Cyrodiil", "Argonia", "Resdayn", "Argonia", "Elsweyr", "Skyrim", ""}; |
| 614 | + Object[] after = {"Cyrodiil", "Argonia", "Resdayn", "Elsweyr", "Skyrim", "", ""}; |
608 | 615 |
|
| 616 | + removeLast(before, "", "Argonia"); |
| 617 | + assertThat(before, is(equalTo(after))); |
609 | 618 | }
|
610 | 619 |
|
611 | 620 | @Test
|
612 | 621 | public final void removeLast_RemoveEmptyElement()
|
613 | 622 | {
|
| 623 | + String[] before = {"Coldharbor", "Infernace", "Ashpit", "Fourth Sinus of Takubar", ""}; |
| 624 | + String[] after = {"Coldharbor", "Infernace", "Ashpit", "Fourth Sinus of Takubar", ""}; |
614 | 625 |
|
| 626 | + removeLast(before, "", ""); |
| 627 | + assertThat(before, is(equalTo(after))); |
615 | 628 | }
|
616 | 629 |
|
617 | 630 | @Test
|
618 | 631 | public final void removeLast_RemoveNonExistent()
|
619 | 632 | {
|
| 633 | + String[] before = {"Vokun", "Morokei", "Nahkriin", "Hevnoraak", null}; |
| 634 | + String[] after = {"Vokun", "Morokei", "Nahkriin", "Hevnoraak", null}; |
620 | 635 |
|
| 636 | + removeLast(before, null, "Konahriik"); |
| 637 | + assertThat(before, is(equalTo(after))); |
621 | 638 | }
|
622 | 639 |
|
623 |
| - @Test |
| 640 | + @Test(expected = NullPointerException.class) |
624 | 641 | public final void removeLast_NullArray()
|
625 | 642 | {
|
626 |
| - |
| 643 | + Object[] arr = null; |
| 644 | + removeLast(arr, null, "Magna-ge"); |
627 | 645 | }
|
628 | 646 |
|
629 |
| - @Test |
| 647 | + @Test(expected = IllegalArgumentException.class) |
630 | 648 | public final void removeLast_EmptyArray()
|
631 | 649 | {
|
632 |
| - |
| 650 | + String[] arr = {}; |
| 651 | + removeLast(arr, "", "Aetherius"); |
633 | 652 | }
|
634 | 653 |
|
635 |
| - @Test |
| 654 | + @Test(expected = IncompleteArrayException.class) |
636 | 655 | public final void removeLast_IncompleteArray()
|
637 | 656 | {
|
638 |
| - |
| 657 | + String[] arr = {"Yol Tor Shuul", "", "Fus Ro Dah", "Lok Vah Koor", ""}; |
| 658 | + removeLast(arr, "", "Fus Ro Dah"); |
639 | 659 | }
|
640 | 660 | }
|
641 | 661 |
|
|
0 commit comments