想要测试这个功能。你能为其中一种方法写一个测试吗?我已经阅读了有关JUnit测试的内容,但我真的不知道如何测试它。
public class SomeClass {
@Override
public void render(Screen screen)
{
int xTile = playerLook[0];
int yTile = playerLook[1];
int walkingSpeed = 4;
int flipTop = (numSteps >> walkingSpeed) & 1;
int flipBottom = (numSteps >> walkingSpeed) & 1;
if (movingDir == 1) {
xTile += 2;
}
else if (movingDir > 1) {
xTile += 4 + ((numSteps >> walkingSpeed) & 1) * 2;
flipTop = (movingDir - 1) % 2;
}
int modifier = 8 * scale;
int xOffset = x - modifier / 2;
int yOffset = y - modifier / 2 - 4;
if (isSwimming) {
int waterColor = 0;
yOffset += 4;
if (tickCount % 60 < 15) {
waterColor = Colors.get(-1, -1, 225, -1);
} else if ((15 <= tickCount % 60) && (tickCount % 60 < 30)) {
yOffset -= 1;
waterColor = Colors.get(-1, 225, 115, -1);
} else if ((30 <= tickCount % 60) && (tickCount % 60 < 45)) {
waterColor = Colors.get(-1, 115, -1, 225);
} else {
yOffset -= 1;
waterColor = Colors.get(-1, 225, 115, -1);
}
screen.render(xOffset, yOffset + 3, 0 + 27 * MAP_TILE_SIZE, waterColor, 0x00, 1);
screen.render(xOffset + 8, yOffset + 3, 0 + 27 * MAP_TILE_SIZE, waterColor, 0x01, 1);
}
screen.render(xOffset + (modifier * flipTop), yOffset, xTile + yTile * MAP_TILE_SIZE, color, flipTop, scale);
screen.render(xOffset + modifier - (modifier * flipTop), yOffset, (xTile + 1) + yTile * MAP_TILE_SIZE, color, flipTop, scale);
if (!isSwimming) {
screen.render(xOffset + (modifier * flipBottom), yOffset + modifier, xTile + (yTile + 1) * MAP_TILE_SIZE, color, flipBottom, scale);
screen.render(xOffset + modifier - (modifier * flipBottom), yOffset + modifier, (xTile + 1) + (yTile + 1) * MAP_TILE_SIZE, color, flipBottom, scale);
}
}
@Override
public boolean hasCollided(int xa, int ya)
{
int xMin = 0;
int xMax = 7;
int yMin = 3;
int yMax = 7;
for (int x = xMin; x < xMax; x++) {
if (isSolidTile(xa, ya, x, yMin)) {
return true;
}
}
for (int x = xMin; x < xMax; x++) {
if (isSolidTile(xa, ya, x, yMax)) {
return true;
}
}
for (int y = yMin; y < yMax; y++) {
if (isSolidTile(xa, ya, xMin, y)) {
return true;
}
}
for (int y = yMin; y < yMax; y++) {
if (isSolidTile(xa, ya, xMax, y)) {
return true;
}
}
return false;
}
}
真的很感激一些帮助。
谢谢你们