@Test public void testExactDivideSmallExhaustive() {

  for (int a = 10; a >= -10; --a) {
    for (int b = 10; b >= -10; --b) {
      int p = a * b;
      BigInteger aVal = BigInteger.valueOf(a);
      BigInteger bVal = BigInteger.valueOf(b);
      BigInteger pVal = BigInteger.valueOf(p);
      // exactDivide should work both ways
      if (a != 0) {
        assertEquals(String.format("a %d, b %d, p %d", a, b, p), bVal, exactDivide(pVal, aVal));
      } else {
        try {
          exactDivide(pVal, aVal);
          fail("ArithmeticException expected");
        } catch (ArithmeticException expected) {
        }
      }
    }
  }
}