Skip to content

Add junit test #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/main/java/com/hackerrank/algorithms/test/TestTwoString.Java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.hackerrank.algorithms.test;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some review comments:

  • The file location isn't correct. See file structure for maven projects and see where "tests" classes should reside.
  • File is not formatted properly. Default IntelliJ formatting would suffice here.



import com.hackerrank.algorithms.strings.TwoStrings;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestTwoString {
@Test
void test1IsSubstringInBoth(){
String[] test1 = {"oo", "ab"};
String result = TwoStrings.isSubstringInBoth(test1);
assertEquals("NO",result);
}
@Test
void test2IsSubstringInBoth(){
String[] test1 = {"123a", "1a2"};
String result = TwoStrings.isSubstringInBoth(test1);
assertEquals("YES",result);
}
@Test
void test3IsSubstringInBoth(){
String[] test1 = {"ooa", "ab"};
String result = TwoStrings.isSubstringInBoth(test1);
assertEquals("YES",result);
}
@Test
void test4IsSubstringInBoth(){
String[] test1 = {"ooA", "ab"};
String result = TwoStrings.isSubstringInBoth(test1);
assertEquals("NO",result);
}
@Test
void test5IsSubstringInBoth(){
String[] test1 = {"@@@", "ab@"};
String result = TwoStrings.isSubstringInBoth(test1);
assertEquals("NO",result);
}
@Test
void test6IsSubstringInBoth(){
String[] test1 = {"", "ab"};
String result = TwoStrings.isSubstringInBoth(test1);
assertEquals("NO",result);
}
@Test
void test7IsSubstringInBoth(){
String[] test1 = {"", ""};
String result = TwoStrings.isSubstringInBoth(test1);
assertEquals("NO",result);
}
}