]> source.dussan.org Git - poi.git/commitdiff
Tests for improved child record adding code
authorNick Burch <nick@apache.org>
Sun, 19 Mar 2006 16:29:50 +0000 (16:29 +0000)
committerNick Burch <nick@apache.org>
Sun, 19 Mar 2006 16:29:50 +0000 (16:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@386997 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java

index 2b44114b6b0d24ba50aa22c71a0f19a089780e2e..bd11a01beba3d6f2b1fb6dccf6bb0628d15ecf82 100644 (file)
@@ -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();