### Question:
BBoxUtil { public BBox boundingBox(final CIDR cidr) { BBox bbox = new BBox(); long diag = DIAG_INIT; if (cidr.getMask() >= MAX_MASK) { Point p = Hilbert.getPoint(cidr.getStart() >> 8, hilbertCurveOrder); bbox.setXmin(p.x); bbox.setXmax(p.x); bbox.setYmin(p.y); bbox.setYmax(p.y); } else if (0 == (cidr.getMask() & 1)) { diag >>= cidr.getMask(); Point p1 = Hilbert.getPoint(cidr.getStart() >> bitsPerPixel, hilbertCurveOrder); Point p2 = Hilbert .getPoint((cidr.getStart() + diag) >> bitsPerPixel, hilbertCurveOrder); bbox.setXmin(Math.min(p1.x, p2.x)); bbox.setXmax(Math.max(p1.x, p2.x)); bbox.setYmin(Math.min(p1.y, p2.y)); bbox.setYmax(Math.max(p1.y, p2.y)); } else { CIDR cidrCopy1 = new CIDR(cidr); cidrCopy1.setMask(cidrCopy1.getMask() + 1); BBox b1 = boundingBox(cidrCopy1); CIDR cidrCopy2 = new CIDR(cidr); cidrCopy2.setStart(cidr.getStart() + (1 << (MAX_MASK - (cidr.getMask() + 1)))); cidrCopy2.setMask(cidrCopy2.getMask() + 1); BBox b2 = boundingBox(cidrCopy2); bbox.setXmin(Math.min(b1.getXmin(), b2.getXmin())); bbox.setXmax(Math.max(b1.getXmax(), b2.getXmax())); bbox.setYmin(Math.min(b1.getYmin(), b2.getYmin())); bbox.setYmax(Math.max(b1.getYmax(), b2.getYmax())); } return bbox; } BBoxUtil(final int hilbertOrder, final int inBitsPerPixel); BBox boundingBox(final CIDR cidr);  }### Answer:
@Test public void testBoundingBox() { int bitsPerPixel = 28; int hilbertOrder = (32 - bitsPerPixel) / 2; BBoxUtil util = new BBoxUtil(hilbertOrder, bitsPerPixel); BBox bbox; bbox = util.boundingBox(new CIDR("0.0.0.0/2")); assertEquals(new BBox(0, 0, 1, 1), bbox); bbox = util.boundingBox(new CIDR("64.0.0.0/2")); assertEquals(new BBox(0, 2, 1, 3), bbox); bbox = util.boundingBox(new CIDR("128.0.0.0/2")); assertEquals(new BBox(2, 2, 3, 3), bbox); bbox = util.boundingBox(new CIDR("192.0.0.0/2")); assertEquals(new BBox(2, 0, 3, 1), bbox); bbox = util.boundingBox(new CIDR("0.0.0.0/1")); assertEquals(new BBox(0, 0, 1, 3), bbox); bbox = util.boundingBox(new CIDR("64.0.0.0/1")); assertEquals(new BBox(0, 2, 3, 3), bbox); bbox = util.boundingBox(new CIDR("128.0.0.0/1")); assertEquals(new BBox(2, 0, 3, 3), bbox); bbox = util.boundingBox(new CIDR("0.0.0.0/32")); assertEquals(new BBox(0, 0, 0, 0), bbox); }