def test_active_index_list_add_active(): # add elements, mode is changed to partly active active_list_obj = ActiveList() assign_list = [0, 1, 4, 12, 88, 77, 5] for index in assign_list: active_list_obj.addActiveIndex(index) mode = active_list_obj.getMode() assert mode == ActiveMode.PARTLY_ACTIVE list2 = active_list_obj.get_active_index_list() # Can not assume that the list is sorted or that it is # in the same order as the order the elements are added assign_list.sort() list2.sort() assert assign_list == list2 default_value = 10 size = active_list_obj.getActiveSize(default_value) assert size == len(list2)
def test_active_size(self): al = ActiveList() self.assertEqual(None, al.getActiveSize(None)) self.assertEqual(7, al.getActiveSize(7)) self.assertEqual(-1, al.getActiveSize(-1)) al.addActiveIndex(10) self.assertEqual(1, al.getActiveSize(7)) al.addActiveIndex(10) self.assertEqual(1, al.getActiveSize(7)) al.addActiveIndex(100) self.assertEqual(2, al.getActiveSize(7))