@@ -121,35 +121,42 @@ describe('text encodings', () => {
121121
122122 describe ( 'Utf8ToUtf32 decoder' , ( ) => {
123123 describe ( 'full codepoint test' , ( ) => {
124-
125- it ( '0..65535 (1/2/3 byte sequences)' , ( ) => {
126- const decoder = new Utf8ToUtf32 ( ) ;
127- const target = new Uint32Array ( 5 ) ;
128- for ( let i = 0 ; i < 65536 ; ++ i ) {
129- // skip surrogate pairs and a BOM
130- if ( ( i >= 0xD800 && i <= 0xDFFF ) || i === 0xFEFF ) {
131- continue ;
124+ function formatRange ( min : number , max : number ) : string {
125+ return `${ min } ..${ max } (0x${ min . toString ( 16 ) . toUpperCase ( ) } ..0x${ max . toString ( 16 ) . toUpperCase ( ) } )` ;
126+ }
127+ for ( let min = 0 ; min < 65535 ; min += 10000 ) {
128+ const max = Math . min ( min + 10000 , 65536 ) ;
129+ it ( `${ formatRange ( min , max ) } (1/2/3 byte sequences)` , ( ) => {
130+ const decoder = new Utf8ToUtf32 ( ) ;
131+ const target = new Uint32Array ( 5 ) ;
132+ for ( let i = min ; i < max ; ++ i ) {
133+ // skip surrogate pairs and a BOM
134+ if ( ( i >= 0xD800 && i <= 0xDFFF ) || i === 0xFEFF ) {
135+ continue ;
136+ }
137+ const utf8Data = fromByteString ( encode ( String . fromCharCode ( i ) ) ) ;
138+ const length = decoder . decode ( utf8Data , target ) ;
139+ assert . equal ( length , 1 ) ;
140+ assert . equal ( toString ( target , length ) , String . fromCharCode ( i ) ) ;
141+ decoder . clear ( ) ;
132142 }
133- const utf8Data = fromByteString ( encode ( String . fromCharCode ( i ) ) ) ;
134- const length = decoder . decode ( utf8Data , target ) ;
135- assert . equal ( length , 1 ) ;
136- assert . equal ( toString ( target , length ) , String . fromCharCode ( i ) ) ;
137- decoder . clear ( ) ;
138- }
139- } ) ;
140-
141- it ( '65536..0x10FFFF (4 byte sequences)' , function ( ) : void {
142- this . timeout ( 20000 ) ;
143- const decoder = new Utf8ToUtf32 ( ) ;
144- const target = new Uint32Array ( 5 ) ;
145- for ( let i = 65536 ; i < 0x10FFFF ; ++ i ) {
146- const utf8Data = fromByteString ( encode ( stringFromCodePoint ( i ) ) ) ;
147- const length = decoder . decode ( utf8Data , target ) ;
148- assert . equal ( length , 1 ) ;
149- assert . equal ( target [ 0 ] , i ) ;
150- decoder . clear ( ) ;
151- }
152- } ) ;
143+ } ) ;
144+ }
145+ for ( let minRaw = 60000 ; minRaw < 0x10FFFF ; minRaw += 10000 ) {
146+ const min = Math . max ( minRaw , 65536 ) ;
147+ const max = Math . min ( minRaw + 10000 , 0x10FFFF ) ;
148+ it ( `${ formatRange ( min , max ) } (4 byte sequences)` , function ( ) : void {
149+ const decoder = new Utf8ToUtf32 ( ) ;
150+ const target = new Uint32Array ( 5 ) ;
151+ for ( let i = min ; i < max ; ++ i ) {
152+ const utf8Data = fromByteString ( encode ( stringFromCodePoint ( i ) ) ) ;
153+ const length = decoder . decode ( utf8Data , target ) ;
154+ assert . equal ( length , 1 ) ;
155+ assert . equal ( target [ 0 ] , i ) ;
156+ decoder . clear ( ) ;
157+ }
158+ } ) ;
159+ }
153160
154161 it ( '0xFEFF(BOM)' , ( ) => {
155162 const decoder = new Utf8ToUtf32 ( ) ;
0 commit comments