| 1 |
# vim:fileencoding=utf-8 |
| 2 |
# License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net> |
| 3 |
from __python__ import bound_methods, hash_literals |
| 4 |
|
| 5 |
from session import deep_eq |
| 6 |
from testing import assert_equal, test |
| 7 |
from utils import fmt_sidx, human_readable, rating_to_stars |
| 8 |
|
| 9 |
|
| 10 |
@test |
| 11 |
def misc_utils(): |
| 12 |
assert_equal(rating_to_stars(3, True), '★⯨') |
| 13 |
assert_equal(fmt_sidx(10), 'X') |
| 14 |
assert_equal(fmt_sidx(1.2), '1.20') |
| 15 |
assert_equal(list(map(human_readable, [1, 1024.0, 1025, 1024 * 1024 * 2.3])), ['1 B', '1 KB', '1 KB', '2.3 MB']) |
| 16 |
assert_equal(False, deep_eq({'portrait': 0, 'landscape': 0}, {'landscape': 3, 'portrait': 0})) |
| 17 |
assert_equal(False, deep_eq(1, 2)) |
| 18 |
assert_equal(True, deep_eq(1, 1)) |