Gibi units

closes #70
This commit is contained in:
sadellie 2023-08-03 16:43:50 +03:00
parent 08abe751f2
commit 9c1cd8e05b
5 changed files with 21 additions and 1 deletions

View File

@ -175,6 +175,8 @@
<string name="mebibit_short">Mib</string>
<string name="gigabit">Gigabit</string>
<string name="gigabit_short">Gb</string>
<string name="gibibit">Gibibit</string>
<string name="gibibit_short">Gib</string>
<string name="terabit">Terabit</string>
<string name="terabit_short">Tb</string>
<string name="petabit">Petabit</string>
@ -193,6 +195,8 @@
<string name="mebibyte_short">MiB</string>
<string name="gigabyte">Gigabyte</string>
<string name="gigabyte_short">GB</string>
<string name="gibibyte">Gibibyte</string>
<string name="gibibyte_short">GiB</string>
<string name="terabyte">Terabyte</string>
<string name="terabyte_short">TB</string>
<string name="petabyte">Petabyte</string>
@ -213,6 +217,8 @@
<string name="mebibit_per_second_short">Mib/s</string>
<string name="gigabit_per_second">Gigabit/second</string>
<string name="gigabit_per_second_short">Gb/s</string>
<string name="gibibit_per_second">Gibibit/second</string>
<string name="gibibit_per_second_short">Gib/s</string>
<string name="terabit_per_second">Terabit/second</string>
<string name="terabit_per_second_short">Tb/s</string>
<string name="petabit_per_second">Petabit/second</string>
@ -231,6 +237,8 @@
<string name="mebibyte_per_second_short">MiB/s</string>
<string name="gigabyte_per_second">Gigabyte/second</string>
<string name="gigabyte_per_second_short">GB/s</string>
<string name="gibibyte_per_second">Gibibyte/second</string>
<string name="gibibyte_per_second_short">GiB/s</string>
<string name="terabyte_per_second">Terabyte/second</string>
<string name="terabyte_per_second_short">TB/s</string>
<string name="petabyte_per_second">Petabyte/second</string>

View File

