import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; public class Question4Test { String s1, s2, s3, s4, s5,s6; @Before public void setUp() { s1 = "s9782647 and S9782647 and especially s0000001 but never s876"; s2 = "s1234567 and S1234567 then input s8765432 S0000005 S8765432"; s3 = "s86 s976753 s s123 s957"; s4 = "s9782647,S9782647 and especially s0000001 but never s876."; s5 = "s9782647_S9782647 and especially s0000001 but never s876."; s6 = "s1234567"; } @Test public void testBasicWithCase() { assertEquals("s9782647,S9782647,s0000001", Question4.findStudentIds(s1)); } @Test public void testNone() { assertEquals("", Question4.findStudentIds(s3)); } @Test public void testLots() { assertEquals("s1234567,S1234567,s8765432,S0000005,S8765432", Question4.findStudentIds(s2)); } @Test public void testComma() { assertEquals("s9782647,S9782647,s0000001", Question4.findStudentIds(s4)); } @Test public void testUnderscore() { assertEquals("s0000001", Question4.findStudentIds(s5)); } // don't actually mind if this fails @Test public void testNull() { assertEquals("", Question4.findStudentIds(null)); } @Test public void testWholeStringIsMatch() { assertEquals("s1234567", Question4.findStudentIds(s6)); } }