|
44 | 44 | import com.igormaznitsa.jbbp.model.JBBPFieldArrayShort; |
45 | 45 | import com.igormaznitsa.jbbp.model.JBBPFieldArrayStruct; |
46 | 46 | import com.igormaznitsa.jbbp.model.JBBPFieldArrayUByte; |
| 47 | +import com.igormaznitsa.jbbp.model.JBBPFieldArrayUInt; |
47 | 48 | import com.igormaznitsa.jbbp.model.JBBPFieldArrayUShort; |
48 | 49 | import com.igormaznitsa.jbbp.model.JBBPFieldBit; |
49 | 50 | import com.igormaznitsa.jbbp.model.JBBPFieldBoolean; |
|
56 | 57 | import com.igormaznitsa.jbbp.model.JBBPFieldString; |
57 | 58 | import com.igormaznitsa.jbbp.model.JBBPFieldStruct; |
58 | 59 | import com.igormaznitsa.jbbp.model.JBBPFieldUByte; |
| 60 | +import com.igormaznitsa.jbbp.model.JBBPFieldUInt; |
59 | 61 | import com.igormaznitsa.jbbp.model.JBBPFieldUShort; |
60 | 62 | import com.igormaznitsa.jbbp.utils.JBBPIntCounter; |
61 | 63 | import com.igormaznitsa.jbbp.utils.TargetSources; |
@@ -2473,4 +2475,21 @@ public void testConvertToSrc_Java_DefaultPackage() { |
2473 | 2475 | assertTrue(src.get(0).getResult().get("SomeClass.java").length() > 128); |
2474 | 2476 | } |
2475 | 2477 |
|
| 2478 | + @Test |
| 2479 | + public void testUintUseInExpression() throws Exception { |
| 2480 | + final JBBPParser parser = JBBPParser.prepare("uint length; uint[(length * 2) >> 1] array;"); |
| 2481 | + final JBBPFieldStruct struct = parser.parse( |
| 2482 | + new byte[] {0, 0, 0, 2, (byte) 0xFF, (byte) 0xF0, (byte) 0xE0, (byte) 0x12, 0x01, 0x02, |
| 2483 | + 0x03, 0x04}); |
| 2484 | + final JBBPFieldUInt length = struct.findFieldForPathAndType("length", JBBPFieldUInt.class); |
| 2485 | + final JBBPFieldArrayUInt array = |
| 2486 | + struct.findFieldForPathAndType("array", JBBPFieldArrayUInt.class); |
| 2487 | + |
| 2488 | + assertEquals(2, length.getAsInt()); |
| 2489 | + assertEquals(2, array.size()); |
| 2490 | + assertThrows(IllegalStateException.class, () -> array.getElementAt(0).getAsInt()); |
| 2491 | + assertEquals(0xFFF0E012L, array.getElementAt(0).getAsLong()); |
| 2492 | + assertEquals(0x01020304, array.getElementAt(1).getAsInt()); |
| 2493 | + } |
| 2494 | + |
2476 | 2495 | } |
0 commit comments