         layout.startLayout(with: layoutRect)
         let availableSideLength = (l3.sideLength + l3.verticalMargins) // Largest element as base.
         
-        XCTAssertEqual(l1.frame, CGRect(
-            x: layoutRect.origin.x + l1.layoutMargins.left,
-            y: layoutRect.origin.y + l1.layoutMargins.top,
-            width: l1.sideLength,
-            height: l1.sideLength))
-        XCTAssertEqual(l2.frame, CGRect(
-            x: layoutRect.origin.x + l2.layoutMargins.left,
-            y: layoutRect.origin.y
-                + availableSideLength
-                + spacing
-                + l2.layoutMargins.top,
-            width: l2.sideLength,
-            height: l2.sideLength))
-        XCTAssertEqual(l3.frame,CGRect(
-            x: layoutRect.origin.x + l3.layoutMargins.left,
-            y: layoutRect.origin.y
-                + availableSideLength * 2
-                + spacing * 2
-                + l3.layoutMargins.top,
-            width: l3.sideLength,
-            height: l3.sideLength))
+        XCTAssertEqual(
+            l1.frame,
+            CGRect(
+                x: layoutRect.origin.x + l1.layoutMargins.left,
+                y: layoutRect.origin.y + l1.layoutMargins.top,
+                width: l1.sideLength,
+                height: l1.sideLength))
+        XCTAssertEqual(
+            l2.frame,
+            CGRect(
+                x: layoutRect.origin.x + l2.layoutMargins.left,
+                y: layoutRect.origin.y
+                    + availableSideLength
+                    + spacing
+                    + l2.layoutMargins.top,
+                width: l2.sideLength,
+                height: l2.sideLength))
+        XCTAssertEqual(
+            l3.frame,
+            CGRect(
+                x: layoutRect.origin.x + l3.layoutMargins.left,
+                y: layoutRect.origin.y
+                    + availableSideLength * 2
+                    + spacing * 2
+                    + l3.layoutMargins.top,
+                width: l3.sideLength,
+                height: l3.sideLength))
+    }
+
+    func testVerticalMatchingParent() {
+        l1 = TestLayoutable(sideLength: 30, layoutModes: BayaLayoutModes(width: .matchParent, height: .matchParent))
+        l2 = TestLayoutable(sideLength: 60, layoutModes: BayaLayoutModes(width: .matchParent, height: .matchParent))
+        l3 = TestLayoutable(sideLength: 90, layoutModes: BayaLayoutModes(width: .matchParent, height: .matchParent))
+        var layout = [l1, l2, l3]
+            .layoutAsEqualSegments(
+            orientation: .vertical,
+            gutter: spacing)
+        
+        layout.startLayout(with: layoutRect)
+        let maxHeight = max(
+            l1.sideLength + l1.verticalMargins,
+            l2.sideLength + l2.verticalMargins,
+            l3.sideLength + l3.verticalMargins)
+        let maxWidth = max(
+            l1.sideLength + l1.horizontalMargins,
+            l2.sideLength + l2.horizontalMargins,
+            l3.sideLength + l3.horizontalMargins)
+        
+        XCTAssertEqual(
+            l1.frame,
+            CGRect(
+                x: layoutRect.minX + l1.layoutMargins.left,
+                y: layoutRect.minY + l1.layoutMargins.top,
+                width: maxWidth - l1.horizontalMargins,
+                height: maxHeight - l1.verticalMargins))
+        XCTAssertEqual(
+            l2.frame,
+            CGRect(
+                x: layoutRect.minX + l2.layoutMargins.left,
+                y: layoutRect.minY
+                    + maxHeight
+                    + spacing
+                    + l2.layoutMargins.top,
+                width: maxWidth - l2.horizontalMargins,
+                height: maxHeight - l2.verticalMargins))
+        XCTAssertEqual(
+            l3.frame,
+            CGRect(
+                x: layoutRect.minX + l3.layoutMargins.left,
+                y: layoutRect.minY
+                    + maxHeight * 2
+                    + spacing * 2
+                    + l3.layoutMargins.top,
+                width: maxWidth - l3.horizontalMargins,
+                height: maxHeight - l3.verticalMargins))
+    }
+
+    func testVerticalSmallEnforcedFrame() {
+        var layout = [l1, l2, l3]
+            .layoutAsEqualSegments(
+            orientation: .vertical,
+            gutter: spacing)
+
+        layout.startLayout(with: layoutRectTooSmall)
+        let availableSideLength = (layoutRectTooSmall.height - spacing * 2) / 3 // Rect now dictates the size
+
+        XCTAssertEqual(
+            l1.frame,
+            CGRect(
+                x: layoutRectTooSmall.origin.x + l1.layoutMargins.left,
+                y: layoutRectTooSmall.origin.y + l1.layoutMargins.top,
+                width: l1.sideLength,
+                height: min(
+                    (availableSideLength - l1.verticalMargins) > 0 ? (availableSideLength - l1.verticalMargins) : 0,
+                    l2.sideLength)))
+        XCTAssertEqual(
+            l2.frame,
+            CGRect(
+                x: layoutRectTooSmall.origin.x + l2.layoutMargins.left,
+                y: layoutRectTooSmall.origin.y
+                    + availableSideLength
+                    + spacing
+                    + l2.layoutMargins.top,
+                width: l2.sideLength,
+                height: min(
+                    (availableSideLength - l2.verticalMargins) > 0 ? (availableSideLength - l1.verticalMargins) : 0,
+                    l2.sideLength)))
+        XCTAssertEqual(
+            l3.frame,
+            CGRect(
+                x: layoutRectTooSmall.origin.x
+                    + availableSideLength * 2
+                    + spacing * 2
+                    + l3.layoutMargins.left,
+                y: layoutRectTooSmall.origin.y + l3.layoutMargins.top,
+                width: l3.sideLength,
+                height: min(
+                    (availableSideLength - l3.verticalMargins) > 0 ? (availableSideLength - l3.verticalMargins) : 0,
+                    l3.sideLength)))
     }
 
     func testMeasureHorizontal() {

            orientation: .horizontal,
            gutter: spacing)

        let targetSize = CGSize(
            width: (l3.sideLength + l3.horizontalMargins) * 3
                + spacing * 2,
            height: l3.sideLength + l3.verticalMargins)  // largest element
        let size1 = layout.sizeThatFits(CGSize(width: 400, height: 300))
        let size2 = layout.sizeThatFits(CGSize(width: 200, height: 30))


            .layoutAsEqualSegments(
                orientation: .horizontal,
                gutter: spacing)
        layout.startLayout(with: layoutRect)
        let availableSideLength = (l3.sideLength + l3.horizontalMargins) // Largest element as base.

