1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
import org.junit.Test;
import static org.junit.Assert.*;
public class TestJava {
@Test
public void testRegExp() {
// TODO Auto-generated method stub
String regexp = "/ID[0-9]*$/";
String s1 = "I"; //FALSE
String s2 = "ID"; //FALSE
String s3 = "IDA"; //FALSE
String s4 = "IDA0000"; //FALSE
String s5 = "ID0000A"; //FALSE
String s6 = "ID0123";//TRUE
String s7 = "ID0123A";//FALSE
assertEquals(false, s1.matches(regexp));
assertEquals(false, s2.matches(regexp));
assertEquals(false, s3.matches(regexp));
assertEquals(false, s4.matches(regexp));
assertEquals(false, s5.matches(regexp));
assertEquals(true, s6.matches(regexp));
assertEquals(false, s7.matches(regexp));
}
} |
Partager