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