From 3c265aae3f5b8a906f517b3c7da05852517cc975 Mon Sep 17 00:00:00 2001 From: anand6105 Date: Tue, 19 Nov 2019 10:42:17 +0100 Subject: [PATCH 1/2] Added new comment to my program --- src/palindrom/palindrom.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/palindrom/palindrom.java b/src/palindrom/palindrom.java index d24ea5f..9a1ba88 100644 --- a/src/palindrom/palindrom.java +++ b/src/palindrom/palindrom.java @@ -2,6 +2,7 @@ import java.io.EOFException; import java.util.Scanner; +/* This is my new palindrome program*/ public class palindrom { public boolean isPal(int a){ int b,c, e; From a394498900679491ba5d375e5518f07cd94ac544 Mon Sep 17 00:00:00 2001 From: anand6105 Date: Tue, 19 Nov 2019 11:59:27 +0100 Subject: [PATCH 2/2] Added test suite AllTest and new test cases --- src/palindrom/palindrom.java | 2 +- untest/palindrom/AllTests.java | 11 ++++++ untest/palindrom/PalindromeTest1.java | 52 +++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 untest/palindrom/AllTests.java create mode 100644 untest/palindrom/PalindromeTest1.java diff --git a/src/palindrom/palindrom.java b/src/palindrom/palindrom.java index 9a1ba88..fcc6614 100644 --- a/src/palindrom/palindrom.java +++ b/src/palindrom/palindrom.java @@ -90,7 +90,7 @@ public static void main(String[] args) { { if(obj.isPal(mas[i])) { - System.out.print(mas[i] + " "); + System.out.print(mas[i] + " It is palindrome"); } } scanner.close(); diff --git a/untest/palindrom/AllTests.java b/untest/palindrom/AllTests.java new file mode 100644 index 0000000..22bb926 --- /dev/null +++ b/untest/palindrom/AllTests.java @@ -0,0 +1,11 @@ +package palindrom; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ PalindromeTest1.class, palindromTest.class }) +public class AllTests { + +} diff --git a/untest/palindrom/PalindromeTest1.java b/untest/palindrom/PalindromeTest1.java new file mode 100644 index 0000000..f670a6b --- /dev/null +++ b/untest/palindrom/PalindromeTest1.java @@ -0,0 +1,52 @@ +package palindrom; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class PalindromeTest1 { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + System.out.println("Test setup for test suite"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + System.out.println("test cleanup after all the tests have executed"); + } + + @Before + public void setUp() throws Exception { + System.out.println("Test setup after each test case"); + } + + @After + public void tearDown() throws Exception { + System.out.println("Test clean up after each test"); + } + + @Test + public void isPalindromPositive() { + palindrom test = new palindrom(); + assertTrue(test.isPal(12321)); + } + + @Test + public void isPalindromeNegative() { + palindrom test = new palindrom(); + assertFalse(test.isPal(1234)); + } + + @Test + public void runExistingTestCase() + { + palindromTest palindromTest = new palindromTest(); + palindromTest.testIsPal(); + } + +}