From a36a11502e1ecda1b679a5321d74d25631383217 Mon Sep 17 00:00:00 2001 From: TruongCongTri <44316735+TruongCongTri@users.noreply.github.com> Date: Thu, 15 Jul 2021 16:53:19 +0700 Subject: [PATCH] add unit test add unit test for ReverseWordsInAString function. --- .../yelp/ReverseWordsInAStringUnitTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 company/yelp/ReverseWordsInAStringUnitTest.java diff --git a/company/yelp/ReverseWordsInAStringUnitTest.java b/company/yelp/ReverseWordsInAStringUnitTest.java new file mode 100644 index 00000000..5365e938 --- /dev/null +++ b/company/yelp/ReverseWordsInAStringUnitTest.java @@ -0,0 +1,65 @@ + +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 YelpUnitTest { + private ReverseWordsInAString reverseString; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + reverseString = new ReverseWordsInAString(); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void trueTest() { + String s = "Today is Monday"; + String expectResult = "Monday is Today"; + + assertEquals(expectResult, reverseString.reverseWords(s)); + } + + @Test + public void trueTest2() { + String s = "One plus One equals Two"; + String expectResult = "Two equals One plus One"; + + assertEquals(expectResult, reverseString.reverseWords(s)); + } + + @Test + public void trueTest3() { + String s = "Saturday Night Live"; + String expectResult = "Live Night Saturday"; + + assertEquals(expectResult, reverseString.reverseWords(s)); + } + + @Test + public void emptyTest() { + String s = ""; + String expectResult = ""; + + assertEquals(expectResult, reverseString.reverseWords(s)); + } + + +}