def test_value_crossing_detector1(self): """ Test the most basic case of a straight line trajectory """ zcd = value_crossing_detector([5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5], 0) self.assertEqual(zcd, 1)
def test_value_crossing_detector2(self): """ Test the case where no crossing has occurred """ zcd = value_crossing_detector([5, 4, 3, 2, 3], 0) self.assertEqual(zcd, 0)
def test_value_crossing_detector16(self): """ A random test """ zcd = value_crossing_detector([5, 1, 2, -3, 4, 5, 0, 0, 0, -1, 0], 1) self.assertEqual(zcd, 3)
def test_value_crossing_detector17(self): """ A random test with non-integer value """ zcd = value_crossing_detector([5, 1, 2, -3, 4, 5, 0, 0, 0, -1, 0], 0.5) self.assertEqual(zcd, 3)
def test_value_crossing_detector14(self): """ Test the case where 2 crossings have occurred, it lingers at zero """ zcd = value_crossing_detector([5, 4, 3, 2, 3, -5, 2, -7, 0, 0, 0, -1, 0], -6) self.assertEqual(zcd, 2)
def test_value_crossing_detector15(self): """ Test the case where 4 crossings occur, it lingers at zero """ zcd = value_crossing_detector([5, 4, 3, 2, 3, -5, 2, -7, 0, 0, 0, -1, 0, 1, 1, 1], -1) self.assertEqual(zcd, 4)
def test_value_crossing_detector13(self): """ Test the case where 1 crossings have occurred but it hits the value (i.e. not crossing) """ zcd = value_crossing_detector([5, 4, 3, 2, 3, -5, 2, -7, 0, 0, 0], 2) self.assertEqual(zcd, 1)
def test_value_crossing_detector12(self): """ Test the case where 3 crossing have occurred """ zcd = value_crossing_detector([5, 4, 3, 2, 3, -5, 2, -7], -1) self.assertEqual(zcd, 3)
def test_value_crossing_detector11(self): """ Test the case where 1 crossing has occurred """ zcd = value_crossing_detector([5, 4, 3, 2, 3, -5], 2) self.assertEqual(zcd, 1)
def test_value_crossing_detector6(self): """ Test the case where 3 crossings have occurred, it lingers at zero and goes back (i.e. hasn't crossed) """ zcd = value_crossing_detector([5, 4, 3, 2, 3, -5, 2, -7, 0, 0, 0, -1, 0], 0) self.assertEqual(zcd, 3)
def test_value_crossing_detector5(self): """ Test the case where 3 crossings have occurred but it lingers on zero (i.e. not crossing) """ zcd = value_crossing_detector([5, 4, 3, 2, 3, -5, 2, -7, 0, 0, 0], 0) self.assertEqual(zcd, 3)