def test__find_convex_hull__when_three_points__then_these_points_are_hull(): # given points = [Point2D(1.0, -1.0), Point2D(5.0, 1.0), Point2D(3.0, 4.0)] # when result = find_convex_hull(points) # then assert_that(result).is_equal_to(points)
def test__find_closest_points__when_three_points__then_pair_of_closest_points( ): # when result = find_closest_points( [Point2D(3, 2), Point2D(1, 1), Point2D(7, 0)]) # then assert_that(result).is_equal_to((Point2D(1, 1), Point2D(3, 2)))
def test__find_closest_points__when_multiple_points__then_pair_of_closest_points( ): # when result = find_closest_points([ Point2D(1, 1), Point2D(-2, 2), Point2D(-4, 4), Point2D(3, -3), Point2D(0, -5), Point2D(1, 0), Point2D(-7, 2), Point2D(4, 5) ]) # then assert_that(result).is_equal_to((Point2D(1, 1), Point2D(1, 0)))
def test__translate__when_zero_vector__then_same_point(): # given point = Point2D(13.5, 6.5) # when result = translate(point, Vector2D(0.0, 0.0)) # then assert_that(result).is_equal_to(point)
def test__distance__when_same_point__then_zero(): # given point = Point2D(13.5, 6.5) # when result = distance(point, point) # then assert_that(result).is_equal_to(0.0)
def test__sorted_by_angle__when_equal_angles__then_compare_radius(): # given sequence = [ Point2D(0.0, 0.0), Point2D(1.0, 1.0), Point2D(-2.0, -2.0), Point2D(-3.0, -3.0), Point2D(4.0, 4.0) ] # when result = sorted_by_angle(sequence) # then assert_that(result).is_instance_of(list) assert_that(result).is_equal_to([ Point2D(0.0, 0.0), Point2D(1.0, 1.0), Point2D(4.0, 4.0), Point2D(-2.0, -2.0), Point2D(-3.0, -3.0) ])
def test__find_closest_points__when_two_points__then_these_points(): # when result = find_closest_points([Point2D(2, 2), Point2D(4, 4)]) # then assert_that(result).is_equal_to((Point2D(2, 2), Point2D(4, 4)))
def test__find_closest_points__when_one_point__then_this_point(): # when result = find_closest_points([Point2D(2, 2)]) # then assert_that(result).is_equal_to((Point2D(2, 2), Point2D(2, 2)))
def test__between__then_vector_from_begin_to_end(): # when result = Vector2D.between(Point2D(2.4, 7.8), Point2D(-1.5, 13.2)) # then assert_that(result).is_equal_to(Vector2D(-3.9, 5.4))
def test__find_convex_hull__when_multiple_points_are_collinear__then_inner_points_omitted(): # when result = find_convex_hull( [Point2D(-1, -3), Point2D(-3, -3), Point2D(-3, -1), Point2D(2, -3), Point2D(-3, 5), Point2D(0, -3), Point2D(7, -3), Point2D(-3, -2)]) # then assert_that(result).is_equal_to([Point2D(-3, -3), Point2D(7, -3), Point2D(-3, 5)])
def test__find_convex_hull__then_points_in_hull(): # when result = find_convex_hull( [Point2D(1, -3), Point2D(-4, 6), Point2D(-5, -7), Point2D(-8, -7), Point2D(-3, -4), Point2D(5, 9), Point2D(-1, -8), Point2D(-5, 10), Point2D(8, 0), Point2D(3, -6), Point2D(-2, 1), Point2D(-2, 8), Point2D(10, 2), Point2D(6, 3), Point2D(-7, 7), Point2D(6, -4)]) # then assert_that(result).is_equal_to( [Point2D(-8, -7), Point2D(-1, -8), Point2D(3, -6), Point2D(6, -4), Point2D(10, 2), Point2D(5, 9), Point2D(-5, 10), Point2D(-7, 7)])
def test__find_convex_hull__when_two_points__then_empty(): # when result = find_convex_hull([Point2D(2.0, 3.0), Point2D(3.0, 2.0)]) # then assert_that(result).is_length(0)
def test__sorted_by_angle__then_new_list_sorted_ascending(): # given sequence = [ Point2D(0, 0), Point2D(-2, -3), Point2D(-3, -2), Point2D(3, -2), Point2D(-2, 3), Point2D(3, 2), Point2D(2, -3), Point2D(2, 3), Point2D(-3, 2) ] # when result = sorted_by_angle(sequence) # then assert_that(result).is_instance_of(list) assert_that(result).is_equal_to([ Point2D(0, 0), Point2D(3, 2), Point2D(2, 3), Point2D(-2, 3), Point2D(-3, 2), Point2D(-3, -2), Point2D(-2, -3), Point2D(2, -3), Point2D(3, -2) ])
def test__sorted_by_y__when_tuple__then_new_list_sorted_stably_ascending(): # given sequence = (Point2D(0.0, 0.0), Point2D(-2.0, -3.0), Point2D(-3.0, 2.0), Point2D(2.0, 3.0), Point2D(3.0, -2.0), Point2D(-2.0, 3.0), Point2D(3.0, 2.0), Point2D(2.0, -3.0), Point2D(-3.0, -2.0)) # when result = sorted_by_y(sequence) # then assert_that(result).is_instance_of(list) assert_that(result).is_equal_to([ Point2D(-2.0, -3.0), Point2D(2.0, -3.0), Point2D(3.0, -2.0), Point2D(-3.0, -2.0), Point2D(0.0, 0.0), Point2D(-3.0, 2.0), Point2D(3.0, 2.0), Point2D(2.0, 3.0), Point2D(-2.0, 3.0) ])
def test__translate__then_point_translated(): # when result = translate(Point2D(13.7, 6.5), Vector2D(-10.4, 3.3)) # then assert_that(result).is_equal_to(Point2D(3.3, 9.8))
def test__distance__when_different_points__then_distance(): # when result = distance(Point2D(4.0, 5.0), Point2D(-2.0, -3.0)) # then assert_that(result).is_equal_to(10.0)