Merge branch 'master' into feature/auto-size-text

# Conflicts:
#	feature/calculator/src/main/java/com/sadellie/unitto/feature/calculator/CalculatorScreen.kt
#	feature/calculator/src/main/java/com/sadellie/unitto/feature/calculator/components/CalculatorKeyboard.kt
This commit is contained in:
Sad Ellie 2023-03-27 15:14:33 +03:00
commit 6cf49812b7
23 changed files with 953 additions and 418 deletions

View File

@ -1,3 +1,11 @@
<a href="https://github.com/sadellie/unitto/discussions/26">
<p align="middle">
<img src="./where-logo.png" width="99%" />
</p>
</a>
# Unitto calculator and unit converter
<p align="middle">
<img src="./fastlane/metadata/android/en-US/images/featureGraphic.png" width="99%" />
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/slide1.png" width="19%" />
@ -10,7 +18,7 @@
## 📲 Download
<a href="https://play.google.com/store/apps/details?id=com.sadellie.unitto"><img alt="Google Play" src="./content/googlePlay.png" width="32%"/></a>
<a href="https://f-droid.org/packages/com.sadellie.unitto"><img alt="F-Droid" src="./content/fDroid.png" width="32%"/></a>
<a href="https://appgallery.huawei.com/app/C105740875"><img alt="AppGallery" src="./content/appGallery.png" width="32%"/></a>
<a href="https://apps.rustore.ru/app/com.sadellie.unitto"><img alt="RuMarket" src="./content/ruStore.png" width="32%"/></a>
## 😎 Features
- Instant expression evaluation

View File

@ -32,7 +32,7 @@ android {
applicationId = "com.sadellie.unitto"
minSdk = 21
targetSdk = 33
versionCode = 17
versionCode = 18
versionName = "Illuminating emerald"
}

View File

@ -122,47 +122,47 @@
<string name="kelvin_short" translatable="false">K</string>
<!--Speed-->
<string name="millimeter_per_hour">Millimeter per hour</string>
<string name="millimeter_per_hour">Millimeter/hour</string>
<string name="millimeter_per_hour_short">mm/h</string>
<string name="millimeter_per_minute">Millimeter per minute</string>
<string name="millimeter_per_minute">Millimeter/minute</string>
<string name="millimeter_per_minute_short">mm/m</string>
<string name="millimeter_per_second">Millimeter per second</string>
<string name="millimeter_per_second">Millimeter/second</string>
<string name="millimeter_per_second_short">mm/s</string>
<string name="centimeter_per_hour">Centimeter per hour</string>
<string name="centimeter_per_hour">Centimeter/hour</string>
<string name="centimeter_per_hour_short">cm/h</string>
<string name="centimeter_per_minute">Centimeter per minute</string>
<string name="centimeter_per_minute">Centimeter/minute</string>
<string name="centimeter_per_minute_short">cm/m</string>
<string name="centimeter_per_second">Centimeter per second</string>
<string name="centimeter_per_second">Centimeter/second</string>
<string name="centimeter_per_second_short">cm/s</string>
<string name="meter_per_hour">Meter per hour</string>
<string name="meter_per_hour">Meter/hour</string>
<string name="meter_per_hour_short">m/h</string>
<string name="meter_per_minute">Meter per minute</string>
<string name="meter_per_minute">Meter/minute</string>
<string name="meter_per_minute_short">m/m</string>
<string name="meter_per_second">Meter per second</string>
<string name="meter_per_second">Meter/second</string>
<string name="meter_per_second_short">m/s</string>
<string name="kilometer_per_hour">Kilometer per hour</string>
<string name="kilometer_per_hour">Kilometer/hour</string>
<string name="kilometer_per_hour_short">km/h</string>
<string name="kilometer_per_minute">Kilometer per minute</string>
<string name="kilometer_per_minute">Kilometer/minute</string>
<string name="kilometer_per_minute_short">km/m</string>
<string name="kilometer_per_second">Kilometer per second</string>
<string name="kilometer_per_second">Kilometer/second</string>
<string name="kilometer_per_second_short">km/s</string>
<string name="foot_per_hour">Foot per hour</string>
<string name="foot_per_hour">Foot/hour</string>
<string name="foot_per_hour_short">ft/h</string>
<string name="foot_per_minute">Foot per minute</string>
<string name="foot_per_minute">Foot/minute</string>
<string name="foot_per_minute_short">ft/m</string>
<string name="foot_per_second">Foot per second</string>
<string name="foot_per_second">Foot/second</string>
<string name="foot_per_second_short">ft/s</string>
<string name="yard_per_hour">Yard per hour</string>
<string name="yard_per_hour">Yard/hour</string>
<string name="yard_per_hour_short">yd/h</string>
<string name="yard_per_minute">Yard per minute</string>
<string name="yard_per_minute">Yard/minute</string>
<string name="yard_per_minute_short">yd/m</string>
<string name="yard_per_second">Yard per second</string>
<string name="yard_per_second">Yard/second</string>
<string name="yard_per_second_short">yd/s</string>
<string name="mile_per_hour">Mile per hour</string>
<string name="mile_per_hour">Mile/hour</string>
<string name="mile_per_hour_short">mi/h</string>
<string name="mile_per_minute">Mile per minute</string>
<string name="mile_per_minute">Mile/minute</string>
<string name="mile_per_minute_short">mi/m</string>
<string name="mile_per_second">Mile per second</string>
<string name="mile_per_second">Mile/second</string>
<string name="mile_per_second_short">mi/s</string>
<string name="knot">Knot</string>
<string name="knot_short">kt</string>
@ -220,41 +220,41 @@
<string name="exabyte_short">EB</string>
<!--Data transfer-->
<string name="bit_per_second">Bit per second</string>
<string name="bit_per_second">Bit/second</string>
<string name="bit_per_second_short">b/s</string>
<string name="kibibit_per_second">Kibibit per second</string>
<string name="kibibit_per_second">Kibibit/second</string>
<string name="kibibit_per_second_short">Kib/s</string>
<string name="kilobit_per_second">Kilobit per second</string>
<string name="kilobit_per_second">Kilobit/second</string>
<string name="kilobit_per_second_short">Kb/s</string>
<string name="megabit_per_second">Megabit per second</string>
<string name="megabit_per_second">Megabit/second</string>
<string name="megabit_per_second_short">Mb/s</string>
<string name="mebibit_per_second">Mebibit per second</string>
<string name="mebibit_per_second">Mebibit/second</string>
<string name="mebibit_per_second_short">Mib/s</string>
<string name="gigabit_per_second">Gigabit per second</string>
<string name="gigabit_per_second">Gigabit/second</string>
<string name="gigabit_per_second_short">Gb/s</string>
<string name="terabit_per_second">Terabit per second</string>
<string name="terabit_per_second">Terabit/second</string>
<string name="terabit_per_second_short">Tb/s</string>
<string name="petabit_per_second">Petabit per second</string>
<string name="petabit_per_second">Petabit/second</string>
<string name="petabit_per_second_short">Pb/s</string>
<string name="exabit_per_second">Exabit per second</string>
<string name="exabit_per_second">Exabit/second</string>
<string name="exabit_per_second_short">Eb/s</string>
<string name="byte_per_second">Byte per second</string>
<string name="byte_per_second">Byte/second</string>
<string name="byte_per_second_short">B/s</string>
<string name="kibibyte_per_second">Kibibyte per second</string>
<string name="kibibyte_per_second">Kibibyte/second</string>
<string name="kibibyte_per_second_short">KiB/s</string>
<string name="kilobyte_per_second">Kilobyte per second</string>
<string name="kilobyte_per_second">Kilobyte/second</string>
<string name="kilobyte_per_second_short">KB/s</string>
<string name="megabyte_per_second">Megabyte per second</string>
<string name="megabyte_per_second">Megabyte/second</string>
<string name="megabyte_per_second_short">MB/s</string>
<string name="mebibyte_per_second">Mebibyte per second</string>
<string name="mebibyte_per_second">Mebibyte/second</string>
<string name="mebibyte_per_second_short">MiB/s</string>
<string name="gigabyte_per_second">Gigabyte per second</string>
<string name="gigabyte_per_second">Gigabyte/second</string>
<string name="gigabyte_per_second_short">GB/s</string>
<string name="terabyte_per_second">Terabyte per second</string>
<string name="terabyte_per_second">Terabyte/second</string>
<string name="terabyte_per_second_short">TB/s</string>
<string name="petabyte_per_second">Petabyte per second</string>
<string name="petabyte_per_second">Petabyte/second</string>
<string name="petabyte_per_second_short">PB/s</string>
<string name="exabyte_per_second">Exabyte per second</string>
<string name="exabyte_per_second">Exabyte/second</string>
<string name="exabyte_per_second_short">EB/s</string>
<!--Volume-->
@ -446,9 +446,9 @@
<string name="petapascal_short">PPa</string>
<string name="exapascal">Exapascal</string>
<string name="exapascal_short">EPa</string>
<string name="psi">Pound per square inch</string>
<string name="psi">Pound/square inch</string>
<string name="psi_short" translatable="false">psi</string>
<string name="ksi">Kilopound per square inch</string>
<string name="ksi">Kilopound/square inch</string>
<string name="ksi_short" translatable="false">ksi</string>
<string name="standard_atmosphere">Standard atmosphere</string>
<string name="standard_atmosphere_short">atm</string>
@ -460,29 +460,29 @@
<string name="millimeter_of_mercury_short">mm Hg</string>
<!--Acceleration-->
<string name="attometer_per_square_second">Attometer per square second</string>
<string name="attometer_per_square_second">Attometer/square second</string>
<string name="attometer_per_square_second_short">am/s^2</string>
<string name="femtometer_per_square_second">Femtometer per square second</string>
<string name="femtometer_per_square_second">Femtometer/square second</string>
<string name="femtometer_per_square_second_short">fm/s^2</string>
<string name="picometer_per_square_second">Picometer per square second</string>
<string name="picometer_per_square_second">Picometer/square second</string>
<string name="picometer_per_square_second_short">pm/s^2</string>
<string name="nanometer_per_square_second">Nanometer per square second</string>
<string name="nanometer_per_square_second">Nanometer/square second</string>
<string name="nanometer_per_square_second_short">nm/s^2</string>
<string name="micrometer_per_square_second">Micrometer per square second</string>
<string name="micrometer_per_square_second">Micrometer/square second</string>
<string name="micrometer_per_square_second_short">µm/s^2</string>
<string name="millimeter_per_square_second">Millimeter per square second</string>
<string name="millimeter_per_square_second">Millimeter/square second</string>
<string name="millimeter_per_square_second_short">mm/s^2</string>
<string name="centimeter_per_square_second">Centimeter per square second</string>
<string name="centimeter_per_square_second">Centimeter/square second</string>
<string name="centimeter_per_square_second_short">cm/s^2</string>
<string name="decimeter_per_square_second">Decimeter per square second</string>
<string name="decimeter_per_square_second">Decimeter/square second</string>
<string name="decimeter_per_square_second_short">dm/s^2</string>
<string name="meter_per_square_second">Meter per square second</string>
<string name="meter_per_square_second">Meter/square second</string>
<string name="meter_per_square_second_short">m/s^2</string>
<string name="kilometer_per_square_second">Kilometer per square second</string>
<string name="kilometer_per_square_second">Kilometer/square second</string>
<string name="kilometer_per_square_second_short">km/s^2</string>
<string name="dekameter_per_square_second">Dekameter per square second</string>
<string name="dekameter_per_square_second">Dekameter/square second</string>
<string name="dekameter_per_square_second_short">dam/s^2</string>
<string name="hectometer_per_square_second">Hectometer per square second</string>
<string name="hectometer_per_square_second">Hectometer/square second</string>
<string name="hectometer_per_square_second_short">hm/s^2</string>
<string name="gal">Gal</string>
<string name="gal_short">Gal</string>
@ -971,6 +971,152 @@
<string name="hexadecimal">Hexadecimal</string>
<string name="hexadecimal_short">base16</string>
<!--ELECTROSTATIC CAPACITANCE-->
<string name="attofarad">Attofarad</string>
<string name="attofarad_short">aF</string>
<string name="statfarad">Statfarad</string>
<string name="statfarad_short">stF</string>
<string name="farad">Farad</string>
<string name="farad_short">F</string>
<string name="exafarad">Exafarad</string>
<string name="exafarad_short">EF</string>
<string name="picofarad">Picofarad</string>
<string name="picofarad_short">pF</string>
<string name="nanofarad">Nanofarad</string>
<string name="nanofarad_short">nF</string>
<string name="microfarad">Microfarad</string>
<string name="microfarad_short">µF</string>
<string name="millifarad">Millifarad</string>
<string name="millifarad_short">mF</string>
<string name="kilofarad">Kilofarad</string>
<string name="kilofarad_short">kF</string>
<string name="megafarad">Megafarad</string>
<string name="megafarad_short">MF</string>
<string name="gigafarad">Gigafarad</string>
<string name="gigafarad_short">GF</string>
<string name="petafarad">Petafarad</string>
<string name="petafarad_short">PF</string>
<!--Prefixes-->
<string name="prefix_quetta">Quetta</string>
<string name="prefix_quetta_short">Q</string>
<string name="prefix_ronna">Ronna</string>
<string name="prefix_ronna_short">R</string>
<string name="prefix_yotta">Yotta</string>
<string name="prefix_yotta_short">Y</string>
<string name="prefix_zetta">Zetta</string>
<string name="prefix_zetta_short">Z</string>
<string name="prefix_exa">Exa</string>
<string name="prefix_exa_short">E</string>
<string name="prefix_peta">Peta</string>
<string name="prefix_peta_short">P</string>
<string name="prefix_tera">Tera</string>
<string name="prefix_tera_short">T</string>
<string name="prefix_giga">Giga</string>
<string name="prefix_giga_short">G</string>
<string name="prefix_mega">Mega</string>
<string name="prefix_mega_short">M</string>
<string name="prefix_kilo">Kilo</string>
<string name="prefix_kilo_short">k</string>
<string name="prefix_hecto">Hecto</string>
<string name="prefix_hecto_short">h</string>
<string name="prefix_deca">Deca</string>
<string name="prefix_deca_short">da</string>
<string name="prefix_base">Base</string>
<string name="prefix_base_short">Base</string>
<string name="prefix_deci">Deci</string>
<string name="prefix_deci_short">d</string>
<string name="prefix_centi">Centi</string>
<string name="prefix_centi_short">c</string>
<string name="prefix_milli">Milli</string>
<string name="prefix_milli_short">m</string>
<string name="prefix_micro">Micro</string>
<string name="prefix_micro_short">μ</string>
<string name="prefix_nano">Nano</string>
<string name="prefix_nano_short">n</string>
<string name="prefix_pico">Pico</string>
<string name="prefix_pico_short">p</string>
<string name="prefix_femto">Femto</string>
<string name="prefix_femto_short">f</string>
<string name="prefix_atto">Atto</string>
<string name="prefix_atto_short">a</string>
<string name="prefix_zepto">Zepto</string>
<string name="prefix_zepto_short">z</string>
<string name="prefix_yocto">Yocto</string>
<string name="prefix_yocto_short">y</string>
<string name="prefix_ronto">Ronto</string>
<string name="prefix_ronto_short">r</string>
<string name="prefix_quecto">Quecto</string>
<string name="prefix_quecto_short">q</string>
<!--Force-->
<string name="newton">Newton</string>
<string name="newton_short">N</string>
<string name="kilonewton">Kilonewton</string>
<string name="kilonewton_short">kN</string>
<string name="gram_force">Gram-force</string>
<string name="gram_force_short">gf</string>
<string name="kilogram_force">Kilogram-force</string>
<string name="kilogram_force_short">kgf</string>
<string name="ton_force">Ton-force</string>
<string name="ton_force_short">tf</string>
<string name="millinewton">Millinewton</string>
<string name="millinewton_short">mN</string>
<string name="attonewton">attonewton</string>
<string name="attonewton_short">aN</string>
<string name="dyne">dyne</string>
<string name="dyne_short">dyn</string>
<string name="joule_per_meter">Joule/meter</string>
<string name="joule_per_meter_short">J/m</string>
<string name="joule_per_centimeter">Joule/centimeter</string>
<string name="joule_per_centimeter_short">J/cm</string>
<string name="kilopound_force">Kilopound-force</string>
<string name="kilopound_force_short">kipf</string>
<string name="pound_force">Pound-force</string>
<string name="pound_force_short">lbf</string>
<string name="ounce_force">Ounce-force</string>
<string name="ounce_force_short">ozf</string>
<string name="pond">Pond</string>
<string name="pond_short">p</string>
<string name="kilopond">Kilopond</string>
<string name="kilopond_short">kp</string>
<!--Torque-->
<string name="newton_meter">Newton meter</string>
<string name="newton_meter_short">N*m</string>
<string name="newton_centimeter">Newton centimeter</string>
<string name="newton_centimeter_short">N*cm</string>
<string name="newton_millimeter">Newton millimeter</string>
<string name="newton_millimeter_short">N*mm</string>
<string name="kilonewton_meter">Kilonewton meter</string>
<string name="kilonewton_meter_short">kN*m</string>
<string name="dyne_meter">Dyne meter</string>
<string name="dyne_meter_short">dyn*m</string>
<string name="dyne_centimeter">Dyne centimeter</string>
<string name="dyne_centimeter_short">dyn*cm</string>
<string name="dyne_millimeter">Dyne millimeter</string>
<string name="dyne_millimeter_short">dyn*mm</string>
<string name="kilogram_force_meter">Kilogram-force meter</string>
<string name="kilogram_force_meter_short">kgf*m</string>
<string name="kilogram_force_centimeter">Kilogram-force centimeter</string>
<string name="kilogram_force_centimeter_short">kgf*cm</string>
<string name="kilogram_force_millimeter">Kilogram-force millimeter</string>
<string name="kilogram_force_millimeter_short">kgf*mm</string>
<string name="gram_force_meter">Gram-force meter</string>
<string name="gram_force_meter_short">gf*m</string>
<string name="gram_force_centimeter">Gram-force centimeter</string>
<string name="gram_force_centimeter_short">gf*cm</string>
<string name="gram_force_millimeter">Gram-force millimeter</string>
<string name="gram_force_millimeter_short">gf*mm</string>
<string name="ounce_force_foot">Ounce-force foot</string>
<string name="ounce_force_foot_short">ozf*ft</string>
<string name="ounce_force_inch">Ounce-force inch</string>
<string name="ounce_force_inch_short">ozf*in</string>
<string name="pound_force_foot">Pound-force foot</string>
<string name="pound_force_foot_short">lbf*ft</string>
<string name="pound_force_inch">Pound-force inch</string>
<string name="pound_force_inch_short">lbf*in</string>
<!--Groups-->
<string name="length">Length</string>
<string name="time">Time</string>
@ -989,6 +1135,10 @@
<string name="currency">Currency</string>
<string name="flux">Flux</string>
<string name="number_base">Base</string>
<string name="electrostatic_capacitance">Capacitance</string>
<string name="prefix">Prefix</string>
<string name="force">Force</string>
<string name="torque">Torque</string>
<!--Screen names-->
<string name="units_screen_from">Convert from</string>

