From 96fab27f9bfb12428687e461b858917ce57b424e Mon Sep 17 00:00:00 2001 From: aakritithecoder Date: Tue, 3 Mar 2026 18:14:18 +0530 Subject: [PATCH] Add ShapeTests for Processing4 --- core/test/processing/ShapeTests.java | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 core/test/processing/ShapeTests.java diff --git a/core/test/processing/ShapeTests.java b/core/test/processing/ShapeTests.java new file mode 100644 index 000000000..b146da472 --- /dev/null +++ b/core/test/processing/ShapeTests.java @@ -0,0 +1,35 @@ +package processing; +import org.junit.Test; +import static org.junit.Assert.*; +import processing.core.PGraphics; + +public class ShapeTests { + + @Test + public void testCanvasWidthAfterSetSize() { + // Create a PGraphics object and set its size + PGraphics pg = new PGraphics(); + pg.setSize(200, 100); // canvas size + + pg.beginDraw(); + pg.rect(10, 10, 100, 50); // draw a rectangle + pg.endDraw(); + + // Assert that the canvas width is 200 (not the rect width) + assertEquals(200, pg.width); + } + + @Test + public void testCanvasHeightAfterSetSize() { + // Create a PGraphics object and set its size + PGraphics pg = new PGraphics(); + pg.setSize(300, 150); // canvas size + + pg.beginDraw(); + pg.rect(20, 20, 50, 25); // draw another rectangle + pg.endDraw(); + + // Assert that the canvas height is 150 + assertEquals(150, pg.height); + } +} \ No newline at end of file