java - testing regular expression using junit? -


i have written regular expression ignore space: regular expression

string ignore_regx = "[^\\s]";  testcase: public void testclass {  @test public void testignoreregx() {  string input = " hai"; asserttrue(input.matches(ignore_regx));  } } 

but above test failing.

could body please how test above expression using junit?

consider using theories test multiple values.

@runwith(theories.class)  public void testclass {    @datapoints   public static final string[] truevalues = new string[]{"", "blah", ...};    @datapoints   public static final string[] falsevalues = new string[]{"  ", " blah", "glah "};   @theory  public void testignoreregx_true(string input) {     assume.assumethat(input, isin.isin(truevalues));     asserttrue(input.matches(ignore_regx));  }   @theory  public void testignoreregx_false(string input) {     assume.assumethat(input, isin.isin(falsevalues ));     assertfalse(input.matches(ignore_regx));  } } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -