|
1 | 1 | /* eslint-disable no-new */ |
| 2 | +import { Uint256 } from '../../../src'; |
2 | 3 | import { |
3 | 4 | CairoUint256, |
4 | 5 | UINT_256_HIGH_MAX, |
@@ -100,6 +101,32 @@ describe('CairoUint256 class test', () => { |
100 | 101 | expect(case1).toEqual(case4); |
101 | 102 | }); |
102 | 103 |
|
| 104 | + test('constructor 2 should support Uint256 {low, high}', () => { |
| 105 | + const cases: Uint256[] = []; |
| 106 | + cases[cases.length] = new CairoUint256({ low: 0, high: 0 }); |
| 107 | + cases[cases.length] = new CairoUint256({ low: '0', high: '0' }); |
| 108 | + cases[cases.length] = new CairoUint256({ low: 0n, high: 0n }); |
| 109 | + cases[cases.length] = new CairoUint256({ low: '0x0', high: '0x0' }); |
| 110 | + |
| 111 | + const cases2: Uint256[] = []; |
| 112 | + cases2[cases2.length] = new CairoUint256({ low: 10000, high: 10000 }); |
| 113 | + cases2[cases2.length] = new CairoUint256({ low: '10000', high: '10000' }); |
| 114 | + cases2[cases2.length] = new CairoUint256({ low: 10000n, high: 10000n }); |
| 115 | + cases2[cases2.length] = new CairoUint256({ low: '0x2710', high: '0x2710' }); |
| 116 | + |
| 117 | + expect( |
| 118 | + cases.every((it) => { |
| 119 | + return it.low === 0n && it.high === 0n; |
| 120 | + }) |
| 121 | + ).toEqual(true); |
| 122 | + |
| 123 | + expect( |
| 124 | + cases2.every((it) => { |
| 125 | + return it.low === 10000n && it.high === 10000n; |
| 126 | + }) |
| 127 | + ).toEqual(true); |
| 128 | + }); |
| 129 | + |
103 | 130 | test('should convert UINT_256_MAX to Uint256 dec struct', () => { |
104 | 131 | const u256 = new CairoUint256(UINT_256_MAX); |
105 | 132 | const u256Hex = u256.toUint256DecimalString(); |
|
0 commit comments