Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve code coverage #476

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Soil-Core-Tests/SoilBTreeTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,8 @@ SoilBTreeTest >> testRemoveKey [

self assert: (btree at: 1) equals: #[ 1 2 3 4 5 6 7 8 ].
self assert: (btree at: capacity) equals: #[ 1 2 3 4 5 6 7 8 ].
self should: [ btree at: 20 ] raise: KeyNotFound.
btree at: 20 put: #[ 1 2 3 4 5 6 7 8 ].
self assert: (btree at: 20) equals: #[ 1 2 3 4 5 6 7 8 ].
self should: [ btree at: 20 ] raise: KeyNotFound.
self should: [ btree removeKey: 20 ] raise: KeyNotFound.
]

{ #category : #tests }
Expand Down
120 changes: 115 additions & 5 deletions src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,41 @@ SoilIndexedDictionaryTest >> testAddToNewList [
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirst [
SoilIndexedDictionaryTest >> testAt [
dict at: #foo2 put: #bar2.
dict at: #foo put: #bar.

self assert: (dict at: #foo2) equals: #bar2.
self should: [dict at: #ff] raise: KeyNotFound
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testAtIndex [
dict at: #foo2 put: #bar2.
dict at: #foo put: #bar.

self assert: (dict atIndex: 1) equals: #bar2
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirst [
dict at: #foo2 put: #bar2.
dict at: #foo put: #bar.

"first in key order"
self assert: dict first equals: #bar.
self assert: (dict first: 1) first equals: #bar.
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirstAssociation [
dict at: #foo2 put: #bar2.
dict at: #foo put: #bar.

"firstAssocation in key order"
self assert: dict firstAssociation equals: #foo->#bar.
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirstAssociationWithSingleRemovedItem [

Expand All @@ -165,6 +191,22 @@ SoilIndexedDictionaryTest >> testFirstAssociationWithSingleRemovedItem [
self assert: dict firstAssociation equals: nil
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirstAssociationWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: 1 put: #one.
dict at: 2 put: #two.
"self assert: dict last equals: #two."
tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last"
self assert: tx2 root firstAssociation equals: 1->#one.

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirstWithSingleRemovedItem [

Expand Down Expand Up @@ -199,19 +241,45 @@ SoilIndexedDictionaryTest >> testIsEmpty [

{ #category : #tests }
SoilIndexedDictionaryTest >> testLast [
dict at: #foo put: #bar.
dict at: #foo2 put: #bar2.

dict at: #foo put: #bar.

"last in key order"
self assert: dict last equals: #bar2
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testLastAssociation [
dict at: #foo2 put: #bar2.
dict at: #foo put: #bar.

"last association in key order"
self assert: dict lastAssociation equals: #foo2->#bar2
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testLastAssociationWithSingleRemovedItem [
dict at: #foo put: #bar.
dict removeKey: #foo.
self assert: dict lastAssociation equals: nil
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testLastAssociationWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: 2 put: #two.
dict at: 1 put: #one.

"self assert: dict last equals: #two."
tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last, not: key order"
self assert: tx2 root lastAssociation equals: 2->#two
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testLastWithSingleRemovedItem [
dict at: #foo put: #bar.
Expand All @@ -224,13 +292,14 @@ SoilIndexedDictionaryTest >> testLastWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: 1 put: #one.
dict at: 2 put: #two.
dict at: 1 put: #one.

"self assert: dict last equals: #two."
tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last"
"and test last, note: keyorder"
self assert: tx2 root last equals: #two
]

Expand Down Expand Up @@ -273,6 +342,17 @@ SoilIndexedDictionaryTest >> testNextAfterWithTransaction [
self assert: (tx2 root nextAfter: 1) value equals: #two
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testRemoveKey [
dict at: #foo put: #bar.
dict at: #foo2 put: #bar2.

dict removeKey: #foo.
self assert: dict size equals: 1.

self should: [ dict removeKey: #blah ] raise: KeyNotFound
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testSecond [
dict at: #foo put: #bar.
Expand All @@ -281,6 +361,21 @@ SoilIndexedDictionaryTest >> testSecond [
self assert: dict second equals: #bar2
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testSecondWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: 1 put: #one.
dict at: 2 put: #two.
"self assert: dict last equals: #two."
tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last"
self assert: tx2 root second equals: #two
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testSize [
dict at: #foo put: #bar.
Expand All @@ -289,6 +384,21 @@ SoilIndexedDictionaryTest >> testSize [
self assert: dict size equals: 2
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testSizeWithTransaction [
| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: 1 put: #one.
dict at: 2 put: #two.
"self assert: dict last equals: #two."
tx commit.
"open a second transaction ..."
tx2 := soil newTransaction.
"and test last"
self assert: tx2 root size equals: 2
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testValues [
dict at: #foo put: #bar.
Expand Down
11 changes: 11 additions & 0 deletions src/Soil-Core-Tests/SoilSkipListTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ SoilSkipListTest >> testFirst [
self assert: (skipList first: 2) second equals: #[ 1 2 3 4 5 6 7 8 ].
]

{ #category : #tests }
SoilSkipListTest >> testFirstArgLargerThenSize [

1 to: 4 do: [ :n |
skipList at: n put: #[ 1 2 3 4 5 6 7 8 ] ].
self assert: skipList pages size equals: 1.
self assert: (skipList first: 5) size equals: 4
]

{ #category : #tests }
SoilSkipListTest >> testIsEmpty [
self assert: skipList isEmpty.
Expand Down Expand Up @@ -384,6 +393,8 @@ SoilSkipListTest >> testRemoveKey [
self should: [ skipList at: 20 ] raise: KeyNotFound.
skipList at: 20 put: #[ 1 2 3 4 5 6 7 8 ].
self assert: (skipList at: 20) equals: #[ 1 2 3 4 5 6 7 8 ].

self should: [ skipList removeKey: capacity + 1 ] raise: KeyNotFound
]

{ #category : #tests }
Expand Down
Loading