bool isPalindrome(int x) { int sign = 1; if(x < 0) return false; long result = 0; result = ReverseInteger(x); if( result > INT_MAX || result < INT_MIN ) return false; if( result == x ) return true; else return false; }
int main (int argc, char *argv[]) { // Run some basic tests to check functionality bool passedTests = true; if (0 != ReverseInteger(0)) passedTests = false; if (1 != ReverseInteger(1)) passedTests = false; if (-1 != ReverseInteger(-1)) passedTests = false; if (1 != ReverseInteger(10)) passedTests = false; if (-1 != ReverseInteger(-10)) passedTests = false; if (1 != ReverseInteger(100)) passedTests = false; if (-1 != ReverseInteger(-100)) passedTests = false; if (8005 != ReverseInteger(5008)) passedTests = false; if (-8005 != ReverseInteger(-5008)) passedTests = false; if (7463847412 != ReverseInteger(2147483647)) passedTests = false; if (-7463847412 != ReverseInteger(-2147483647)) passedTests = false; std::cout << "Test status: " << passedTests << std::endl; }