@@ -47,26 +47,26 @@ TEST(PathTest, PathBuilderSetsCorrectContourPropertiesForAddCommands) {
4747 Path path = PathBuilder{}.AddCircle ({100 , 100 }, 50 ).TakePath ();
4848 ContourComponent contour;
4949 path.GetContourComponentAtIndex (0 , contour);
50- ASSERT_POINT_NEAR (contour.destination , Point (100 , 50 ));
51- ASSERT_TRUE (contour.is_closed );
50+ EXPECT_POINT_NEAR (contour.destination , Point (100 , 50 ));
51+ EXPECT_TRUE (contour.is_closed );
5252 }
5353
5454 {
5555 Path path =
5656 PathBuilder{}.AddOval (Rect::MakeXYWH (100 , 100 , 100 , 100 )).TakePath ();
5757 ContourComponent contour;
5858 path.GetContourComponentAtIndex (0 , contour);
59- ASSERT_POINT_NEAR (contour.destination , Point (150 , 100 ));
60- ASSERT_TRUE (contour.is_closed );
59+ EXPECT_POINT_NEAR (contour.destination , Point (150 , 100 ));
60+ EXPECT_TRUE (contour.is_closed );
6161 }
6262
6363 {
6464 Path path =
6565 PathBuilder{}.AddRect (Rect::MakeXYWH (100 , 100 , 100 , 100 )).TakePath ();
6666 ContourComponent contour;
6767 path.GetContourComponentAtIndex (0 , contour);
68- ASSERT_POINT_NEAR (contour.destination , Point (100 , 100 ));
69- ASSERT_TRUE (contour.is_closed );
68+ EXPECT_POINT_NEAR (contour.destination , Point (100 , 100 ));
69+ EXPECT_TRUE (contour.is_closed );
7070 }
7171
7272 {
@@ -75,8 +75,8 @@ TEST(PathTest, PathBuilderSetsCorrectContourPropertiesForAddCommands) {
7575 .TakePath ();
7676 ContourComponent contour;
7777 path.GetContourComponentAtIndex (0 , contour);
78- ASSERT_POINT_NEAR (contour.destination , Point (110 , 100 ));
79- ASSERT_TRUE (contour.is_closed );
78+ EXPECT_POINT_NEAR (contour.destination , Point (110 , 100 ));
79+ EXPECT_TRUE (contour.is_closed );
8080 }
8181
8282 {
@@ -86,8 +86,8 @@ TEST(PathTest, PathBuilderSetsCorrectContourPropertiesForAddCommands) {
8686 .TakePath ();
8787 ContourComponent contour;
8888 path.GetContourComponentAtIndex (0 , contour);
89- ASSERT_POINT_NEAR (contour.destination , Point (110 , 100 ));
90- ASSERT_TRUE (contour.is_closed );
89+ EXPECT_POINT_NEAR (contour.destination , Point (110 , 100 ));
90+ EXPECT_TRUE (contour.is_closed );
9191 }
9292
9393 // Open shapes.
@@ -454,6 +454,34 @@ TEST(PathTest, SimplePath) {
454454 });
455455}
456456
457+ TEST (PathTest, RepeatCloseDoesNotAddNewLines) {
458+ PathBuilder builder;
459+ auto path = builder.LineTo ({0 , 10 })
460+ .LineTo ({10 , 10 })
461+ .Close () // Returns to (0, 0)
462+ .Close () // No Op
463+ .Close () // Still No op
464+ .TakePath ();
465+
466+ EXPECT_EQ (path.GetComponentCount (), 5u );
467+ EXPECT_EQ (path.GetComponentCount (Path::ComponentType::kLinear ), 3u );
468+ EXPECT_EQ (path.GetComponentCount (Path::ComponentType::kContour ), 2u );
469+ }
470+
471+ TEST (PathTest, CloseAfterMoveDoesNotAddNewLines) {
472+ PathBuilder builder;
473+ auto path = builder.LineTo ({0 , 10 })
474+ .LineTo ({10 , 10 })
475+ .MoveTo ({30 , 30 }) // Moves to (30, 30)
476+ .Close () // No Op
477+ .Close () // Still No op
478+ .TakePath ();
479+
480+ EXPECT_EQ (path.GetComponentCount (), 4u );
481+ EXPECT_EQ (path.GetComponentCount (Path::ComponentType::kLinear ), 2u );
482+ EXPECT_EQ (path.GetComponentCount (Path::ComponentType::kContour ), 2u );
483+ }
484+
457485TEST (PathTest, CanBeCloned) {
458486 PathBuilder builder;
459487 builder.MoveTo ({10 , 10 });
0 commit comments