Add unit tests for PalindromeNumber (#4227)

This commit is contained in:
Albina Gimaletdinova
2023-07-01 21:29:10 +03:00
committed by GitHub
parent 8862a4dea5
commit 4b45ac7e71
3 changed files with 32 additions and 8 deletions

View File

@ -1,13 +1,6 @@
package com.thealgorithms.maths;
public class PalindromeNumber {
public static void main(String[] args) {
assert isPalindrome(12321);
assert !isPalindrome(1234);
assert isPalindrome(1);
}
/**
* Check if {@code n} is palindrome number or not
*
@ -17,7 +10,7 @@ public class PalindromeNumber {
*/
public static boolean isPalindrome(int number) {
if (number < 0) {
throw new IllegalArgumentException(number + "");
throw new IllegalArgumentException("Input parameter must not be negative!");
}
int numberCopy = number;
int reverseNumber = 0;