Exemple #1
0
    def test_exclusions_extensive(self):
        """Test IntegerSequence methods for sequences with exclusions."""
        point_0 = IntegerPoint(0)
        point_1 = IntegerPoint(1)
        point_2 = IntegerPoint(2)
        point_3 = IntegerPoint(3)
        point_4 = IntegerPoint(4)

        sequence = IntegerSequence('R/P1!3', 1, 5)
        self.assertFalse(sequence.is_on_sequence(point_3))
        self.assertFalse(sequence.is_valid(point_3))
        self.assertEqual(sequence.get_prev_point(point_3), point_2)
        self.assertEqual(sequence.get_prev_point(point_4), point_2)
        self.assertEqual(sequence.get_nearest_prev_point(point_3), point_2)
        self.assertEqual(sequence.get_nearest_prev_point(point_3), point_2)
        self.assertEqual(sequence.get_next_point(point_3), point_4)
        self.assertEqual(sequence.get_next_point(point_2), point_4)
        self.assertEqual(sequence.get_next_point_on_sequence(point_3), point_4)
        self.assertEqual(sequence.get_next_point_on_sequence(point_2), point_4)

        sequence = IntegerSequence('R/P1!1', 1, 5)
        self.assertEqual(sequence.get_first_point(point_1), point_2)
        self.assertEqual(sequence.get_first_point(point_0), point_2)
        self.assertEqual(sequence.get_start_point(), point_2)

        sequence = IntegerSequence('R/P1!5', 1, 5)
        self.assertEqual(sequence.get_stop_point(), point_4)
Exemple #2
0
    def test_multiple_exclusions_extensive(self):
        """Tests IntegerSequence methods for sequences with multi-exclusions"""
        points = [IntegerPoint(i) for i in range(10)]
        sequence = IntegerSequence('R/P1!(2,3,7)', 1, 10)
        self.assertFalse(sequence.is_on_sequence(points[3]))
        self.assertFalse(sequence.is_valid(points[3]))
        self.assertEqual(sequence.get_prev_point(points[3]), points[1])
        self.assertEqual(sequence.get_prev_point(points[4]), points[1])
        self.assertEqual(sequence.get_nearest_prev_point(points[3]), points[1])
        self.assertEqual(sequence.get_nearest_prev_point(points[4]), points[1])
        self.assertEqual(sequence.get_next_point(points[3]), points[4])
        self.assertEqual(sequence.get_next_point(points[2]), points[4])
        self.assertEqual(sequence.get_next_point_on_sequence(
            points[3]),
            points[4])
        self.assertEqual(sequence.get_next_point_on_sequence(
            points[6]),
            points[8])

        sequence = IntegerSequence('R/P1!(1,3,4)', 1, 10)
        self.assertEqual(sequence.get_first_point(points[1]), points[2])
        self.assertEqual(sequence.get_first_point(points[0]), points[2])
        self.assertEqual(sequence.get_start_point(), points[2])

        sequence = IntegerSequence('R/P1!(8,9,10)', 1, 10)
        self.assertEqual(sequence.get_stop_point(), points[7])
Exemple #3
0
    def test_multiple_exclusions_extensive(self):
        """Tests IntegerSequence methods for sequences with multi-exclusions"""
        points = [IntegerPoint(i) for i in range(10)]
        sequence = IntegerSequence('R/P1!(2,3,7)', 1, 10)
        self.assertFalse(sequence.is_on_sequence(points[3]))
        self.assertFalse(sequence.is_valid(points[3]))
        self.assertEqual(sequence.get_prev_point(points[3]), points[1])
        self.assertEqual(sequence.get_prev_point(points[4]), points[1])
        self.assertEqual(sequence.get_nearest_prev_point(points[3]), points[1])
        self.assertEqual(sequence.get_nearest_prev_point(points[4]), points[1])
        self.assertEqual(sequence.get_next_point(points[3]), points[4])
        self.assertEqual(sequence.get_next_point(points[2]), points[4])
        self.assertEqual(sequence.get_next_point_on_sequence(
            points[3]),
            points[4])
        self.assertEqual(sequence.get_next_point_on_sequence(
            points[6]),
            points[8])

        sequence = IntegerSequence('R/P1!(1,3,4)', 1, 10)
        self.assertEqual(sequence.get_first_point(points[1]), points[2])
        self.assertEqual(sequence.get_first_point(points[0]), points[2])
        self.assertEqual(sequence.get_start_point(), points[2])

        sequence = IntegerSequence('R/P1!(8,9,10)', 1, 10)
        self.assertEqual(sequence.get_stop_point(), points[7])
Exemple #4
0
    def test_exclusions_extensive(self):
        """Test IntegerSequence methods for sequences with exclusions."""
        point_0 = IntegerPoint(0)
        point_1 = IntegerPoint(1)
        point_2 = IntegerPoint(2)
        point_3 = IntegerPoint(3)
        point_4 = IntegerPoint(4)

        sequence = IntegerSequence('R/P1!3', 1, 5)
        self.assertFalse(sequence.is_on_sequence(point_3))
        self.assertFalse(sequence.is_valid(point_3))
        self.assertEqual(sequence.get_prev_point(point_3), point_2)
        self.assertEqual(sequence.get_prev_point(point_4), point_2)
        self.assertEqual(sequence.get_nearest_prev_point(point_3), point_2)
        self.assertEqual(sequence.get_nearest_prev_point(point_3), point_2)
        self.assertEqual(sequence.get_next_point(point_3), point_4)
        self.assertEqual(sequence.get_next_point(point_2), point_4)
        self.assertEqual(sequence.get_next_point_on_sequence(point_3), point_4)
        self.assertEqual(sequence.get_next_point_on_sequence(point_2), point_4)

        sequence = IntegerSequence('R/P1!1', 1, 5)
        self.assertEqual(sequence.get_first_point(point_1), point_2)
        self.assertEqual(sequence.get_first_point(point_0), point_2)
        self.assertEqual(sequence.get_start_point(), point_2)

        sequence = IntegerSequence('R/P1!5', 1, 5)
        self.assertEqual(sequence.get_stop_point(), point_4)