stevedlawrence commented on a change in pull request #571:
URL: https://github.com/apache/daffodil/pull/571#discussion_r636053789
##########
File path: daffodil-lib/src/test/scala/passera/test/TestULong.scala
##########
@@ -64,5 +63,45 @@ class TestULong {
val remainder = mm1 % mm2
assertEquals(ULong(1), remainder)
}
-
+
+ @Test def testULongMostNegativeLong1: Unit = {
+ val v = ULong(Long.MinValue)
+ val vbi = v.toBigInt
+ val vhex = vbi.toString(16)
+ assertEquals("8000000000000000", vhex)
+ assertEquals("8000000000000000", v.toHexString)
+ assertEquals(-9223372036854775808L, v.longValue)
+ assertEquals("9223372036854775808", v.toString)
+ }
+
+ @Test def testULongMaxValue: Unit = {
+ val v = ULong.MaxValue
+ assertEquals("FFFFFFFFFFFFFFFF", v.toHexString.toUpperCase)
+ assertEquals(ULong(0), v + ULong(1))
+ val v1 = ULong.MaxValue.toBigInt.add(JBigInt.TWO) // 0x8000000000000001
+ assertEquals(ULong(1), ULong(v1)) // preserves only 64 bits
+ }
+
+ @Test def testULongFromBigInt: Unit = {
+ val zero = JBigInt.ZERO
+ val one = JBigInt.ONE
+ val two = JBigInt.TWO
Review comment:
Looks like JBigInt.TWO wasn't added until Java 9. I guess we'll need
``JBigInt.valueOf(2)`` or something.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]