@@ -105,6 +105,46 @@ describe('BSON BigInt support', function () {
105105
106106 it ( description , test ) ;
107107 }
108+
109+ it ( 'correctly deserializes min 64 bit int (-2n**63n)' , function ( ) {
110+ expect (
111+ BSON . deserialize ( Buffer . from ( '10000000126100000000000000008000' , 'hex' ) , {
112+ useBigInt64 : true
113+ } )
114+ ) . to . deep . equal ( { a : - ( 2n ** 63n ) } ) ;
115+ } ) ;
116+
117+ it ( 'correctly deserializes -1n' , function ( ) {
118+ expect (
119+ BSON . deserialize ( Buffer . from ( '10000000126100FFFFFFFFFFFFFFFF00' , 'hex' ) , {
120+ useBigInt64 : true
121+ } )
122+ ) . to . deep . equal ( { a : - 1n } ) ;
123+ } ) ;
124+
125+ it ( 'correctly deserializes 0n' , function ( ) {
126+ expect (
127+ BSON . deserialize ( Buffer . from ( '10000000126100000000000000000000' , 'hex' ) , {
128+ useBigInt64 : true
129+ } )
130+ ) . to . deep . equal ( { a : 0n } ) ;
131+ } ) ;
132+
133+ it ( 'correctly deserializes 1n' , function ( ) {
134+ expect (
135+ BSON . deserialize ( Buffer . from ( '10000000126100010000000000000000' , 'hex' ) , {
136+ useBigInt64 : true
137+ } )
138+ ) . to . deep . equal ( { a : 1n } ) ;
139+ } ) ;
140+
141+ it ( 'correctly deserializes max 64 bit int (2n**63n -1n)' , function ( ) {
142+ expect (
143+ BSON . deserialize ( Buffer . from ( '10000000126100FFFFFFFFFFFFFF7F00' , 'hex' ) , {
144+ useBigInt64 : true
145+ } )
146+ ) . to . deep . equal ( { a : 2n ** 63n - 1n } ) ;
147+ } ) ;
108148 } ) ;
109149
110150 describe ( 'BSON.serialize()' , function ( ) {
0 commit comments