@Test
  public void testFractionOfRoot_tree_complete() {
    Allocation root = Allocation.newRoot("ignored", 2);

    Allocation left = root.newChild("ignored", 3);
    Allocation leftLeft = left.newChild("ignored", 1);
    Allocation leftLeftDown = leftLeft.newChild("ignored", 100);
    Allocation leftMiddle = left.newChild("ignored", 100);
    Allocation leftRight = left.newChild("ignored", 100);

    Allocation right = root.newChild("ignored", 1);
    Allocation rightDown = right.newChild("ignored", 100);

    // Checks that the leaf allocations add up to a full 1.0.
    double total =
        leftLeftDown.getFractionOfRoot() * leftLeftDown.getAllocationUnits()
            + leftMiddle.getFractionOfRoot() * leftMiddle.getAllocationUnits()
            + leftRight.getFractionOfRoot() * leftRight.getAllocationUnits()
            + rightDown.getFractionOfRoot() * rightDown.getAllocationUnits();
    Assert.assertEquals(1.0, total, DOUBLE_ERROR_MARGIN);
  }
Error margin for checking equality of two doubles.
jib-core/src/test/java/com/google/cloud/tools/jib/event/progress/AllocationTest.java