mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-30 16:30:04 -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;
|
boolean wasChar = true;
|
||||||
do {
|
do {
|
||||||
c = readChar();
|
c = readChar();
|
||||||
if (isNumberChar(c) || c == 'x' || c == 'X') {
|
if (isNumberChar(c) || isHexChar(c) || c == 'x' || c == 'X') {
|
||||||
builder.append((char) c);
|
builder.append((char) c);
|
||||||
} else {
|
} else {
|
||||||
unreadChar(c);
|
unreadChar(c);
|
||||||
@ -208,6 +208,11 @@ public class Tokenizer {
|
|||||||
|| (c == '_');
|
|| (c == '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isHexChar(int c) {
|
||||||
|
return (c >= 'a' && c <= 'f')
|
||||||
|
|| (c >= 'A' && c <= 'F');
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isNumberChar(int c) {
|
private boolean isNumberChar(int c) {
|
||||||
return (c >= '0' && c <= '9');
|
return (c >= '0' && c <= '9');
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,19 @@ public class ParserTest extends TestCase {
|
|||||||
assertEquals(Value.Type.DONTCARE, td.getLines().get(2)[1].getType());
|
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 {
|
public void testMissingValue() throws IOException, ParserException {
|
||||||
try {
|
try {
|
||||||
new Parser("A B\n0 0\n1").parse();
|
new Parser("A B\n0 0\n1").parse();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user