@Test
  public void testToFormalString() {
    assertEquals("0", zero.toFormalString());
    assertEquals("1", one.toFormalString());
    assertEquals("-1", negativeOne.toFormalString());
    assertEquals("-2", negativeTwo.toFormalString());

    assertEquals("30", new SignedInt128(30).toFormalString());
    assertEquals("680000000000",
        new SignedInt128(680000000000L).toFormalString());
    assertEquals("6800000000000",
        new SignedInt128(6800000000000L).toFormalString());
    assertEquals("68", new SignedInt128(68).toFormalString());

    assertEquals("-30", new SignedInt128(-30).toFormalString());
    assertEquals("-680000000000",
        new SignedInt128(-680000000000L).toFormalString());
    assertEquals("-6800000000000",
        new SignedInt128(-6800000000000L).toFormalString());
    assertEquals("-68", new SignedInt128(-68).toFormalString());

    assertEquals(zero, new SignedInt128("0"));
    assertEquals(one, new SignedInt128("1"));

    assertEquals(zero, new SignedInt128("-0"));
    assertEquals(negativeOne, new SignedInt128("-1"));
    assertEquals(negativeTwo, new SignedInt128("-2"));

    assertEquals(new SignedInt128(30), new SignedInt128("30"));
    assertEquals(new SignedInt128(680000000000L), new SignedInt128(
        "680000000000"));
    assertEquals(new SignedInt128(6800000000000L), new SignedInt128(
        "6800000000000"));
    assertEquals(new SignedInt128(68), new SignedInt128("68"));

    assertEquals(new SignedInt128(-30), new SignedInt128("-30"));
    assertEquals(new SignedInt128(-680000000000L), new SignedInt128(
        "-680000000000"));
    assertEquals(new SignedInt128(-6800000000000L), new SignedInt128(
        "-6800000000000"));
    assertEquals(new SignedInt128(-68), new SignedInt128("-68"));
  }
Testcases for {@link SignedInt128}

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