-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nbauma109
committed
May 20, 2023
1 parent
446270a
commit 4c8c59a
Showing
1 changed file
with
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.jd.core.v1.util; | ||
|
||
import org.junit.Test; | ||
import org.junit.Assert; | ||
import java.util.Iterator; | ||
import java.util.NoSuchElementException; | ||
|
||
public class BaseTest { | ||
static class BaseImpl implements Base<BaseImpl> {} | ||
|
||
@Test | ||
public void isListTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
Assert.assertFalse(base.isList()); | ||
} | ||
|
||
@Test | ||
public void getFirstTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
Assert.assertEquals(base, base.getFirst()); | ||
} | ||
|
||
@Test | ||
public void getLastTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
Assert.assertEquals(base, base.getLast()); | ||
} | ||
|
||
@Test(expected = UnsupportedOperationException.class) | ||
public void getListTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
base.getList(); | ||
} | ||
|
||
@Test | ||
public void sizeTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
Assert.assertEquals(1, base.size()); | ||
} | ||
|
||
@Test | ||
public void iteratorTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
Iterator<BaseImpl> iterator = base.iterator(); | ||
|
||
Assert.assertTrue(iterator.hasNext()); | ||
Assert.assertEquals(base, iterator.next()); | ||
Assert.assertFalse(iterator.hasNext()); | ||
} | ||
|
||
@Test(expected = NoSuchElementException.class) | ||
public void iteratorNextNoElementTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
Iterator<BaseImpl> iterator = base.iterator(); | ||
iterator.next(); | ||
iterator.next(); // This will throw NoSuchElementException | ||
} | ||
|
||
@Test(expected = UnsupportedOperationException.class) | ||
public void iteratorRemoveTest() { | ||
Base<BaseImpl> base = new BaseImpl(); | ||
Iterator<BaseImpl> iterator = base.iterator(); | ||
iterator.remove(); // This will throw UnsupportedOperationException | ||
} | ||
} |