Skip to content

Commit c2ccab3

Browse files
tests
1 parent b473f0b commit c2ccab3

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/draw_test.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6311,6 +6311,45 @@ class to add any draw.arc specific tests to.
63116311
"""
63126312

63136313

6314+
class DrawFloodFillMixin(unittest.TestCase):
6315+
"""Mixin tests for flood fill.
6316+
"""
6317+
6318+
def test_flood_fill(self):
6319+
"""Ensures flood fill fills with solid color"""
6320+
surf = pygame.Surface((100, 100))
6321+
surf.fill((0,0,0))
6322+
6323+
pygame.draw.line (surf, (255,0,0), (10,10), (90,90), 5)
6324+
6325+
self.assertEqual(surf.get_at((10,10)), (255,0,0), "line drawing precondition")
6326+
self.assertEqual(surf.get_at((90,90)), (255,0,0), "line drawing precondition")
6327+
6328+
pygame.draw.flood_fill(surf, (255,255,255), (90, 90))
6329+
6330+
self.assertEqual(surf.get_at((90,90)), (255,255,255), "flood fill start point")
6331+
self.assertEqual(surf.get_at((10,10)), (255,255,255), "flood fill reaching the end")
6332+
6333+
6334+
def test_flood_pattern(self):
6335+
"""Ensures flood fill fills in a pattern"""
6336+
surf = pygame.Surface((100, 100))
6337+
surf.fill((0,0,0))
6338+
6339+
pattern = pygame.Surface((2, 2))
6340+
pattern.fill((255,255,255))
6341+
pattern.set_at((0,0), (255,0,0))
6342+
pattern.set_at((1,1), (0,0,255))
6343+
6344+
pygame.draw.line (surf, (0,0,0), (5,95), (95,5))
6345+
pygame.draw.line (surf, (0,0,0), (50, 0), (50,95))
6346+
6347+
pygame.draw.flood_fill(surf, pattern, (95, 95))
6348+
6349+
for pt in [(0,0),(0,1),(1,0),(1,1)]:
6350+
self.assertEqual(surf.get_at(pt), pattern.get_at(pt), pt)
6351+
6352+
63146353
### Draw Module Testing #######################################################
63156354

63166355

0 commit comments

Comments
 (0)