Start adding some tests
Improve the fixed_version function Better binary search parameter return values
This commit is contained in:
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__author__ = 'david'
|
||||
23
tests/utils_test.py
Normal file
23
tests/utils_test.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import unittest
|
||||
|
||||
from zttf.utils import fixed_version, binary_search_parameters
|
||||
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
def test_fixed_version(self):
|
||||
cases = [
|
||||
(0x00005000, 0.5),
|
||||
(0x00010000, 1.0),
|
||||
(0x00035000, 3.5),
|
||||
(0x00105000, 10.5)
|
||||
]
|
||||
for case in cases:
|
||||
self.assertEqual(fixed_version(case[0]), case[1])
|
||||
|
||||
def test_binary_parameters(self):
|
||||
cases = {
|
||||
39: (5, 64, 14),
|
||||
10: (3, 16, 4)
|
||||
}
|
||||
for n, result in cases.items():
|
||||
self.assertEqual(binary_search_parameters(n), result)
|
||||
Reference in New Issue
Block a user