Start adding some tests

Improve the fixed_version function
Better binary search parameter return values
This commit is contained in:
david reid
2015-03-21 22:52:32 +00:00
parent c1876477c0
commit 8342904f7f
4 changed files with 38 additions and 17 deletions

1
tests/__init__.py Normal file
View File

@@ -0,0 +1 @@
__author__ = 'david'

23
tests/utils_test.py Normal file
View 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)