[Abora-cvs] abora-ash/src/org/abora/ash/ent/tests ContentLeafTest.java,NONE,1.1 CollectionLeafTest.j
Status: Alpha
Brought to you by:
dgjones
Update of /cvsroot/abora/abora-ash/src/org/abora/ash/ent/tests In directory sc8-pr-cvs1:/tmp/cvs-serv11397/src/org/abora/ash/ent/tests Modified Files: RootNodeTest.java AllTests.java Added Files: ContentLeafTest.java CollectionLeafTest.java EntTestCase.java Log Message: -STart leaf tests --- NEW FILE: ContentLeafTest.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 org.abora.ash.content.BeCollectionHolder; import org.abora.ash.content.BeContentElement; import org.abora.ash.content.BeEdition; import org.abora.ash.ent.ContentLeaf; import org.abora.ash.ent.RootNode; import org.abora.ash.ent.SequenceNumber; /** */ public class ContentLeafTest extends EntTestCase { public ContentLeafTest(String arg0) { super(arg0); } // "Filed out from Dolphin Smalltalk 2002 release 5.00"! // // AboraBeTests subclass: #ContentLeafTest // instanceVariableNames: '' // classVariableNames: '' // poolDictionaries: '' // classInstanceVariableNames: ''! // ContentLeafTest guid: (GUID fromString: '{0D230093-2E44-4D9C-839C-7678FC96F2B5}')! // ContentLeafTest comment: ''! // !ContentLeafTest categoriesForClass!Kernel-Objects! ! // !ContentLeafTest methodsFor! // // testContentsAt // | leaf content | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 3 // startPosition: 2 // contentElement: content. // self should: [(leaf contentsAt: 2) == content]! // // testContentsAtBadPosition // | leaf content | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 3 // startPosition: 2 // contentElement: content. // self should: [leaf contentsAt: 1] raise: BoundsError. // self should: [leaf contentsAt: 3] raise: BoundsError! // // testContentsFromExtentDo // | leaf content out | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 3 // startPosition: 2 // contentElement: content. // out := OrderedCollection new. // leaf // contentsFrom: 2 // extent: 1 // do: [:data | out add: data]. // self should: [out = (OrderedCollection with: content)]. // out := OrderedCollection new. // leaf // contentsFrom: 1 // extent: 3 // do: [:data | out add: data]. // self should: [out = (OrderedCollection with: content)]! // public void testCount() { BeContentElement content = new BeEdition(); ContentLeaf leaf = new ContentLeaf(new SequenceNumber(3), 2, content); assertEquals(1, leaf.count()); } // testCount // | leaf content | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 3 // startPosition: 2 // contentElement: content. // self should: [leaf count = 1]! // public void testCountCollection() { BeContentElement content = new BeCollectionHolder(new byte[] { 0, 1, 2 }); ContentLeaf leaf = new ContentLeaf(new SequenceNumber(3), 2, content); assertEquals(1, leaf.count()); } // testCountCollection // | leaf content | // content := BeDataHolder value: 'hello'. // leaf := ContentLeaf // branch: 3 // startPosition: 2 // contentElement: content. // self should: [leaf count = 1]! // public void testCreate() { BeContentElement content = new BeEdition(); assertTrue(content.getParents().isEmpty()); ContentLeaf leaf = new ContentLeaf(new SequenceNumber(3), 2, content); assertEquals(content, leaf.getContentElement()); assertEquals(new SequenceNumber(3), leaf.getBranch()); assertEquals(2, leaf.getStartPosition()); assertEquals(1, content.getParents().size()); assertTrue(content.getParents().contains(leaf)); } // testCreate // | leaf content | // content := BeDataHolder value: 123. // self should: [content parents isEmpty]. // leaf := ContentLeaf // branch: 3 // startPosition: 2 // contentElement: content. // self should: [leaf contentElement = content]. // self should: [leaf branch = 3]. // self should: [leaf startPosition = 2]. // self should: [content parents = (OrderedCollection with: leaf)]! // // testSharedWithForMappingsMultiple // | leaf content edition anotherEdition mappings | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 1 // startPosition: 1 // contentElement: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition contents: content. // anotherEdition := anotherEdition append: (BeDataHolder value: 9). // anotherEdition := anotherEdition append: content. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 2]. // self should: [mappings first first = (IntegerRegion startPosition: 1 extent: 1)]. // self should: [mappings first last = (IntegerRegion startPosition: 1 extent: 1)]. // self should: [mappings last first = (IntegerRegion startPosition: 1 extent: 1)]. // self should: [mappings last last = (IntegerRegion startPosition: 3 extent: 1)]! // // testSharedWithForMappingsNone // | leaf content edition anotherEdition mappings | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 1 // startPosition: 1 // contentElement: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition new. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings isEmpty]! // // testSharedWithForMappingsSimpleDisplacement // | leaf content edition anotherEdition mappings | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 1 // startPosition: 1 // contentElement: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition contents: (BeDataHolder value: 9). // anotherEdition := anotherEdition append: content. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 1]. // self should: [mappings first first = (IntegerRegion startPosition: 1 extent: 1)]. // self should: [mappings first last = (IntegerRegion startPosition: 2 extent: 1)]! // // testSharedWithForMappingsStraight // | leaf content edition anotherEdition mappings | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 1 // startPosition: 1 // contentElement: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition contents: content. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 1]. // self should: [mappings first first = (IntegerRegion startPosition: 1 extent: 1)]. // self should: [mappings first last = (IntegerRegion startPosition: 1 extent: 1)]! // public void testSplitAbout() { BeContentElement content = new BeEdition(); ContentLeaf leaf = new ContentLeaf(new SequenceNumber(3), 2, content); RootNode root = new RootNode(null, new SequenceNumber(3), leaf); try { leaf.splitAbout(1, 2); fail(); } catch (UnsupportedOperationException e) { assertEquals("should not implement", e.getMessage()); } } // testSplitAbout // | leaf content root | // content := BeDataHolder value: 123. // leaf := ContentLeaf // branch: 3 // startPosition: 2 // contentElement: content. // root := RootNode // edition: nil // branch: 1 // with: leaf. // // "test" // self // should: [leaf split: 1 about: 2] // raise: Error // description: 'ContentLeaf should not implement #split:about:'! ! // !ContentLeafTest categoriesFor: #testContentsAt!public! ! // !ContentLeafTest categoriesFor: #testContentsAtBadPosition!public! ! // !ContentLeafTest categoriesFor: #testContentsFromExtentDo!public! ! // !ContentLeafTest categoriesFor: #testCount!public! ! // !ContentLeafTest categoriesFor: #testCountCollection!public! ! // !ContentLeafTest categoriesFor: #testCreate!public! ! // !ContentLeafTest categoriesFor: #testSharedWithForMappingsMultiple!public! ! // !ContentLeafTest categoriesFor: #testSharedWithForMappingsNone!public! ! // !ContentLeafTest categoriesFor: #testSharedWithForMappingsSimpleDisplacement!public! ! // !ContentLeafTest categoriesFor: #testSharedWithForMappingsStraight!public! ! // !ContentLeafTest categoriesFor: #testSplitAbout!public! ! } --- NEW FILE: CollectionLeafTest.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 org.abora.ash.engine.AboraConverter; import org.abora.ash.ent.CollectionLeaf; import org.abora.ash.ent.SequenceNumber; /** */ public class CollectionLeafTest extends EntTestCase { public CollectionLeafTest(String arg0) { super(arg0); } //:"Filed out from Dolphin Smalltalk 2002 release 5.00"! // //AboraBeTests subclass: #CollectionLeafTest // instanceVariableNames: '' // classVariableNames: '' // poolDictionaries: '' // classInstanceVariableNames: ''! //CollectionLeafTest guid: (GUID fromString: '{5D1379AA-01B5-4DC8-AEF9-C5B54A1529AD}')! //CollectionLeafTest comment: ''! //!CollectionLeafTest categoriesForClass!SUnit! ! //!CollectionLeafTest methodsFor! // //testAllEditions // | leaf root1 edition1 root2 edition2 | // leaf := CollectionLeaf // branch: 1 // startPosition: 10 // elements: 'abcdef' asAboraContent. // edition1 := BeEdition new. // root1 := RootNode // edition: edition1 // branch: 1 // with: leaf. // edition2 := BeEdition new. // root2 := RootNode // edition: edition2 // branch: 2 // with: leaf. // self should: [leaf allEditions size = 2]. // self should: [leaf allEditions includes: edition1]. // self should: [leaf allEditions includes: edition2]! // //testAllRoots // | leaf root1 root2 | // leaf := CollectionLeaf // branch: 1 // startPosition: 10 // elements: 'abcdef' asAboraContent. // root1 := RootNode // edition: nil // branch: 1 // with: leaf. // root2 := RootNode // edition: nil // branch: 2 // with: leaf. // self should: [leaf allRoots size = 2]. // self should: [leaf allRoots includes: root1]. // self should: [leaf allRoots includes: root2]! // //testContents // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 10 // elements: 'abcdef' asAboraContent. // self should: [leaf contents = 'abcdef' asAboraContent]! // //testContentsAt // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 10 // elements: 'abcdef' asAboraContent. // self should: [(leaf contentsAt: 10) = $a codePoint]. // self should: [(leaf contentsAt: 11) = $b codePoint]. // self should: [(leaf contentsAt: 15) = $f codePoint]! // //testContentsAtBadPosition // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 10 // elements: 'abcdef' asAboraContent. // self should: [leaf contentsAt: 9] raise: BoundsError. // self should: [leaf contentsAt: 16] raise: BoundsError! // //testContentsFromExtentDo // | leaf out do | // leaf := CollectionLeaf // branch: 1 // startPosition: 10 // elements: 'abcdef' asAboraContent. // out := ''. // do := [:int | out := out , (Character codePoint: int) asString]. // leaf // contentsFrom: 10 // extent: 6 // do: do. // self should: [out = 'abcdef']. // out := ''. // leaf // contentsFrom: 11 // extent: 3 // do: do. // self should: [out = 'bcd']. // out := ''. // leaf // contentsFrom: 8 // extent: 13 // do: do. // self should: [out = 'abcdef']. // out := ''. // leaf // contentsFrom: 8 // extent: 3 // do: do. // self should: [out = 'a']. // out := ''. // leaf // contentsFrom: 15 // extent: 6 // do: do. // self should: [out = 'f']. // out := ''. // leaf // contentsFrom: 5 // extent: 5 // do: do. // self should: [out = '']. // out := ''. // leaf // contentsFrom: 16 // extent: 5 // do: do. // self should: [out = '']! // //testCount // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 10 // elements: 'hello' asAboraContent. // self should: [leaf count = 5]! // 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()); } //testCreate // | leaf | // leaf := CollectionLeaf // branch: 3 // startPosition: 2 // elements: 'hello' asAboraContent. // self should: [leaf elements = 'hello' asAboraContent]. // self should: [leaf branch = 3]. // self should: [leaf startPosition = 2]! // //testDuplicateFor // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // self should: [leaf duplicateFor: 1] raise: Error! // //testGlobalPositionFor // | leaf1 leaf2 split root | // leaf1 := CollectionLeaf // branch: 1 // startPosition: 4 // elements: '12' asAboraContent. // leaf2 := CollectionLeaf // branch: 1 // startPosition: 5 // elements: '3' asAboraContent. // split := SplitNode // branch: 1 // split: 7 // left: leaf1 // leftDsp: 1 // right: leaf2 // rightDsp: 2. // root := RootNode // edition: nil // branch: 1 // with: split // dsp: -4. // self assertTextContentsOf: root is: '123'. // // "test" // self should: [(leaf1 globalPositionFor: 1) = 1]. // self should: [(leaf2 globalPositionFor: 1) = 3]! // //testGlobalPositionForSimple // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // self should: [(leaf globalPositionFor: 1) = 1]! // //testGlobalRegionFor // | leaf1 leaf2 split root | // leaf1 := CollectionLeaf // branch: 1 // startPosition: 4 // elements: '12' asAboraContent. // leaf2 := CollectionLeaf // branch: 1 // startPosition: 5 // elements: '3' asAboraContent. // split := SplitNode // branch: 1 // split: 7 // left: leaf1 // leftDsp: 1 // right: leaf2 // rightDsp: 2. // root := RootNode // edition: nil // branch: 1 // with: split // dsp: -4. // self assertTextContentsOf: root is: '123'. // // "test" // self should: [(leaf1 globalRegionFor: 1) = (IntegerRegion startPosition: 1 extent: 2)]. // self should: [(leaf2 globalRegionFor: 1) = (IntegerRegion startPosition: 3 extent: 1)]! // //testInsertAtRootBadPosition // | root leaf insertedNode | // leaf := CollectionLeaf // branch: 3 // startPosition: 4 // elements: 'hello' asAboraContent. // root := RootNode // edition: nil // branch: 4 // with: leaf // dsp: -3. // insertedNode := CollectionLeaf // branch: 3 // startPosition: 0 // elements: 'ab' asAboraContent. // self should: // [leaf // insert: insertedNode // at: 3 // root: root] // raise: BoundsError. // self should: // [leaf // insert: insertedNode // at: 9 + 1 // root: root] // raise: BoundsError! // //testIsMaxNodeFor // | root leaf | // root := self createBalanced12345678. // 1 to: 7 // do: // [:index | // leaf := root nodeAt: index. // self should: [(leaf isMaxNodeFor: 1) not]]. // leaf := root nodeAt: 8. // self should: [leaf isMaxNodeFor: 1]! // //testIsMaxNodeForSingle // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // self should: [leaf isMaxNodeFor: 1]! // //testIsMinNodeFor // | root leaf | // root := self createBalanced12345678. // 2 to: 8 // do: // [:index | // leaf := root nodeAt: index. // self should: [(leaf isMinNodeFor: 1) not]]. // leaf := root nodeAt: 1. // self should: [leaf isMinNodeFor: 1]! // //testIsMinNodeForSingle // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // self should: [leaf isMinNodeFor: 1]! // //testMaxNode // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // self should: [leaf maxNode == leaf]! // //testMinNode // | leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // self should: [leaf minNode == leaf]! // //testRemoveFromRoot // | root leaf | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // root := RootNode // edition: nil // branch: 1 // with: leaf. // // "test" // leaf removeFor: 1. // self should: [root count = 0]. // self assertTextContentsOf: root is: ''! // //testRemoveFromSplitLeft // | root leaf1 leaf2 splitNode | // leaf1 := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'a' asAboraContent. // leaf2 := CollectionLeaf // branch: 1 // startPosition: 2 // elements: 'b' asAboraContent. // splitNode := SplitNode // branch: 1 // split: 2 // left: leaf1 // right: leaf2. // root := RootNode // edition: nil // branch: 1 // with: splitNode. // // "test" // leaf1 removeFor: 1. // self assertTextContentsOf: root is: 'b'! // //testRemoveFromSplitRight // | root leaf1 leaf2 splitNode | // leaf1 := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'a' asAboraContent. // leaf2 := CollectionLeaf // branch: 1 // startPosition: 2 // elements: 'b' asAboraContent. // splitNode := SplitNode // branch: 1 // split: 2 // left: leaf1 // right: leaf2. // root := RootNode // edition: nil // branch: 1 // with: splitNode. // // "test" // leaf2 removeFor: 1. // self assertTextContentsOf: root is: 'a'! // //testReplaceWithSplitAbout // | root leaf splitNode collection | // collection := BeCollectionHolder collection: 'hello' asAboraContent. // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // collection: collection. // root := RootNode // edition: nil // branch: 1 // with: leaf. // self should: [collection parents = (OrderedCollection with: leaf)]. // // "test" // splitNode := leaf replaceWithSplit: 1 about: 3. // self should: [splitNode left elements = 'he' asAboraContent]. // self should: [splitNode right elements = 'llo' asAboraContent]. // self should: [splitNode left parents = (OrderedCollection with: splitNode)]. // self should: [splitNode right parents = (OrderedCollection with: splitNode)]. // self // should: [collection parents = (OrderedCollection with: splitNode left with: splitNode right)]. // "existing parents should be updated with new splitNode" // self should: [leaf parents = OrderedCollection new]. // self should: [root child == splitNode]. // self should: [splitNode parents = (OrderedCollection with: root)]! // //testSharedWithForMappingsMultiple // | leaf content edition anotherEdition mappings | // content := BeCollectionHolder collection: '123' asAboraContent. // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // collection: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition contents: content. // anotherEdition := anotherEdition append: 'abcde' asAboraContent. // anotherEdition := anotherEdition append: content. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 2]. // self should: [mappings first first = (IntegerRegion startPosition: 1 extent: 3)]. // self should: [mappings first last = (IntegerRegion startPosition: 1 extent: 3)]. // self should: [mappings last first = (IntegerRegion startPosition: 1 extent: 3)]. // self should: [mappings last last = (IntegerRegion startPosition: 9 extent: 3)]! // //testSharedWithForMappingsNone // | leaf content edition anotherEdition mappings | // content := BeCollectionHolder collection: '123' asAboraContent. // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // collection: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition new. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings isEmpty]! // //testSharedWithForMappingsNoneByPartialOverlap // | leaf content edition anotherEdition mappings | // content := BeCollectionHolder collection: '123' asAboraContent. // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // collection: content. // edition := BeEdition new. // edition root insert: leaf. // edition := edition removeFrom: 1 extent: 2. // anotherEdition := BeEdition contents: content. // anotherEdition := anotherEdition removeFrom: 2 extent: 2. // mappings := OrderedCollection new. // self should: [edition root child contents = '3' asAboraContent]. // edition root child // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 0]! // //testSharedWithForMappingsPartialOverlap // | leaf content edition anotherEdition mappings | // content := BeCollectionHolder collection: '123' asAboraContent. // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // collection: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition contents: 'abcd' asAboraContent. // anotherEdition := anotherEdition insert: content at: 5. // anotherEdition := anotherEdition removeFrom: 5 extent: 2. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 1]. // self should: [mappings first first = (IntegerRegion startPosition: 3 extent: 1)]. // self should: [mappings first last = (IntegerRegion startPosition: 5 extent: 1)]! // //testSharedWithForMappingsSimpleDisplacement // | leaf content edition anotherEdition mappings | // content := BeCollectionHolder collection: '123' asAboraContent. // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // collection: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition contents: 'abcde' asAboraContent. // anotherEdition := anotherEdition append: content. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 1]. // self should: [mappings first first = (IntegerRegion startPosition: 1 extent: 3)]. // self should: [mappings first last = (IntegerRegion startPosition: 6 extent: 3)]! // //testSharedWithForMappingsStraight // | leaf content edition anotherEdition mappings | // content := BeCollectionHolder collection: '123' asAboraContent. // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // collection: content. // edition := BeEdition new. // edition root insert: leaf. // anotherEdition := BeEdition contents: content. // mappings := OrderedCollection new. // leaf // sharedWith: anotherEdition // for: anotherEdition branch // mappings: mappings. // self should: [mappings size = 1]. // self should: [mappings first first = (IntegerRegion startPosition: 1 extent: 3)]. // self should: [mappings first last = (IntegerRegion startPosition: 1 extent: 3)]! // //testSplitAbout // | root leaf splitNode | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // root := RootNode // edition: nil // branch: 1 // with: leaf. // // "test" // splitNode := leaf split: 1 about: 3. // self should: [splitNode left elements = 'he' asAboraContent]. // self should: [splitNode right elements = 'llo' asAboraContent]. // self should: [splitNode left parents = (OrderedCollection with: splitNode)]. // self should: [splitNode right parents = (OrderedCollection with: splitNode)]. // self assertTextContentsOf: root is: 'hello'. // "existing parents should be left untouched" // self should: [splitNode parents = OrderedCollection new]. // self should: [root child == leaf]. // self should: [leaf parents = (OrderedCollection with: root)]! // //testSplitAboutBadAbout // | root leaf splitNode | // leaf := CollectionLeaf // branch: 1 // startPosition: 1 // elements: 'hello' asAboraContent. // root := RootNode // edition: nil // branch: 1 // with: leaf. // // "test" // self should: [splitNode := leaf split: 1 about: 0] raise: BoundsError. // self should: [splitNode := leaf split: 1 about: 1] raise: BoundsError. // self should: [splitNode := leaf split: 1 about: 6] raise: BoundsError. // self should: [splitNode := leaf split: 1 about: 7] raise: BoundsError! ! //!CollectionLeafTest categoriesFor: #testAllEditions!public! ! //!CollectionLeafTest categoriesFor: #testAllRoots!public! ! //!CollectionLeafTest categoriesFor: #testContents!public! ! //!CollectionLeafTest categoriesFor: #testContentsAt!public! ! //!CollectionLeafTest categoriesFor: #testContentsAtBadPosition!public! ! //!CollectionLeafTest categoriesFor: #testContentsFromExtentDo!public! ! //!CollectionLeafTest categoriesFor: #testCount!public! ! //!CollectionLeafTest categoriesFor: #testCreate!public! ! //!CollectionLeafTest categoriesFor: #testDuplicateFor!public! ! //!CollectionLeafTest categoriesFor: #testGlobalPositionFor!public! ! //!CollectionLeafTest categoriesFor: #testGlobalPositionForSimple!public! ! //!CollectionLeafTest categoriesFor: #testGlobalRegionFor!public! ! //!CollectionLeafTest categoriesFor: #testInsertAtRootBadPosition!public! ! //!CollectionLeafTest categoriesFor: #testIsMaxNodeFor!public! ! //!CollectionLeafTest categoriesFor: #testIsMaxNodeForSingle!public! ! //!CollectionLeafTest categoriesFor: #testIsMinNodeFor!public! ! //!CollectionLeafTest categoriesFor: #testIsMinNodeForSingle!public! ! //!CollectionLeafTest categoriesFor: #testMaxNode!public! ! //!CollectionLeafTest categoriesFor: #testMinNode!public! ! //!CollectionLeafTest categoriesFor: #testRemoveFromRoot!public! ! //!CollectionLeafTest categoriesFor: #testRemoveFromSplitLeft!public! ! //!CollectionLeafTest categoriesFor: #testRemoveFromSplitRight!public! ! //!CollectionLeafTest categoriesFor: #testReplaceWithSplitAbout!public! ! //!CollectionLeafTest categoriesFor: #testSharedWithForMappingsMultiple!public! ! //!CollectionLeafTest categoriesFor: #testSharedWithForMappingsNone!public! ! //!CollectionLeafTest categoriesFor: #testSharedWithForMappingsNoneByPartialOverlap!public! ! //!CollectionLeafTest categoriesFor: #testSharedWithForMappingsPartialOverlap!public! ! //!CollectionLeafTest categoriesFor: #testSharedWithForMappingsSimpleDisplacement!public! ! //!CollectionLeafTest categoriesFor: #testSharedWithForMappingsStraight!public! ! //!CollectionLeafTest categoriesFor: #testSplitAbout!public! ! //!CollectionLeafTest categoriesFor: #testSplitAboutBadAbout!public! ! // } --- NEW FILE: EntTestCase.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 junit.framework.TestCase; import org.abora.ash.ent.EntNode; /** */ public class EntTestCase extends TestCase { public EntTestCase(String name) { super(name); } // "Filed out from Dolphin Smalltalk 2002 release 5.00"! // // AboraTests subclass: #AboraBeTests // instanceVariableNames: '' // classVariableNames: '' // poolDictionaries: '' // classInstanceVariableNames: ''! // AboraBeTests guid: (GUID fromString: '{8B40BB18-EAF8-4BB9-8BBD-4644045F1CBE}')! // AboraBeTests comment: ''! // !AboraBeTests categoriesForClass!Kernel-Objects! ! // !AboraBeTests methodsFor! // protected void assertTextContents(String expectedText, EntNode node) { //TODO } // assertTextContentsOf: root is: expectedText // | actualText | // actualText := root contents asAboraText. // self should: [actualText = expectedText]. // expectedText // keysAndValuesDo: [:i :char | self should: [(root contentsAt: i) = char codePoint]]! // // createBalanced12345678 // | splitC1 splitC2 splitC3 splitA splitC4 splitB1 splitB2 | // splitC1 := SplitNode // branch: 1 // split: 2 // left: (CollectionLeaf // branch: 1 // startPosition: 1 // elements: '1' asAboraContent) // right: (CollectionLeaf // branch: 1 // startPosition: 2 // elements: '2' asAboraContent). // splitC2 := SplitNode // branch: 1 // split: 4 // left: (CollectionLeaf // branch: 1 // startPosition: 3 // elements: '3' asAboraContent) // right: (CollectionLeaf // branch: 1 // startPosition: 4 // elements: '4' asAboraContent). // splitC3 := SplitNode // branch: 1 // split: 6 // left: (CollectionLeaf // branch: 1 // startPosition: 5 // elements: '5' asAboraContent) // right: (CollectionLeaf // branch: 1 // startPosition: 6 // elements: '6' asAboraContent). // splitC4 := SplitNode // branch: 1 // split: 8 // left: (CollectionLeaf // branch: 1 // startPosition: 7 // elements: '7' asAboraContent) // right: (CollectionLeaf // branch: 1 // startPosition: 8 // elements: '8' asAboraContent). // splitB1 := SplitNode // branch: 1 // split: 3 // left: splitC1 // right: splitC2. // splitB2 := SplitNode // branch: 1 // split: 7 // left: splitC3 // right: splitC4. // splitA := SplitNode // branch: 1 // split: 5 // left: splitB1 // right: splitB2. // ^RootNode // edition: nil // branch: 1 // with: splitA! // // createSourceEdition12345678 // | edition | // edition := BeEdition new. // edition root insert: (CollectionLeaf // branch: 1 // startPosition: 1 // elements: '12345678' asAboraContent). // ^edition! ! // !AboraBeTests categoriesFor: #assertTextContentsOf:is:!public! ! // !AboraBeTests categoriesFor: #createBalanced12345678!private! ! // !AboraBeTests categoriesFor: #createSourceEdition12345678!private! ! // // !AboraBeTests class methodsFor! // // isAbstract // "Override to true if a TestCase subclass is Abstract and should not have // TestCase instances built from it" // // ^self name = #AboraBeTests! ! // !AboraBeTests class categoriesFor: #isAbstract!public! ! // } Index: RootNodeTest.java =================================================================== RCS file: /cvsroot/abora/abora-ash/src/org/abora/ash/ent/tests/RootNodeTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RootNodeTest.java 4 May 2003 18:32:06 -0000 1.1 --- RootNodeTest.java 8 May 2003 13:53:09 -0000 1.2 *************** *** 7,23 **** package org.abora.ash.ent.tests; ! import org.abora.ash.engine.AboraConverter; import org.abora.ash.content.BeEdition; import org.abora.ash.ent.ChildNode; import org.abora.ash.ent.CollectionLeaf; import org.abora.ash.ent.NonCompatibleBranchException; import org.abora.ash.ent.RootNode; import org.abora.ash.ent.SequenceNumber; [...1233 lines suppressed...] ! // found := root splay: 4. ! // self assertTextContentsOf: root is: '12345678'. ! // self should: [found elements = '4' asAboraContent]. ! // self shouldHaveMatchingParents: root. ! // ! ! // ! // testSplayChild ! // | root found leaf | ! // leaf := CollectionLeaf ! // branch: 1 ! // startPosition: 1 ! // elements: '1' asAboraContent. ! // root := RootNode ! // edition: nil ! // branch: 1 ! // with: leaf. ! // root splay: 1. ! // self should: [root child == leaf]! ! } Index: AllTests.java =================================================================== RCS file: /cvsroot/abora/abora-ash/src/org/abora/ash/ent/tests/AllTests.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AllTests.java 4 May 2003 18:32:06 -0000 1.1 --- AllTests.java 8 May 2003 13:53:09 -0000 1.2 *************** *** 18,23 **** TestSuite suite = new TestSuite("Test for org.abora.be.ent.tests"); //$JUnit-BEGIN$ ! suite.addTest(new TestSuite(SequenceNumberTest.class)); suite.addTest(new TestSuite(RootNodeTest.class)); //$JUnit-END$ return suite; --- 18,25 ---- TestSuite suite = new TestSuite("Test for org.abora.be.ent.tests"); //$JUnit-BEGIN$ ! suite.addTest(new TestSuite(CollectionLeafTest.class)); ! suite.addTest(new TestSuite(ContentLeafTest.class)); suite.addTest(new TestSuite(RootNodeTest.class)); + suite.addTest(new TestSuite(SequenceNumberTest.class)); //$JUnit-END$ return suite; |