A very simple code,I can't understand this error.pleace help me !
Does '#' need "\" ? I tried but it doesn't work!
Or if you have any more helpful test this 'charTest' method or code please tell me!
public class Stringtest {
String charTest(char first,char second){
System.out.println("first = " + first);
System.out.println("second = " + second);
String res="";
if(first=='#'||first=='*'){
if(isNumbers(second)){
res+="FILE_CHANGE";
return res;
}
}
res+="N";
if(!isNumbers(second)){
res+="M";
}
return res;
}
boolean isNumbers(char chars){
return Character.getNumericValue(chars)<=57 && Character.getNumericValue(chars)>=48;
}
@CsvSource(value = {
"*1",
"#0", // #0 throws org.junit.platform.commons.PreconditionViolationException: Line at index 1 contains invalid CSV: "#0"
"*w",
"#?", // why # can't be the firstchar?
"A1",
"cc"
})
@ParameterizedTest(name = "nums {index}==>firstchar:{0},sencondchar:{1}")
void test1(ArgumentsAccessor accessor){
System.out.println(charTest(accessor.getString(0).charAt(0),accessor.getString(0).charAt(1)));
}
}
This is the Exception stack for top 5
org.junit.platform.commons.PreconditionViolationException: Line at index 1 contains invalid CSV: "#0"
at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:296)
at org.junit.platform.commons.util.Preconditions.notNull(Preconditions.java:68)
at org.junit.jupiter.params.provider.CsvArgumentsProvider.parseLine(CsvArgumentsProvider.java:73)
at org.junit.jupiter.params.provider.CsvArgumentsProvider.lambda$provideArguments$0(CsvArgumentsProvider.jav