View File

@ -48,4 +48,8 @@ enum class UnitGroup(
DATA_TRANSFER(res = R.string.data_transfer),
FLUX(res = R.string.flux),
NUMBER_BASE(res = R.string.number_base),
ELECTROSTATIC_CAPACITANCE(res = R.string.electrostatic_capacitance),
PREFIX(res = R.string.prefix),
FORCE(res = R.string.force),
TORQUE(res = R.string.torque),
}

View File

@ -20,6 +20,7 @@ package com.sadellie.unitto.data.units
import android.content.Context
import com.sadellie.unitto.core.base.MAX_PRECISION
import com.sadellie.unitto.data.database.UnitsEntity
import com.sadellie.unitto.data.model.AbstractUnit
import com.sadellie.unitto.data.model.UnitGroup
import com.sadellie.unitto.data.model.sortByLev
@ -29,18 +30,21 @@ import com.sadellie.unitto.data.units.collections.areaCollection
import com.sadellie.unitto.data.units.collections.currencyCollection
import com.sadellie.unitto.data.units.collections.dataCollection
import com.sadellie.unitto.data.units.collections.dataTransferCollection
import com.sadellie.unitto.data.units.collections.electrostaticCapacitance
import com.sadellie.unitto.data.units.collections.energyCollection
import com.sadellie.unitto.data.units.collections.fluxCollection
import com.sadellie.unitto.data.units.collections.forceCollection
import com.sadellie.unitto.data.units.collections.lengthCollection
import com.sadellie.unitto.data.units.collections.massCollection
import com.sadellie.unitto.data.units.collections.numberBaseCollection
import com.sadellie.unitto.data.units.collections.powerCollection
import com.sadellie.unitto.data.units.collections.prefixCollection
import com.sadellie.unitto.data.units.collections.pressureCollection
import com.sadellie.unitto.data.units.collections.speedCollection
import com.sadellie.unitto.data.units.collections.temperatureCollection
import com.sadellie.unitto.data.units.collections.timeCollection
import com.sadellie.unitto.data.units.collections.torqueCollection
import com.sadellie.unitto.data.units.collections.volumeCollection
import com.sadellie.unitto.data.database.UnitsEntity
import java.math.BigDecimal
import javax.inject.Inject
import javax.inject.Singleton
@ -79,6 +83,10 @@ class AllUnitsRepository @Inject constructor() {
UnitGroup.DATA_TRANSFER to dataTransferCollection,
UnitGroup.FLUX to fluxCollection,
UnitGroup.NUMBER_BASE to numberBaseCollection,
UnitGroup.ELECTROSTATIC_CAPACITANCE to electrostaticCapacitance,
UnitGroup.PREFIX to prefixCollection,
UnitGroup.FORCE to forceCollection,
UnitGroup.TORQUE to torqueCollection
)
}

View File

@ -516,4 +516,81 @@ object MyUnitIDS {
const val tetradecimal = "tetradecimal"
const val pentadecimal = "pentadecimal"
const val hexadecimal = "hexadecimal"
// ELECTROSTATIC CAPACITANCE
const val attofarad = "attofarad"
const val statfarad = "statfarad"
const val farad = "farad"
const val exafarad = "exafarad"
const val picofarad = "picofarad"
const val nanofarad = "nanofarad"
const val microfarad = "microfarad"
const val millifarad = "millifarad"
const val kilofarad = "kilofarad"
const val megafarad = "megafarad"
const val gigafarad = "gigafarad"
const val petafarad = "petafarad"
// PREFIX
const val prefix_quetta = "quetta"
const val prefix_ronna = "ronna"
const val prefix_yotta = "yotta"
const val prefix_zetta = "zetta"
const val prefix_exa = "exa"
const val prefix_peta = "peta"
const val prefix_tera = "tera"
const val prefix_giga = "giga"
const val prefix_mega = "mega"
const val prefix_kilo = "kilo"
const val prefix_hecto = "hecto"
const val prefix_deca = "deca"
const val prefix_base = "base"
const val prefix_deci = "deci"
const val prefix_centi = "centi"
const val prefix_milli = "milli"
const val prefix_micro = "micro"
const val prefix_nano = "nano"
const val prefix_pico = "pico"
const val prefix_femto = "femto"
const val prefix_atto = "atto"
const val prefix_zepto = "zepto"
const val prefix_yocto = "yocto"
const val prefix_ronto = "ronto"
const val prefix_quecto = "quecto"
// FORCE
const val newton = "newton"
const val kilonewton = "kilonewton"
const val gram_force = "gram_force"
const val kilogram_force = "kilogram_force"
const val ton_force = "ton_force"
const val millinewton = "millinewton"
const val attonewton = "attonewton"
const val dyne = "dyne"
const val joule_per_meter = "joule_per_meter"
const val joule_per_centimeter = "joule_per_centimeter"
const val kilopound_force = "kilopound_force"
const val pound_force = "pound_force"
const val ounce_force = "ounce_force"
const val pond = "pond"
const val kilopond = "kilopond"
// TORQUE
const val newton_meter = "newton_meter"
const val newton_centimeter = "newton_centimeter"
const val newton_millimeter = "newton_millimeter"
const val kilonewton_meter = "kilonewton_meter"
const val dyne_meter = "dyne_meter"
const val dyne_centimeter = "dyne_centimeter"
const val dyne_millimeter = "dyne_millimeter"
const val kilogram_force_meter = "kilogram_force_meter"
const val kilogram_force_centimeter = "kilogram_force_centimeter"
const val kilogram_force_millimeter = "kilogram_force_millimeter"
const val gram_force_meter = "gram_force_meter"
const val gram_force_centimeter = "gram_force_centimeter"
const val gram_force_millimeter = "gram_force_millimeter"
const val ounce_force_foot = "ounce_force_foot"
const val ounce_force_inch = "ounce_force_inch"
const val pound_force_foot = "pound_force_foot"
const val pound_force_inch = "pound_force_inch"
}

View File

