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();
Comment on lines +6 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing PGraphics please update the class name, and place this in the core/test/processing/core folder

pg.setSize(200, 100); // canvas size

pg.beginDraw();
pg.rect(10, 10, 100, 50); // draw a rectangle
pg.endDraw();

Comment on lines +14 to +17
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessary since you are testing setSize

// 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);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test of the pg height can be done in the other test function that tests width.