Skip to content

Commit

Permalink
Add explicit tests based on examples in issue #52.
Browse files Browse the repository at this point in the history
  • Loading branch information
SethMMorton committed Apr 12, 2018
1 parent 322f52e commit 5f0abd8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test_natsort/test_fake_fastnumbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def test_fast_float_converts_float_string_to_float_example():
assert isnan(fast_float('nan'))
assert isnan(fast_float('+nan'))
assert isnan(fast_float('-NaN'))
assert fast_float('۱۲.۱۲') == 12.12
assert fast_float('-۱۲.۱۲') == -12.12


@given(floats(allow_nan=False))
Expand Down Expand Up @@ -117,6 +119,8 @@ def test_fast_int_leaves_float_string_as_is(x):
def test_fast_int_converts_int_string_to_int_example():
assert fast_int('-45') == -45
assert fast_int('+45') == 45
assert fast_int('۱۲') == 12
assert fast_int('-۱۲') == -12


@given(integers())
Expand Down
10 changes: 10 additions & 0 deletions test_natsort/test_natsorted.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,13 @@ def test_natsorted_sorts_an_odd_collection_of_string():
'apple', 'banana', 'corn', '~~~~~~']
assert natsorted(a, alg=ns.NUMAFTER) == ['Apple', 'Banana', 'Corn',
'apple', 'banana', 'corn', '~~~~~~', '73', '5039']


def test_natsorted_sorts_mixed_ascii_and_non_ascii_numbers():
a = ['1st street', '10th street', '2nd street', '2 street', '1 street', '1street',
'11 street', 'street 2', 'street 1', 'Street 11', '۲ street', '۱ street', '۱street',
'۱۲street', '۱۱ street', 'street ۲', 'street ۱', 'street ۱', 'street ۱۲', 'street ۱۱']
expected = ['1 street', '۱ street', '1st street', '1street', '۱street', '2 street', '۲ street',
'2nd street', '10th street', '11 street', '۱۱ street', '۱۲street', 'street 1',
'street ۱', 'street ۱', 'street 2', 'street ۲', 'Street 11', 'street ۱۱', 'street ۱۲']
assert natsorted(a, alg=ns.IGNORECASE) == expected

0 comments on commit 5f0abd8

Please sign in to comment.