@@ -494,20 +494,25 @@ func testSprSize(t *testing.T, sprSize func(spriteNo int, x, y int, w, h float64
494
494
495
495
t .Run ("should draw sprite" , func (t * testing.T ) {
496
496
tests := map [string ]struct {
497
+ spriteNo int
497
498
w , h float64
498
499
x , y int
499
500
expectedScreenFile string
500
501
}{
501
- "sprite at (0,0,0.5,1.0)" : {w : 0.5 , h : 1.0 , expectedScreenFile : "spr_0_0_0.5_1.0.png" },
502
- "sprite at (0,0,1.0,0.5)" : {w : 1.0 , h : 0.5 , expectedScreenFile : "spr_0_0_1.0_0.5.png" },
503
- "sprite at (0,0,2.0,1.0)" : {w : 2.0 , h : 1.0 , expectedScreenFile : "spr_0_0_2.0_1.0.png" },
504
- "sprite at (0,0,1.0,2.0)" : {w : 1.0 , h : 2.0 , expectedScreenFile : "spr_0_0_1.0_2.0.png" },
505
- "sprite at (0,0,2.5,1.0)" : {w : 2.5 , h : 1.0 , expectedScreenFile : "spr_0_0_2.0_1.0.png" },
506
- "sprite at (0,0,1.0,2.5)" : {w : 1.0 , h : 2.5 , expectedScreenFile : "spr_0_0_1.0_2.0.png" },
507
- "sprite at (8,0,2.0,1.0)" : {x : 8 , w : 2.0 , h : 1.0 , expectedScreenFile : "spr_8_0_2.0_1.0.png" },
508
- "sprite at (0,8,1.0,2.0)" : {y : 8 , w : 1.0 , h : 2.0 , expectedScreenFile : "spr_0_8_1.0_2.0.png" },
509
- "sprite at (0,0,1.1,0.5)" : {w : 1.1 , h : 0.5 , expectedScreenFile : "spr_0_0_1.0_0.5.png" }, // should floor(w*8)
510
- "sprite at (0,0,0.5,1.1)" : {w : 0.5 , h : 1.1 , expectedScreenFile : "spr_0_0_0.5_1.0.png" }, // should floor(h*8)
502
+ "sprite at (0,0,0.5,1.0)" : {w : 0.5 , h : 1.0 , expectedScreenFile : "spr_0_0_0.5_1.0.png" },
503
+ "sprite at (0,0,1.0,0.5)" : {w : 1.0 , h : 0.5 , expectedScreenFile : "spr_0_0_1.0_0.5.png" },
504
+ "sprite at (0,0,2.0,1.0)" : {w : 2.0 , h : 1.0 , expectedScreenFile : "spr_0_0_2.0_1.0.png" },
505
+ "sprite at (0,0,1.0,2.0)" : {w : 1.0 , h : 2.0 , expectedScreenFile : "spr_0_0_1.0_2.0.png" },
506
+ "sprite at (0,0,2.5,1.0)" : {w : 2.5 , h : 1.0 , expectedScreenFile : "spr_0_0_2.0_1.0.png" },
507
+ "sprite at (0,0,1.0,2.5)" : {w : 1.0 , h : 2.5 , expectedScreenFile : "spr_0_0_1.0_2.0.png" },
508
+ "sprite at (8,0,2.0,1.0)" : {x : 8 , w : 2.0 , h : 1.0 , expectedScreenFile : "spr_8_0_2.0_1.0.png" },
509
+ "sprite at (0,8,1.0,2.0)" : {y : 8 , w : 1.0 , h : 2.0 , expectedScreenFile : "spr_0_8_1.0_2.0.png" },
510
+ "sprite at (0,0,1.1,0.5)" : {w : 1.1 , h : 0.5 , expectedScreenFile : "spr_0_0_1.0_0.5.png" }, // should floor(w*8)
511
+ "sprite at (0,0,0.5,1.1)" : {w : 0.5 , h : 1.1 , expectedScreenFile : "spr_0_0_0.5_1.0.png" }, // should floor(h*8)
512
+ "sprite 1 at (0,0,2.0,1.0)" : {spriteNo : 1 , w : 2.0 , h : 1.0 , expectedScreenFile : "spr_1_at_0_0_2.0_1.0.png" },
513
+ "sprite 1 at (0,0,1.9,1.0)" : {spriteNo : 1 , w : 1.9 , h : 1.0 , expectedScreenFile : "spr_1_at_0_0_2.0_1.0.png" },
514
+ "sprite 2 at (0,0,1.0,2.0)" : {spriteNo : 2 , w : 1.0 , h : 2.0 , expectedScreenFile : "spr_2_at_0_0_1.0_2.0.png" },
515
+ "sprite 2 at (0,0,1.0,1.9)" : {spriteNo : 2 , w : 1.0 , h : 1.9 , expectedScreenFile : "spr_2_at_0_0_1.0_2.0.png" },
511
516
}
512
517
for name , test := range tests {
513
518
t .Run (name , func (t * testing.T ) {
@@ -519,7 +524,7 @@ func testSprSize(t *testing.T, sprSize func(spriteNo int, x, y int, w, h float64
519
524
pi .BootOrPanic ()
520
525
expectedScreen := decodePNG (t , "internal/testimage/" + test .expectedScreenFile )
521
526
// when
522
- sprSize (0 , test .x , test .y , test .w , test .h )
527
+ sprSize (test . spriteNo , test .x , test .y , test .w , test .h )
523
528
// then
524
529
assert .Equal (t , expectedScreen .Pixels , pi .ScreenData )
525
530
})
0 commit comments