[Abora-cvs] abora-ash/src/org/abora/ash/ent/tests SplitNodeTest.java,NONE,1.1 AllTests.java,1.2,1.3
Status: Alpha
Brought to you by:
dgjones
From: <dg...@us...> - 2003-05-09 13:58:50
|
Update of /cvsroot/abora/abora-ash/src/org/abora/ash/ent/tests In directory sc8-pr-cvs1:/tmp/cvs-serv2145/src/org/abora/ash/ent/tests Modified Files: AllTests.java CollectionLeafTest.java Added Files: SplitNodeTest.java Log Message: -Start split node testing --- NEW FILE: SplitNodeTest.java --- /* * Abora-Ash * Part of the Abora hypermedia project: http://www.abora.org * Copyright 2003 David G Jones */ package org.abora.ash.ent.tests; import java.util.List; import org.abora.ash.engine.AboraConverter; import org.abora.ash.ent.CollectionLeaf; import org.abora.ash.ent.SequenceNumber; import org.abora.ash.ent.SplitNode; /** */ public class SplitNodeTest extends EntTestCase { public SplitNodeTest(String arg0) { super(arg0); } // "Filed out from Dolphin Smalltalk 2002 release 5.00"! // // AboraBeTests subclass: #SplitNodeTest // instanceVariableNames: '' // classVariableNames: '' // poolDictionaries: '' // classInstanceVariableNames: ''! // SplitNodeTest guid: (GUID fromString: '{CC025AE1-680C-498F-BF70-ABE7C6E62C9F}')! // SplitNodeTest comment: ''! // !SplitNodeTest categoriesForClass!SUnit! ! // !SplitNodeTest methodsFor! // // testAssertIsChild // | splitNode leaf1 leaf2 leaf3 | // leaf1 := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'abcdef' asAboraContent. // leaf2 := CollectionLeaf // branch: 1 // startPosition: 7 // elements: 'ghijk' asAboraContent. // leaf3 := CollectionLeaf // branch: 1 // startPosition: 7 // elements: 'ghijk' asAboraContent. // splitNode := SplitNode // branch: 1 // split: 7 // left: leaf1 // right: leaf2. // splitNode assertIsChild: leaf1. // splitNode assertIsChild: leaf2. // self should: [splitNode assertIsChild: leaf3] raise: EntError! // public void testChildren() { CollectionLeaf leaf1 = new CollectionLeaf(new SequenceNumber(1), 0, AboraConverter.toAboraContent("hello ")); CollectionLeaf leaf2 = new CollectionLeaf(new SequenceNumber(1), 6, AboraConverter.toAboraContent("there")); SplitNode split = new SplitNode(new SequenceNumber(1), 6, leaf1, leaf2); List children = split.children(); assertEquals(2, children.size()); assertTrue(children.contains(leaf1)); assertTrue(children.contains(leaf2)); } // testChildren // | dataLeaf1 dataLeaf2 splitNode | // dataLeaf1 := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello ' asAboraContent. // dataLeaf2 := CollectionLeaf // branch: 1 // startPosition: 7 // elements: 'there' asAboraContent. // // "test" // splitNode := SplitNode // branch: 1 // split: 7 // left: dataLeaf1 // right: dataLeaf2. // self should: [splitNode children = (Array with: dataLeaf1 with: dataLeaf2)]! // // testContents // | dataLeaf1 dataLeaf2 splitNode | // dataLeaf1 := CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'h' asAboraContent. // dataLeaf2 := CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'there' asAboraContent. // splitNode := SplitNode // branch: 1 // split: 20 // left: dataLeaf1 // leftDsp: 16 // right: dataLeaf2 // rightDsp: -80. // // "test" // self should: [splitNode contents = 'hthere' asAboraContent]! // // testContentsAt // | splitNode leaf1 leaf2 | // leaf1 := CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'abcdef' asAboraContent. // leaf2 := CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'ghijk' asAboraContent. // splitNode := SplitNode // branch: 1 // split: 20 // left: leaf1 // leftDsp: 11 // right: leaf2 // rightDsp: -80. // self should: [(splitNode contentsAt: 14) = $a codePoint]. // self should: [(splitNode contentsAt: 15) = $b codePoint]. // self should: [(splitNode contentsAt: 19) = $f codePoint]. // self should: [(splitNode contentsAt: 20) = $g codePoint]. // self should: [(splitNode contentsAt: 24) = $k codePoint]! // // testContentsAtBadPosition // | splitNode leaf1 leaf2 | // leaf1 := CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'abcdef' asAboraContent. // leaf2 := CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'ghijk' asAboraContent. // splitNode := SplitNode // branch: 1 // split: 20 // left: leaf1 // leftDsp: 11 // right: leaf2 // rightDsp: -80. // self should: [splitNode contentsAt: 13] raise: BoundsError. // self should: [splitNode contentsAt: 25] raise: BoundsError! // // testContentsFromExtentDo // | splitNode out do | // splitNode := SplitNode // branch: 1 // split: 7 // left: (CollectionLeaf // branch: 1 // startPosition: 1 // elements: '123456' asAboraContent) // right: (CollectionLeaf // branch: 1 // startPosition: 7 // elements: '78901' asAboraContent). // out := ''. // do := [:int | out := out , (Character codePoint: int) asString]. // splitNode // contentsFrom: 1 // extent: 11 // do: do. // self should: [out = '12345678901']. // out := ''. // splitNode // contentsFrom: 1 // extent: 6 // do: do. // self should: [out = '123456']. // out := ''. // splitNode // contentsFrom: 7 // extent: 5 // do: do. // self should: [out = '78901']. // out := ''. // splitNode // contentsFrom: 2 // extent: 3 // do: do. // self should: [out = '234']. // out := ''. // splitNode // contentsFrom: 8 // extent: 2 // do: do. // self should: [out = '89']. // out := ''. // splitNode // contentsFrom: 3 // extent: 7 // do: do. // self should: [out = '3456789']. // out := ''. // splitNode // contentsFrom: -4 // extent: 10 // do: do. // self should: [out = '12345']. // out := ''. // splitNode // contentsFrom: 8 // extent: 10 // do: do. // self should: [out = '8901']. // out := ''. // splitNode // contentsFrom: -4 // extent: 20 // do: do. // self should: [out = '12345678901']. // out := ''. // splitNode // contentsFrom: -4 // extent: 6 // do: do. // self should: [out = '1']. // out := ''. // splitNode // contentsFrom: -4 // extent: 5 // do: do. // self should: [out = '']. // out := ''. // splitNode // contentsFrom: 11 // extent: 2 // do: do. // self should: [out = '1']. // out := ''. // splitNode // contentsFrom: 12 // extent: 2 // do: do. // self should: [out = '']! // public void testCount() { CollectionLeaf leaf1 = new CollectionLeaf(new SequenceNumber(1), 2, AboraConverter.toAboraContent("hello ")); CollectionLeaf leaf2 = new CollectionLeaf(new SequenceNumber(1), 99, AboraConverter.toAboraContent("there")); SplitNode split = new SplitNode(new SequenceNumber(1), 19, leaf1, 12, leaf2, 80); assertEquals(11, split.count()); } // testCount // | splitNode | // splitNode := SplitNode // branch: 1 // split: 20 // left: (CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'hello ' asAboraContent) // leftDsp: 12 // right: (CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'there' asAboraContent) // rightDsp: 80. // self should: [splitNode count = 11]! // // testCreate // | dataLeaf1 dataLeaf2 splitNode | // dataLeaf1 := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello ' asAboraContent. // dataLeaf2 := CollectionLeaf // branch: 1 // startPosition: 7 // elements: 'there' asAboraContent. // // "test" // splitNode := SplitNode // branch: 1 // split: 7 // left: dataLeaf1 // right: dataLeaf2. // self should: [splitNode split = 7]. // self should: [splitNode left == dataLeaf1]. // self should: [splitNode right == dataLeaf2]. // self should: [dataLeaf1 parents = (OrderedCollection with: splitNode)]. // self should: [dataLeaf2 parents = (OrderedCollection with: splitNode)]! // // testCreateDsp // | dataLeaf1 dataLeaf2 splitNode | // dataLeaf1 := CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'hello ' asAboraContent. // dataLeaf2 := CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'there' asAboraContent. // // "test" // splitNode := SplitNode // branch: 1 // split: 20 // left: dataLeaf1 // leftDsp: 14 // right: dataLeaf2 // rightDsp: -80. // self should: [splitNode split = 20]. // self should: [splitNode left == dataLeaf1]. // self should: [splitNode leftDsp = 14]. // self should: [splitNode right == dataLeaf2]. // self should: [splitNode rightDsp = -80]. // self should: [dataLeaf1 parents = (OrderedCollection with: splitNode)]. // self should: [dataLeaf2 parents = (OrderedCollection with: splitNode)]! // public void testDspForChild() { CollectionLeaf leaf1 = new CollectionLeaf(new SequenceNumber(1), 2, AboraConverter.toAboraContent("hello ")); CollectionLeaf leaf2 = new CollectionLeaf(new SequenceNumber(1), 99, AboraConverter.toAboraContent("there")); SplitNode split = new SplitNode(new SequenceNumber(1), 19, leaf1, 14, leaf2, -80); assertEquals(14, split.dspForChild(leaf1)); assertEquals(-80, split.dspForChild(leaf2)); } // testDspForChild // | dataLeaf1 dataLeaf2 splitNode | // dataLeaf1 := CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'hello ' asAboraContent. // dataLeaf2 := CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'there' asAboraContent. // // "test" // splitNode := SplitNode // branch: 1 // split: 20 // left: dataLeaf1 // leftDsp: 14 // right: dataLeaf2 // rightDsp: -80. // self should: [(splitNode dspForChild: dataLeaf1) = 14]. // self should: [(splitNode dspForChild: dataLeaf2) = -80]! // public void testDspSetForChild() { CollectionLeaf leaf1 = new CollectionLeaf(new SequenceNumber(1), 2, AboraConverter.toAboraContent("hello ")); CollectionLeaf leaf2 = new CollectionLeaf(new SequenceNumber(1), 99, AboraConverter.toAboraContent("there")); SplitNode split = new SplitNode(new SequenceNumber(1), 19, leaf1, 14, leaf2, -80); split.setDspForChild(15, leaf1); assertEquals(15, split.dspForChild(leaf1)); assertEquals(-80, split.dspForChild(leaf2)); split.setDspForChild(-60, leaf2); assertEquals(15, split.dspForChild(leaf1)); assertEquals(-60, split.dspForChild(leaf2)); } public void testDspSetForChildUnknown() { CollectionLeaf leaf1 = new CollectionLeaf(new SequenceNumber(1), 2, AboraConverter.toAboraContent("hello ")); CollectionLeaf leaf2 = new CollectionLeaf(new SequenceNumber(1), 99, AboraConverter.toAboraContent("there")); SplitNode split = new SplitNode(new SequenceNumber(1), 19, leaf1, 14, leaf2, -80); CollectionLeaf leaf3 = new CollectionLeaf(new SequenceNumber(1), 2, AboraConverter.toAboraContent("hello ")); try { split.setDspForChild(15, leaf3); fail(); } catch (IllegalStateException e) { assertEquals("unknown child", e.getMessage()); } } // testDspSetForChild // | dataLeaf1 dataLeaf2 splitNode | // dataLeaf1 := CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'hello ' asAboraContent. // dataLeaf2 := CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'there' asAboraContent. // // "test" // splitNode := SplitNode // branch: 1 // split: 20 // left: dataLeaf1 // leftDsp: 14 // right: dataLeaf2 // rightDsp: -80. // splitNode dsp: 15 forChild: dataLeaf1. // self should: [(splitNode dspForChild: dataLeaf1) = 15]. // self should: [(splitNode dspForChild: dataLeaf2) = -80]. // splitNode dsp: -60 forChild: dataLeaf2. // self should: [(splitNode dspForChild: dataLeaf1) = 15]. // self should: [(splitNode dspForChild: dataLeaf2) = -60]! // // testDuplicate // | root1 split newSplit | // root1 := self createBalanced12345678. // self assertTextContentsOf: root1 is: '12345678'. // // "operation" // split := (root1 nodeAt: 8) singleParentFor: 1. // newSplit := split duplicateFor: 2. // // self should: [split ~~ newSplit]. // self assertTextContentsOf: root1 is: '12345678'. // self should: [newSplit left == split left]. // self should: [newSplit right == split right]. // self should: [newSplit leftDsp == split leftDsp]. // self should: [newSplit rightDsp == split rightDsp]. // self should: [newSplit parents isEmpty]. // self should: [split parents size = 1]. // // // // ! // // testDuplicateAndParents // | root1 originalChild duplicateSplit root2 | // root1 := self createBalanced12345678. // root2 := RootNode // edition: nil // branch: 2 // with: root1 child // dsp: root1 dsp. // originalChild := root2 child. // self assertTextContentsOf: root1 is: '12345678'. // // "operation" // duplicateSplit := ((root1 nodeAt: 8) singleParentFor: 1) duplicateWithParentsFor: 2. // self assertTextContentsOf: root1 is: '12345678'. // self assertTextContentsOf: root2 is: '12345678'. // self should: [root2 child ~~ originalChild]. // self should: [root2 child right ~~ originalChild right]. // self should: [root2 child left == originalChild left]. // self should: [root2 child right right ~~ originalChild right right]. // self should: [root2 child right left == originalChild right left]. // self should: [root2 child right right right == originalChild right right right]. // self assertTextContentsOf: originalChild is: '12345678'! // // testDuplicateAndParentsSameRevision // | root1 originalChild duplicateSplit originalSplit | // root1 := self createBalanced12345678. // originalChild := root1 child. // self assertTextContentsOf: root1 is: '12345678'. // originalSplit := (root1 nodeAt: 8) singleParentFor: 1. // // "operation" // duplicateSplit := originalSplit duplicateWithParentsFor: 1. // self should: [duplicateSplit == originalSplit]. // self assertTextContentsOf: root1 is: '12345678'. // self should: [root1 child == originalChild]. // self should: [((root1 nodeAt: 8) singleParentFor: 1) == originalSplit]. // self should: [originalSplit parents size = 1].! // // testDuplicateBadRevision // | root1 node | // root1 := self createBalanced12345678. // self assertTextContentsOf: root1 is: '12345678'. // // "operation" // node := (root1 nodeAt: 8) singleParentFor: 1. // self should: [node duplicateFor: 0] raise: EntError.! // // testDuplicateSameRevision // | root1 split newSplit | // root1 := self createBalanced12345678. // self assertTextContentsOf: root1 is: '12345678'. // // "operation" // split := (root1 nodeAt: 8) singleParentFor: 1. // newSplit := split duplicateFor: 1. // // self should: [split == newSplit].! // public void testIsLeft() { CollectionLeaf leaf1 = new CollectionLeaf(new SequenceNumber(1), 2, AboraConverter.toAboraContent("hello ")); CollectionLeaf leaf2 = new CollectionLeaf(new SequenceNumber(1), 99, AboraConverter.toAboraContent("there")); SplitNode split = new SplitNode(new SequenceNumber(1), 19, leaf1, 14, leaf2, -80); assertTrue(split.isLeft(17)); assertTrue(split.isLeft(18)); assertFalse(split.isLeft(19)); assertFalse(split.isLeft(20)); } // testIsLeft // | dataLeaf1 dataLeaf2 splitNode | // dataLeaf1 := CollectionLeaf // branch: 1 // startPosition: 3 // elements: 'hello ' asAboraContent. // dataLeaf2 := CollectionLeaf // branch: 1 // startPosition: 100 // elements: 'there' asAboraContent. // // "test" // splitNode := SplitNode // branch: 1 // split: 20 // left: dataLeaf1 // leftDsp: 14 // right: dataLeaf2 // rightDsp: -80. // self should: [splitNode isLeft: 18]. // self should: [splitNode isLeft: 19]. // self shouldnt: [splitNode isLeft: 20]. // self shouldnt: [splitNode isLeft: 21]! // // testSingleRotateLeftDifferentForRevision // | split1 split2 root1 root2 | // split1 := SplitNode // branch: 1 // split: 2 // left: (CollectionLeaf // branch: 1 // startPosition: 0 // elements: 'a' asAboraContent) // leftDsp: 1 // right: (CollectionLeaf // branch: 1 // startPosition: 0 // elements: 'b' asAboraContent) // rightDsp: 2. // split2 := SplitNode // branch: 2 // split: 6 // left: split1 // leftDsp: 3 // right: (CollectionLeaf // branch: 2 // startPosition: 0 // elements: 'c' asAboraContent) // rightDsp: 6. // root1 := RootNode // edition: nil // branch: 1 // with: split1. // root2 := RootNode // edition: nil // branch: 2 // with: split2 // dsp: 4. // self should: [(root2 contentsAt: 8) = $a codePoint]. // self should: [(root2 contentsAt: 9) = $b codePoint]. // self should: [(root2 contentsAt: 10) = $c codePoint]. // self should: [(root1 contentsAt: 1) = $a codePoint]. // self should: [(root1 contentsAt: 2) = $b codePoint]. // split2 singleRotateLeftFor: 2. // "split2 should have been duplicated due to the version difference between split1 & split2" // self should: [root2 child ~~ split1]. // self should: [root2 child ~~ split2]. // self should: [root2 child right == split2]. // self should: [root1 child == split1]. // self should: [(root2 contentsAt: 8) = $a codePoint]. // self should: [(root2 contentsAt: 9) = $b codePoint]. // self should: [(root2 contentsAt: 10) = $c codePoint]. // self should: [(root1 contentsAt: 1) = $a codePoint]. // self should: [(root1 contentsAt: 2) = $b codePoint]! // // testSingleRotateLeftFor // | split1 split2 root | // split1 := SplitNode // branch: 1 // split: 2 // left: (CollectionLeaf // branch: 1 // startPosition: 0 // elements: 'a' asAboraContent) // leftDsp: 1 // right: (CollectionLeaf // branch: 1 // startPosition: 0 // elements: 'b' asAboraContent) // rightDsp: 2. // split2 := SplitNode // branch: 1 // split: 6 // left: split1 // leftDsp: 3 // right: (CollectionLeaf // branch: 1 // startPosition: 0 // elements: 'c' asAboraContent) // rightDsp: 6. // root := RootNode // edition: nil // branch: 1 // with: split2 // dsp: 4. // self should: [(root contentsAt: 8) = $a codePoint]. // self should: [(root contentsAt: 9) = $b codePoint]. // self should: [(root contentsAt: 10) = $c codePoint]. // split2 singleRotateLeftFor: 1. // self should: [root child == split1]. // self should: [split1 right == split2]. // self should: [(root contentsAt: 8) = $a codePoint]. // self should: [(root contentsAt: 9) = $b codePoint]. // self should: [(root contentsAt: 10) = $c codePoint]! // // testSingleRotateRightFor // | split1 split2 root | // split1 := SplitNode // branch: 1 // split: -1 // left: (CollectionLeaf // branch: 1 // startPosition: -4 // elements: 'b' asAboraContent) // leftDsp: 2 // right: (CollectionLeaf // branch: 1 // startPosition: -7 // elements: 'c' asAboraContent) // rightDsp: 6. // split2 := SplitNode // branch: 1 // split: 2 // left: (CollectionLeaf // branch: 1 // startPosition: 0 // elements: 'a' asAboraContent) // leftDsp: 1 // right: split1 // rightDsp: 4. // root := RootNode // edition: nil // branch: 1 // with: split2 // dsp: 5. // self should: [(root contentsAt: 6) = $a codePoint]. // self should: [(root contentsAt: 7) = $b codePoint]. // self should: [(root contentsAt: 8) = $c codePoint]. // split2 singleRotateRightFor: 1. // self should: [root child == split1]. // self should: [split1 left == split2]. // self should: [(root contentsAt: 6) = $a codePoint]. // self should: [(root contentsAt: 7) = $b codePoint]. // self should: [(root contentsAt: 8) = $c codePoint]! // // testSingleRotateRightForDifferentRevision // | split1 split2 root1 root2 | // split1 := SplitNode // branch: 1 // split: -1 // left: (CollectionLeaf // branch: 1 // startPosition: -4 // elements: 'b' asAboraContent) // leftDsp: 2 // right: (CollectionLeaf // branch: 1 // startPosition: -7 // elements: 'c' asAboraContent) // rightDsp: 6. // split2 := SplitNode // branch: 2 // split: 2 // left: (CollectionLeaf // branch: 1 // startPosition: 0 // elements: 'a' asAboraContent) // leftDsp: 1 // right: split1 // rightDsp: 4. // root1 := RootNode // edition: nil // branch: 1 // with: split1. // root2 := RootNode // edition: nil // branch: 2 // with: split2 // dsp: 5. // self should: [(root2 contentsAt: 6) = $a codePoint]. // self should: [(root2 contentsAt: 7) = $b codePoint]. // self should: [(root2 contentsAt: 8) = $c codePoint]. // self should: [(root1 contentsAt: -2) = $b codePoint]. // self should: [(root1 contentsAt: -1) = $c codePoint]. // split2 singleRotateRightFor: 2. // "split2 should have been duplicated due to the version difference between split1 & split2" // self should: [root2 child ~~ split1]. // self should: [root2 child ~~ split2]. // self should: [root2 child left == split2]. // self should: [root1 child == split1]. // self should: [(root2 contentsAt: 6) = $a codePoint]. // self should: [(root2 contentsAt: 7) = $b codePoint]. // self should: [(root2 contentsAt: 8) = $c codePoint]. // self should: [(root1 contentsAt: -2) = $b codePoint]. // self should: [(root1 contentsAt: -1) = $c codePoint]! ! // !SplitNodeTest categoriesFor: #testAssertIsChild!public! ! // !SplitNodeTest categoriesFor: #testChildren!public! ! // !SplitNodeTest categoriesFor: #testContents!public! ! // !SplitNodeTest categoriesFor: #testContentsAt!public! ! // !SplitNodeTest categoriesFor: #testContentsAtBadPosition!public! ! // !SplitNodeTest categoriesFor: #testContentsFromExtentDo!public! ! // !SplitNodeTest categoriesFor: #testCount!public! ! // !SplitNodeTest categoriesFor: #testCreate!public! ! // !SplitNodeTest categoriesFor: #testCreateDsp!public! ! // !SplitNodeTest categoriesFor: #testDspForChild!public! ! // !SplitNodeTest categoriesFor: #testDspSetForChild!public! ! // !SplitNodeTest categoriesFor: #testDuplicate!public! ! // !SplitNodeTest categoriesFor: #testDuplicateAndParents!public! ! // !SplitNodeTest categoriesFor: #testDuplicateAndParentsSameRevision!public! ! // !SplitNodeTest categoriesFor: #testDuplicateBadRevision!public! ! // !SplitNodeTest categoriesFor: #testDuplicateSameRevision!public! ! // !SplitNodeTest categoriesFor: #testIsLeft!public! ! // !SplitNodeTest categoriesFor: #testSingleRotateLeftDifferentForRevision!public! ! // !SplitNodeTest categoriesFor: #testSingleRotateLeftFor!public! ! // !SplitNodeTest categoriesFor: #testSingleRotateRightFor!public! ! // !SplitNodeTest categoriesFor: #testSingleRotateRightForDifferentRevision!public! ! // } Index: AllTests.java =================================================================== RCS file: /cvsroot/abora/abora-ash/src/org/abora/ash/ent/tests/AllTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AllTests.java 8 May 2003 13:53:09 -0000 1.2 --- AllTests.java 9 May 2003 13:58:47 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- suite.addTest(new TestSuite(RootNodeTest.class)); suite.addTest(new TestSuite(SequenceNumberTest.class)); + suite.addTest(new TestSuite(SplitNodeTest.class)); //$JUnit-END$ return suite; Index: CollectionLeafTest.java =================================================================== RCS file: /cvsroot/abora/abora-ash/src/org/abora/ash/ent/tests/CollectionLeafTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CollectionLeafTest.java 8 May 2003 13:53:09 -0000 1.1 --- CollectionLeafTest.java 9 May 2003 13:58:47 -0000 1.2 *************** *** 7,14 **** package org.abora.ash.ent.tests; import org.abora.ash.engine.AboraConverter; import org.abora.ash.ent.CollectionLeaf; import org.abora.ash.ent.SequenceNumber; ! /** --- 7,19 ---- package org.abora.ash.ent.tests; + import java.util.List; + + import org.abora.ash.content.BeCollectionHolder; + import org.abora.ash.content.BeEdition; import org.abora.ash.engine.AboraConverter; import org.abora.ash.ent.CollectionLeaf; + import org.abora.ash.ent.RootNode; import org.abora.ash.ent.SequenceNumber; ! import org.abora.ash.space.IntegerRegion; /** *************** *** 32,35 **** --- 37,54 ---- //!CollectionLeafTest methodsFor! // + + public void testAllEditions() { + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 10, AboraConverter.toAboraContent("abcdef")); + BeEdition edition1 = new BeEdition(); + RootNode root1 = new RootNode(edition1, new SequenceNumber(1), leaf); + BeEdition edition2 = new BeEdition(); + RootNode root2 = new RootNode(edition2, new SequenceNumber(2), leaf); + + List allEditions = leaf.allEditions(); + assertEquals(2, allEditions.size()); + assertTrue(allEditions.contains(edition1)); + assertTrue(allEditions.contains(edition2)); + } + //testAllEditions // | leaf root1 edition1 root2 edition2 | *************** *** 52,55 **** --- 71,88 ---- // self should: [leaf allEditions includes: edition2]! // + + public void testAllRoots() { + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 10, AboraConverter.toAboraContent("abcdef")); + BeEdition edition1 = new BeEdition(); + RootNode root1 = new RootNode(edition1, new SequenceNumber(1), leaf); + BeEdition edition2 = new BeEdition(); + RootNode root2 = new RootNode(edition2, new SequenceNumber(2), leaf); + + List allRoots = leaf.allRoots(); + assertEquals(2, allRoots.size()); + assertTrue(allRoots.contains(root1)); + assertTrue(allRoots.contains(root2)); + } + //testAllRoots // | leaf root1 root2 | *************** *** 147,150 **** --- 180,195 ---- // self should: [out = '']! // + + public void testCount() { + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 10, AboraConverter.toAboraContent("hello")); + assertEquals(5, leaf.count()); + } + + public void testCountRegion() { + BeCollectionHolder holder = new BeCollectionHolder(AboraConverter.toAboraContent("Hello")); + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 10, holder, IntegerRegion.startExtent(1, 2)); + assertEquals(2, leaf.count()); + } + //testCount // | leaf | *************** *** 158,162 **** public void testCreate() { CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(3), 2, AboraConverter.toAboraContent("hello")); ! //TODO assertEquals("hello", AboraConverter.toJavaString(leaf.getElements())); assertEquals(new SequenceNumber(3), leaf.getBranch()); assertEquals(2, leaf.getStartPosition()); --- 203,207 ---- public void testCreate() { CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(3), 2, AboraConverter.toAboraContent("hello")); ! //TODO assertEquals("hello", AboraConverter.toJavaString(leaf.getElements())); assertEquals(new SequenceNumber(3), leaf.getBranch()); assertEquals(2, leaf.getStartPosition()); *************** *** 173,176 **** --- 218,232 ---- // self should: [leaf startPosition = 2]! // + + public void testDuplicateFor() { + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello")); + try { + leaf.duplicateFor(new SequenceNumber(1)); + fail(); + } catch (UnsupportedOperationException e) { + assertEquals("duplicateFor", e.getMessage()); + } + } + //testDuplicateFor // | leaf | *************** *** 311,314 **** --- 367,377 ---- // self should: [leaf isMinNodeFor: 1]! // + + public void testMaxNode() { + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello")); + assertSame(leaf, leaf.maxNode()); + } + + //testMaxNode // | leaf | *************** *** 319,322 **** --- 382,391 ---- // self should: [leaf maxNode == leaf]! // + + public void testMinNode() { + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello")); + assertSame(leaf, leaf.minNode()); + } + //testMinNode // | leaf | *************** *** 560,563 **** --- 629,661 ---- // self should: [leaf parents = (OrderedCollection with: root)]! // + + public void testSplitAboutBadAbout() { + CollectionLeaf leaf = new CollectionLeaf(new SequenceNumber(1), 1, AboraConverter.toAboraContent("hello")); + try { + leaf.splitAbout(1, -1); + fail("-1"); + } catch (IndexOutOfBoundsException e) { + assertEquals("-1", e.getMessage()); + } + try { + leaf.splitAbout(1, 0); + fail("0"); + } catch (IndexOutOfBoundsException e) { + assertEquals("0", e.getMessage()); + } + try { + leaf.splitAbout(1, 5); + fail("5"); + } catch (IndexOutOfBoundsException e) { + assertEquals("5", e.getMessage()); + } + try { + leaf.splitAbout(1, 6); + fail("6"); + } catch (IndexOutOfBoundsException e) { + assertEquals("6", e.getMessage()); + } + } + //testSplitAboutBadAbout // | root leaf splitNode | |