Add tests for jeb_utils.utils.is_number
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
from src.jeb_utils.utils import is_number
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('string,base,expected', [
|
||||||
|
# Valid
|
||||||
|
('7', 8, True),
|
||||||
|
('0', 8, True),
|
||||||
|
('0', 36, True),
|
||||||
|
('0', 2, True),
|
||||||
|
('0', 10, True),
|
||||||
|
('1', 10, True),
|
||||||
|
('0a', 11, True),
|
||||||
|
('helloworld', 36, True),
|
||||||
|
('helloworld', 35, True),
|
||||||
|
('helloworld', 34, True),
|
||||||
|
('helloworld', 33, True),
|
||||||
|
|
||||||
|
|
||||||
|
# Invalid
|
||||||
|
|
||||||
|
# Invalid numbers
|
||||||
|
('', 10, False),
|
||||||
|
('a', 10, False),
|
||||||
|
('1a', 10, False),
|
||||||
|
('0a', 10, False),
|
||||||
|
('0a', 8, False),
|
||||||
|
('helloworld', 32, False),
|
||||||
|
('9', 8, False),
|
||||||
|
('8', 8, False),
|
||||||
|
|
||||||
|
# Invalid bases
|
||||||
|
('0', 37, False),
|
||||||
|
('0', 1, False),
|
||||||
|
('1', 1, False),
|
||||||
|
('2', 1, False),
|
||||||
|
('0', 0, False),
|
||||||
|
('1', 0, False),
|
||||||
|
('2', 0, False),
|
||||||
|
])
|
||||||
|
def test_is_number(string, base, expected):
|
||||||
|
assert is_number(string, base) == expected
|
||||||
Reference in New Issue
Block a user