add more tests
This commit is contained in:
@@ -33,3 +33,59 @@ sprite_quad_origin_center :: proc(t: ^testing.T) {
|
||||
testing.expect_value(t, o.x, f32(350))
|
||||
testing.expect_value(t, o.y, f32(400))
|
||||
}
|
||||
|
||||
@(test)
|
||||
frame_uvs_unflipped :: proc(t: ^testing.T) {
|
||||
u0, v0, u1, v1 := frame_uvs({10, 20, 30, 40}, 100, 200, false)
|
||||
testing.expect_value(t, u0, f32(0.1))
|
||||
testing.expect_value(t, v0, f32(0.1))
|
||||
testing.expect_value(t, u1, f32(0.4))
|
||||
testing.expect_value(t, v1, f32(0.3))
|
||||
testing.expect(t, u0 < u1)
|
||||
}
|
||||
|
||||
@(test)
|
||||
frame_uvs_flipped :: proc(t: ^testing.T) {
|
||||
a0, _, a1, _ := frame_uvs({10, 20, 30, 40}, 100, 200, false)
|
||||
b0, v0, b1, v1 := frame_uvs({10, 20, 30, 40}, 100, 200, true)
|
||||
testing.expect_value(t, b0, a1)
|
||||
testing.expect_value(t, b1, a0)
|
||||
testing.expect_value(t, v0, f32(0.1))
|
||||
testing.expect_value(t, v1, f32(0.3))
|
||||
}
|
||||
|
||||
@(test)
|
||||
sprite_feet_quad_no_flip :: proc(t: ^testing.T) {
|
||||
// feet (400,500), source 100x200, pivot feet, trim (10,20), packed 80x160
|
||||
x0, y0, x1, y1 := sprite_feet_quad(
|
||||
{400, 500},
|
||||
100,
|
||||
200,
|
||||
{10, 20},
|
||||
{80, 160},
|
||||
{0.5, 1.0},
|
||||
false,
|
||||
)
|
||||
testing.expect_value(t, x0, f32(360)) // 400 - 50 + 10
|
||||
testing.expect_value(t, y0, f32(320)) // 500 - 200 + 20
|
||||
testing.expect_value(t, x1, f32(440))
|
||||
testing.expect_value(t, y1, f32(480))
|
||||
}
|
||||
|
||||
@(test)
|
||||
sprite_feet_quad_flip_x :: proc(t: ^testing.T) {
|
||||
x0, y0, x1, y1 := sprite_feet_quad(
|
||||
{400, 500},
|
||||
100,
|
||||
200,
|
||||
{5, 20},
|
||||
{80, 160},
|
||||
{0.5, 1.0},
|
||||
true,
|
||||
)
|
||||
// canvas_left = 350; trim_x_draw = 100 - 5 - 80 = 15 → x0 = 365
|
||||
testing.expect_value(t, x0, f32(365))
|
||||
testing.expect_value(t, y0, f32(320))
|
||||
testing.expect_value(t, x1, f32(445))
|
||||
testing.expect_value(t, y1, f32(480))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user