Skip to content

Commit

Permalink
6.4.1. Сравнить последние элементы двух массивов;
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzor committed Sep 27, 2023
1 parent 6af4652 commit 0f463ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/ru/j4j/array/EqLast.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ru.j4j.array;

public class EqLast {
public static boolean check(int[] left, int[] right) {
return left[left.length - 1] == right[right.length - 1];
}
}
23 changes: 23 additions & 0 deletions src/test/java/ru/j4j/array/EqLastTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.j4j.array;

import static org.assertj.core.api.Assertions.*;

import org.junit.jupiter.api.Test;

class EqLastTest {
@Test
public void whenEq() {
int[] left = {1, 2, 3};
int[] right = {5, 4, 3};
boolean result = EqLast.check(left, right);
assertThat(result).isTrue();
}

@Test
public void whenNotEq() {
int[] left = {1, 2, 3};
int[] right = {3, 3, 4};
boolean result = EqLast.check(left, right);
assertThat(result).isFalse();
}
}

0 comments on commit 0f463ab

Please sign in to comment.