@Test
  public void testAddDestructive() {
    one.addDestructive(two);
    assertEquals(3L, one.asLong());
    assertEquals(2L, two.asLong());

    UnsignedInt128 big = new UnsignedInt128((1L << 62) + 3L);
    UnsignedInt128 tmp = new UnsignedInt128(0L);
    for (int i = 0; i < 54; ++i) {
      tmp.addDestructive(big);
    }

    assertEquals(3 * 54, tmp.getV0());
    assertEquals(0x80000000, tmp.getV1()); // (54 % 4) << 62
    assertEquals(13, tmp.getV2()); // 54/4
    assertEquals(0, tmp.getV3());

    assertEquals((1L << 62) + 3L, big.asLong());

    UnsignedInt128 huge = one.shiftLeftConstructive(127);
    UnsignedInt128 huge2 = one.shiftLeftConstructive(127);
    try {
      huge2.addDestructive(huge);
      fail();
    } catch (ArithmeticException ex) {
      // ok
    }
  }
Testcases for {@link UnsignedInt128}

This code was based on code from Microsoft's PolyBase.
common/src/test/org/apache/hadoop/hive/common/type/TestUnsignedInt128.java