view tests/test_sort.py @ 160:3bcd097c27f2

more convenience reduce functions, muahahaha
author Jeff Hammel <k0scist@gmail.com>
date Wed, 13 May 2015 16:13:06 -0700
parents 12649a88545c
children
line wrap: on
line source

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
unit tests for sort
"""

import unittest
from numerics.sort import Sorter

class SortUnitTest(unittest.TestCase):

    def test_sort(self):
        """test array sorter"""

        data = [[1,2,3],
                [5,6,4],
                [2,7,2]]

        # forward
        self.assertEqual(Sorter((-1, True))(data),
                         [[2,7,2],
                          [1,2,3],
                          [5,6,4]])
        self.assertEqual(Sorter((0, True))(data),
                         [[1,2,3],
                          [2,7,2],
                          [5,6,4]])
        self.assertEqual(Sorter((1, True))(data),
                         [[1,2,3],
                          [5,6,4],
                          [2,7,2]])
    def test_reverse(self):
        data = [[1,2,3],
                [5,6,4],
                [2,7,2]]
        self.assertEqual(Sorter((-1, False))(data),
                         [[5,6,4],
                          [1,2,3],
                          [2,7,2]])

if __name__ == '__main__':
    unittest.main()