@Test
  public void testUnsignedInt128Count() {
    UnsignedInt128 minValue = UnsignedInt128.MIN_VALUE;
    assertEquals((byte) 0, minValue.getCount());
    UnsignedInt128 maxValue = UnsignedInt128.MAX_VALUE;
    assertEquals((byte) 4, maxValue.getCount());
    UnsignedInt128 unsignedInt128 = new UnsignedInt128(0, 0, 0, 0);
    assertEquals((byte) 0, unsignedInt128.getCount());

    // Let count equals 4. updateCount() will not be called if update v0, v1, v2, v3.
    unsignedInt128.setV3(100);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.setV3(200);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.setV2(100);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.setV1(100);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.setV0(100);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.zeroClear();
    assertEquals((byte) 0, unsignedInt128.getCount());

    // Let count equals 3. updateCount() will not be called if update v0, v1, v2.
    unsignedInt128.setV2(100);
    assertEquals((byte) 3, unsignedInt128.getCount());
    unsignedInt128.setV2(200);
    assertEquals((byte) 3, unsignedInt128.getCount());
    unsignedInt128.setV1(100);
    assertEquals((byte) 3, unsignedInt128.getCount());
    unsignedInt128.setV0(100);
    assertEquals((byte) 3, unsignedInt128.getCount());
    unsignedInt128.setV3(100);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.zeroClear();
    assertEquals((byte) 0, unsignedInt128.getCount());

    // Let count equals 2. updateCount() will not be called if update v0, v1.
    unsignedInt128.setV1(100);
    assertEquals((byte) 2, unsignedInt128.getCount());
    unsignedInt128.setV1(100);
    assertEquals((byte) 2, unsignedInt128.getCount());
    unsignedInt128.setV0(1);
    assertEquals((byte) 2, unsignedInt128.getCount());
    unsignedInt128.setV2(100);
    assertEquals((byte) 3, unsignedInt128.getCount());
    unsignedInt128.setV3(100);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.zeroClear();
    assertEquals((byte) 0, unsignedInt128.getCount());

    // Let count equals 2. updateCount() will not be called if update v0.
    unsignedInt128.setV0(2);
    assertEquals((byte) 1, unsignedInt128.getCount());
    unsignedInt128.setV0(2);
    assertEquals((byte) 1, unsignedInt128.getCount());
    unsignedInt128.setV1(100);
    assertEquals((byte) 2, unsignedInt128.getCount());
    unsignedInt128.setV2(100);
    assertEquals((byte) 3, unsignedInt128.getCount());
    unsignedInt128.setV3(100);
    assertEquals((byte) 4, unsignedInt128.getCount());
    unsignedInt128.zeroClear();
    assertEquals((byte) 0, unsignedInt128.getCount());
  }
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