Advertisement
colinm86

Untitled

Oct 13th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. from radixsort import RadixSort
  2. from queue import Queue
  3. import unittest
  4.  
  5. class TestStringMethods(unittest.TestCase):
  6.     """Unit tests for RadixSort Class
  7.    Arguments:
  8.        unittest {unittest}
  9.    """
  10.     def setUp(self):
  11.         """Sets up RadixSort properties to be tested"""
  12.         self.rdxsortone = RadixSort([12,43,1,545,21,2,7,4,2,8])
  13.    
  14.     def test_properties(self):
  15.         """Tests RadixSort object properties"""
  16.         self.assertEqual(self.rdxsortone.lst, ['12','43','1','545','21','2','7','4','2','8'])
  17.         self.assertEqual(isinstance(self.rdxsortone.mainqueue,Queue), True)
  18.         self.assertEqual(self.rdxsortone.mainqueue.isEmpty(), False)
  19.         self.assertEqual(self.rdxsortone.mainqueue.size(), 10)
  20.         self.assertEqual(isinstance(self.rdxsortone.binsqueue,list), True)
  21.         self.assertEqual(len(self.rdxsortone.binsqueue), 10)
  22.         self.assertEqual(self.rdxsortone.maxnum, 545)
  23.         with self.assertRaises(TypeError):
  24.             RadixSort('12,1,3,45,6,6')
  25.         with self.assertRaises(TypeError):
  26.             RadixSort([12,1.1,3,45,6,6])
  27.        
  28.     def test_list_int_to_str(self):
  29.         """Test RadixSort object list int to string method"""
  30.         self.assertEqual(self.rdxsortone.list_int_to_str([1,2,3,4,5,6]),['1','2','3','4','5','6'])
  31.  
  32.     def test_list_str_to_int(self):
  33.         """Test RadixSort object list string to int method"""
  34.         self.assertEqual(self.rdxsortone.list_str_to_int(['1','2','3','4','5','6']),[1,2,3,4,5,6])
  35.  
  36.     def test_sort(self):
  37.         """Test RadixSort object sort method"""
  38.         self.assertEqual(self.rdxsortone.sort(),[1, 2, 2, 4, 7, 8, 12, 21, 43, 545])
  39.         radix2 = RadixSort([324,1232,2,32,5,1,32454,3,1,99])
  40.         self.assertEqual(radix2.sort(),[1, 1, 2, 3, 5, 32, 99, 324, 1232, 32454])
  41.  
  42. if __name__ == '__main__':
  43.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement