@Test
  public void testSmoke_linear() {
    Allocation root = Allocation.newRoot("root", 1);
    Allocation node1 = root.newChild("node1", 2);
    Allocation node2 = node1.newChild("node2", 3);

    Assert.assertEquals("node2", node2.getDescription());
    Assert.assertEquals(3, node2.getAllocationUnits());
    Assert.assertEquals(1.0 / 2 / 3, node2.getFractionOfRoot(), DOUBLE_ERROR_MARGIN);
    Assert.assertTrue(node2.getParent().isPresent());
    Assert.assertEquals(node1, node2.getParent().get());

    Assert.assertEquals("node1", node1.getDescription());
    Assert.assertEquals(2, node1.getAllocationUnits());
    Assert.assertTrue(node1.getParent().isPresent());
    Assert.assertEquals(root, node1.getParent().get());
    Assert.assertEquals(1.0 / 2, node1.getFractionOfRoot(), DOUBLE_ERROR_MARGIN);

    Assert.assertEquals("root", root.getDescription());
    Assert.assertEquals(1, root.getAllocationUnits());
    Assert.assertFalse(root.getParent().isPresent());
    Assert.assertEquals(1.0, root.getFractionOfRoot(), 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