mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-21 15:26:15 -04:00
feat(tool): base converter
This commit is contained in:
parent
5cd9997a84
commit
034c686896
5 changed files with 118 additions and 1 deletions
|
@ -0,0 +1,17 @@
|
|||
import { expect, describe, it } from 'vitest';
|
||||
import { convertBase } from './integer-base-converter.model';
|
||||
|
||||
describe('integer-base-converter', () => {
|
||||
describe('convertBase', () => {
|
||||
describe('when the input and target bases are between 2 and 64', () => {
|
||||
it('should convert integer between different bases', () => {
|
||||
expect(convertBase({ value: '0', fromBase: 2, toBase: 11 })).toEqual('0');
|
||||
expect(convertBase({ value: '0', fromBase: 5, toBase: 2 })).toEqual('0');
|
||||
expect(convertBase({ value: '0', fromBase: 10, toBase: 16 })).toEqual('0');
|
||||
expect(convertBase({ value: '10100101', fromBase: 2, toBase: 16 })).toEqual('a5');
|
||||
expect(convertBase({ value: '192654', fromBase: 10, toBase: 8 })).toEqual('570216');
|
||||
expect(convertBase({ value: 'zz', fromBase: 64, toBase: 10 })).toEqual('2275');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue