Skip to content

HumanSizeWithPrecision uses scientific notation in some invalid cases #44

@kmirzavaziri

Description

@kmirzavaziri

Let's keep it short, such a test will fail:

assertEquals(t, "1GB", HumanSizeWithPrecision(999.6*MB, 3))

With the following message:

Expected '1GB' but got '1e+03MB'

The case holds in the following scenarios:

  • any 999.5 <= x < 1000 for any unit including bytes, kB, MB, GB, etc. (with precision 1, 2, or 3)
  • any 99.5 <= x < 1000 for any unit including bytes, kB, MB, GB, etc. (with precision 1 or 2)
  • any 9.5 <= x < 1000 for any unit including bytes, kB, MB, GB, etc. (with precision 1)

However, it works fine with precision 4 or higher.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions