Mercurial > hg > numerics
comparison tests/test_sort.py @ 135:12649a88545c
stubbing: hooking this up to command line
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 17 Mar 2015 11:53:33 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
134:b6242f916cef | 135:12649a88545c |
---|---|
1 #!/usr/bin/env python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 unit tests for sort | |
6 """ | |
7 | |
8 import unittest | |
9 from numerics.sort import Sorter | |
10 | |
11 class SortUnitTest(unittest.TestCase): | |
12 | |
13 def test_sort(self): | |
14 """test array sorter""" | |
15 | |
16 data = [[1,2,3], | |
17 [5,6,4], | |
18 [2,7,2]] | |
19 | |
20 # forward | |
21 self.assertEqual(Sorter((-1, True))(data), | |
22 [[2,7,2], | |
23 [1,2,3], | |
24 [5,6,4]]) | |
25 self.assertEqual(Sorter((0, True))(data), | |
26 [[1,2,3], | |
27 [2,7,2], | |
28 [5,6,4]]) | |
29 self.assertEqual(Sorter((1, True))(data), | |
30 [[1,2,3], | |
31 [5,6,4], | |
32 [2,7,2]]) | |
33 def test_reverse(self): | |
34 data = [[1,2,3], | |
35 [5,6,4], | |
36 [2,7,2]] | |
37 self.assertEqual(Sorter((-1, False))(data), | |
38 [[5,6,4], | |
39 [1,2,3], | |
40 [2,7,2]]) | |
41 | |
42 if __name__ == '__main__': | |
43 unittest.main() | |
44 |