@ -0,0 +1,43 @@
/*
* Unitto is a unit converter for Android
* Copyright (c) 2023 Elshan Agaev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sadellie.unitto.data.units.collections
import com.sadellie.unitto.data.model.AbstractUnit
import com.sadellie.unitto.data.model.MyUnit
import com.sadellie.unitto.data.model.UnitGroup
import com.sadellie.unitto.data.units.MyUnitIDS
import com.sadellie.unitto.data.units.R
import java.math.BigDecimal
internal val electrostaticCapacitance: List<AbstractUnit> by lazy {
listOf(
MyUnit(MyUnitIDS.attofarad, BigDecimal.valueOf(1), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.attofarad, R.string.attofarad_short),
MyUnit(MyUnitIDS.picofarad, BigDecimal.valueOf(1E+6), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.picofarad, R.string.picofarad_short),
MyUnit(MyUnitIDS.statfarad, BigDecimal.valueOf(1112650.0561), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.statfarad, R.string.statfarad_short),
MyUnit(MyUnitIDS.nanofarad, BigDecimal.valueOf(1E+9), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.nanofarad, R.string.nanofarad_short),
MyUnit(MyUnitIDS.microfarad, BigDecimal.valueOf(1E+12), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.microfarad, R.string.microfarad_short),
MyUnit(MyUnitIDS.millifarad, BigDecimal.valueOf(1E+15), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.millifarad, R.string.millifarad_short),
MyUnit(MyUnitIDS.farad, BigDecimal.valueOf(1E+18), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.farad, R.string.farad_short),
MyUnit(MyUnitIDS.kilofarad, BigDecimal.valueOf(1E+21), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.kilofarad, R.string.kilofarad_short),
MyUnit(MyUnitIDS.megafarad, BigDecimal.valueOf(1E+24), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.megafarad, R.string.megafarad_short),
MyUnit(MyUnitIDS.gigafarad, BigDecimal.valueOf(1E+27), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.gigafarad, R.string.gigafarad_short),
MyUnit(MyUnitIDS.petafarad, BigDecimal.valueOf(1E+33), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.petafarad, R.string.petafarad_short),
MyUnit(MyUnitIDS.exafarad, BigDecimal.valueOf(1E+36), UnitGroup.ELECTROSTATIC_CAPACITANCE, R.string.exafarad, R.string.exafarad_short),
)
}

View File

@ -0,0 +1,46 @@
/*
* Unitto is a unit converter for Android
* Copyright (c) 2023 Elshan Agaev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sadellie.unitto.data.units.collections
import com.sadellie.unitto.data.model.AbstractUnit
import com.sadellie.unitto.data.model.MyUnit
import com.sadellie.unitto.data.model.UnitGroup
import com.sadellie.unitto.data.units.MyUnitIDS
import com.sadellie.unitto.data.units.R
import java.math.BigDecimal
val forceCollection: List<AbstractUnit> by lazy {
listOf(
MyUnit(MyUnitIDS.attonewton, BigDecimal.valueOf(1), UnitGroup.FORCE, R.string.attonewton, R.string.attonewton_short),
MyUnit(MyUnitIDS.dyne, BigDecimal.valueOf(1E+13), UnitGroup.FORCE, R.string.dyne, R.string.dyne_short),
MyUnit(MyUnitIDS.millinewton, BigDecimal.valueOf(1E+15), UnitGroup.FORCE, R.string.millinewton, R.string.millinewton_short),
MyUnit(MyUnitIDS.joule_per_centimeter, BigDecimal.valueOf(1E+16), UnitGroup.FORCE, R.string.joule_per_centimeter, R.string.joule_per_centimeter_short),
MyUnit(MyUnitIDS.newton, BigDecimal.valueOf(1E+18), UnitGroup.FORCE, R.string.newton, R.string.newton_short),
MyUnit(MyUnitIDS.joule_per_meter, BigDecimal.valueOf(1E+18), UnitGroup.FORCE, R.string.joule_per_meter, R.string.joule_per_meter_short),
MyUnit(MyUnitIDS.kilonewton, BigDecimal.valueOf(1E+21), UnitGroup.FORCE, R.string.kilonewton, R.string.kilonewton_short),
MyUnit(MyUnitIDS.gram_force, BigDecimal.valueOf(9.80665E+15), UnitGroup.FORCE, R.string.gram_force, R.string.gram_force_short),
MyUnit(MyUnitIDS.kilogram_force, BigDecimal.valueOf(9.80665E+18), UnitGroup.FORCE, R.string.kilogram_force, R.string.kilogram_force_short),
MyUnit(MyUnitIDS.ton_force, BigDecimal.valueOf(9.80665E+21), UnitGroup.FORCE, R.string.ton_force, R.string.ton_force_short),
MyUnit(MyUnitIDS.ounce_force, BigDecimal.valueOf(2.78013850953423008E17), UnitGroup.FORCE, R.string.ounce_force, R.string.ounce_force_short),
MyUnit(MyUnitIDS.pound_force, BigDecimal.valueOf(4.4482216152550001E18), UnitGroup.FORCE, R.string.pound_force, R.string.pound_force_short),
MyUnit(MyUnitIDS.kilopound_force, BigDecimal.valueOf(4.448221615255E+21), UnitGroup.FORCE, R.string.kilopound_force, R.string.kilopound_force_short),
MyUnit(MyUnitIDS.pond, BigDecimal.valueOf(9.80665E+15), UnitGroup.FORCE, R.string.pond, R.string.pond_short),
MyUnit(MyUnitIDS.kilopond, BigDecimal.valueOf(9.80665E+18), UnitGroup.FORCE, R.string.kilopond, R.string.kilopond_short),
)
}

View File

@ -0,0 +1,56 @@
/*
* Unitto is a unit converter for Android
* Copyright (c) 2023 Elshan Agaev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sadellie.unitto.data.units.collections
import com.sadellie.unitto.data.model.AbstractUnit
import com.sadellie.unitto.data.model.MyUnit
import com.sadellie.unitto.data.model.UnitGroup
import com.sadellie.unitto.data.units.MyUnitIDS
import com.sadellie.unitto.data.units.R
import java.math.BigDecimal
val prefixCollection: List<AbstractUnit> by lazy {
listOf(
MyUnit(MyUnitIDS.prefix_quetta, BigDecimal.valueOf(1E+30), UnitGroup.PREFIX, R.string.prefix_quetta, R.string.prefix_quetta_short),
MyUnit(MyUnitIDS.prefix_ronna, BigDecimal.valueOf(1E+27), UnitGroup.PREFIX, R.string.prefix_ronna, R.string.prefix_ronna_short),
MyUnit(MyUnitIDS.prefix_yotta, BigDecimal.valueOf(1E+24), UnitGroup.PREFIX, R.string.prefix_yotta, R.string.prefix_yotta_short),
MyUnit(MyUnitIDS.prefix_zetta, BigDecimal.valueOf(1E+21), UnitGroup.PREFIX, R.string.prefix_zetta, R.string.prefix_zetta_short),
MyUnit(MyUnitIDS.prefix_exa, BigDecimal.valueOf(1E+18), UnitGroup.PREFIX, R.string.prefix_exa, R.string.prefix_exa_short),
MyUnit(MyUnitIDS.prefix_peta, BigDecimal.valueOf(1E+15), UnitGroup.PREFIX, R.string.prefix_peta, R.string.prefix_peta_short),
MyUnit(MyUnitIDS.prefix_tera, BigDecimal.valueOf(1E+12), UnitGroup.PREFIX, R.string.prefix_tera, R.string.prefix_tera_short),
MyUnit(MyUnitIDS.prefix_giga, BigDecimal.valueOf(1E+9), UnitGroup.PREFIX, R.string.prefix_giga, R.string.prefix_giga_short),
MyUnit(MyUnitIDS.prefix_mega, BigDecimal.valueOf(1E+6), UnitGroup.PREFIX, R.string.prefix_mega, R.string.prefix_mega_short),
MyUnit(MyUnitIDS.prefix_kilo, BigDecimal.valueOf(1E+3), UnitGroup.PREFIX, R.string.prefix_kilo, R.string.prefix_kilo_short),
MyUnit(MyUnitIDS.prefix_hecto, BigDecimal.valueOf(1E+2), UnitGroup.PREFIX, R.string.prefix_hecto, R.string.prefix_hecto_short),
MyUnit(MyUnitIDS.prefix_deca, BigDecimal.valueOf(1E+1), UnitGroup.PREFIX, R.string.prefix_deca, R.string.prefix_deca_short),
MyUnit(MyUnitIDS.prefix_base, BigDecimal.valueOf(1E+0), UnitGroup.PREFIX, R.string.prefix_base, R.string.prefix_base_short),
MyUnit(MyUnitIDS.prefix_deci, BigDecimal.valueOf(1E-1), UnitGroup.PREFIX, R.string.prefix_deci, R.string.prefix_deci_short),
MyUnit(MyUnitIDS.prefix_centi, BigDecimal.valueOf(1E-2), UnitGroup.PREFIX, R.string.prefix_centi, R.string.prefix_centi_short),
MyUnit(MyUnitIDS.prefix_milli, BigDecimal.valueOf(1E-3), UnitGroup.PREFIX, R.string.prefix_milli, R.string.prefix_milli_short),
MyUnit(MyUnitIDS.prefix_micro, BigDecimal.valueOf(1E-6), UnitGroup.PREFIX, R.string.prefix_micro, R.string.prefix_micro_short),
MyUnit(MyUnitIDS.prefix_nano, BigDecimal.valueOf(1E-9), UnitGroup.PREFIX, R.string.prefix_nano, R.string.prefix_nano_short),
MyUnit(MyUnitIDS.prefix_pico, BigDecimal.valueOf(1E-12), UnitGroup.PREFIX, R.string.prefix_pico, R.string.prefix_pico_short),
MyUnit(MyUnitIDS.prefix_femto, BigDecimal.valueOf(1E-15), UnitGroup.PREFIX, R.string.prefix_femto, R.string.prefix_femto_short),
MyUnit(MyUnitIDS.prefix_atto, BigDecimal.valueOf(1E-18), UnitGroup.PREFIX, R.string.prefix_atto, R.string.prefix_atto_short),
MyUnit(MyUnitIDS.prefix_zepto, BigDecimal.valueOf(1E-21), UnitGroup.PREFIX, R.string.prefix_zepto, R.string.prefix_zepto_short),
MyUnit(MyUnitIDS.prefix_yocto, BigDecimal.valueOf(1E-24), UnitGroup.PREFIX, R.string.prefix_yocto, R.string.prefix_yocto_short),
MyUnit(MyUnitIDS.prefix_ronto, BigDecimal.valueOf(1E-27), UnitGroup.PREFIX, R.string.prefix_ronto, R.string.prefix_ronto_short),
MyUnit(MyUnitIDS.prefix_quecto, BigDecimal.valueOf(1E-30), UnitGroup.PREFIX, R.string.prefix_quecto, R.string.prefix_quecto_short),
)
}

View File

@ -0,0 +1,48 @@
/*
* Unitto is a unit converter for Android
* Copyright (c) 2023 Elshan Agaev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sadellie.unitto.data.units.collections
import com.sadellie.unitto.data.model.AbstractUnit
import com.sadellie.unitto.data.model.MyUnit
import com.sadellie.unitto.data.model.UnitGroup
import com.sadellie.unitto.data.units.MyUnitIDS
import com.sadellie.unitto.data.units.R
import java.math.BigDecimal
val torqueCollection: List<AbstractUnit> by lazy {
listOf(
MyUnit(MyUnitIDS.dyne_millimeter, BigDecimal.valueOf(1), UnitGroup.TORQUE, R.string.dyne_millimeter, R.string.dyne_millimeter_short),
MyUnit(MyUnitIDS.dyne_centimeter, BigDecimal.valueOf(10), UnitGroup.TORQUE, R.string.dyne_centimeter, R.string.dyne_centimeter_short),
MyUnit(MyUnitIDS.dyne_meter, BigDecimal.valueOf(1000), UnitGroup.TORQUE, R.string.dyne_meter, R.string.dyne_meter_short),
MyUnit(MyUnitIDS.newton_millimeter, BigDecimal.valueOf(100000), UnitGroup.TORQUE, R.string.newton_millimeter, R.string.newton_millimeter_short),
MyUnit(MyUnitIDS.newton_centimeter, BigDecimal.valueOf(1000000), UnitGroup.TORQUE, R.string.newton_centimeter, R.string.newton_centimeter_short),
MyUnit(MyUnitIDS.newton_meter, BigDecimal.valueOf(100000000), UnitGroup.TORQUE, R.string.newton_meter, R.string.newton_meter_short),
MyUnit(MyUnitIDS.kilonewton_meter, BigDecimal.valueOf(100000000000), UnitGroup.TORQUE, R.string.kilonewton_meter, R.string.kilonewton_meter_short),
MyUnit(MyUnitIDS.gram_force_millimeter, BigDecimal.valueOf(980.665), UnitGroup.TORQUE, R.string.gram_force_millimeter, R.string.gram_force_millimeter_short),
MyUnit(MyUnitIDS.gram_force_centimeter, BigDecimal.valueOf(9806.65), UnitGroup.TORQUE, R.string.gram_force_centimeter, R.string.gram_force_centimeter_short),
MyUnit(MyUnitIDS.kilogram_force_millimeter, BigDecimal.valueOf(980665), UnitGroup.TORQUE, R.string.kilogram_force_millimeter, R.string.kilogram_force_millimeter_short),
MyUnit(MyUnitIDS.gram_force_meter, BigDecimal.valueOf(980665), UnitGroup.TORQUE, R.string.gram_force_meter, R.string.gram_force_meter_short),
MyUnit(MyUnitIDS.kilogram_force_centimeter, BigDecimal.valueOf(9806650), UnitGroup.TORQUE, R.string.kilogram_force_centimeter, R.string.kilogram_force_centimeter_short),
MyUnit(MyUnitIDS.kilogram_force_meter, BigDecimal.valueOf(980665000), UnitGroup.TORQUE, R.string.kilogram_force_meter, R.string.kilogram_force_meter_short),
MyUnit(MyUnitIDS.ounce_force_foot, BigDecimal.valueOf(8473862.4), UnitGroup.TORQUE, R.string.ounce_force_foot, R.string.ounce_force_foot_short),
MyUnit(MyUnitIDS.ounce_force_inch, BigDecimal.valueOf(706155.2), UnitGroup.TORQUE, R.string.ounce_force_inch, R.string.ounce_force_inch_short),
MyUnit(MyUnitIDS.pound_force_foot, BigDecimal.valueOf(135581800), UnitGroup.TORQUE, R.string.pound_force_foot, R.string.pound_force_foot_short),
MyUnit(MyUnitIDS.pound_force_inch, BigDecimal.valueOf(1.1298483333333334E7), UnitGroup.TORQUE, R.string.pound_force_inch, R.string.pound_force_inch_short),
)
}

View File

@ -35,344 +35,429 @@ class AllUnitsTest {
private val allUnitsRepository = AllUnitsRepository()
@Test
fun testAcceleration() {
MyUnitIDS.attometer_per_square_second.checkWith(MyUnitIDS.femtometer_per_square_second, "69", "0.069")
MyUnitIDS.femtometer_per_square_second.checkWith(MyUnitIDS.picometer_per_square_second, "69", "0.069")
MyUnitIDS.picometer_per_square_second.checkWith(MyUnitIDS.micrometer_per_square_second, "69", "0.00007")
MyUnitIDS.nanometer_per_square_second.checkWith(MyUnitIDS.centimeter_per_square_second, "69", "0.000007")
MyUnitIDS.micrometer_per_square_second.checkWith(MyUnitIDS.nanometer_per_square_second, "69", "69000")
MyUnitIDS.millimeter_per_square_second.checkWith(MyUnitIDS.centimeter_per_square_second, "69", "6.9")
MyUnitIDS.centimeter_per_square_second.checkWith(MyUnitIDS.meter_per_square_second, "69", "0.69")
MyUnitIDS.decimeter_per_square_second.checkWith(MyUnitIDS.meter_per_square_second, "69", "6.9")
MyUnitIDS.meter_per_square_second.checkWith(MyUnitIDS.micrometer_per_square_second, "69", "69000000")
MyUnitIDS.kilometer_per_square_second.checkWith(MyUnitIDS.hectometer_per_square_second, "69", "690")
MyUnitIDS.dekameter_per_square_second.checkWith(MyUnitIDS.gal, "69", "69000")
MyUnitIDS.hectometer_per_square_second.checkWith(MyUnitIDS.gal, "69", "690000")
MyUnitIDS.gal.checkWith(MyUnitIDS.centimeter_per_square_second, "69", "69")
MyUnitIDS.mercury_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "3.7")
MyUnitIDS.venus_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "8.87")
MyUnitIDS.earth_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "9.80655")
MyUnitIDS.mars_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "3.71")
MyUnitIDS.jupiter_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "24.79")
MyUnitIDS.saturn_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "10.44")
MyUnitIDS.uranus_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "8.87")
MyUnitIDS.neptune_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "11.15")
MyUnitIDS.sun_surface_gravity.checkWith(MyUnitIDS.meter_per_square_second, "1", "274")
fun testAcceleration() = testWithUnits {
attometer_per_square_second.checkWith(femtometer_per_square_second, "69", "0.069")
femtometer_per_square_second.checkWith(picometer_per_square_second, "69", "0.069")
picometer_per_square_second.checkWith(micrometer_per_square_second, "69", "0.00007")
nanometer_per_square_second.checkWith(centimeter_per_square_second, "69", "0.000007")
micrometer_per_square_second.checkWith(nanometer_per_square_second, "69", "69000")
millimeter_per_square_second.checkWith(centimeter_per_square_second, "69", "6.9")
centimeter_per_square_second.checkWith(meter_per_square_second, "69", "0.69")
decimeter_per_square_second.checkWith(meter_per_square_second, "69", "6.9")
meter_per_square_second.checkWith(micrometer_per_square_second, "69", "69000000")
kilometer_per_square_second.checkWith(hectometer_per_square_second, "69", "690")
dekameter_per_square_second.checkWith(gal, "69", "69000")
hectometer_per_square_second.checkWith(gal, "69", "690000")
gal.checkWith(centimeter_per_square_second, "69", "69")
mercury_surface_gravity.checkWith(meter_per_square_second, "1", "3.7")
venus_surface_gravity.checkWith(meter_per_square_second, "1", "8.87")
earth_surface_gravity.checkWith(meter_per_square_second, "1", "9.80655")
mars_surface_gravity.checkWith(meter_per_square_second, "1", "3.71")
jupiter_surface_gravity.checkWith(meter_per_square_second, "1", "24.79")
saturn_surface_gravity.checkWith(meter_per_square_second, "1", "10.44")
uranus_surface_gravity.checkWith(meter_per_square_second, "1", "8.87")
neptune_surface_gravity.checkWith(meter_per_square_second, "1", "11.15")
sun_surface_gravity.checkWith(meter_per_square_second, "1", "274")
}
@Test
fun testAngle() {
MyUnitIDS.angle_second.checkWith(MyUnitIDS.angle_minute, "420.5", "7.00833")
MyUnitIDS.angle_minute.checkWith(MyUnitIDS.radian, "420.5", "0.12232")
MyUnitIDS.degree.checkWith(MyUnitIDS.turn, "420.5", "1.16806")
MyUnitIDS.radian.checkWith(MyUnitIDS.turn, "420.5", "66.92465")
MyUnitIDS.sextant.checkWith(MyUnitIDS.radian, "420.5", "440.34657")
MyUnitIDS.turn.checkWith(MyUnitIDS.angle_minute, "420.5", "9082800")
fun testAngle() = testWithUnits {
angle_second.checkWith(angle_minute, "420.5", "7.00833")
angle_minute.checkWith(radian, "420.5", "0.12232")
degree.checkWith(turn, "420.5", "1.16806")
radian.checkWith(turn, "420.5", "66.92465")
sextant.checkWith(radian, "420.5", "440.34657")
turn.checkWith(angle_minute, "420.5", "9082800")
}
@Test
fun testArea() {
MyUnitIDS.cent.checkWith(MyUnitIDS.acre, "75.9", "7590")
MyUnitIDS.acre.checkWith(MyUnitIDS.square_kilometer, "75.9", "0.30716")
MyUnitIDS.hectare.checkWith(MyUnitIDS.square_foot, "75.9", "8169808.00585")
MyUnitIDS.square_foot.checkWith(MyUnitIDS.square_decimeter, "75.9", "705.13407")
MyUnitIDS.square_mile.checkWith(MyUnitIDS.square_foot, "75.9", "2115970560.8762")
MyUnitIDS.square_yard.checkWith(MyUnitIDS.square_foot, "75.9", "683.1")
MyUnitIDS.square_inch.checkWith(MyUnitIDS.square_foot, "75.9", "0.52708")
MyUnitIDS.square_micrometer.checkWith(MyUnitIDS.square_millimeter, "75.9", "0.00008")
MyUnitIDS.square_millimeter.checkWith(MyUnitIDS.square_centimeter, "75.9", "0.759")
MyUnitIDS.square_centimeter.checkWith(MyUnitIDS.acre, "75.9", "0.000002")
MyUnitIDS.square_decimeter.checkWith(MyUnitIDS.square_meter, "75.9", "0.759")
MyUnitIDS.square_meter.checkWith(MyUnitIDS.acre, "75.9", "0.01876")
MyUnitIDS.square_kilometer.checkWith(MyUnitIDS.hectare, "75.9", "7590")
MyUnitIDS.electron_cross_section.checkWith(MyUnitIDS.square_micrometer, "75.9", "0.000000000000005")
fun testArea() = testWithUnits {
cent.checkWith(acre, "75.9", "7590")
acre.checkWith(square_kilometer, "75.9", "0.30716")
hectare.checkWith(square_foot, "75.9", "8169808.00585")
square_foot.checkWith(square_decimeter, "75.9", "705.13407")
square_mile.checkWith(square_foot, "75.9", "2115970560.8762")
square_yard.checkWith(square_foot, "75.9", "683.1")
square_inch.checkWith(square_foot, "75.9", "0.52708")
square_micrometer.checkWith(square_millimeter, "75.9", "0.00008")
square_millimeter.checkWith(square_centimeter, "75.9", "0.759")
square_centimeter.checkWith(acre, "75.9", "0.000002")
square_decimeter.checkWith(square_meter, "75.9", "0.759")
square_meter.checkWith(acre, "75.9", "0.01876")
square_kilometer.checkWith(hectare, "75.9", "7590")
electron_cross_section.checkWith(square_micrometer, "75.9", "0.000000000000005")
}
@Test
fun testDataTransfer() {
MyUnitIDS.bit_per_second.checkWith(MyUnitIDS.kilobit_per_second, "2048", "2.048")
MyUnitIDS.kibibit_per_second.checkWith(MyUnitIDS.bit_per_second, "2048", "2097152")
MyUnitIDS.kilobit_per_second.checkWith(MyUnitIDS.bit_per_second, "2048", "2048000")
MyUnitIDS.megabit_per_second.checkWith(MyUnitIDS.kilobit_per_second, "2048", "2048000")
MyUnitIDS.mebibit_per_second.checkWith(MyUnitIDS.kilobit_per_second, "2048", "2147483.648")
MyUnitIDS.gigabit_per_second.checkWith(MyUnitIDS.kilobit_per_second, "2048", "2048000000")
MyUnitIDS.terabit_per_second.checkWith(MyUnitIDS.gigabyte_per_second, "2048", "256000")
MyUnitIDS.petabit_per_second.checkWith(MyUnitIDS.gigabyte_per_second, "2048", "256000000")
MyUnitIDS.exabit_per_second.checkWith(MyUnitIDS.petabit_per_second, "2048", "2048000")
MyUnitIDS.byte_per_second.checkWith(MyUnitIDS.bit_per_second, "2048", "16384")
MyUnitIDS.kibibyte_per_second.checkWith(MyUnitIDS.bit_per_second, "2048", "16777216")
MyUnitIDS.kilobyte_per_second.checkWith(MyUnitIDS.kibibit_per_second, "2048", "16000")
MyUnitIDS.megabyte_per_second.checkWith(MyUnitIDS.kilobyte_per_second, "2048", "2048000")
MyUnitIDS.mebibyte_per_second.checkWith(MyUnitIDS.bit_per_second, "2048", "17179869184")
MyUnitIDS.gigabyte_per_second.checkWith(MyUnitIDS.kilobyte_per_second, "2048", "2048000000")
MyUnitIDS.terabyte_per_second.checkWith(MyUnitIDS.gigabyte_per_second, "2048", "2048000")
MyUnitIDS.petabyte_per_second.checkWith(MyUnitIDS.terabyte_per_second, "2048", "2048000")
MyUnitIDS.exabyte_per_second.checkWith(MyUnitIDS.petabyte_per_second, "2048", "2048000")
fun testDataTransfer() = testWithUnits {
bit_per_second.checkWith(kilobit_per_second, "2048", "2.048")
kibibit_per_second.checkWith(bit_per_second, "2048", "2097152")
kilobit_per_second.checkWith(bit_per_second, "2048", "2048000")
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")
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")
byte_per_second.checkWith(bit_per_second, "2048", "16384")
kibibyte_per_second.checkWith(bit_per_second, "2048", "16777216")
kilobyte_per_second.checkWith(kibibit_per_second, "2048", "16000")
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")
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")
}
@Test
fun testEnergy() {
MyUnitIDS.electron_volt.checkWith(MyUnitIDS.joule, "56000000000000000000", "8.97219")
MyUnitIDS.attojoule.checkWith(MyUnitIDS.calorie_th, "41840000000000", "0.00001")
MyUnitIDS.joule.checkWith(MyUnitIDS.kilocalorie_th, "4184", "1")
MyUnitIDS.kilojoule.checkWith(MyUnitIDS.calorie_th, "4184000000", "1000000000000")
MyUnitIDS.megajoule.checkWith(MyUnitIDS.calorie_th, "0.4184", "100000")
MyUnitIDS.gigajoule.checkWith(MyUnitIDS.calorie_th, "0.4184", "100000000")
MyUnitIDS.energy_ton.checkWith(MyUnitIDS.calorie_th, "0.4184", "418400000")
MyUnitIDS.kiloton.checkWith(MyUnitIDS.calorie_th, "0.4184", "418400000000")
MyUnitIDS.megaton.checkWith(MyUnitIDS.calorie_th, "0.4184", "418400000000000")
MyUnitIDS.gigaton.checkWith(MyUnitIDS.calorie_th, "0.000000004184", "4184000000")
MyUnitIDS.energy_horse_power_metric.checkWith(MyUnitIDS.joule, "10", "26477955")
MyUnitIDS.calorie_th.checkWith(MyUnitIDS.joule, "10", "41.84")
MyUnitIDS.kilocalorie_th.checkWith(MyUnitIDS.joule, "10", "41840")
fun testEnergy() = testWithUnits {
electron_volt.checkWith(joule, "56000000000000000000", "8.97219")
attojoule.checkWith(calorie_th, "41840000000000", "0.00001")
joule.checkWith(kilocalorie_th, "4184", "1")
kilojoule.checkWith(calorie_th, "4184000000", "1000000000000")
megajoule.checkWith(calorie_th, "0.4184", "100000")
gigajoule.checkWith(calorie_th, "0.4184", "100000000")
energy_ton.checkWith(calorie_th, "0.4184", "418400000")
kiloton.checkWith(calorie_th, "0.4184", "418400000000")
megaton.checkWith(calorie_th, "0.4184", "418400000000000")
gigaton.checkWith(calorie_th, "0.000000004184", "4184000000")
energy_horse_power_metric.checkWith(joule, "10", "26477955")
calorie_th.checkWith(joule, "10", "41.84")
kilocalorie_th.checkWith(joule, "10", "41840")
}
@Test
fun testFileSize() {
MyUnitIDS.bit.checkWith(MyUnitIDS.kilobit, "2048", "2.048")
MyUnitIDS.kibibit.checkWith(MyUnitIDS.bit, "2048", "2097152")
MyUnitIDS.kilobit.checkWith(MyUnitIDS.bit, "2048", "2048000")
MyUnitIDS.megabit.checkWith(MyUnitIDS.kilobit, "2048", "2048000")
MyUnitIDS.mebibit.checkWith(MyUnitIDS.kilobit, "2048", "2147483.648")
MyUnitIDS.gigabit.checkWith(MyUnitIDS.kilobit, "2048", "2048000000")
MyUnitIDS.terabit.checkWith(MyUnitIDS.gigabyte, "2048", "256000")
MyUnitIDS.petabit.checkWith(MyUnitIDS.gigabyte, "2048", "256000000")
MyUnitIDS.exabit.checkWith(MyUnitIDS.petabit, "2048", "2048000")
MyUnitIDS.byte.checkWith(MyUnitIDS.bit, "2048", "16384")
MyUnitIDS.kibibyte.checkWith(MyUnitIDS.bit, "2048", "16777216")
MyUnitIDS.kilobyte.checkWith(MyUnitIDS.kibibit, "2048", "16000")
MyUnitIDS.megabyte.checkWith(MyUnitIDS.kilobyte, "2048", "2048000")
MyUnitIDS.mebibyte.checkWith(MyUnitIDS.bit, "2048", "17179869184")
MyUnitIDS.gigabyte.checkWith(MyUnitIDS.kilobyte, "2048", "2048000000")
MyUnitIDS.terabyte.checkWith(MyUnitIDS.gigabyte, "2048", "2048000")
MyUnitIDS.petabyte.checkWith(MyUnitIDS.terabyte, "2048", "2048000")
MyUnitIDS.exabyte.checkWith(MyUnitIDS.petabyte, "2048", "2048000")
fun testFileSize() = 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")
terabit.checkWith(gigabyte, "2048", "256000")
petabit.checkWith(gigabyte, "2048", "256000000")
exabit.checkWith(petabit, "2048", "2048000")
byte.checkWith(bit, "2048", "16384")
kibibyte.checkWith(bit, "2048", "16777216")
kilobyte.checkWith(kibibit, "2048", "16000")
megabyte.checkWith(kilobyte, "2048", "2048000")
mebibyte.checkWith(bit, "2048", "17179869184")
gigabyte.checkWith(kilobyte, "2048", "2048000000")
terabyte.checkWith(gigabyte, "2048", "2048000")
petabyte.checkWith(terabyte, "2048", "2048000")
exabyte.checkWith(petabyte, "2048", "2048000")
}
@Test
fun testLength() {
MyUnitIDS.attometer.checkWith(MyUnitIDS.micrometer, "158000000000.7", "0.158")
MyUnitIDS.nanometer.checkWith(MyUnitIDS.inch, "158000000000.7", "6220.47244")
MyUnitIDS.micrometer.checkWith(MyUnitIDS.inch, "158000000000.7", "6220472.44097")
MyUnitIDS.millimeter.checkWith(MyUnitIDS.inch, "158000.7", "6220.5")
MyUnitIDS.centimeter.checkWith(MyUnitIDS.inch, "158000.7", "62205")
MyUnitIDS.decimeter.checkWith(MyUnitIDS.foot, "158000.7", "51837.5")
MyUnitIDS.meter.checkWith(MyUnitIDS.yard, "158000.7", "172791.66667")
MyUnitIDS.kilometer.checkWith(MyUnitIDS.mile, "100", "62.13712")
MyUnitIDS.nautical_mile.checkWith(MyUnitIDS.kilometer, "100", "185.2")
MyUnitIDS.inch.checkWith(MyUnitIDS.foot, "100", "8.33333")
MyUnitIDS.foot.checkWith(MyUnitIDS.inch, "100", "1200")
MyUnitIDS.yard.checkWith(MyUnitIDS.foot, "100", "300")
MyUnitIDS.mile.checkWith(MyUnitIDS.foot, "100", "528000")
MyUnitIDS.light_year.checkWith(MyUnitIDS.foot, "0.0000001", "3103914196.85037")
MyUnitIDS.parsec.checkWith(MyUnitIDS.foot, "0.00000001", "1012361411.25044")
MyUnitIDS.kiloparsec.checkWith(MyUnitIDS.foot, "0.00000000001", "1012361411.25044")
MyUnitIDS.megaparsec.checkWith(MyUnitIDS.foot, "0.00000000000001", "1012361411.25044")
MyUnitIDS.mercury_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "2439.7")
MyUnitIDS.venus_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "6051.8")
MyUnitIDS.earth_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "6371")
MyUnitIDS.mars_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "3389.5")
MyUnitIDS.jupiter_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "69911")
MyUnitIDS.saturn_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "58232")
MyUnitIDS.uranus_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "25362")
MyUnitIDS.neptune_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "24622")
MyUnitIDS.sun_equatorial_radius.checkWith(MyUnitIDS.kilometer, "1", "695508")
fun testLength() = testWithUnits {
attometer.checkWith(micrometer, "158000000000.7", "0.158")
nanometer.checkWith(inch, "158000000000.7", "6220.47244")
micrometer.checkWith(inch, "158000000000.7", "6220472.44097")
millimeter.checkWith(inch, "158000.7", "6220.5")
centimeter.checkWith(inch, "158000.7", "62205")
decimeter.checkWith(foot, "158000.7", "51837.5")
meter.checkWith(yard, "158000.7", "172791.66667")
kilometer.checkWith(mile, "100", "62.13712")
nautical_mile.checkWith(kilometer, "100", "185.2")
inch.checkWith(foot, "100", "8.33333")
foot.checkWith(inch, "100", "1200")
yard.checkWith(foot, "100", "300")
mile.checkWith(foot, "100", "528000")
light_year.checkWith(foot, "0.0000001", "3103914196.85037")
parsec.checkWith(foot, "0.00000001", "1012361411.25044")
kiloparsec.checkWith(foot, "0.00000000001", "1012361411.25044")
megaparsec.checkWith(foot, "0.00000000000001", "1012361411.25044")
mercury_equatorial_radius.checkWith(kilometer, "1", "2439.7")
venus_equatorial_radius.checkWith(kilometer, "1", "6051.8")
earth_equatorial_radius.checkWith(kilometer, "1", "6371")
mars_equatorial_radius.checkWith(kilometer, "1", "3389.5")
jupiter_equatorial_radius.checkWith(kilometer, "1", "69911")
saturn_equatorial_radius.checkWith(kilometer, "1", "58232")
uranus_equatorial_radius.checkWith(kilometer, "1", "25362")
neptune_equatorial_radius.checkWith(kilometer, "1", "24622")
sun_equatorial_radius.checkWith(kilometer, "1", "695508")
}
@Test
fun testMass() {
MyUnitIDS.electron_mass_rest.checkWith(MyUnitIDS.milligram, "1500000000000000000", "0.000001")
MyUnitIDS.atomic_mass_unit.checkWith(MyUnitIDS.electron_mass_rest, "150", "273433.27951")
MyUnitIDS.milligram.checkWith(MyUnitIDS.ounce, "1500", "0.05291")
MyUnitIDS.gram.checkWith(MyUnitIDS.ounce, "1500", "52.91094")
MyUnitIDS.kilogram.checkWith(MyUnitIDS.carat, "1500", "7500000")
MyUnitIDS.metric_ton.checkWith(MyUnitIDS.carat, "1500", "7500000000")
MyUnitIDS.imperial_ton.checkWith(MyUnitIDS.kilogram, "1500", "1524070.3632")
MyUnitIDS.ounce.checkWith(MyUnitIDS.pound, "1500", "93.75")
MyUnitIDS.carat.checkWith(MyUnitIDS.pound, "1500", "0.66139")
MyUnitIDS.pound.checkWith(MyUnitIDS.kilogram, "1500", "680.38856")
MyUnitIDS.mercury_mass.checkWith(MyUnitIDS.kilogram, "1", "330104000000000000000000")
MyUnitIDS.venus_mass.checkWith(MyUnitIDS.kilogram, "1", "4867320000000000000000000")
MyUnitIDS.earth_mass.checkWith(MyUnitIDS.kilogram, "1", "5972190000000000000000000")
MyUnitIDS.mars_mass.checkWith(MyUnitIDS.kilogram, "1", "641693000000000000000000")
MyUnitIDS.jupiter_mass.checkWith(MyUnitIDS.kilogram, "1", "1898130000000000000000000000")
MyUnitIDS.saturn_mass.checkWith(MyUnitIDS.kilogram, "1", "568319000000000000000000000")
MyUnitIDS.uranus_mass.checkWith(MyUnitIDS.kilogram, "1", "86810300000000000000000000")
MyUnitIDS.neptune_mass.checkWith(MyUnitIDS.kilogram, "1", "102410000000000000000000000")
MyUnitIDS.sun_mass.checkWith(MyUnitIDS.kilogram, "1", "1989100000000000000000000000000")
fun testMass() = testWithUnits {
electron_mass_rest.checkWith(milligram, "1500000000000000000", "0.000001")
atomic_mass_unit.checkWith(electron_mass_rest, "150", "273433.27951")
milligram.checkWith(ounce, "1500", "0.05291")
gram.checkWith(ounce, "1500", "52.91094")
kilogram.checkWith(carat, "1500", "7500000")
metric_ton.checkWith(carat, "1500", "7500000000")
imperial_ton.checkWith(kilogram, "1500", "1524070.3632")
ounce.checkWith(pound, "1500", "93.75")
carat.checkWith(pound, "1500", "0.66139")
pound.checkWith(kilogram, "1500", "680.38856")
mercury_mass.checkWith(kilogram, "1", "330104000000000000000000")
venus_mass.checkWith(kilogram, "1", "4867320000000000000000000")
earth_mass.checkWith(kilogram, "1", "5972190000000000000000000")
mars_mass.checkWith(kilogram, "1", "641693000000000000000000")
jupiter_mass.checkWith(kilogram, "1", "1898130000000000000000000000")
saturn_mass.checkWith(kilogram, "1", "568319000000000000000000000")
uranus_mass.checkWith(kilogram, "1", "86810300000000000000000000")
neptune_mass.checkWith(kilogram, "1", "102410000000000000000000000")
sun_mass.checkWith(kilogram, "1", "1989100000000000000000000000000")
}
@Test
fun testPower() {
MyUnitIDS.attowatt.checkWith(MyUnitIDS.watt, "3950000000000000", "0.00395")
MyUnitIDS.watt.checkWith(MyUnitIDS.kilowatt, "395", "0.395")
MyUnitIDS.kilowatt.checkWith(MyUnitIDS.horse_power_mechanical, "395", "529.70373")
MyUnitIDS.megawatt.checkWith(MyUnitIDS.horse_power_mechanical, "395", "529703.72539")
MyUnitIDS.horse_power_mechanical.checkWith(MyUnitIDS.kilowatt, "395", "294.55145")
fun testPower() = testWithUnits {
attowatt.checkWith(watt, "3950000000000000", "0.00395")
watt.checkWith(kilowatt, "395", "0.395")
kilowatt.checkWith(horse_power_mechanical, "395", "529.70373")
megawatt.checkWith(horse_power_mechanical, "395", "529703.72539")
horse_power_mechanical.checkWith(kilowatt, "395", "294.55145")
}
@Test
fun testPressure() {
MyUnitIDS.attopascal.checkWith(MyUnitIDS.femtopascal, "456", "0.456")
MyUnitIDS.femtopascal.checkWith(MyUnitIDS.picopascal, "456", "0.456")
MyUnitIDS.picopascal.checkWith(MyUnitIDS.nanopascal, "456", "0.456")
MyUnitIDS.nanopascal.checkWith(MyUnitIDS.micropascal, "456", "0.456")
MyUnitIDS.micropascal.checkWith(MyUnitIDS.millipascal, "456", "0.456")
MyUnitIDS.millipascal.checkWith(MyUnitIDS.centipascal, "456", "45.6")
MyUnitIDS.centipascal.checkWith(MyUnitIDS.decipascal, "456", "45.6")
MyUnitIDS.decipascal.checkWith(MyUnitIDS.dekapascal, "456", "4.56")
MyUnitIDS.pascal.checkWith(MyUnitIDS.bar, "456", "0.00456")
MyUnitIDS.dekapascal.checkWith(MyUnitIDS.bar, "456", "0.0456")
MyUnitIDS.hectopascal.checkWith(MyUnitIDS.psi, "456", "6.61372")
MyUnitIDS.millibar.checkWith(MyUnitIDS.psi, "456", "6.61372")
MyUnitIDS.bar.checkWith(MyUnitIDS.ksi, "456", "6.61372")
MyUnitIDS.kilopascal.checkWith(MyUnitIDS.psi, "456", "66.13721")
MyUnitIDS.megapascal.checkWith(MyUnitIDS.ksi, "456", "66.13721")
MyUnitIDS.gigapascal.checkWith(MyUnitIDS.torr, "456", "3420281273.13024")
MyUnitIDS.terapascal.checkWith(MyUnitIDS.gigapascal, "456", "456000")
MyUnitIDS.petapascal.checkWith(MyUnitIDS.gigapascal, "456", "456000000")
MyUnitIDS.exapascal.checkWith(MyUnitIDS.gigapascal, "456", "456000000000")
MyUnitIDS.psi.checkWith(MyUnitIDS.gigapascal, "456", "0.00314")
MyUnitIDS.ksi.checkWith(MyUnitIDS.gigapascal, "456", "3.14401")
MyUnitIDS.standard_atmosphere.checkWith(MyUnitIDS.torr, "456", "346560")
MyUnitIDS.torr.checkWith(MyUnitIDS.hectopascal, "456", "607.95")
MyUnitIDS.micron_of_mercury.checkWith(MyUnitIDS.hectopascal, "456", "0.60795")
MyUnitIDS.millimeter_of_mercury.checkWith(MyUnitIDS.hectopascal, "456", "607.95")
fun testPressure() = testWithUnits {
attopascal.checkWith(femtopascal, "456", "0.456")
femtopascal.checkWith(picopascal, "456", "0.456")
picopascal.checkWith(nanopascal, "456", "0.456")
nanopascal.checkWith(micropascal, "456", "0.456")
micropascal.checkWith(millipascal, "456", "0.456")
millipascal.checkWith(centipascal, "456", "45.6")
centipascal.checkWith(decipascal, "456", "45.6")
decipascal.checkWith(dekapascal, "456", "4.56")
pascal.checkWith(bar, "456", "0.00456")
dekapascal.checkWith(bar, "456", "0.0456")
hectopascal.checkWith(psi, "456", "6.61372")
millibar.checkWith(psi, "456", "6.61372")
bar.checkWith(ksi, "456", "6.61372")
kilopascal.checkWith(psi, "456", "66.13721")
megapascal.checkWith(ksi, "456", "66.13721")
gigapascal.checkWith(torr, "456", "3420281273.13024")
terapascal.checkWith(gigapascal, "456", "456000")
petapascal.checkWith(gigapascal, "456", "456000000")
exapascal.checkWith(gigapascal, "456", "456000000000")
psi.checkWith(gigapascal, "456", "0.00314")
ksi.checkWith(gigapascal, "456", "3.14401")
standard_atmosphere.checkWith(torr, "456", "346560")
torr.checkWith(hectopascal, "456", "607.95")
micron_of_mercury.checkWith(hectopascal, "456", "0.60795")
millimeter_of_mercury.checkWith(hectopascal, "456", "607.95")
}
@Test
fun testSpeed() {
MyUnitIDS.millimeter_per_hour.checkWith(MyUnitIDS.kilometer_per_hour, "396", "0.0004")
MyUnitIDS.millimeter_per_minute.checkWith(MyUnitIDS.kilometer_per_hour, "396", "0.02376")
MyUnitIDS.millimeter_per_second.checkWith(MyUnitIDS.kilometer_per_hour, "396", "1.4256")
MyUnitIDS.centimeter_per_hour.checkWith(MyUnitIDS.kilometer_per_hour, "396", "0.00396")
MyUnitIDS.centimeter_per_minute.checkWith(MyUnitIDS.kilometer_per_hour, "396", "0.2376")
MyUnitIDS.centimeter_per_second.checkWith(MyUnitIDS.kilometer_per_hour, "396", "14.256")
MyUnitIDS.meter_per_hour.checkWith(MyUnitIDS.kilometer_per_hour, "396", "0.396")
MyUnitIDS.meter_per_minute.checkWith(MyUnitIDS.kilometer_per_hour, "396", "23.76")
MyUnitIDS.meter_per_second.checkWith(MyUnitIDS.kilometer_per_hour, "396", "1425.6")
MyUnitIDS.kilometer_per_hour.checkWith(MyUnitIDS.mile_per_hour, "396", "246.06299")
MyUnitIDS.kilometer_per_minute.checkWith(MyUnitIDS.mile_per_hour, "396", "14763.77953")
MyUnitIDS.kilometer_per_second.checkWith(MyUnitIDS.mile_per_hour, "396", "885826.77165")
MyUnitIDS.foot_per_hour.checkWith(MyUnitIDS.mile_per_hour, "396", "0.075")
MyUnitIDS.foot_per_minute.checkWith(MyUnitIDS.mile_per_hour, "396", "4.5")
MyUnitIDS.foot_per_second.checkWith(MyUnitIDS.mile_per_hour, "396", "270")
MyUnitIDS.yard_per_hour.checkWith(MyUnitIDS.mile_per_hour, "396", "0.225")
MyUnitIDS.yard_per_minute.checkWith(MyUnitIDS.mile_per_hour, "396", "13.5")
MyUnitIDS.yard_per_second.checkWith(MyUnitIDS.mile_per_hour, "396", "810")
MyUnitIDS.mile_per_hour.checkWith(MyUnitIDS.foot_per_hour, "396", "2090880")
MyUnitIDS.mile_per_minute.checkWith(MyUnitIDS.foot_per_hour, "396", "125452800")
MyUnitIDS.mile_per_second.checkWith(MyUnitIDS.foot_per_hour, "396", "7527168000")
MyUnitIDS.knot.checkWith(MyUnitIDS.meter_per_hour, "396", "733392")
MyUnitIDS.velocity_of_light_in_vacuum.checkWith(MyUnitIDS.meter_per_second, "1", "299792458")
MyUnitIDS.cosmic_velocity_first.checkWith(MyUnitIDS.meter_per_second, "1", "7900")
MyUnitIDS.cosmic_velocity_second.checkWith(MyUnitIDS.meter_per_second, "1", "11200")
MyUnitIDS.cosmic_velocity_third.checkWith(MyUnitIDS.meter_per_second, "1", "16670")
MyUnitIDS.earths_orbital_speed.checkWith(MyUnitIDS.meter_per_second, "1", "29765")
MyUnitIDS.mach.checkWith(MyUnitIDS.meter_per_second, "1", "343.6")
MyUnitIDS.mach_si_standard.checkWith(MyUnitIDS.meter_per_second, "1", "295.0464")
fun testSpeed() = testWithUnits {
millimeter_per_hour.checkWith(kilometer_per_hour, "396", "0.0004")
millimeter_per_minute.checkWith(kilometer_per_hour, "396", "0.02376")
millimeter_per_second.checkWith(kilometer_per_hour, "396", "1.4256")
centimeter_per_hour.checkWith(kilometer_per_hour, "396", "0.00396")
centimeter_per_minute.checkWith(kilometer_per_hour, "396", "0.2376")
centimeter_per_second.checkWith(kilometer_per_hour, "396", "14.256")
meter_per_hour.checkWith(kilometer_per_hour, "396", "0.396")
meter_per_minute.checkWith(kilometer_per_hour, "396", "23.76")
meter_per_second.checkWith(kilometer_per_hour, "396", "1425.6")
kilometer_per_hour.checkWith(mile_per_hour, "396", "246.06299")
kilometer_per_minute.checkWith(mile_per_hour, "396", "14763.77953")
kilometer_per_second.checkWith(mile_per_hour, "396", "885826.77165")
foot_per_hour.checkWith(mile_per_hour, "396", "0.075")
foot_per_minute.checkWith(mile_per_hour, "396", "4.5")
foot_per_second.checkWith(mile_per_hour, "396", "270")
yard_per_hour.checkWith(mile_per_hour, "396", "0.225")
yard_per_minute.checkWith(mile_per_hour, "396", "13.5")
yard_per_second.checkWith(mile_per_hour, "396", "810")
mile_per_hour.checkWith(foot_per_hour, "396", "2090880")
mile_per_minute.checkWith(foot_per_hour, "396", "125452800")
mile_per_second.checkWith(foot_per_hour, "396", "7527168000")
knot.checkWith(meter_per_hour, "396", "733392")
velocity_of_light_in_vacuum.checkWith(meter_per_second, "1", "299792458")
cosmic_velocity_first.checkWith(meter_per_second, "1", "7900")
cosmic_velocity_second.checkWith(meter_per_second, "1", "11200")
cosmic_velocity_third.checkWith(meter_per_second, "1", "16670")
earths_orbital_speed.checkWith(meter_per_second, "1", "29765")
mach.checkWith(meter_per_second, "1", "343.6")
mach_si_standard.checkWith(meter_per_second, "1", "295.0464")
}
@Test
fun testTemperature() {
MyUnitIDS.celsius.checkWith(MyUnitIDS.celsius, "0", "0")
MyUnitIDS.celsius.checkWith(MyUnitIDS.fahrenheit, "0", "32")
MyUnitIDS.celsius.checkWith(MyUnitIDS.kelvin, "0", "273.15")
MyUnitIDS.celsius.checkWith(MyUnitIDS.celsius, "36.6", "36.6")
MyUnitIDS.celsius.checkWith(MyUnitIDS.fahrenheit, "36.6", "97.88")
MyUnitIDS.celsius.checkWith(MyUnitIDS.kelvin, "36.6", "309.75")
MyUnitIDS.celsius.checkWith(MyUnitIDS.celsius, "-36.6", "-36.6")
MyUnitIDS.celsius.checkWith(MyUnitIDS.fahrenheit, "-36.6", "-33.88")
MyUnitIDS.celsius.checkWith(MyUnitIDS.kelvin, "-36.6", "236.55")
fun testTemperature() = testWithUnits {
celsius.checkWith(celsius, "0", "0")
celsius.checkWith(fahrenheit, "0", "32")
celsius.checkWith(kelvin, "0", "273.15")
celsius.checkWith(celsius, "36.6", "36.6")
celsius.checkWith(fahrenheit, "36.6", "97.88")
celsius.checkWith(kelvin, "36.6", "309.75")
celsius.checkWith(celsius, "-36.6", "-36.6")
celsius.checkWith(fahrenheit, "-36.6", "-33.88")
celsius.checkWith(kelvin, "-36.6", "236.55")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.celsius, "0", "-17.77778")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.fahrenheit, "0", "0")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.kelvin, "0", "255.37222")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.celsius, "36.6", "2.55556")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.fahrenheit, "36.6", "36.6")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.kelvin, "36.6", "275.70556")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.celsius, "-36.6", "-38.11111")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.fahrenheit, "-36.6", "-36.6")
MyUnitIDS.fahrenheit.checkWith(MyUnitIDS.kelvin, "-36.6", "235.03889")
fahrenheit.checkWith(celsius, "0", "-17.77778")
fahrenheit.checkWith(fahrenheit, "0", "0")
fahrenheit.checkWith(kelvin, "0", "255.37222")
fahrenheit.checkWith(celsius, "36.6", "2.55556")
fahrenheit.checkWith(fahrenheit, "36.6", "36.6")
fahrenheit.checkWith(kelvin, "36.6", "275.70556")
fahrenheit.checkWith(celsius, "-36.6", "-38.11111")
fahrenheit.checkWith(fahrenheit, "-36.6", "-36.6")
fahrenheit.checkWith(kelvin, "-36.6", "235.03889")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.celsius, "0", "-273.15")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.fahrenheit, "0", "-459.67")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.kelvin, "0", "0")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.celsius, "36.6", "-236.55")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.fahrenheit, "36.6", "-393.79")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.kelvin, "36.6", "36.6")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.celsius, "-36.6", "-309.75")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.fahrenheit, "-36.6", "-525.55")
MyUnitIDS.kelvin.checkWith(MyUnitIDS.kelvin, "-36.6", "-36.6")
kelvin.checkWith(celsius, "0", "-273.15")
kelvin.checkWith(fahrenheit, "0", "-459.67")
kelvin.checkWith(kelvin, "0", "0")
kelvin.checkWith(celsius, "36.6", "-236.55")
kelvin.checkWith(fahrenheit, "36.6", "-393.79")
kelvin.checkWith(kelvin, "36.6", "36.6")
kelvin.checkWith(celsius, "-36.6", "-309.75")
kelvin.checkWith(fahrenheit, "-36.6", "-525.55")
kelvin.checkWith(kelvin, "-36.6", "-36.6")
}
@Test
fun testTime() {
MyUnitIDS.attosecond.checkWith(MyUnitIDS.millisecond, "366000000000", "0.00037")
MyUnitIDS.nanosecond.checkWith(MyUnitIDS.millisecond, "366", "0.00037")
MyUnitIDS.microsecond.checkWith(MyUnitIDS.millisecond, "366", "0.366")
MyUnitIDS.millisecond.checkWith(MyUnitIDS.second, "366", "0.366")
MyUnitIDS.jiffy.checkWith(MyUnitIDS.second, "366", "3.66")
MyUnitIDS.second.checkWith(MyUnitIDS.millisecond, "366", "366000")
MyUnitIDS.minute.checkWith(MyUnitIDS.millisecond, "366", "21960000")
MyUnitIDS.hour.checkWith(MyUnitIDS.millisecond, "366", "1317600000")
MyUnitIDS.day.checkWith(MyUnitIDS.hour, "366", "8784")
MyUnitIDS.week.checkWith(MyUnitIDS.hour, "366", "61488")
fun testTime() = testWithUnits {
attosecond.checkWith(millisecond, "366000000000", "0.00037")
nanosecond.checkWith(millisecond, "366", "0.00037")
microsecond.checkWith(millisecond, "366", "0.366")
millisecond.checkWith(second, "366", "0.366")
jiffy.checkWith(second, "366", "3.66")
second.checkWith(millisecond, "366", "366000")
minute.checkWith(millisecond, "366", "21960000")
hour.checkWith(millisecond, "366", "1317600000")
day.checkWith(hour, "366", "8784")
week.checkWith(hour, "366", "61488")
}
@Test
fun testVolume() {
MyUnitIDS.attoliter.checkWith(MyUnitIDS.millimeter, "1507000000000", "0.00151")
MyUnitIDS.milliliter.checkWith(MyUnitIDS.liter, "1507", "1.507")
MyUnitIDS.liter.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "398.10728")
MyUnitIDS.us_liquid_gallon.checkWith(MyUnitIDS.us_fluid_ounce, "1507", "192896")
MyUnitIDS.us_liquid_quart.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "376.75")
MyUnitIDS.us_liquid_pint.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "188.375")
MyUnitIDS.us_legal_cup.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "94.1875")
MyUnitIDS.us_fluid_ounce.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "11.77344")
MyUnitIDS.us_tablespoon.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "5.88672")
MyUnitIDS.us_teaspoon.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "1.96224")
MyUnitIDS.imperial_gallon.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "1809.83154")
MyUnitIDS.imperial_quart.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "452.45788")
MyUnitIDS.imperial_pint.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "226.22894")
MyUnitIDS.imperial_cup.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "113.11447")
MyUnitIDS.imperial_fluid_ounce.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "11.31145")
MyUnitIDS.imperial_tablespoon.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "7.06965")
MyUnitIDS.imperial_teaspoon.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "2.35655")
MyUnitIDS.cubic_millimeter.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "0.0004")
MyUnitIDS.cubic_centimeter.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "0.39811")
MyUnitIDS.cubic_meter.checkWith(MyUnitIDS.us_liquid_gallon, "1507", "398107.2829")
MyUnitIDS.cubic_kilometer.checkWith(MyUnitIDS.us_liquid_gallon, "0.0000001507", "39810.72829")
fun testVolume() = testWithUnits {
attoliter.checkWith(millimeter, "1507000000000", "0.00151")
milliliter.checkWith(liter, "1507", "1.507")
liter.checkWith(us_liquid_gallon, "1507", "398.10728")
us_liquid_gallon.checkWith(us_fluid_ounce, "1507", "192896")
us_liquid_quart.checkWith(us_liquid_gallon, "1507", "376.75")
us_liquid_pint.checkWith(us_liquid_gallon, "1507", "188.375")
us_legal_cup.checkWith(us_liquid_gallon, "1507", "94.1875")
us_fluid_ounce.checkWith(us_liquid_gallon, "1507", "11.77344")
us_tablespoon.checkWith(us_liquid_gallon, "1507", "5.88672")
us_teaspoon.checkWith(us_liquid_gallon, "1507", "1.96224")
imperial_gallon.checkWith(us_liquid_gallon, "1507", "1809.83154")
imperial_quart.checkWith(us_liquid_gallon, "1507", "452.45788")
imperial_pint.checkWith(us_liquid_gallon, "1507", "226.22894")
imperial_cup.checkWith(us_liquid_gallon, "1507", "113.11447")
imperial_fluid_ounce.checkWith(us_liquid_gallon, "1507", "11.31145")
imperial_tablespoon.checkWith(us_liquid_gallon, "1507", "7.06965")
imperial_teaspoon.checkWith(us_liquid_gallon, "1507", "2.35655")
cubic_millimeter.checkWith(us_liquid_gallon, "1507", "0.0004")
cubic_centimeter.checkWith(us_liquid_gallon, "1507", "0.39811")
cubic_meter.checkWith(us_liquid_gallon, "1507", "398107.2829")
cubic_kilometer.checkWith(us_liquid_gallon, "0.0000001507", "39810.72829")
}
@Test
fun testFlux() {
MyUnitIDS.maxwell.checkWith(MyUnitIDS.milliweber, "68.2", "0.00068")
MyUnitIDS.weber.checkWith(MyUnitIDS.milliweber, "68.2", "68200")
MyUnitIDS.milliweber.checkWith(MyUnitIDS.weber, "68.2", "0.0682")
MyUnitIDS.microweber.checkWith(MyUnitIDS.milliweber, "68.2", "0.0682")
MyUnitIDS.kiloweber.checkWith(MyUnitIDS.weber, "68.2", "68200")
MyUnitIDS.megaweber.checkWith(MyUnitIDS.weber, "68.2", "68200000")
MyUnitIDS.gigaweber.checkWith(MyUnitIDS.weber, "68.2", "68200000000")
fun testFlux() = testWithUnits {
maxwell.checkWith(milliweber, "68.2", "0.00068")
weber.checkWith(milliweber, "68.2", "68200")
milliweber.checkWith(weber, "68.2", "0.0682")
microweber.checkWith(milliweber, "68.2", "0.0682")
kiloweber.checkWith(weber, "68.2", "68200")
megaweber.checkWith(weber, "68.2", "68200000")
gigaweber.checkWith(weber, "68.2", "68200000000")
}
@Test
fun testNumberBase() {
MyUnitIDS.binary.checkWith(MyUnitIDS.octal, "1000001001", "1011")
MyUnitIDS.ternary.checkWith(MyUnitIDS.decimal, "10112020111", "69430")
MyUnitIDS.quaternary.checkWith(MyUnitIDS.quinary, "20321", "4234")
MyUnitIDS.quinary.checkWith(MyUnitIDS.nonary, "4234", "702")
MyUnitIDS.senary.checkWith(MyUnitIDS.nonary, "4234", "1274")
MyUnitIDS.septenary.checkWith(MyUnitIDS.nonary, "4234", "2041")
MyUnitIDS.octal.checkWith(MyUnitIDS.undecimal, "42343277", "5107945")
MyUnitIDS.nonary.checkWith(MyUnitIDS.duodecimal, "42343287", "69b9a81")
MyUnitIDS.decimal.checkWith(MyUnitIDS.duodecimal, "42343287", "12220273")
MyUnitIDS.undecimal.checkWith(MyUnitIDS.hexadecimal, "4234a287", "4e3f0c2")
MyUnitIDS.duodecimal.checkWith(MyUnitIDS.hexadecimal, "4234a287", "8f30d07")
MyUnitIDS.tridecimal.checkWith(MyUnitIDS.hexadecimal, "4234a287", "f9c3ff4")
MyUnitIDS.tetradecimal.checkWith(MyUnitIDS.hexadecimal, "bb", "a5")
MyUnitIDS.pentadecimal.checkWith(MyUnitIDS.hexadecimal, "BABE", "9a82")
MyUnitIDS.hexadecimal.checkWith(MyUnitIDS.quinary, "FADE", "4023342")
fun testNumberBase() = testWithUnits {
binary.checkWith(octal, "1000001001", "1011")
ternary.checkWith(decimal, "10112020111", "69430")
quaternary.checkWith(quinary, "20321", "4234")
quinary.checkWith(nonary, "4234", "702")
senary.checkWith(nonary, "4234", "1274")
septenary.checkWith(nonary, "4234", "2041")
octal.checkWith(undecimal, "42343277", "5107945")
nonary.checkWith(duodecimal, "42343287", "69b9a81")
decimal.checkWith(duodecimal, "42343287", "12220273")
undecimal.checkWith(hexadecimal, "4234a287", "4e3f0c2")
duodecimal.checkWith(hexadecimal, "4234a287", "8f30d07")
tridecimal.checkWith(hexadecimal, "4234a287", "f9c3ff4")
tetradecimal.checkWith(hexadecimal, "bb", "a5")
pentadecimal.checkWith(hexadecimal, "BABE", "9a82")
hexadecimal.checkWith(quinary, "FADE", "4023342")
}
@Test
fun testElectrostaticCapacitance() = testWithUnits {
attofarad.checkWith(nanofarad, "364354322342", "364.35432")
statfarad.checkWith(microfarad, "123312", "0.1372")
farad.checkWith(kilofarad, "123312", "123.312")
exafarad.checkWith(petafarad, "123312", "123312000")
picofarad.checkWith(nanofarad, "11233", "11.233")
nanofarad.checkWith(millifarad, "11233", "0.01123")
microfarad.checkWith(nanofarad, "1123433", "1123433000")
millifarad.checkWith(nanofarad, "112", "112000000")
kilofarad.checkWith(microfarad, "11132", "11132000000000")
megafarad.checkWith(kilofarad, "11132", "11132000")
gigafarad.checkWith(petafarad, "11132", "0.01113")
petafarad.checkWith(kilofarad, "11132", "11132000000000000")
}
@Test
fun testPrefix() = testWithUnits {
prefix_quetta.checkWith(prefix_base, "1", "1000000000000000000000000000000")
prefix_ronna.checkWith(prefix_base, "1", "1000000000000000000000000000")
prefix_yotta.checkWith(prefix_base, "1", "1000000000000000000000000")
prefix_zetta.checkWith(prefix_base, "1", "1000000000000000000000")
prefix_exa.checkWith(prefix_base, "1", "1000000000000000000")
prefix_peta.checkWith(prefix_base, "1", "1000000000000000")
prefix_tera.checkWith(prefix_base, "1", "1000000000000")
prefix_giga.checkWith(prefix_base, "1", "1000000000")
prefix_mega.checkWith(prefix_base, "1", "1000000")
prefix_kilo.checkWith(prefix_base, "1", "1000")
prefix_hecto.checkWith(prefix_base, "1", "100")
prefix_deca.checkWith(prefix_base, "1", "10")
prefix_base.checkWith(prefix_base, "77777", "77777")
prefix_deci.checkWith(prefix_base, "1", "0.1")
prefix_centi.checkWith(prefix_base, "1", "0.01")
prefix_milli.checkWith(prefix_base, "1", "0.001")
prefix_micro.checkWith(prefix_base, "1", "0.000001")
prefix_nano.checkWith(prefix_base, "1", "0.000000001")
prefix_pico.checkWith(prefix_base, "1", "0.000000000001")
prefix_femto.checkWith(prefix_base, "1", "0.000000000000001")
prefix_atto.checkWith(prefix_base, "1", "0.000000000000000001")
prefix_zepto.checkWith(prefix_base, "1", "0.000000000000000000001")
prefix_yocto.checkWith(prefix_base, "1", "0.000000000000000000000001")
prefix_ronto.checkWith(prefix_base, "1", "0.000000000000000000000000001")
prefix_quecto.checkWith(prefix_base, "1", "0.000000000000000000000000000001")
}
@Test
fun testForce() = testWithUnits {
newton.checkWith(pond, "6553", "668220.03436")
kilonewton.checkWith(kilopound_force, "6553", "1473.173")
gram_force.checkWith(kilonewton, "6553", "0.06426")
kilogram_force.checkWith(ton_force, "6553", "6.553")
ton_force.checkWith(millinewton, "6553", "64262977450")
millinewton.checkWith(kilonewton, "6553", "0.00655")
attonewton.checkWith(dyne, "6553123123", "0.00066")
dyne.checkWith(joule_per_meter, "6553", "0.06553")
joule_per_meter.checkWith(pond, "6553", "668220.03436")
joule_per_centimeter.checkWith(kilopond, "6553", "6.6822")
kilopound_force.checkWith(kilopond, "6553", "2972390.80061")
pound_force.checkWith(ounce_force, "6553", "104848")
ounce_force.checkWith(pound_force, "6553", "409.5625")
pond.checkWith(kilonewton, "6553", "0.06426")
kilopond.checkWith(kilonewton, "6553", "64.26298")
}
@Test
fun testTorque() = testWithUnits {
newton_meter.checkWith(dyne_meter, "2134", "213400000")
newton_centimeter.checkWith(kilogram_force_millimeter, "2345", "2391.23452")
newton_millimeter.checkWith(pound_force_inch, "2345", "20.755")
kilonewton_meter.checkWith(kilogram_force_meter, "2134", "217607.43985")
dyne_meter.checkWith(newton_centimeter, "2134", "2.134")
dyne_centimeter.checkWith(gram_force_centimeter, "2134", "2.17607")
dyne_millimeter.checkWith(gram_force_millimeter, "2134", "2.17607")
kilogram_force_meter.checkWith(dyne_millimeter, "2134", "2092739110000")
kilogram_force_centimeter.checkWith(gram_force_meter, "2134", "21340")
kilogram_force_millimeter.checkWith(ounce_force_inch, "2134", "2963.56822")
gram_force_meter.checkWith(newton_millimeter, "2134", "20927.3911")
gram_force_centimeter.checkWith(kilogram_force_centimeter, "2134", "2.134")
gram_force_millimeter.checkWith(kilonewton_meter, "2134", "0.00002")
ounce_force_foot.checkWith(kilogram_force_millimeter, "2134", "18439.75503")
ounce_force_inch.checkWith(dyne_meter, "2134", "1506935.1968")
pound_force_foot.checkWith(newton_millimeter, "2134", "2893315.612")
pound_force_inch.checkWith(ounce_force_foot, "2134", "2845.33337")
}
private fun String.checkWith(checkingId: String, value: String, expected: String) {
@ -399,4 +484,6 @@ class AllUnitsTest {
// GROUP : testedCount / totalCount
println("${unitGroup.name} : ${history[unitGroup]?.size} / ${allUnitsRepository.getCollectionByGroup(unitGroup).size}")
}
private fun testWithUnits(block: MyUnitIDS.() -> Unit): Unit = with(MyUnitIDS, block = block)
}

View File

@ -54,6 +54,7 @@ import javax.inject.Inject
* @property shownUnitGroups [UnitGroup]s that user wants to see. Excludes other [UnitGroup]s,
* @property enableVibrations When true will use haptic feedback in app.
* @property enableToolsExperiment When true will enable experimental Tools screen.
* @property radianMode AngleMode in mxParser. When true - Radian, when False - Degree.
*/
data class UserPreferences(
val themingMode: ThemingMode? = null,
@ -67,7 +68,8 @@ data class UserPreferences(
val shownUnitGroups: List<UnitGroup> = ALL_UNIT_GROUPS,
val enableVibrations: Boolean = true,
val enableToolsExperiment: Boolean = false,
val startingScreen: String = TopLevelDestinations.Converter.route
val startingScreen: String = TopLevelDestinations.Converter.route,
val radianMode: Boolean = true
)
/**
@ -90,6 +92,7 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS
val ENABLE_VIBRATIONS = booleanPreferencesKey("ENABLE_VIBRATIONS_PREF_KEY")
val ENABLE_TOOLS_EXPERIMENT = booleanPreferencesKey("ENABLE_TOOLS_EXPERIMENT_PREF_KEY")
val STARTING_SCREEN = stringPreferencesKey("STARTING_SCREEN_PREF_KEY")
val RADIAN_MODE = booleanPreferencesKey("RADIAN_MODE_PREF_KEY")
}
val userPreferencesFlow: Flow<UserPreferences> = dataStore.data
@ -134,6 +137,7 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS
val enableVibrations: Boolean = preferences[PrefsKeys.ENABLE_VIBRATIONS] ?: true
val enableToolsExperiment: Boolean = preferences[PrefsKeys.ENABLE_TOOLS_EXPERIMENT] ?: false
val startingScreen: String = preferences[PrefsKeys.STARTING_SCREEN] ?: TopLevelDestinations.Converter.route
val radianMode: Boolean = preferences[PrefsKeys.RADIAN_MODE] ?: true
UserPreferences(
themingMode = themingMode,
@ -147,7 +151,8 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS
shownUnitGroups = shownUnitGroups,
enableVibrations = enableVibrations,
enableToolsExperiment = enableToolsExperiment,
startingScreen = startingScreen
startingScreen = startingScreen,
radianMode = radianMode
)
}
@ -269,4 +274,15 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS
preferences[PrefsKeys.ENABLE_TOOLS_EXPERIMENT] = enabled
}
}
/**
* Update angle mode for calculator.
*
* @param radianMode When true - Radian, when False - Degree.
*/
suspend fun updateRadianMode(radianMode: Boolean) {
dataStore.edit { preferences ->
preferences[PrefsKeys.RADIAN_MODE] = radianMode
}
}
}

