| 68 | |
| 69 | template <bool success> |
| 70 | static void testMove(int move_dir, int x, int y, int dir, int face, |
| 71 | int dx, int dy, int tdir, int tface, |
| 72 | int freq, int speed, bool facing_locked) { |
| 73 | const MockGame mg(MockMap::ePassBlock20x15); |
| 74 | |
| 75 | auto& ch = *mg.GetEvent(1); |
| 76 | ch.SetX(x); |
| 77 | ch.SetY(y); |
| 78 | ch.SetDirection(dir); |
| 79 | ch.SetFacing(face); |
| 80 | ch.SetMoveSpeed(speed); |
| 81 | ch.SetMoveFrequency(freq); |
| 82 | const auto maxstop = ch.GetMaxStopCount(); |
| 83 | if (facing_locked) { |
| 84 | ch.SetFacingLocked(facing_locked); |
| 85 | } |
| 86 | |
| 87 | const auto tx = x + dx; |
| 88 | const auto ty = y + dy; |
| 89 | |
| 90 | CAPTURE(success); |
| 91 | CAPTURE(x); |
| 92 | CAPTURE(y); |
| 93 | CAPTURE(dx); |
| 94 | CAPTURE(dy); |
| 95 | |
| 96 | REQUIRE_EQ(ch.Move(move_dir), success); |
| 97 | |
| 98 | if (!success) { |
| 99 | testChar(ch, tx, ty, tdir, tface, 0, false, 0, 0, freq, speed, 0, maxstop); |
| 100 | return; |
| 101 | } |
| 102 | testChar(ch, tx, ty, tdir, tface, 256, false, 0, 0, freq, speed, 0, maxstop); |
| 103 | |
| 104 | const auto dt = 1 << (1 + speed); |
| 105 | |
| 106 | CAPTURE(dt); |
| 107 | for(int i = 256 - dt; i > 0; i -= dt) { |
| 108 | CAPTURE(i); |
| 109 | ForceUpdate(ch); |
| 110 | testChar(ch, tx, ty, tdir, tface, i, false, 0, 0, freq, speed, 0, maxstop); |
| 111 | } |
| 112 | |
| 113 | ForceUpdate(ch); |
| 114 | testChar(ch, tx, ty, tdir, tface, 0, false, 0, 0, freq, speed, 0, maxstop); |
| 115 | } |
| 116 | |
| 117 | TEST_CASE("Move") { |
| 118 | for (int freq = 1; freq <= 8; ++freq) { |
nothing calls this directly
no test coverage detected