mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 17:23:00 +02:00
TERMINAL: Add RAM usage and detailed file size to ls -l output (#2135)
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
FormatsNeedToChange,
|
||||
formatNumber,
|
||||
formatRam,
|
||||
formatBytes,
|
||||
} from "../../../src/ui/formatNumber";
|
||||
|
||||
describe("Suffix rounding test", () => {
|
||||
@@ -187,6 +188,7 @@ describe("Ram formatting", () => {
|
||||
Settings.hideTrailingDecimalZeros = false;
|
||||
FormatsNeedToChange.emit();
|
||||
// Base unit for ram is GB.
|
||||
expect(formatRam(0)).toEqual("0.00GB");
|
||||
expect(formatRam(1)).toEqual("1.00GB");
|
||||
expect(formatRam(1e3)).toEqual("1.00TB");
|
||||
expect(formatRam(1024)).toEqual("1.02TB");
|
||||
@@ -194,6 +196,9 @@ describe("Ram formatting", () => {
|
||||
expect(formatRam(1048576)).toEqual("1.05PB");
|
||||
expect(formatRam(1e9)).toEqual("1.00EB");
|
||||
expect(formatRam(1073741824)).toEqual("1.07EB");
|
||||
expect(formatRam(NaN)).toEqual("NaNGB");
|
||||
expect(formatRam(Infinity)).toEqual("∞EB");
|
||||
expect(formatRam(-Infinity)).toEqual("-∞EB");
|
||||
});
|
||||
test("With GiB mode", () => {
|
||||
// Initial settings
|
||||
@@ -201,6 +206,7 @@ describe("Ram formatting", () => {
|
||||
Settings.hideTrailingDecimalZeros = false;
|
||||
FormatsNeedToChange.emit();
|
||||
// Base unit for ram is now GiB.
|
||||
expect(formatRam(0)).toEqual("0.00GiB");
|
||||
expect(formatRam(1)).toEqual("1.00GiB");
|
||||
expect(formatRam(1e3)).toEqual("1,000.00GiB");
|
||||
expect(formatRam(1024)).toEqual("1.00TiB");
|
||||
@@ -208,5 +214,46 @@ describe("Ram formatting", () => {
|
||||
expect(formatRam(1048576)).toEqual("1.00PiB");
|
||||
expect(formatRam(1e9)).toEqual("953.67PiB");
|
||||
expect(formatRam(1073741824)).toEqual("1.00EiB");
|
||||
expect(formatRam(NaN)).toEqual("NaNGiB");
|
||||
expect(formatRam(Infinity)).toEqual("∞EiB");
|
||||
expect(formatRam(-Infinity)).toEqual("-∞EiB");
|
||||
});
|
||||
});
|
||||
describe("Filesize formatting", () => {
|
||||
test("With default GB mode", () => {
|
||||
// Initial settings
|
||||
Settings.UseIEC60027_2 = false;
|
||||
Settings.hideTrailingDecimalZeros = false;
|
||||
FormatsNeedToChange.emit();
|
||||
// Base unit for ram is GB.
|
||||
expect(formatBytes(0)).toEqual("0.0B");
|
||||
expect(formatBytes(1)).toEqual("1.0B");
|
||||
expect(formatBytes(1e3)).toEqual("1.0KB");
|
||||
expect(formatBytes(1024)).toEqual("1.0KB");
|
||||
expect(formatBytes(1e6)).toEqual("1.0MB");
|
||||
expect(formatBytes(1048576)).toEqual("1.0MB");
|
||||
expect(formatBytes(1e9)).toEqual("1.0GB");
|
||||
expect(formatBytes(1073741824)).toEqual("1.1GB");
|
||||
expect(formatBytes(NaN)).toEqual("NaNB");
|
||||
expect(formatBytes(Infinity)).toEqual("∞EB");
|
||||
expect(formatBytes(-Infinity)).toEqual("-∞EB");
|
||||
});
|
||||
test("With GiB mode", () => {
|
||||
// Initial settings
|
||||
Settings.UseIEC60027_2 = true;
|
||||
Settings.hideTrailingDecimalZeros = false;
|
||||
FormatsNeedToChange.emit();
|
||||
// Base unit for ram is now GiB.
|
||||
expect(formatBytes(0)).toEqual("0.0B");
|
||||
expect(formatBytes(1)).toEqual("1.0B");
|
||||
expect(formatBytes(1e3)).toEqual("1,000.0B");
|
||||
expect(formatBytes(1024)).toEqual("1.0KiB");
|
||||
expect(formatBytes(1e6)).toEqual("976.6KiB");
|
||||
expect(formatBytes(1048576)).toEqual("1.0MiB");
|
||||
expect(formatBytes(1e9)).toEqual("953.7MiB");
|
||||
expect(formatBytes(1073741824)).toEqual("1.0GiB");
|
||||
expect(formatBytes(NaN)).toEqual("NaNB");
|
||||
expect(formatBytes(Infinity)).toEqual("∞EiB");
|
||||
expect(formatBytes(-Infinity)).toEqual("-∞EiB");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user