View File

@ -0,0 +1 @@
Fixed crashes in calculator.

View File

@ -0,0 +1 @@
Исправлены ошибки в калькуляторе.

View File

@ -1,21 +0,0 @@
/*
* Unitto is a unit converter for Android
* Copyright (c) 2023 Elshan Agaev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sadellie.unitto.feature.calculator
internal enum class AngleMode { DEG, RAD }

View File

@ -270,7 +270,7 @@ private fun CalculatorScreen(
numPad = {
CalculatorKeyboard(
modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp, vertical = 4.dp),
angleMode = uiState.angleMode,
radianMode = uiState.radianMode,
allowVibration = uiState.allowVibration,
addSymbol = addSymbol,
clearSymbols = clearSymbols,

View File

@ -24,7 +24,7 @@ import com.sadellie.unitto.data.model.HistoryItem
internal data class CalculatorUIState(
val input: TextFieldValue = TextFieldValue(),
val output: String = "",
val angleMode: AngleMode = AngleMode.RAD,
val radianMode: Boolean = true,
val history: List<HistoryItem> = emptyList(),
val allowVibration: Boolean = false
)

View File

@ -34,7 +34,6 @@ import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
@ -46,7 +45,7 @@ import org.mariuszgromada.math.mxparser.mXparser as MathParser
@HiltViewModel
internal class CalculatorViewModel @Inject constructor(
userPrefsRepository: UserPreferencesRepository,
private val userPrefsRepository: UserPreferencesRepository,
private val calculatorHistoryRepository: CalculatorHistoryRepository,
private val textFieldController: TextFieldController
) : ViewModel() {
@ -58,16 +57,15 @@ internal class CalculatorViewModel @Inject constructor(
)
private val _output: MutableStateFlow<String> = MutableStateFlow("")
private val _angleMode: MutableStateFlow<AngleMode> = MutableStateFlow(AngleMode.RAD)
private val _history = calculatorHistoryRepository.historyFlow
val uiState = combine(
textFieldController.input, _output, _angleMode, _history, _userPrefs
) { input, output, angleMode, history, userPrefs ->
textFieldController.input, _output, _history, _userPrefs
) { input, output, history, userPrefs ->
return@combine CalculatorUIState(
input = input,
output = output,
angleMode = angleMode,
radianMode = userPrefs.radianMode,
history = history,
allowVibration = userPrefs.enableVibrations
)
@ -82,14 +80,8 @@ internal class CalculatorViewModel @Inject constructor(
fun clearSymbols() = textFieldController.clearInput()
fun toggleCalculatorMode() {
_angleMode.update {
if (it == AngleMode.DEG) {
MathParser.setRadiansMode()
AngleMode.RAD
} else {
MathParser.setDegreesMode()
AngleMode.DEG
}
viewModelScope.launch {
userPrefsRepository.updateRadianMode(!_userPrefs.value.radianMode)
}
}
@ -185,7 +177,9 @@ internal class CalculatorViewModel @Inject constructor(
// Observe and invoke calculation without UI lag.
viewModelScope.launch(Dispatchers.Default) {
merge(_userPrefs, textFieldController.input, _angleMode).collectLatest {
combine(_userPrefs, textFieldController.input) { userPrefs, _ ->
if (userPrefs.radianMode) MathParser.setRadiansMode() else MathParser.setDegreesMode()
}.collectLatest {
calculateInput()
}
}

View File

@ -57,11 +57,15 @@ class TextFieldController @Inject constructor() {
val inputFormatted = newInput.fixFormat()
val newSelectionStartEnd = inputFormatted.length - lastToEndDistance
val fixedCursor = fixCursor(
newPosition = newSelectionStartEnd..newSelectionStartEnd,
currentInput = inputFormatted
) ?: newSelectionStartEnd..newSelectionStartEnd
input.update {
it.copy(
text = inputFormatted,
selection = TextRange(newSelectionStartEnd, newSelectionStartEnd)
selection = TextRange(fixedCursor)
)
}
}
@ -72,16 +76,9 @@ class TextFieldController @Inject constructor() {
fun pasteSymbols(symbols: String) = addToInput(symbols.filterUnknownSymbols())
fun moveCursor(newPosition: IntRange) {
val currentInput = input.value.text
if (newPosition.last > currentInput.length) return
val fixedLeftCursor = cursorFixer.fixCursorIfNeeded(currentInput, newPosition.first)
val fixedRightCursor = cursorFixer.fixCursorIfNeeded(currentInput, newPosition.last)
// Will modify
input.update {
it.copy(
selection = TextRange(fixedLeftCursor, fixedRightCursor)
selection = TextRange(fixCursor(newPosition) ?: return)
)
}
}
@ -115,7 +112,7 @@ class TextFieldController @Inject constructor() {
.fixFormat()
it.copy(
text = newText,
selection = TextRange(newText.length - distanceFromEnd)
selection = TextRange((newText.length - distanceFromEnd).coerceAtLeast(0))
)
}
}
@ -126,10 +123,24 @@ class TextFieldController @Inject constructor() {
.replace(localFormatter.grouping, "")
.replace(localFormatter.fractional, Token.dot)
private fun fixCursor(
newPosition: IntRange,
currentInput: String = input.value.text
): IntRange? {
if (newPosition.last > currentInput.length) return null
val fixedLeftCursor = cursorFixer.fixCursorIfNeeded(currentInput, newPosition.first)
val fixedRightCursor = cursorFixer.fixCursorIfNeeded(currentInput, newPosition.last)
return fixedLeftCursor..fixedRightCursor
}
private fun String.fixFormat(): String = localFormatter.reFormat(this)
private fun String.filterUnknownSymbols() = localFormatter.filterUnknownSymbols(this)
private fun TextRange(range: IntRange): TextRange = TextRange(range.first, range.last)
inner class CursorFixer {
private val illegalTokens by lazy {
listOf(

View File

@ -98,12 +98,11 @@ import com.sadellie.unitto.core.ui.common.key.unittoicons.RightBracket
import com.sadellie.unitto.core.ui.common.key.unittoicons.Sin
import com.sadellie.unitto.core.ui.common.key.unittoicons.SquareRootWide
import com.sadellie.unitto.core.ui.common.key.unittoicons.Tan
import com.sadellie.unitto.feature.calculator.AngleMode
@Composable
internal fun CalculatorKeyboard(
modifier: Modifier,
angleMode: AngleMode,
radianMode: Boolean,
allowVibration: Boolean,
addSymbol: (String) -> Unit,
clearSymbols: () -> Unit,
@ -114,7 +113,7 @@ internal fun CalculatorKeyboard(
if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT) {
PortraitKeyboard(
modifier = modifier,
angleMode = angleMode,
radianMode = radianMode,
allowVibration = allowVibration,
addSymbol = addSymbol,
toggleAngleMode = toggleAngleMode,
@ -125,7 +124,7 @@ internal fun CalculatorKeyboard(
} else {
LandscapeKeyboard(
modifier = modifier,
angleMode = angleMode,
radianMode = radianMode,
allowVibration = allowVibration,
addSymbol = addSymbol,
toggleAngleMode = toggleAngleMode,
@ -139,7 +138,7 @@ internal fun CalculatorKeyboard(
@Composable
private fun PortraitKeyboard(
modifier: Modifier,
angleMode: AngleMode,
radianMode: Boolean,
allowVibration: Boolean,
addSymbol: (String) -> Unit,
toggleAngleMode: () -> Unit,
@ -185,7 +184,7 @@ private fun PortraitKeyboard(
allowVibration = allowVibration,
addSymbol = addSymbol,
showAdditional = showAdditional,
angleMode = angleMode,
radianMode = radianMode,
toggleAngleMode = toggleAngleMode,
toggleInvMode = { invMode = !invMode }
)
@ -195,7 +194,7 @@ private fun PortraitKeyboard(
allowVibration = allowVibration,
addSymbol = addSymbol,
showAdditional = showAdditional,
angleMode = angleMode,
radianMode = radianMode,
toggleAngleMode = toggleAngleMode,
toggleInvMode = { invMode = !invMode }
)
@ -212,7 +211,7 @@ private fun PortraitKeyboard(
}
}
}
Spacer(modifier = Modifier.height(verticalFraction(0.015f)))
Row(weightModifier) {
@ -257,7 +256,7 @@ private fun AdditionalButtonsPortrait(
allowVibration: Boolean,
addSymbol: (String) -> Unit,
showAdditional: Boolean,
angleMode: AngleMode,
radianMode: Boolean,
toggleAngleMode: () -> Unit,
toggleInvMode: () -> Unit
) {
@ -271,7 +270,7 @@ private fun AdditionalButtonsPortrait(
AnimatedVisibility(showAdditional) {
Column {
Row {
KeyboardButtonAdditional(modifier, if (angleMode == AngleMode.DEG) UnittoIcons.Deg else UnittoIcons.Rad, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(modifier, if (radianMode) UnittoIcons.Rad else UnittoIcons.Deg, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(modifier, UnittoIcons.Sin, allowVibration) { addSymbol(Token.sin) }
KeyboardButtonAdditional(modifier, UnittoIcons.Cos, allowVibration) { addSymbol(Token.cos) }
KeyboardButtonAdditional(modifier, UnittoIcons.Tan, allowVibration) { addSymbol(Token.tan) }
@ -293,7 +292,7 @@ private fun AdditionalButtonsPortraitInverse(
allowVibration: Boolean,
addSymbol: (String) -> Unit,
showAdditional: Boolean,
angleMode: AngleMode,
radianMode: Boolean,
toggleAngleMode: () -> Unit,
toggleInvMode: () -> Unit
) {
@ -307,7 +306,7 @@ private fun AdditionalButtonsPortraitInverse(
AnimatedVisibility(showAdditional) {
Column {
Row {
KeyboardButtonAdditional(modifier, if (angleMode == AngleMode.DEG) UnittoIcons.Deg else UnittoIcons.Rad, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(modifier, if (radianMode) UnittoIcons.Rad else UnittoIcons.Deg, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(modifier, UnittoIcons.ArSin, allowVibration) { addSymbol(Token.arSin) }
KeyboardButtonAdditional(modifier, UnittoIcons.ArCos, allowVibration) { addSymbol(Token.arCos) }
KeyboardButtonAdditional(modifier, UnittoIcons.AcTan, allowVibration) { addSymbol(Token.acTan) }
@ -326,7 +325,7 @@ private fun AdditionalButtonsPortraitInverse(
@Composable
private fun LandscapeKeyboard(
modifier: Modifier,
angleMode: AngleMode,
radianMode: Boolean,
allowVibration: Boolean,
addSymbol: (String) -> Unit,
toggleAngleMode: () -> Unit,
@ -350,7 +349,7 @@ private fun LandscapeKeyboard(
modifier = Modifier.weight(1f),
buttonModifier = buttonModifier,
allowVibration = allowVibration,
angleMode = angleMode,
radianMode = radianMode,
addSymbol = addSymbol,
toggleAngleMode = toggleAngleMode,
toggleInvMode = { invMode = !invMode }
@ -360,7 +359,7 @@ private fun LandscapeKeyboard(
modifier = Modifier.weight(1f),
buttonModifier = buttonModifier,
allowVibration = allowVibration,
angleMode = angleMode,
radianMode = radianMode,
addSymbol = addSymbol,
toggleAngleMode = toggleAngleMode,
toggleInvMode = { invMode = !invMode }
@ -408,13 +407,13 @@ private fun AdditionalButtonsLandscape(
modifier: Modifier,
buttonModifier: Modifier,
allowVibration: Boolean,
angleMode: AngleMode,
radianMode: Boolean,
addSymbol: (String) -> Unit,
toggleAngleMode: () -> Unit,
toggleInvMode: () -> Unit
) {
Column(modifier) {
KeyboardButtonAdditional(buttonModifier, if (angleMode == AngleMode.DEG) UnittoIcons.Deg else UnittoIcons.Rad, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(buttonModifier, if (radianMode) UnittoIcons.Rad else UnittoIcons.Deg, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(buttonModifier, UnittoIcons.Inv, allowVibration) { toggleInvMode() }
KeyboardButtonAdditional(buttonModifier, UnittoIcons.Sin, allowVibration) { addSymbol(Token.sin) }
KeyboardButtonAdditional(buttonModifier, UnittoIcons.E, allowVibration) { addSymbol(Token.e) }
@ -440,13 +439,13 @@ private fun AdditionalButtonsLandscapeInverse(
modifier: Modifier,
buttonModifier: Modifier,
allowVibration: Boolean,
angleMode: AngleMode,
radianMode: Boolean,
addSymbol: (String) -> Unit,
toggleAngleMode: () -> Unit,
toggleInvMode: () -> Unit
) {
Column(modifier) {
KeyboardButtonAdditional(buttonModifier, if (angleMode == AngleMode.DEG) UnittoIcons.Deg else UnittoIcons.Rad, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(buttonModifier, if (radianMode) UnittoIcons.Rad else UnittoIcons.Deg, allowVibration) { toggleAngleMode() }
KeyboardButtonAdditional(buttonModifier, UnittoIcons.Inv, allowVibration) { toggleInvMode() }
KeyboardButtonAdditional(buttonModifier, UnittoIcons.ArSin, allowVibration) { addSymbol(Token.arSin) }
KeyboardButtonAdditional(buttonModifier, UnittoIcons.E, allowVibration) { addSymbol(Token.e) }
@ -472,7 +471,7 @@ private fun AdditionalButtonsLandscapeInverse(
private fun PreviewCalculatorKeyboard() {
CalculatorKeyboard(
modifier = Modifier,
angleMode = AngleMode.DEG,
radianMode = true,
addSymbol = {},
clearSymbols = {},
deleteSymbol = {},

View File

@ -184,6 +184,13 @@ internal class TextFieldControllerTest {
textFieldController.delete()
assertEquals("", textFieldController.text)
assertEquals(0..0, textFieldController.selection)
textFieldController.addToInput("1234")
// Place cursor like 1|,234
textFieldController.moveCursor(1..1)
textFieldController.delete()
assertEquals("234", textFieldController.text)
assertEquals(0..0, textFieldController.selection)
}
@Test

View File

@ -1,5 +1,5 @@
[versions]
appCode = "17"
appCode = "18"
appName = "Illuminating emerald"
kotlin = "1.8.10"
androidxCore = "1.9.0"

BIN
where-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB