ARver/tests/helpers_test.py
arcctgx 81265e4142 fix length calculation of non-CDDA input files
The integer division is only correct in case of CDDA rips, where the
audio file length is guaranteed to be a multiple of the CD sector size.
For non-CDDA files the quotient must be rounded up to the next integer
to correctly account for fractional CDDA sectors (e.g. 700 audio frames
would require two 588-frame CDDA sectors, not one). Rounding the result
does not change the behavior for CDDA input data (no fractional sectors
are expected by definition).

This is not really a problem because ARver is designed to be used with
CDDA rips, and non-CDDA files were expected to fail verification anyway.
But the clearly incorrect method of converting the audio frames to CDDA
sectors was confusing when reading the code, even if it did not result
in runtime errors.
2025-06-11 00:08:19 +02:00

16 lines
403 B
Python

"""Tests of helper functions."""
# pylint: disable=missing-function-docstring
import unittest
from arver.rip.rip import _ceil_div
class TestHelperFunctions(unittest.TestCase):
"""Tests of helper functions."""
def test_ceiling_division(self):
self.assertEqual(_ceil_div(0, 588), 0)
self.assertEqual(_ceil_div(1000, 588), 2)
self.assertEqual(_ceil_div(2940, 588), 5)