@ -117,6 +117,7 @@ object MyUnitIDS {
const val megabit = "megabit"
const val mebibit = "mebibit"
const val gigabit = "gigabit"
const val gibibit = "gibibit"
const val terabit = "terabit"
const val petabit = "petabit"
const val exabit = "exabit"
@ -126,6 +127,7 @@ object MyUnitIDS {
const val megabyte = "megabyte"
const val mebibyte = "mebibyte"
const val gigabyte = "gigabyte"
const val gibibyte = "gibibyte"
const val terabyte = "terabyte"
const val petabyte = "petabyte"
const val exabyte = "exabyte"
@ -218,6 +220,7 @@ object MyUnitIDS {
const val megabit_per_second = "megabit_per_second"
const val mebibit_per_second = "mebibit_per_second"
const val gigabit_per_second = "gigabit_per_second"
const val gibibit_per_second = "gibibit_per_second"
const val terabit_per_second = "terabit_per_second"
const val petabit_per_second = "petabit_per_second"
const val exabit_per_second = "exabit_per_second"
@ -227,6 +230,7 @@ object MyUnitIDS {
const val megabyte_per_second = "megabyte_per_second"
const val mebibyte_per_second = "mebibyte_per_second"
const val gigabyte_per_second = "gigabyte_per_second"
const val gibibyte_per_second = "gibibyte_per_second"
const val terabyte_per_second = "terabyte_per_second"
const val petabyte_per_second = "petabyte_per_second"
const val exabyte_per_second = "exabyte_per_second"

View File

@ -33,6 +33,7 @@ internal val dataCollection: List<AbstractUnit> by lazy {
DefaultUnit(MyUnitIDS.megabit, BigDecimal.valueOf(1_000_000), UnitGroup.DATA, R.string.megabit, R.string.megabit_short),
DefaultUnit(MyUnitIDS.mebibit, BigDecimal.valueOf(1_048_576), UnitGroup.DATA, R.string.mebibit, R.string.mebibit_short),
DefaultUnit(MyUnitIDS.gigabit, BigDecimal.valueOf(1_000_000_000), UnitGroup.DATA, R.string.gigabit, R.string.gigabit_short),
DefaultUnit(MyUnitIDS.gibibit, BigDecimal.valueOf(1_073_741_824), UnitGroup.DATA, R.string.gibibit, R.string.gibibit_short),
DefaultUnit(MyUnitIDS.terabit, BigDecimal.valueOf(1_000_000_000_000), UnitGroup.DATA, R.string.terabit, R.string.terabit_short),
DefaultUnit(MyUnitIDS.petabit, BigDecimal.valueOf(1_000_000_000_000_000), UnitGroup.DATA, R.string.petabit, R.string.petabit_short),
DefaultUnit(MyUnitIDS.exabit, BigDecimal.valueOf(1_000_000_000_000_000_000), UnitGroup.DATA, R.string.exabit, R.string.exabit_short),
@ -42,6 +43,7 @@ internal val dataCollection: List<AbstractUnit> by lazy {
DefaultUnit(MyUnitIDS.megabyte, BigDecimal.valueOf(8_000_000), UnitGroup.DATA, R.string.megabyte, R.string.megabyte_short),
DefaultUnit(MyUnitIDS.mebibyte, BigDecimal.valueOf(8_388_608), UnitGroup.DATA, R.string.mebibyte, R.string.mebibyte_short),
DefaultUnit(MyUnitIDS.gigabyte, BigDecimal.valueOf(8_000_000_000), UnitGroup.DATA, R.string.gigabyte, R.string.gigabyte_short),
DefaultUnit(MyUnitIDS.gibibyte, BigDecimal.valueOf(8_589_934_592), UnitGroup.DATA, R.string.gibibyte, R.string.gibibyte_short),
DefaultUnit(MyUnitIDS.terabyte, BigDecimal.valueOf(8_000_000_000_000), UnitGroup.DATA, R.string.terabyte, R.string.terabyte_short),
DefaultUnit(MyUnitIDS.petabyte, BigDecimal.valueOf(8_000_000_000_000_000), UnitGroup.DATA, R.string.petabyte, R.string.petabyte_short),
DefaultUnit(MyUnitIDS.exabyte, BigDecimal.valueOf(8_000_000_000_000_000_000), UnitGroup.DATA, R.string.exabyte, R.string.exabyte_short),

View File

@ -33,6 +33,7 @@ internal val dataTransferCollection: List<AbstractUnit> by lazy {
DefaultUnit(MyUnitIDS.megabit_per_second, BigDecimal.valueOf(1_000_000), UnitGroup.DATA_TRANSFER, R.string.megabit_per_second, R.string.megabit_per_second_short),
DefaultUnit(MyUnitIDS.mebibit_per_second, BigDecimal.valueOf(1_048_576), UnitGroup.DATA_TRANSFER, R.string.mebibit_per_second, R.string.mebibit_per_second_short),
DefaultUnit(MyUnitIDS.gigabit_per_second, BigDecimal.valueOf(1_000_000_000), UnitGroup.DATA_TRANSFER, R.string.gigabit_per_second, R.string.gigabit_per_second_short),
DefaultUnit(MyUnitIDS.gibibit_per_second, BigDecimal.valueOf(1_073_741_824), UnitGroup.DATA_TRANSFER, R.string.gibibit_per_second, R.string.gibibit_per_second_short),
DefaultUnit(MyUnitIDS.terabit_per_second, BigDecimal.valueOf(1_000_000_000_000), UnitGroup.DATA_TRANSFER, R.string.terabit_per_second, R.string.terabit_per_second_short),
DefaultUnit(MyUnitIDS.petabit_per_second, BigDecimal.valueOf(1_000_000_000_000_000), UnitGroup.DATA_TRANSFER, R.string.petabit_per_second, R.string.petabit_per_second_short),
DefaultUnit(MyUnitIDS.exabit_per_second, BigDecimal.valueOf(1_000_000_000_000_000_000), UnitGroup.DATA_TRANSFER, R.string.exabit_per_second, R.string.exabit_per_second_short),
@ -42,6 +43,7 @@ internal val dataTransferCollection: List<AbstractUnit> by lazy {
DefaultUnit(MyUnitIDS.megabyte_per_second, BigDecimal.valueOf(8_000_000), UnitGroup.DATA_TRANSFER, R.string.megabyte_per_second, R.string.megabyte_per_second_short),
DefaultUnit(MyUnitIDS.mebibyte_per_second, BigDecimal.valueOf(8_388_608), UnitGroup.DATA_TRANSFER, R.string.mebibyte_per_second, R.string.mebibyte_per_second_short),
DefaultUnit(MyUnitIDS.gigabyte_per_second, BigDecimal.valueOf(8_000_000_000), UnitGroup.DATA_TRANSFER, R.string.gigabyte_per_second, R.string.gigabyte_per_second_short),
DefaultUnit(MyUnitIDS.gibibyte_per_second, BigDecimal.valueOf(8_589_934_592), UnitGroup.DATA_TRANSFER, R.string.gibibyte_per_second, R.string.gibibyte_per_second_short),
DefaultUnit(MyUnitIDS.terabyte_per_second, BigDecimal.valueOf(8_000_000_000_000), UnitGroup.DATA_TRANSFER, R.string.terabyte_per_second, R.string.terabyte_per_second_short),
DefaultUnit(MyUnitIDS.petabyte_per_second, BigDecimal.valueOf(8_000_000_000_000_000), UnitGroup.DATA_TRANSFER, R.string.petabyte_per_second, R.string.petabyte_per_second_short),
DefaultUnit(MyUnitIDS.exabyte_per_second, BigDecimal.valueOf(8_000_000_000_000_000_000), UnitGroup.DATA_TRANSFER, R.string.exabyte_per_second, R.string.exabyte_per_second_short),

View File

@ -93,6 +93,7 @@ class AllUnitsTest {
megabit_per_second.checkWith(kilobit_per_second, "2048", "2048000")
mebibit_per_second.checkWith(kilobit_per_second, "2048", "2147483.648")
gigabit_per_second.checkWith(kilobit_per_second, "2048", "2048000000")
gibibit_per_second.checkWith(mebibit_per_second, "24", "24576")
terabit_per_second.checkWith(gigabyte_per_second, "2048", "256000")
petabit_per_second.checkWith(gigabyte_per_second, "2048", "256000000")
exabit_per_second.checkWith(petabit_per_second, "2048", "2048000")
@ -102,6 +103,7 @@ class AllUnitsTest {
megabyte_per_second.checkWith(kilobyte_per_second, "2048", "2048000")
mebibyte_per_second.checkWith(bit_per_second, "2048", "17179869184")
gigabyte_per_second.checkWith(kilobyte_per_second, "2048", "2048000000")
gibibyte_per_second.checkWith(mebibit_per_second, "24", "196608")
terabyte_per_second.checkWith(gigabyte_per_second, "2048", "2048000")
petabyte_per_second.checkWith(terabyte_per_second, "2048", "2048000")
exabyte_per_second.checkWith(petabyte_per_second, "2048", "2048000")
@ -125,13 +127,14 @@ class AllUnitsTest {
}
@Test
fun testFileSize() = testWithUnits {
fun testData() = testWithUnits {
bit.checkWith(kilobit, "2048", "2.048")
kibibit.checkWith(bit, "2048", "2097152")
kilobit.checkWith(bit, "2048", "2048000")
megabit.checkWith(kilobit, "2048", "2048000")
mebibit.checkWith(kilobit, "2048", "2147483.648")
gigabit.checkWith(kilobit, "2048", "2048000000")
gibibit.checkWith(mebibit, "24", "24576")
terabit.checkWith(gigabyte, "2048", "256000")
petabit.checkWith(gigabyte, "2048", "256000000")
exabit.checkWith(petabit, "2048", "2048000")
@ -141,6 +144,7 @@ class AllUnitsTest {
megabyte.checkWith(kilobyte, "2048", "2048000")
mebibyte.checkWith(bit, "2048", "17179869184")
gigabyte.checkWith(kilobyte, "2048", "2048000000")
gibibyte.checkWith(mebibit, "24", "196608")
terabyte.checkWith(gigabyte, "2048", "2048000")
petabyte.checkWith(terabyte, "2048", "2048000")
exabyte.checkWith(petabyte, "2048", "2048000")