|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import { describe, it, expect } from 'vitest';
-
- import { exponentialToNumberString, numberToExponential } from '../src/exponent';
-
- describe('numberToExponential', () => {
- it('converts 0 to 0e+0', () => {
- expect(numberToExponential(0)).toBe('0e+0');
- });
-
- it('converts "0" to 0e+0', () => {
- expect(numberToExponential('0')).toBe('0e+0');
- });
-
- it('converts "00000000000000000" to 0e+0', () => {
- expect(numberToExponential('00000000000000000')).toBe('0e+0');
- });
-
- it('converts 1 to 1e+0', () => {
- expect(numberToExponential(1)).toBe('1e+0');
- });
-
- it('converts "0.1" to 1e-1', () => {
- expect(numberToExponential('0.1')).toBe('1e-1');
- });
-
- it('converts "0.10" to 1e-1', () => {
- expect(numberToExponential('0.10')).toBe('1e-1');
- });
-
- it('converts "1" to 1e+0', () => {
- expect(numberToExponential('1')).toBe('1e+0');
- });
-
- it('converts "10" to 1e+1', () => {
- expect(numberToExponential('10')).toBe('1e+1');
- });
-
- it('converts "100" to 1e+2', () => {
- expect(numberToExponential('100')).toBe('1e+2');
- });
-
- it('converts "0100" to 1e+2', () => {
- expect(numberToExponential('0100')).toBe('1e+2');
- });
-
- it('converts "1234567890" to 1.23456789e+9', () => {
- expect(numberToExponential('1234567890')).toBe('1.23456789e+9');
- });
-
- it('converts "1234567890.1234567890" to 1.234567890123456789e+9', () => {
- expect(numberToExponential('1234567890.1234567890')).toBe('1.234567890123456789e+9');
- });
-
- it('converts "1e+100" to 1e+100', () => {
- expect(numberToExponential('1e+100')).toBe('1e+100');
- });
- });
-
- describe.only('exponentialToNumberString', () => {
- it('converts 1e+0 to 1', () => {
- expect(exponentialToNumberString('1e+0')).toBe('1');
- });
-
- it('converts 1e+1 to 10', () => {
- expect(exponentialToNumberString('1e+1')).toBe('10');
- });
-
- it('converts 1.23e+1 to 12.3', () => {
- expect(exponentialToNumberString('1.23e+1')).toBe('12.3');
- });
- });
|