|
1 | 1 | package com.igormaznitsa.jbbp.utils;
|
2 | 2 |
|
| 3 | +import com.igormaznitsa.jbbp.JBBPParser; |
3 | 4 | import com.igormaznitsa.jbbp.io.JBBPBitNumber;
|
4 | 5 | import com.igormaznitsa.jbbp.io.JBBPByteOrder;
|
5 | 6 | import com.igormaznitsa.jbbp.mapper.Bin;
|
6 | 7 | import com.igormaznitsa.jbbp.mapper.BinType;
|
| 8 | +import com.igormaznitsa.jbbp.model.JBBPFieldArrayBit; |
| 9 | +import com.igormaznitsa.jbbp.model.JBBPFieldStruct; |
7 | 10 | import org.junit.jupiter.api.Test;
|
8 | 11 | import org.junit.jupiter.api.function.Executable;
|
9 | 12 |
|
@@ -495,6 +498,21 @@ class Internal {
|
495 | 498 | assertEquals("Test{int a;<int b;int c;d[a+b]{short a;short[8] b;}}", Begin().AnnotatedClass(Test.class).End());
|
496 | 499 | }
|
497 | 500 |
|
| 501 | + @Test |
| 502 | + public void testReportedIssue_20_NPEforOutBitNumber() throws Exception { |
| 503 | + class BreakJBBPDslBuilder { |
| 504 | + @Bin(outOrder = 1, comment = "Reserved", type = BinType.BIT_ARRAY, extra = "4") |
| 505 | + public byte[] reserved; |
| 506 | + } |
| 507 | + |
| 508 | + final String dsl = Begin().AnnotatedClass(BreakJBBPDslBuilder.class).End(); |
| 509 | + |
| 510 | + assertEquals("BreakJBBPDslBuilder{bit:8[4] reserved;}", dsl); |
| 511 | + |
| 512 | + JBBPFieldStruct struct = JBBPParser.prepare(dsl).parse(new byte[] {1, 2, 3, 4}); |
| 513 | + assertArrayEquals(new byte[] {1, 2, 3, 4}, struct.findFieldForType(JBBPFieldStruct.class).findFieldForType(JBBPFieldArrayBit.class).getArray()); |
| 514 | + } |
| 515 | + |
498 | 516 | @Test
|
499 | 517 | public void testAnotatedClass_AnnottatedAllTypes() {
|
500 | 518 | class Test {
|
|
0 commit comments