mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-29 07:50:29 -04:00
new test data parser parses hex numbers correct
This commit is contained in:
parent
a9360a465f
commit
c31554c5b1
@ -143,7 +143,7 @@ public class Tokenizer {
|
||||
boolean wasChar = true;
|
||||
do {
|
||||
c = readChar();
|
||||
if (isNumberChar(c) || c == 'x' || c == 'X') {
|
||||
if (isNumberChar(c) || isHexChar(c) || c == 'x' || c == 'X') {
|
||||
builder.append((char) c);
|
||||
} else {
|
||||
unreadChar(c);
|
||||
@ -208,6 +208,11 @@ public class Tokenizer {
|
||||
|| (c == '_');
|
||||
}
|
||||
|
||||
private boolean isHexChar(int c) {
|
||||
return (c >= 'a' && c <= 'f')
|
||||
|| (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
||||
private boolean isNumberChar(int c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
@ -35,6 +35,19 @@ public class ParserTest extends TestCase {
|
||||
assertEquals(Value.Type.DONTCARE, td.getLines().get(2)[1].getType());
|
||||
}
|
||||
|
||||
public void testHex() throws TestingDataException, IOException, ParserException {
|
||||
Parser td = new Parser("A B\n0 0xff").parse();
|
||||
assertEquals(2, td.getNames().size());
|
||||
|
||||
assertEquals(1, td.getLines().size());
|
||||
|
||||
assertEquals(0, td.getLines().get(0)[0].getValue());
|
||||
assertEquals(Value.Type.NORMAL, td.getLines().get(0)[0].getType());
|
||||
|
||||
assertEquals(255, td.getLines().get(0)[1].getValue());
|
||||
assertEquals(Value.Type.NORMAL, td.getLines().get(0)[1].getType());
|
||||
}
|
||||
|
||||
public void testMissingValue() throws IOException, ParserException {
|
||||
try {
|
||||
new Parser("A B\n0 0\n1").parse();
|
||||
|
Loading…
x
Reference in New Issue
Block a user