-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import eblob_kit | ||
|
||
from collections import namedtuple | ||
|
||
|
||
DummyRecord = namedtuple('DummyRecord', 'a b') | ||
|
||
|
||
def test_sequence_is_sorted_default_key(): | ||
"""Test that sequence is sorted with default key selector.""" | ||
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(): | ||
"""Test that sequence is not sorted with default key selector.""" | ||
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(): | ||
"""Test sequence is sorted with custom field selector.""" | ||
sequence_length = 5 | ||
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) |