test011: Fix move() for very short moves (dx = 1, dy = 0, or vice versa)
diff --git a/tests/test011.c b/tests/test011.c
index 1ec0898..f9c50f9 100644
--- a/tests/test011.c
+++ b/tests/test011.c
@@ -65,21 +65,27 @@
if (gen->x1 == gen->x2)
return 0;
- gen->e += gen->dy;
- if (gen->e >= 0) {
- gen->y1 += gen->sy;
- gen->e -= gen->dx;
+ if (gen->dy) {
+ gen->e += gen->dy;
+ if (gen->e >= 0) {
+ gen->y1 += gen->sy;
+ gen->e -= gen->dx;
+ }
}
+
gen->x1 += gen->sx;
} else {
if (gen->y1 == gen->y2)
return 0;
- gen->e += gen->dx;
- if (gen->e >= 0) {
- gen->x1 += gen->sx;
- gen->e -= gen->dy;
+ if (gen->dx) {
+ gen->e += gen->dx;
+ if (gen->e >= 0) {
+ gen->x1 += gen->sx;
+ gen->e -= gen->dy;
+ }
}
+
gen->y1 += gen->sy;
}
*x = gen->x1;