You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.AssertionError: expected [255] but found [-1]
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.failNotEquals(Assert.java:513)
at org.testng.Assert.assertEqualsImpl(Assert.java:135)
at org.testng.Assert.assertEquals(Assert.java:116)
at org.testng.Assert.assertEquals(Assert.java:389)
at org.testng.Assert.assertEquals(Assert.java:399)
at io.kaitai.struct.spec.CommonSpec.assertIntEquals(CommonSpec.java:36)
at io.kaitai.struct.spec.TestExprBytesOps.testExprBytesOps(TestExprBytesOps.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:607)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.TestNG.privateMain(TestNG.java:1385)
at org.testng.TestNG.main(TestNG.java:1354)
The type of all value instances here, except *_size, is deduced as Int1Type(false) (i.e. u1) which is rendered in Java as int.
byte in Java is signed, when you assign byte value to an int variable or return it from the int method, the sign is propagated. 0xFF (byte) becomes 0xFFFFFFFF (int) which is -1. To get 255 we need to mask value: byte & 0xFF. There is a question, where this conversion should be applied? Obviously, it should not be applied there:
The problem, similar to #1093, in Java with test
tests\formats\expr_bytes_ops.ksy
:The failure is:
The generated code is:
The type of all value instances here, except
*_size
, is deduced asInt1Type(false)
(i.e.u1
) which is rendered in Java asint
.byte
in Java is signed, when you assignbyte
value to anint
variable or return it from theint
method, the sign is propagated. 0xFF (byte) becomes 0xFFFFFFFF (int) which is-1
. To get 255 we need to mask value:byte & 0xFF
. There is a question, where this conversion should be applied? Obviously, it should not be applied there:I think, we need a dedicated type for "element of byte array" to use in such expressions.
The text was updated successfully, but these errors were encountered: