File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ UInt.prototype.parse_number = function (j) {
234
234
235
235
if ( "number" === typeof j &&
236
236
j === + j &&
237
- j > 0 ) {
237
+ j >= 0 ) {
238
238
// XXX Better, faster way to get BigInteger from JS int?
239
239
this . _value = new BigInteger ( "" + j ) ;
240
240
}
Original file line number Diff line number Diff line change
1
+ var assert = require ( 'assert' ) ;
2
+ var utils = require ( './testutils' ) ;
3
+ var UInt128 = utils . load_module ( 'uint128' ) . UInt128 ;
4
+ var config = require ( './testutils' ) . get_config ( ) ;
5
+
6
+ describe ( 'UInt' , function ( ) {
7
+ describe ( '128' , function ( ) {
8
+ describe ( '#parse_number' , function ( ) {
9
+ it ( 'should create 00000000000000000000000000000000 when called with 0' , function ( ) {
10
+ var val = UInt128 . from_number ( 0 ) ;
11
+ assert . strictEqual ( val . to_hex ( ) , '00000000000000000000000000000000' ) ;
12
+ } ) ;
13
+ it ( 'should create 00000000000000000000000000000001 when called with 1' , function ( ) {
14
+ var val = UInt128 . from_number ( 0 ) ;
15
+ assert . strictEqual ( val . to_hex ( ) , '00000000000000000000000000000000' ) ;
16
+ } ) ;
17
+ it ( 'should create 000000000000000000000000FFFFFFFF when called with 0xFFFFFFFF' , function ( ) {
18
+ var val = UInt128 . from_number ( 0xFFFFFFFF ) ;
19
+ assert . strictEqual ( val . to_hex ( ) , '000000000000000000000000FFFFFFFF' ) ;
20
+ } ) ;
21
+ } ) ;
22
+ } ) ;
23
+ } ) ;
24
+
25
+ // vim:sw=2:sts=2:ts=8:et
You can’t perform that action at this time.
0 commit comments