|
@@ -6,7 +6,7 @@ describe('NumberUtils', () => {
|
|
describe('toHex', () => {
|
|
describe('toHex', () => {
|
|
describe('Variant #1: number `0`', () => {
|
|
describe('Variant #1: number `0`', () => {
|
|
const number: number = 0;
|
|
const number: number = 0;
|
|
- const expectedHexString = '0';
|
|
|
|
|
|
+ const expectedHexString = '0x0';
|
|
|
|
|
|
let hexString: string;
|
|
let hexString: string;
|
|
|
|
|
|
@@ -21,7 +21,7 @@ describe('NumberUtils', () => {
|
|
|
|
|
|
describe('Variant #2: number `10`', () => {
|
|
describe('Variant #2: number `10`', () => {
|
|
const number: number = 10;
|
|
const number: number = 10;
|
|
- const expectedHexString = 'a';
|
|
|
|
|
|
+ const expectedHexString = '0xa';
|
|
|
|
|
|
let hexString: string;
|
|
let hexString: string;
|
|
|
|
|
|
@@ -36,7 +36,7 @@ describe('NumberUtils', () => {
|
|
|
|
|
|
describe('Variant #3: number `17`', () => {
|
|
describe('Variant #3: number `17`', () => {
|
|
const number: number = 17;
|
|
const number: number = 17;
|
|
- const expectedHexString = '11';
|
|
|
|
|
|
+ const expectedHexString = '0x11';
|
|
|
|
|
|
let hexString: string;
|
|
let hexString: string;
|
|
|
|
|
|
@@ -51,7 +51,7 @@ describe('NumberUtils', () => {
|
|
|
|
|
|
describe('Variant #4: number `536870912`', () => {
|
|
describe('Variant #4: number `536870912`', () => {
|
|
const number: number = 536870912;
|
|
const number: number = 536870912;
|
|
- const expectedHexString = '20000000';
|
|
|
|
|
|
+ const expectedHexString = '0x20000000';
|
|
|
|
|
|
let hexString: string;
|
|
let hexString: string;
|
|
|
|
|
|
@@ -63,6 +63,22 @@ describe('NumberUtils', () => {
|
|
assert.equal(hexString, expectedHexString);
|
|
assert.equal(hexString, expectedHexString);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ describe('Variant #5: bigint number `10n`', () => {
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ const number: bigint = 10n;
|
|
|
|
+ const expectedHexString = '0xan';
|
|
|
|
+
|
|
|
|
+ let hexString: string;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ hexString = NumberUtils.toHex(number);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should create a string with hexadecimal value from a given bigint number', () => {
|
|
|
|
+ assert.equal(hexString, expectedHexString);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|
|
|
|
|
|
describe('isCeil', () => {
|
|
describe('isCeil', () => {
|
|
@@ -95,5 +111,21 @@ describe('NumberUtils', () => {
|
|
assert.equal(result, expectedResult);
|
|
assert.equal(result, expectedResult);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ describe('bigint number', () => {
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ const number: bigint = 10n;
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NumberUtils.isCeil(number);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should return true', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|
|
});
|
|
});
|