Skip to content

Commit e6c6ad5

Browse files
authored
Merge pull request #126 from andrii-k6a/linked-list-exercise-add-test
[2-2-4-linked-list] add test - removing by zero index from empty list
2 parents eaed788 + 7cea1a7 commit e6c6ad5

File tree

1 file changed

+16
-9
lines changed
  • 2-0-data-structures-and-algorithms/2-2-4-linked-list/src/test/java/com/bobocode/cs

1 file changed

+16
-9
lines changed

Diff for: 2-0-data-structures-and-algorithms/2-2-4-linked-list/src/test/java/com/bobocode/cs/LinkedListTest.java

+16-9
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void addToHeadWhenListIsNotEmpty() {
188188

189189
@Test
190190
@Order(11)
191-
void addThrowsExceptionWenIndexIsNegative() {
191+
void addThrowsExceptionWhenIndexIsNegative() {
192192
assertThatExceptionOfType(IndexOutOfBoundsException.class)
193193
.isThrownBy(() -> intList.add(-1, 66));
194194
}
@@ -423,6 +423,13 @@ void removeWhenListIsEmpty() {
423423

424424
@Test
425425
@Order(33)
426+
void removeByZeroIndexWhenListIsEmpty() {
427+
assertThatExceptionOfType(IndexOutOfBoundsException.class)
428+
.isThrownBy(() -> intList.remove(0));
429+
}
430+
431+
@Test
432+
@Order(34)
426433
void size() {
427434
setInternalSize(5);
428435

@@ -432,15 +439,15 @@ void size() {
432439
}
433440

434441
@Test
435-
@Order(34)
442+
@Order(35)
436443
void sizeWhenListIsEmpty() {
437444
int size = getInternalSize();
438445

439446
assertThat(size).isEqualTo(0);
440447
}
441448

442449
@Test
443-
@Order(35)
450+
@Order(36)
444451
void contains() {
445452
addInternalElements(45, 6, 3, 6);
446453

@@ -452,15 +459,15 @@ void contains() {
452459
}
453460

454461
@Test
455-
@Order(36)
462+
@Order(37)
456463
void containsWhenListIsEmpty() {
457464
boolean contains = intList.contains(34);
458465

459466
assertThat(contains).isFalse();
460467
}
461468

462469
@Test
463-
@Order(37)
470+
@Order(38)
464471
void isEmpty() {
465472
addInternalElements(34, 5, 6);
466473

@@ -470,15 +477,15 @@ void isEmpty() {
470477
}
471478

472479
@Test
473-
@Order(38)
480+
@Order(39)
474481
void isEmptyWhenListIsEmpty() {
475482
boolean empty = intList.isEmpty();
476483

477484
assertThat(empty).isTrue();
478485
}
479486

480487
@Test
481-
@Order(39)
488+
@Order(40)
482489
void clearWhenListIsEmpty() {
483490
intList.clear();
484491

@@ -488,7 +495,7 @@ void clearWhenListIsEmpty() {
488495
}
489496

490497
@Test
491-
@Order(40)
498+
@Order(41)
492499
void clearChangesSize() {
493500
addInternalElements(4, 5, 6);
494501

@@ -500,7 +507,7 @@ void clearChangesSize() {
500507
}
501508

502509
@Test
503-
@Order(41)
510+
@Order(42)
504511
void clearRemovesAllElements() {
505512
addInternalElements(4, 5, 6);
506513

0 commit comments

Comments
 (0)