Files
OmaPhoto/tests/ByteCountsTests.cpp
雷电芽衣andClaude c864304695
Release / deb (push) Canceled after 0s
Release / rpm (push) Canceled after 0s
Release / arch (push) Canceled after 0s
Release / publish (push) Canceled after 0s
OmaPhoto 1.0.0: the Linux port of Compositor
A layered image editor for Linux and Omarchy, ported from Compositor
(github.com/robbietilton/Compositor), whose Swift source is its
specification. It reads and writes Compositor's .comp projects.

Packages for Ubuntu, Fedora and Arch come from the release workflow;
scripts/install/ holds one install script per distribution family,
and flake.nix serves NixOS.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-26 00:44:52 -04:00

40 lines
1.6 KiB
C++

#include "UI/ByteCounts.h"
#include <QtTest>
// Foundation's byte counts: units, places and grouping.
class ByteCountsTests : public QObject {
Q_OBJECT
private slots:
void memoryCountsInBinaryUnits();
void filesCountInThousands();
};
void ByteCountsTests::memoryCountsInBinaryUnits()
{
QCOMPARE(ByteCounts::memory(4), QString("4 bytes"));
QCOMPARE(ByteCounts::memory(1023), QString("1,023 bytes"));
QCOMPARE(ByteCounts::memory(1024), QString("1 KB"));
QCOMPARE(ByteCounts::memory(10 * 1024), QString("10 KB"));
QCOMPARE(ByteCounts::memory(1000 * 1024), QString("1,000 KB"));
QCOMPARE(ByteCounts::memory(1024 * 1024), QString("1 MB"));
QCOMPARE(ByteCounts::memory(3 * 1024 * 1024 + 300 * 1024), QString("3.3 MB"));
QCOMPARE(ByteCounts::memory(qint64(30'000) * 30'000 * 4), QString("3.35 GB"));
QCOMPARE(ByteCounts::memory(qint64(2) * 1024 * 1024 * 1024 + 10 * 1024 * 1024), QString("2.01 GB"));
QCOMPARE(ByteCounts::memory(qint64(2) * 1024 * 1024 * 1024 + 100 * 1024 * 1024), QString("2.1 GB"));
}
void ByteCountsTests::filesCountInThousands()
{
QCOMPARE(ByteCounts::file(631), QString("631 bytes"));
QCOMPARE(ByteCounts::file(999), QString("999 bytes"));
QCOMPARE(ByteCounts::file(1000), QString("1 KB"));
QCOMPARE(ByteCounts::file(20'400), QString("20 KB"));
QCOMPARE(ByteCounts::file(999'999), QString("1,000 KB"));
QCOMPARE(ByteCounts::file(1'000'000), QString("1 MB"));
QCOMPARE(ByteCounts::file(2'345'678), QString("2.3 MB"));
QCOMPARE(ByteCounts::file(40'020'000), QString("40 MB"));
}
QTEST_APPLESS_MAIN(ByteCountsTests)
#include "ByteCountsTests.moc"