Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions core/test/processing/ShapeTests.java
Original file line number Diff line number Diff line change
@@ -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);
}
}