11package com .baeldung .algorithms .sumoftwosquares ;
22
33import org .junit .jupiter .api .Test ;
4+ import org .junit .jupiter .api .DisplayName ;
45import static org .junit .jupiter .api .Assertions .assertTrue ;
56import static org .junit .jupiter .api .Assertions .assertFalse ;
67
78
8- class NumberAsSumOfTwoSquaresTest {
9+ class NumberAsSumOfTwoSquaresUnitTest {
910
1011 @ Test
11- void IsNumberSumOfTwoSquaresValid () {
12+ @ DisplayName ("Given input number can be expressed as a sum of squares, when checked, then returns true" )
13+ void givenNumberIsSumOfSquares_whenCheckIsCalled_thenReturnsTrue () {
1214 // Simple cases
1315 assertTrue (NumberAsSumOfTwoSquares .isSumOfTwoSquares (0 )); // 0^2 + 0^2
1416 assertTrue (NumberAsSumOfTwoSquares .isSumOfTwoSquares (1 )); // 1^2 + 0^2
@@ -22,7 +24,8 @@ void IsNumberSumOfTwoSquaresValid() {
2224 }
2325
2426 @ Test
25- void IsNumberNotSumOfTwoSquaresValid () {
27+ @ DisplayName ("Given input number can't be expressed as a sum of squares, when checked, then returns false" )
28+ void givenNumberIsNotSumOfSquares_whenCheckIsCalled_thenReturnsFalse () {
2629 // Simple cases
2730 assertFalse (NumberAsSumOfTwoSquares .isSumOfTwoSquares (3 )); // 3 (4k+3, exp 1)
2831 assertFalse (NumberAsSumOfTwoSquares .isSumOfTwoSquares (6 )); // 2 * 3 (3 has exp 1)
@@ -36,7 +39,8 @@ void IsNumberNotSumOfTwoSquaresValid() {
3639 }
3740
3841 @ Test
39- void IsNumberNegative () {
42+ @ DisplayName ("Given input number is negative, when checked, then returns false" )
43+ void givenNegativeNumber_whenCheckIsCalled_thenReturnsFalse () {
4044 assertFalse (NumberAsSumOfTwoSquares .isSumOfTwoSquares (-1 )); // Negatives as hygiene
4145 assertFalse (NumberAsSumOfTwoSquares .isSumOfTwoSquares (-10 )); // Negatives as hygiene
4246 }
0 commit comments