# pybsv - Backup, Synchronization, Versioning. # Copyright (C) 2025 Simon Boyé # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . """Tests for cli_utils.py.""" from __future__ import annotations from bsv.cli_utils import format_human_byte_size def test_format_human_byte_size(): assert format_human_byte_size(0) == "0B" assert format_human_byte_size(1) == "1B" assert format_human_byte_size(9) == "9B" assert format_human_byte_size(10) == "10B" assert format_human_byte_size(99) == "99B" assert format_human_byte_size(100) == "100B" assert format_human_byte_size(999) == "999B" assert format_human_byte_size(1000) == "1000B" assert format_human_byte_size(1023) == "1023B" assert format_human_byte_size(2**10) == "1KiB" assert format_human_byte_size(int(1.23456 * 2**10)) == "1.23KiB" assert format_human_byte_size(9 * 2**10) == "9KiB" assert format_human_byte_size(10 * 2**10 - 1) == "10KiB" assert format_human_byte_size(int(98.76543 * 2**10)) == "98.8KiB" assert format_human_byte_size(99 * 2**10 - 1) == "99KiB" assert format_human_byte_size(100 * 2**10 - 1) == "100KiB" assert format_human_byte_size(int(192.8374 * 2**10)) == "193KiB" assert format_human_byte_size(999 * 2**10 - 1) == "999KiB" assert format_human_byte_size(1000 * 2**10 - 1) == "1000KiB" assert format_human_byte_size(2**20 - 1) == "1MiB" assert format_human_byte_size(2**20) == "1MiB" assert format_human_byte_size(2**30) == "1GiB" assert format_human_byte_size(2**40) == "1TiB" assert format_human_byte_size(2**50) == "1PiB" assert format_human_byte_size(2**60) == "1EiB" assert format_human_byte_size(2**70) == "1ZiB" assert format_human_byte_size(2**80) == "1YiB" assert format_human_byte_size(2**90) == "1RiB" assert format_human_byte_size(2**100 - 2**80) == "1QiB" assert format_human_byte_size(2**100) == "1QiB" assert format_human_byte_size(2**110 - 2**90) == "1024QiB" assert format_human_byte_size(2**110) == "1024QiB" assert format_human_byte_size(2**120) == "1048576QiB"