From 4394387aae2ddddecdc3c221c2e1889730a224a5 Mon Sep 17 00:00:00 2001 From: satchidanandhiremath Date: Sat, 27 Apr 2024 12:41:24 +0530 Subject: [PATCH] unittesting2205110(B) --- src/test/java/mes/unittest/MaxFinderTest.java | 16 ++++++++++++++ src/test/java/mes/unittest/findMaxtest.java | 22 +++++++++++++++++++ unittesting.java | 9 ++++++++ 3 files changed, 47 insertions(+) create mode 100644 src/test/java/mes/unittest/MaxFinderTest.java create mode 100644 src/test/java/mes/unittest/findMaxtest.java create mode 100644 unittesting.java diff --git a/src/test/java/mes/unittest/MaxFinderTest.java b/src/test/java/mes/unittest/MaxFinderTest.java new file mode 100644 index 0000000..4bd3a55 --- /dev/null +++ b/src/test/java/mes/unittest/MaxFinderTest.java @@ -0,0 +1,16 @@ +package unittest; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class MaxFinderTest { + + @Test + public void testFindMax() { + MaxFinder maxFinder = new MaxFinder(); + int[] numbers = {1, 3, 4, 2}; + int expectedResult = 4; + int actualResult = maxFinder.findMax(numbers); + assertEquals(expectedResult, actualResult); + } +} \ No newline at end of file diff --git a/src/test/java/mes/unittest/findMaxtest.java b/src/test/java/mes/unittest/findMaxtest.java new file mode 100644 index 0000000..bdbae37 --- /dev/null +++ b/src/test/java/mes/unittest/findMaxtest.java @@ -0,0 +1,22 @@ +package mes.unittest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest + +public class findMaxtest { + @Test + void contextloads(){ + +} +@Test +void assertfindMaxtest(){ + findMax obj=new findMax(); + int ans=obj.findMaxtest(1) + assertEquals(1,3,4,2.ans); +} + +} \ No newline at end of file diff --git a/unittesting.java b/unittesting.java new file mode 100644 index 0000000..c616de9 --- /dev/null +++ b/unittesting.java @@ -0,0 +1,9 @@ +public int findMax(int[]numbers){ + int max = numbers[0]; + for(int i = 1;imax){ + max = numbers[i]; + } + } + return max; +}