From c0d21cf9e2b3a3950f4e235b30bf2ba4efa8171e Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 19 Mar 2006 16:29:50 +0000 Subject: [PATCH] Tests for improved child record adding code git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@386997 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hslf/record/TestRecordContainer.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java index 2b44114b6b..bd11a01beb 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java @@ -92,6 +92,46 @@ public class TestRecordContainer extends TestCase { assertEquals(newRecord, ncr[cr.length]); } + public void testAddChildBefore() { + // Working with new StyleTextPropAtom + Record newRecord = new StyleTextPropAtom(0); + + // Try to add before a mid-record + Record[] cr = recordContainer.getChildRecords(); + Record before = cr[2]; + + recordContainer.addChildBefore(newRecord, before); + Record[] ncr = recordContainer.getChildRecords(); + + assertEquals(cr.length+1, ncr.length); + assertEquals(newRecord, ncr[2]); + assertEquals(before, ncr[3]); + + + // Try again at the end + recordContainer._children = cr; + before = cr[cr.length-1]; + + recordContainer.addChildBefore(newRecord, before); + ncr = recordContainer.getChildRecords(); + + assertEquals(cr.length+1, ncr.length); + assertEquals(newRecord, ncr[cr.length-1]); + assertEquals(before, ncr[cr.length]); + + + // And at the start + recordContainer._children = cr; + before = cr[0]; + + recordContainer.addChildBefore(newRecord, before); + ncr = recordContainer.getChildRecords(); + + assertEquals(cr.length+1, ncr.length); + assertEquals(newRecord, ncr[0]); + assertEquals(before, ncr[1]); + } + protected void setUp() throws Exception { super.setUp(); -- 2.39.5