File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments