Skip to content

Commit 96fab27

Browse files
Add ShapeTests for Processing4
1 parent 4206874 commit 96fab27

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package processing;
2+
import org.junit.Test;
3+
import static org.junit.Assert.*;
4+
import processing.core.PGraphics;
5+
6+
public class ShapeTests {
7+
8+
@Test
9+
public void testCanvasWidthAfterSetSize() {
10+
// Create a PGraphics object and set its size
11+
PGraphics pg = new PGraphics();
12+
pg.setSize(200, 100); // canvas size
13+
14+
pg.beginDraw();
15+
pg.rect(10, 10, 100, 50); // draw a rectangle
16+
pg.endDraw();
17+
18+
// Assert that the canvas width is 200 (not the rect width)
19+
assertEquals(200, pg.width);
20+
}
21+
22+
@Test
23+
public void testCanvasHeightAfterSetSize() {
24+
// Create a PGraphics object and set its size
25+
PGraphics pg = new PGraphics();
26+
pg.setSize(300, 150); // canvas size
27+
28+
pg.beginDraw();
29+
pg.rect(20, 20, 50, 25); // draw another rectangle
30+
pg.endDraw();
31+
32+
// Assert that the canvas height is 150
33+
assertEquals(150, pg.height);
34+
}
35+
}

0 commit comments

Comments
 (0)