-
Notifications
You must be signed in to change notification settings - Fork 19.7k
/
Copy pathPalindromeNumberTest.java
30 lines (26 loc) · 1.09 KB
/
PalindromeNumberTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.thealgorithms.maths;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* @author Albina Gimaletdinova on 01/07/2023
*/
public class PalindromeNumberTest {
@Test
public void testNumbersArePalindromes() {
Assertions.assertTrue(PalindromeNumber.isPalindrome(0));
Assertions.assertTrue(PalindromeNumber.isPalindrome(1));
Assertions.assertTrue(PalindromeNumber.isPalindrome(2332));
Assertions.assertTrue(PalindromeNumber.isPalindrome(12321));
}
@Test
public void testNumbersAreNotPalindromes() {
Assertions.assertFalse(PalindromeNumber.isPalindrome(12));
Assertions.assertFalse(PalindromeNumber.isPalindrome(990));
Assertions.assertFalse(PalindromeNumber.isPalindrome(1234));
}
@Test
public void testIfNegativeInputThenExceptionExpected() {
IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> PalindromeNumber.isPalindrome(-1));
Assertions.assertEquals(exception.getMessage(), "Input parameter must not be negative!");
}
}