Content-Length: 302518 | pFad | http://github.com/TheAlgorithms/Java/pull/6410/commits/158ee510c85f0e90f2d4a435698649b261a9c372

A3 testing: improving `DequeTest` by alxkm · Pull Request #6410 · TheAlgorithms/Java · GitHub
Skip to content

testing: improving DequeTest #6410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
testing: improving DequeTest
  • Loading branch information
alxkm committed Jul 18, 2025
commit 158ee510c85f0e90f2d4a435698649b261a9c372
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.NoSuchElementException;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -50,7 +52,7 @@ void testPollLast() {
@Test
void testIsEmpty() {
Deque<Integer> deque = new Deque<>();
org.junit.jupiter.api.Assertions.assertTrue(deque.isEmpty());
assertTrue(deque.isEmpty());
deque.addFirst(10);
assertFalse(deque.isEmpty());
}
Expand All @@ -70,13 +72,13 @@ void testPeekLastEmpty() {
@Test
void testPollFirstEmpty() {
Deque<Integer> deque = new Deque<>();
org.junit.jupiter.api.Assertions.assertThrows(NoSuchElementException.class, deque::pollFirst);
assertThrows(NoSuchElementException.class, deque::pollFirst);
}

@Test
void testPollLastEmpty() {
Deque<Integer> deque = new Deque<>();
org.junit.jupiter.api.Assertions.assertThrows(NoSuchElementException.class, deque::pollLast);
assertThrows(NoSuchElementException.class, deque::pollLast);
}

@Test
Expand All @@ -87,4 +89,22 @@ void testToString() {
deque.addFirst(5);
assertEquals("Head -> 5 <-> 10 <-> 20 <- Tail", deque.toString());
}

@Test
void testAlternatingAddRemove() {
Deque<Integer> deque = new Deque<>();
deque.addFirst(1);
deque.addLast(2);
deque.addFirst(0);
assertEquals(0, deque.pollFirst());
assertEquals(2, deque.pollLast());
assertEquals(1, deque.pollFirst());
assertTrue(deque.isEmpty());
}

@Test
void testAddNull() {
Deque<Integer> deque = new Deque<>();
assertThrows(NullPointerException.class, () -> deque.addFirst(null));
}
}
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/TheAlgorithms/Java/pull/6410/commits/158ee510c85f0e90f2d4a435698649b261a9c372

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy