@@ -142,15 +142,33 @@ describe('readDicomElementImplicit', () => {
142
142
expect ( invoker ) . to . throw ( ) ;
143
143
} ) ;
144
144
145
- it ( 'bytes resembling an item tag are not treated like an SQ item when using a callback' , ( ) => {
145
+ it ( 'bytes resembling an item tag look like an implicit SQ item when using a callback that returns undefined ' , ( ) => {
146
146
// Arrange
147
147
// (7fe0,0010) 8
148
148
const bytes = [ 0xe0 , 0x7f , 0x10 , 0x00 , 0x08 , 0x00 , 0x00 , 0x00 ,
149
149
// Looks like an item tag, but isn't since it's within pixel data
150
150
0xfe , 0xff , 0x00 , 0xe0 , 0x0A , 0x00 , 0x00 , 0x00 ,
151
151
] ;
152
152
const callback = ( tag ) => {
153
- return undefined ; // nothing should be interpreted as an SQ
153
+ return undefined ;
154
+ } ;
155
+ const byteStream = new ByteStream ( littleEndianByteArrayParser , convertToByteArray ( bytes ) ) ;
156
+ const invoker = ( ) => readDicomElementImplicit ( byteStream , undefined , callback ) ;
157
+
158
+ // Act/Assert
159
+ // invalid value for parameter 'maxPosition'
160
+ expect ( invoker ) . to . throw ( ) ;
161
+ } ) ;
162
+
163
+ it ( 'bytes resembling an item tag are not treated like an SQ item when using a callback (callback overrides peeking)' , ( ) => {
164
+ // Arrange
165
+ // (7fe0,0010) 8
166
+ const bytes = [ 0xe0 , 0x7f , 0x10 , 0x00 , 0x08 , 0x00 , 0x00 , 0x00 ,
167
+ // Looks like an item tag, but isn't since it's within pixel data
168
+ 0xfe , 0xff , 0x00 , 0xe0 , 0x0A , 0x00 , 0x00 , 0x00 ,
169
+ ] ;
170
+ const callback = ( tag ) => {
171
+ return ( tag === 'x7fe00010' ) ? 'OW' : undefined ;
154
172
} ;
155
173
const byteStream = new ByteStream ( littleEndianByteArrayParser , convertToByteArray ( bytes ) ) ;
156
174
@@ -179,7 +197,26 @@ describe('readDicomElementImplicit', () => {
179
197
expect ( invoker ) . to . throw ( ) ;
180
198
} ) ;
181
199
182
- it ( 'bytes resembling an end-of-sequence tag are not treated like an SQ item when using a callback' , ( ) => {
200
+ it ( 'bytes resembling an end-of-sequence tag look like an implicit SQ item when using a callback that returns undefined' , ( ) => {
201
+ // Arrange
202
+ // (7fe0,0010) 11
203
+ const bytes = [ 0xe0 , 0x7f , 0x10 , 0x00 , 0x0B , 0x00 , 0x00 , 0x00 ,
204
+ // Looks like a sequence delimiter tag, but isn't since it's within pixel data
205
+ 0xfe , 0xff , 0xdd , 0xe0 , 0x0A , 0x00 , 0x00 , 0x00 ,
206
+ 0x12 , 0x43 , 0x98 ,
207
+ ] ;
208
+ const callback = ( tag ) => {
209
+ return undefined ;
210
+ } ;
211
+ const byteStream = new ByteStream ( littleEndianByteArrayParser , convertToByteArray ( bytes ) ) ;
212
+ const invoker = ( ) => readDicomElementImplicit ( byteStream , undefined , callback ) ;
213
+
214
+ // Act/Assert
215
+ // item tag (FFFE,E000) not found at offset 8
216
+ expect ( invoker ) . to . throw ( ) ;
217
+ } ) ;
218
+
219
+ it ( 'bytes resembling an end-of-sequence tag are not treated like an SQ item when using a callback (callback overrides peeking)' , ( ) => {
183
220
// Arrange
184
221
// (7fe0,0010) 11
185
222
const bytes = [ 0xe0 , 0x7f , 0x10 , 0x00 , 0x0B , 0x00 , 0x00 , 0x00 ,
@@ -188,7 +225,7 @@ describe('readDicomElementImplicit', () => {
188
225
0x12 , 0x43 , 0x98 ,
189
226
] ;
190
227
const callback = ( tag ) => {
191
- return undefined ; // nothing should be interpreted as an SQ
228
+ return ( tag === 'x7fe00010' ) ? 'OW' : undefined ;
192
229
} ;
193
230
const byteStream = new ByteStream ( littleEndianByteArrayParser , convertToByteArray ( bytes ) ) ;
194
231
0 commit comments