I'm failing the following test case:
@Test (timeout=3000) public void gatenot_0(){
GateNot g = new GateNot (new Wire("inw"), new Wire("outa"));
g.feed("0");
boolean ans = g.propagate();
assertEquals(sigs1, g.read());
}
which says "Invalid character"
- Exception thrown by the following method:
public static List <Signal> fromString(String inps)
{
List<Signal> values = new ArrayList<Signal>();
for(int i = 0; i < inps.length(); i++)
{
if(inps.charAt(i) != '1' && inps.charAt(i) != '0'
&& inps.charAt(i) != 'X' && inps.charAt(i) != 'x'
&& inps.charAt(i) != ' ' && inps.charAt(i) != '\t')
throw new ExceptionLogicMalformedSignal(inps.charAt(0), "Invalid character!");
else if(inps.charAt(i) == '1')
values.add(HI);
else if(inps.charAt(i) == '0')
values.add(LO);
else if(inps.charAt(i) == 'X')
values.add(X);
else if(inps.charAt(i) == 'x')
values.add(X);
}
return values;
}
Everytime I pass something including "0" or "1" it throws Exception So, should I check every letter of String inps as a String instead of charAt()
. If yes, how should I check that? Thanks in advance.