from helix.utility.unit_prefix import UnitPrefix


def test_base_conversion():
    assert UnitPrefix.convert(10**-15, 3) == "0.001p"
    assert UnitPrefix.convert(10**-14, 2) == "0.01p"
    assert UnitPrefix.convert(10**-13) == "0.1p"
    assert UnitPrefix.convert(10**-12) == "1p"
    assert UnitPrefix.convert(10**-11) == "10p"
    assert UnitPrefix.convert(10**-10) == "100p"
    assert UnitPrefix.convert(10**-9) == "1n"
    assert UnitPrefix.convert(10**-8) == "10n"
    assert UnitPrefix.convert(10**-7) == "100n"
    assert UnitPrefix.convert(10**-6) == "1μ"
    assert UnitPrefix.convert(10**-5) == "10μ"
    assert UnitPrefix.convert(10**-4) == "100μ"
    assert UnitPrefix.convert(10**-3) == "1m"
    assert UnitPrefix.convert(10**-2) == "10m"
    assert UnitPrefix.convert(10**-1) == "100m"
    assert UnitPrefix.convert(0) == "0"
    assert UnitPrefix.convert(10**0) == "1"
    assert UnitPrefix.convert(10**1) == "10"
    assert UnitPrefix.convert(10**2) == "100"
    assert UnitPrefix.convert(10**3) == "1k"
    assert UnitPrefix.convert(10**4) == "10k"
    assert UnitPrefix.convert(10**5) == "100k"
    assert UnitPrefix.convert(10**6) == "1M"
    assert UnitPrefix.convert(10**7) == "10M"
    assert UnitPrefix.convert(10**8) == "100M"
    assert UnitPrefix.convert(10**9) == "1G"
    assert UnitPrefix.convert(10**10) == "10G"
    assert UnitPrefix.convert(10**11) == "100G"
    assert UnitPrefix.convert(10**12) == "1T"
    assert UnitPrefix.convert(10**13) == "10T"
    assert UnitPrefix.convert(10**14) == "100T"
    assert UnitPrefix.convert(10**15) == "1P"
    assert UnitPrefix.convert(10**16) == "10P"
    assert UnitPrefix.convert(10**17) == "100P"
    assert UnitPrefix.convert(10**18) == "1000P"
    assert UnitPrefix.convert(10**19) == "10000P"


def test_bytes_conversion():
    assert UnitPrefix.convert_bytes(0) == "0 B"
    assert UnitPrefix.convert_bytes(2**0) == "1 B"
    assert UnitPrefix.convert_bytes(2**1) == "2 B"
    assert UnitPrefix.convert_bytes(2**2) == "4 B"
    assert UnitPrefix.convert_bytes(2**3) == "8 B"
    assert UnitPrefix.convert_bytes(2**4) == "16 B"
    assert UnitPrefix.convert_bytes(2**5) == "32 B"
    assert UnitPrefix.convert_bytes(2**6) == "64 B"
    assert UnitPrefix.convert_bytes(2**7) == "128 B"
    assert UnitPrefix.convert_bytes(2**8) == "256 B"
    assert UnitPrefix.convert_bytes(2**9) == "512 B"
    assert UnitPrefix.convert_bytes(2**10) == "1 kB"
    assert UnitPrefix.convert_bytes(2**11) == "2 kB"
    assert UnitPrefix.convert_bytes(2**12) == "4 kB"
    assert UnitPrefix.convert_bytes(2**13) == "8 kB"
    assert UnitPrefix.convert_bytes(2**14) == "16 kB"
    assert UnitPrefix.convert_bytes(2**15) == "32 kB"
    assert UnitPrefix.convert_bytes(2**16) == "64 kB"
    assert UnitPrefix.convert_bytes(2**17) == "128 kB"
    assert UnitPrefix.convert_bytes(2**18) == "256 kB"
    assert UnitPrefix.convert_bytes(2**19) == "512 kB"
    assert UnitPrefix.convert_bytes(2**20) == "1 MB"
    assert UnitPrefix.convert_bytes(2**21) == "2 MB"
    assert UnitPrefix.convert_bytes(2**22) == "4 MB"
    assert UnitPrefix.convert_bytes(2**23) == "8 MB"
    assert UnitPrefix.convert_bytes(2**24) == "16 MB"
    assert UnitPrefix.convert_bytes(2**25) == "32 MB"
    assert UnitPrefix.convert_bytes(2**26) == "64 MB"
    assert UnitPrefix.convert_bytes(2**27) == "128 MB"
    assert UnitPrefix.convert_bytes(2**28) == "256 MB"
    assert UnitPrefix.convert_bytes(2**29) == "512 MB"
    assert UnitPrefix.convert_bytes(2**30) == "1 GB"
    assert UnitPrefix.convert_bytes(2**31) == "2 GB"
    assert UnitPrefix.convert_bytes(2**32) == "4 GB"
    assert UnitPrefix.convert_bytes(2**33) == "8 GB"
    assert UnitPrefix.convert_bytes(2**34) == "16 GB"
    assert UnitPrefix.convert_bytes(2**35) == "32 GB"
    assert UnitPrefix.convert_bytes(2**36) == "64 GB"
    assert UnitPrefix.convert_bytes(2**37) == "128 GB"
    assert UnitPrefix.convert_bytes(2**38) == "256 GB"
    assert UnitPrefix.convert_bytes(2**39) == "512 GB"
    assert UnitPrefix.convert_bytes(2**40) == "1 TB"
    assert UnitPrefix.convert_bytes(2**41) == "2 TB"
    assert UnitPrefix.convert_bytes(2**42) == "4 TB"
    assert UnitPrefix.convert_bytes(2**43) == "8 TB"
    assert UnitPrefix.convert_bytes(2**44) == "16 TB"
    assert UnitPrefix.convert_bytes(2**45) == "32 TB"
    assert UnitPrefix.convert_bytes(2**46) == "64 TB"
    assert UnitPrefix.convert_bytes(2**47) == "128 TB"
    assert UnitPrefix.convert_bytes(2**48) == "256 TB"
    assert UnitPrefix.convert_bytes(2**49) == "512 TB"
    assert UnitPrefix.convert_bytes(2**50) == "1024 TB"
