@@ -275,10 +275,43 @@ def test_feedback_args(self):
275275 def testConnect (self ):
276276 sys = append (self .sys2 , self .sys3 ) # two siso systems
277277
278- # feedback interconnection -3 is out of bounds
279- Q1 = [[1 , 2 ], [2 , - 3 ]]
280- self .assertRaises (IndexError , connect (sys , Q1 , [2 ], [1 , 2 ]))
281-
278+ # feedback interconnection out of bounds: input too high
279+ Q = [[1 , 3 ], [2 , - 2 ]]
280+ with self .assertRaises (IndexError ) as context :
281+ connect (sys , Q , [2 ], [1 , 2 ])
282+ # feedback interconnection out of bounds: input too low
283+ Q = [[0 , 2 ], [2 , - 2 ]]
284+ with self .assertRaises (IndexError ) as context :
285+ connect (sys , Q , [2 ], [1 , 2 ])
286+
287+ # feedback interconnection out of bounds: output too high
288+ Q = [[1 , 2 ], [2 , - 3 ]]
289+ with self .assertRaises (IndexError ) as context :
290+ connect (sys , Q , [2 ], [1 , 2 ])
291+ Q = [[1 , 2 ], [2 , 4 ]]
292+ with self .assertRaises (IndexError ) as context :
293+ connect (sys , Q , [2 ], [1 , 2 ])
294+
295+ # input/output index testing
296+ Q = [[1 , 2 ], [2 , - 2 ]] # OK interconnection
297+
298+ # input index is out of bounds: too high
299+ with self .assertRaises (IndexError ) as context :
300+ connect (sys , Q , [3 ], [1 , 2 ])
301+ # input index is out of bounds: too low
302+ with self .assertRaises (IndexError ) as context :
303+ connect (sys , Q , [0 ], [1 , 2 ])
304+ with self .assertRaises (IndexError ) as context :
305+ connect (sys , Q , [- 2 ], [1 , 2 ])
306+ # output index is out of bounds: too high
307+ with self .assertRaises (IndexError ) as context :
308+ connect (sys , Q , [2 ], [1 , 3 ])
309+ # output index is out of bounds: too low
310+ with self .assertRaises (IndexError ) as context :
311+ connect (sys , Q , [2 ], [1 , 0 ])
312+ with self .assertRaises (IndexError ) as context :
313+ connect (sys , Q , [2 ], [1 , - 1 ])
314+
282315
283316if __name__ == "__main__" :
284317 unittest .main ()
0 commit comments