test/hexapdf/layout/test_text_box.rb in hexapdf-0.32.2 vs test/hexapdf/layout/test_text_box.rb in hexapdf-0.33.0

- old
+ new

@@ -105,10 +105,18 @@ box = create_box([@inline_box], height: 102) assert_equal([nil, box], box.split(100, 100, @frame)) end + it "works if the box fits exactly (+/- float divergence)" do + box = create_box([@inline_box] * 5) + box.fit(50, 10, @frame) + box.instance_variable_set(:@width, 50.00000000006) + box.instance_variable_set(:@height, 10.00000000003) + assert_equal([box], box.split(50, 10, @frame)) + end + it "splits the box if necessary when using non-flowing text" do box = create_box([@inline_box] * 10) boxes = box.split(50, 10, @frame) assert_equal(2, boxes.length) assert_equal(box, boxes[0]) @@ -122,9 +130,19 @@ box = create_box([@inline_box] * 60, style: {position: :flow}) boxes = box.split(50, 100, @frame) assert_equal(2, boxes.length) assert_equal(box, boxes[0]) assert_equal(5, boxes[1].instance_variable_get(:@items).length) + end + + it "correctly handles text indentation for split boxes" do + [{}, {position: :flow}].each do |styles| + box = create_box([@inline_box] * 202, style: {text_indent: 50, **styles}) + boxes = box.split(100, 100, @frame) + assert_equal(107, boxes[1].instance_variable_get(:@items).length) + boxes = boxes[1].split(100, 100, @frame) + assert_equal(7, boxes[1].instance_variable_get(:@items).length) + end end end describe "draw" do it "draws the layed out inline items onto the canvas" do