@@ -189,8 +189,13 @@ describe('Long', function () {
189189 [ 'min signed binary input' , Long . MIN_VALUE . toString ( 2 ) , false , 2 ] ,
190190 [ 'min signed decimal input' , Long . MIN_VALUE . toString ( 10 ) , false , 10 ] ,
191191 [ 'min signed hex input' , Long . MIN_VALUE . toString ( 16 ) , false , 16 ] ,
192- [ 'signed zero' , '0' , false , 10 ] ,
193- [ 'unsigned zero' , '0' , true , 10 ]
192+ [ 'signed zeros' , '+000000' , false , 10 , '0' ] ,
193+ [ 'unsigned zero' , '0' , true , 10 ] ,
194+ [ 'explicit positive no leading zeros' , '+32' , true , 10 , '32' ] ,
195+ [ 'Infinity' , 'Infinity' , false , 21 , '0' ] ,
196+ [ '-Infinity' , '-Infinity' , false , 13 , '0' ] ,
197+ [ '+Infinity' , '+Infinity' , false , 13 , '0' ] ,
198+ [ 'NaN' , 'NaN' , false , 11 , '0' ]
194199 ] ;
195200
196201 const failureInputs : [ name : string , input : string , unsigned : boolean , radix : number ] [ ] = [
@@ -208,12 +213,17 @@ describe('Long', function () {
208213 [ 'under min signed binary input' , Long . MIN_VALUE . toString ( 2 ) + '1' , false , 2 ] ,
209214 [ 'under min signed decimal input' , Long . MIN_VALUE . toString ( 10 ) + '1' , false , 10 ] ,
210215 [ 'under min signed hex input' , Long . MIN_VALUE . toString ( 16 ) + '1' , false , 16 ] ,
211- [ 'string with whitespace' , ' 3503a ' , false , 11 ]
216+ [ 'string with whitespace' , ' 3503a ' , false , 11 ] ,
217+ [ 'negative zero unsigned' , '-0' , true , 9 ] ,
218+ [ 'negative zero signed' , '-0' , false , 13 ] ,
219+ [ 'radix 1' , '12' , false , 1 ] ,
220+ [ 'negative radix' , '12' , false , - 4 ] ,
221+ [ 'radix over 36' , '12' , false , 37 ]
212222 ] ;
213223
214224 for ( const [ testName , str , unsigned , radix , expectedStr ] of successInputs ) {
215225 context ( `when the input is ${ testName } ` , ( ) => {
216- it ( `should return a Long represenation of the input` , ( ) => {
226+ it ( `should return a Long representation of the input` , ( ) => {
217227 expect ( Long . fromStringStrict ( str , unsigned , radix ) . toString ( radix ) ) . to . equal (
218228 expectedStr ?? str . toLowerCase ( )
219229 ) ;
@@ -228,36 +238,4 @@ describe('Long', function () {
228238 } ) ;
229239 }
230240 } ) ;
231-
232- describe ( 'static validateStringCharacters()' , function ( ) {
233- const successInputs = [
234- [ 'radix does allows given alphabet letter' , 'eEe' , 15 ] ,
235- [ 'empty string' , '' , 2 ] ,
236- [ 'all possible hexadecimal characters' , '12efabc689873dADCDEF' , 16 ] ,
237- [ 'leading zeros' , '0000000004567e' , 16 ]
238- ] ;
239-
240- const failureInputs = [
241- [ 'multiple decimal points' , '..' , 30 ] ,
242- [ 'non a-z or numeric string' , '~~' , 36 ] ,
243- [ 'alphabet in radix < 10' , 'a' , 4 ] ,
244- [ 'radix does not allow all alphabet letters' , 'eee' , 14 ]
245- ] ;
246-
247- for ( const [ testName , str , radix ] of successInputs ) {
248- context ( `when the input is ${ testName } ` , ( ) => {
249- it ( `should return a input string` , ( ) => {
250- expect ( Long . validateStringCharacters ( str , radix ) ) . to . equal ( str ) ;
251- } ) ;
252- } ) ;
253- }
254-
255- for ( const [ testName , str , radix ] of failureInputs ) {
256- context ( `when the input is ${ testName } ` , ( ) => {
257- it ( `should return false` , ( ) => {
258- expect ( Long . validateStringCharacters ( str , radix ) ) . to . equal ( false ) ;
259- } ) ;
260- } ) ;
261- }
262- } ) ;
263241} ) ;
0 commit comments