@@ -19,19 +19,22 @@ test('Test vtkDataArray instance', (t) => {
19
19
20
20
t . throws (
21
21
( ) => vtkDataArray . newInstance ( { } ) ,
22
- 'Create instance without values '
22
+ 'Not allowed to create instance without initialValues '
23
23
) ;
24
24
25
- t . doesNotThrow ( ( ) => vtkDataArray . newInstance ( { empty : true } ) ) ;
25
+ t . doesNotThrow (
26
+ ( ) => vtkDataArray . newInstance ( { empty : true } ) ,
27
+ 'Allowed to create instance with empty true, no values'
28
+ ) ;
26
29
27
30
t . throws (
28
31
( ) => vtkDataArray . newInstance ( { empty : false } ) ,
29
- 'Create instance with empty false, no values'
32
+ 'Not allowed to create instance with empty false, no values'
30
33
) ;
31
34
32
35
t . doesNotThrow (
33
36
( ) => vtkDataArray . newInstance ( { size : 256 } ) ,
34
- 'Create instance with only size'
37
+ 'Allowed to create instance with only size'
35
38
) ;
36
39
37
40
const dataArray0 = vtkDataArray . newInstance ( {
@@ -137,7 +140,7 @@ test('Test vtkDataArray setData', (t) => {
137
140
values : macro . newTypedArrayFrom ( DefaultDataType , [ 4 , 5 , 6 , 7 ] ) ,
138
141
} ,
139
142
getDataArrayProperties ( dataArray ) ,
140
- 'Change data of existing instance'
143
+ 'Change values of existing instance'
141
144
) ;
142
145
143
146
dataArray . setData ( [ 1 , 2 , 3 , 4 , 5 , 6 ] , 2 ) ;
@@ -176,28 +179,29 @@ test('Test vtkDataArray setData', (t) => {
176
179
'Empty an instance (pass [] array)'
177
180
) ;
178
181
179
- // For both of those cases, check it does not change the DataArray
180
- // Not supposed to call setData with typedArray = null
182
+ // Fill the DataArray before so that we are sure the size and the numberOfComponents is updated
183
+ dataArray . setData ( [ 1 , 2 , 3 ] , 3 ) ;
181
184
dataArray . setData ( null ) ;
182
185
t . deepEqual (
183
186
{
184
187
dataType : DefaultDataType ,
185
188
size : 0 ,
186
189
numberOfComponents : 1 ,
187
- values : macro . newTypedArray ( DefaultDataType ) ,
190
+ values : null ,
188
191
} ,
189
192
getDataArrayProperties ( dataArray ) ,
190
193
'Call setData with typedArray = null'
191
194
) ;
192
195
193
- // Not supposed to call setData without parameters
196
+ // Not supposed to call setData without parameters : check it does nothing on the DataArray
197
+ dataArray . setData ( [ 1 , 2 , 3 ] ) ;
194
198
dataArray . setData ( ) ;
195
199
t . deepEqual (
196
200
{
197
201
dataType : DefaultDataType ,
198
- size : 0 ,
202
+ size : 3 ,
199
203
numberOfComponents : 1 ,
200
- values : macro . newTypedArray ( DefaultDataType ) ,
204
+ values : macro . newTypedArrayFrom ( DefaultDataType , [ 1 , 2 , 3 ] ) ,
201
205
} ,
202
206
getDataArrayProperties ( dataArray ) ,
203
207
'Call setData with typedArray = undefined'
@@ -212,7 +216,7 @@ test('Test vtkDataArray setData', (t) => {
212
216
values : macro . newTypedArrayFrom ( 'Uint32Array' , [ 4 , 5 , 6 , 7 ] ) ,
213
217
} ,
214
218
getDataArrayProperties ( dataArray ) ,
215
- 'Change data of existing instance with another type'
219
+ 'Change values of existing instance with another type'
216
220
) ;
217
221
} ) ;
218
222
0 commit comments