import unittest # Assuming your function is imported or defined here: # from your_module import getTupleIndex class TestGetTupleIndex(unittest.TestCase): def setUp(self): # Sample graph branches: (u, v) pairs self.n_ij = [('A', 'B'), ('B', 'C'), ('C', 'D'), ('A', 'C')] def test_found_at_beginning(self): """Test when the target tuple is the first element.""" self.assertEqual(getTupleIndex(self.n_ij, 'A', 'B'), 0) def test_found_in_middle(self): """Test when the target tuple is somewhere in the middle.""" self.assertEqual(getTupleIndex(self.n_ij, 'B', 'C'), 1) def test_found_at_end(self): """Test when the target tuple is the last element.""" self.assertEqual(getTupleIndex(self.n_ij, 'A', 'C'), 3) def test_not_found(self): """Test when the tuple does not exist in the list (should return None).""" self.assertIsNone(getTupleIndex(self.n_ij, 'X', 'Y')) def test_empty_list(self): """Test behavior when passed an empty list.""" self.assertIsNone(getTupleIndex([], 'A', 'B')) if __name__ == '__main__': unittest.main()