Skip to content

Commit 6fa4b20

Browse files
committed
Closed #73
1 parent f2d2b10 commit 6fa4b20

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/DataFrame-Tests/DataFrameTest.class.st

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,16 @@ DataFrameTest >> testRemoveColumnAt [
10901090
self assert: df equals: expected.
10911091
]
10921092

1093+
{ #category : #tests }
1094+
DataFrameTest >> testRemoveColumnAtOutOfRange [
1095+
self should: [ df removeColumnAt: 100 ] raise: SubscriptOutOfBounds.
1096+
]
1097+
1098+
{ #category : #tests }
1099+
DataFrameTest >> testRemoveColumnNotFound [
1100+
self should: [ df removeColumn: #NoSuchColumn ] raise: NotFoundError.
1101+
]
1102+
10931103
{ #category : #tests }
10941104
DataFrameTest >> testRemoveRow [
10951105

@@ -1124,6 +1134,16 @@ DataFrameTest >> testRemoveRowAt [
11241134
self assert: df equals: expected.
11251135
]
11261136

1137+
{ #category : #tests }
1138+
DataFrameTest >> testRemoveRowAtOutOfRange [
1139+
self should: [ df removeRowAt: 100 ] raise: SubscriptOutOfBounds.
1140+
]
1141+
1142+
{ #category : #tests }
1143+
DataFrameTest >> testRemoveRowNotFound [
1144+
self should: [ df removeRow: #NoSuchRow ] raise: NotFoundError.
1145+
]
1146+
11271147
{ #category : #tests }
11281148
DataFrameTest >> testRow [
11291149

src/DataFrame/DataFrame.class.st

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,8 @@ DataFrame >> removeColumn: columnName [
867867

868868
{ #category : #removing }
869869
DataFrame >> removeColumnAt: columnNumber [
870+
(columnNumber < 1 or: [ columnNumber > self numberOfColumns ])
871+
ifTrue: [ SubscriptOutOfBounds signalFor: columnNumber ].
870872

871873
contents removeColumnAt: columnNumber.
872874
columnNames := columnNames copyWithoutIndex: columnNumber.
@@ -882,7 +884,9 @@ DataFrame >> removeRow: rowName [
882884

883885
{ #category : #removing }
884886
DataFrame >> removeRowAt: rowNumber [
885-
887+
(rowNumber < 1 or: [ rowNumber > self numberOfRows ])
888+
ifTrue: [ SubscriptOutOfBounds signalFor: rowNumber ].
889+
886890
contents removeRowAt: rowNumber.
887891
rowNames := rowNames copyWithoutIndex: rowNumber.
888892
]

0 commit comments

Comments
 (0)