package palindrome;

import org.junit.Test;

import static org.junit.Assert.*;

/**

* Unit test for simple App.

*/

public class AppTest {

/**

* Rigourous Test 🙂

*/

@Test

public void testApp() {

assertTrue( true );

}

@Test

public void isPalindrome() {

// Arrange

String strInput = “madam”;

boolean expectedResult = true;

Palindrome objPalindrome = new Palindrome();

// Act

boolean actualResult = objPalindrome.isPal(strInput);

// Assert

assertEquals(expectedResult, actualResult);

}

@Test

public void isNotPalindrome() {

// Arrange

String strInput = “madame”;

boolean expectedResult = false;

Palindrome objPalindrome = new Palindrome();

// Act

boolean actualResult = objPalindrome.isPal(strInput);

// Assert

import org.junit.Test;

import static org.junit.Assert.*;

public class PalindromeTest {

@Test

public void testWordToDeque() {

Palindrome p = new Palindrome();

Deque d = p.wordToDeque(“persiflage”);

String actual = “”;

for (int i = 0; i < "persiflage".length(); i++) { actual += d.removeFirst(); } assertEquals("persiflage", actual);} @Test public void testisPalindrome() { Palindrome p = new Palindrome(); assertFalse(p.isPalindrome("cat"));} @Test public void testisPalindrome1() { OffByOne obo = new OffByOne(); assertTrue(obo.equalChars('a', 'b'));} @Test public void testisPalindrome2() { OffByN obn = new OffByN(5);assertTrue(obn.equal package com.company; import org.junit.Test; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.*; public class PalindromeTester { @Test public void testEvens() { assertTrue(PalindromeChecker.isPalindrome("toot")); assertFalse(PalindromeChecker.isPalindrome("toots")); assertFalse(PalindromeChecker.isPalindrome("toeet")); assertTrue(PalindromeChecker.isPalindrome("tootot")); } @Test public void testOdds() { assertTrue(PalindromeChecker.isPalindrome("tot")); assertFalse(PalindromeChecker.isPalindrome("tots")); assertFalse(PalindromeChecker.isPalindrome("toet")); assertTrue( public class PalindromeTest { public static void main(String[] args) { testIsPalindrome("regallager", true); testIsPalindrome("racecar", true); testIsPalindrome("hello", false); } private static void testIsPalindrome(String word, boolean expected) { boolean actual = Palindrome.isPalindrome(word); System.out.print("Testing that " + word + " is"); if (!expected) { System.out.print(" not"); } System.out.println(" a palindrome..."); if (actual == expected) { System.out.println("PASSED"); } else { System.out.println("FAILED: Expected " + expected + ", but was " + actual); } System.out.println(); // Prints a blank line to separate tests from each other } } package palindrome; import static org.junit.Assert.*; import org.junit.Test; import static org.hamcrest.CoreMatchers.*; public class PalindromeTest { private String palindrome = "Dot saw I was Tod"; private String nonPalindrome = "I am not a palindrome"; @Test public void testForPalindrome() { assertThat(palindrome, is(Palindrome.isPalindrome(palindrome))); } @Test public void testForNonPalindrome() { assertThat(nonPalindrome, is(not(Palindrome.isPalindrome(nonPalindrome)))); } package com.sample; import junit.framework.TestCase; public class PalindromeTest extends TestCase { public void testPalindromeCheck() { boolean isPalindrome = PalindromeChecker.isPalindrome(“karan”); assertFalse(isPalindrome); } } private Palindrome p; public void setUp() { p = new Palindrome(); } public void testPalindrome() { assertFalse(p.isPalindrome("abc")); assertTrue(p.isPalindrome("aba")); }

Tomy

Tomy is a contributor at AskMeCode. We are committed to providing well-researched, accurate, and valuable content to our readers.

You May Also Like

5 Things You Should Know before you Beautify your code

5 Things You Should Know before you Beautify your code

Before you run your code through the beautifier, there are a few things you should consider. First, you need to...

Artistic representation for Common Coding Best Practices Mistakes to Avoid

Common Coding Best Practices Mistakes to Avoid

Common Coding Best Practices Mistakes to Avoid Coding best practices are essential for creating efficient, maintainable, and scalable software solutions....

Artistic representation for Claude 3 7 Sonnet Review : Hybrid Reasoning Coding Expertise

Claude 3 7 Sonnet Review : Hybrid Reasoning Coding Expertise

Here are some key features and benefits of the Claude 3.7 Sonnet model:Key Features and BenefitsEnhanced Reasoning Capabilities: The Claude...

Introducing openai codex Learn To Code with The World’s Most Powerful AI

Introducing openai codex Learn To Code with The World’s Most Powerful AI

Hi there! Today, I’m excited to announce OpenAI Codex — a tool for people around the world to learn how...

Leave a Reply

About | Contact | Privacy Policy | Terms of Service | Disclaimer | Cookie Policy
© 2026 AskMeCode. All rights reserved.