mirror of
https://github.com/tailix/libkernaux.git
synced 2025-03-17 17:14:00 -04:00
Main: fix units
This commit is contained in:
parent
2026526ef3
commit
72582b63a9
3 changed files with 7 additions and 13 deletions
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum KernAux_Unit {
|
||||
KERNAUX_UNIT_BIT,
|
||||
|
@ -25,12 +26,12 @@ enum KernAux_UnitPrefixBin {
|
|||
KERNAUX_UNITPFX_GIBI,
|
||||
};
|
||||
|
||||
bool kernaux_units_human_raw(size_t value, enum KernAux_Unit unit,
|
||||
bool kernaux_units_human_raw(uint64_t value, enum KernAux_Unit unit,
|
||||
char *buffer, size_t buffer_size);
|
||||
bool kernaux_units_human_dec(size_t value, enum KernAux_Unit unit,
|
||||
bool kernaux_units_human_dec(uint64_t value, enum KernAux_Unit unit,
|
||||
enum KernAux_UnitPrefixDec prefix,
|
||||
char *buffer, size_t buffer_size);
|
||||
bool kernaux_units_human_bin(size_t value, enum KernAux_Unit unit,
|
||||
bool kernaux_units_human_bin(uint64_t value, enum KernAux_Unit unit,
|
||||
enum KernAux_UnitPrefixBin prefix,
|
||||
char *buffer, size_t buffer_size);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define TMP_BUFFER_SIZE (64)
|
||||
|
||||
bool kernaux_units_human_raw(
|
||||
const size_t value,
|
||||
const uint64_t value,
|
||||
const enum KernAux_Unit unit,
|
||||
char *const buffer,
|
||||
const size_t buffer_size
|
||||
|
@ -45,7 +45,7 @@ bool kernaux_units_human_raw(
|
|||
}
|
||||
|
||||
bool kernaux_units_human_dec(
|
||||
const size_t value,
|
||||
const uint64_t value,
|
||||
const enum KernAux_Unit unit,
|
||||
const enum KernAux_UnitPrefixDec prefix,
|
||||
char *const buffer,
|
||||
|
@ -91,7 +91,7 @@ bool kernaux_units_human_dec(
|
|||
}
|
||||
|
||||
bool kernaux_units_human_bin(
|
||||
const size_t value,
|
||||
const uint64_t value,
|
||||
const enum KernAux_Unit unit,
|
||||
const enum KernAux_UnitPrefixBin prefix,
|
||||
char *const buffer,
|
||||
|
|
|
@ -42,7 +42,6 @@ int main()
|
|||
test_raw(UINT16_MAX, KERNAUX_UNIT_BYTE, "65535 Byte");
|
||||
test_raw(UINT32_MAX, KERNAUX_UNIT_BIT, "4294967295 bit");
|
||||
test_raw(UINT32_MAX, KERNAUX_UNIT_BYTE, "4294967295 Byte");
|
||||
// TODO: only on 64-bit machine
|
||||
test_raw(UINT64_MAX, KERNAUX_UNIT_BIT, "18446744073709551615 bit");
|
||||
test_raw(UINT64_MAX, KERNAUX_UNIT_BYTE, "18446744073709551615 Byte");
|
||||
|
||||
|
@ -58,7 +57,6 @@ int main()
|
|||
test_dec(UINT16_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_KILO, "65535 kB");
|
||||
test_dec(UINT32_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_KILO, "4294967295 kbit");
|
||||
test_dec(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_KILO, "4294967295 kB");
|
||||
// TODO: only on 64-bit machine
|
||||
test_dec(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_KILO, "18446744073709551615 kbit");
|
||||
test_dec(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_KILO, "18446744073709551615 kB");
|
||||
|
||||
|
@ -74,7 +72,6 @@ int main()
|
|||
test_dec(UINT16_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_MEGA, "65535 MB");
|
||||
test_dec(UINT32_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_MEGA, "4294967295 Mbit");
|
||||
test_dec(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_MEGA, "4294967295 MB");
|
||||
// TODO: only on 64-bit machine
|
||||
test_dec(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_MEGA, "18446744073709551615 Mbit");
|
||||
test_dec(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_MEGA, "18446744073709551615 MB");
|
||||
|
||||
|
@ -90,7 +87,6 @@ int main()
|
|||
test_dec(UINT16_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIGA, "65535 GB");
|
||||
test_dec(UINT32_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_GIGA, "4294967295 Gbit");
|
||||
test_dec(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIGA, "4294967295 GB");
|
||||
// TODO: only on 64-bit machine
|
||||
test_dec(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_GIGA, "18446744073709551615 Gbit");
|
||||
test_dec(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIGA, "18446744073709551615 GB");
|
||||
|
||||
|
@ -106,7 +102,6 @@ int main()
|
|||
test_bin(UINT16_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_KIBI, "65535 KiB");
|
||||
test_bin(UINT32_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_KIBI, "4294967295 Kibit");
|
||||
test_bin(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_KIBI, "4294967295 KiB");
|
||||
// TODO: only on 64-bit machine
|
||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_KIBI, "18446744073709551615 Kibit");
|
||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_KIBI, "18446744073709551615 KiB");
|
||||
|
||||
|
@ -122,7 +117,6 @@ int main()
|
|||
test_bin(UINT16_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_MEBI, "65535 MiB");
|
||||
test_bin(UINT32_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_MEBI, "4294967295 Mibit");
|
||||
test_bin(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_MEBI, "4294967295 MiB");
|
||||
// TODO: only on 64-bit machine
|
||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_MEBI, "18446744073709551615 Mibit");
|
||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_MEBI, "18446744073709551615 MiB");
|
||||
|
||||
|
@ -138,7 +132,6 @@ int main()
|
|||
test_bin(UINT16_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIBI, "65535 GiB");
|
||||
test_bin(UINT32_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_GIBI, "4294967295 Gibit");
|
||||
test_bin(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIBI, "4294967295 GiB");
|
||||
// TODO: only on 64-bit machine
|
||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_GIBI, "18446744073709551615 Gibit");
|
||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIBI, "18446744073709551615 GiB");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue