@Test
  public void testDivideDestructiveUnsignedInt128() {
    UnsignedInt128 remainder = new UnsignedInt128();
    two.divideDestructive(one, remainder);
    assertEquals(1L, one.asLong());
    assertEquals(2L, two.asLong());
    assertEquals(zero, remainder);
    one.divideDestructive(two, remainder);
    assertEquals(0L, one.asLong());
    assertEquals(2L, two.asLong());
    assertEquals(new UnsignedInt128(1), remainder);

    UnsignedInt128 var1 = new UnsignedInt128(1234234662345L);
    var1.divideDestructive(new UnsignedInt128(642337), remainder);
    assertEquals(1234234662345L / 642337L, var1.asLong());
    assertEquals(1234234662345L % 642337L, remainder.asLong());

    UnsignedInt128 complicated1 = new UnsignedInt128(0xF9892FCA, 0x59D109AD,
        0x0534AB4C, 0x42395ADC);
    UnsignedInt128 complicated2 = new UnsignedInt128(0xF09DC19A, 0x00001234, 0,
        0);
    BigInteger bigInteger1 = complicated1.toBigIntegerSlow();
    BigInteger bigInteger2 = complicated2.toBigIntegerSlow();
    complicated1.divideDestructive(complicated2, remainder);
    BigInteger ans = bigInteger1.divide(bigInteger2);
    assertEquals(ans, complicated1.toBigIntegerSlow());

    try {
      complicated1.divideDestructive(zero, remainder);
      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