Skip to content

Commit

Permalink
test: add is_sorted to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karitra committed Jul 3, 2019
1 parent ae65428 commit 4f03d3b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_is_sortable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import eblob_kit

from collections import namedtuple


DummyRecord = namedtuple('DummyRecord', 'a b')


def test_sequence_is_sorted_default_key():
sorted_sequence = [-1, 1, 2, 3, 4, 5, 10, 100, 1000]
assert eblob_kit.is_sorted(sorted_sequence)


def test_sequence_not_sorted_default_key():
non_sorted_sequence = [-1, 1, 2, 3, 4, 5, 10, 100, 99, 1000]
assert not eblob_kit.is_sorted(non_sorted_sequence)


def test_sequence_is_sorted_custom_key():
sequence_length = 10
sequence = [
DummyRecord(i, sequence_length - i) for i in xrange(sequence_length)
]

assert eblob_kit.is_sorted(sequence)
assert eblob_kit.is_sorted(sequence, lambda x: x.a)
assert not eblob_kit.is_sorted(sequence, lambda x: x.b)

0 comments on commit 4f03d3b

Please sign in to comment.