/*******************************************************************************
* Copyright (c) 2001, 2010 Mathew A. Nelson and Robocode contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://robocode.sourceforge.net/license/epl-v10.html
*
* Contributors:
* Pavel Savara
* - Initial implementation
*******************************************************************************/
package net.sf.robocode.test.robots;
import junit.framework.Assert;
import net.sf.robocode.test.helpers.RobocodeTestBed;
import org.junit.Test;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
/**
* @author Pavel Savara (original)
*/
public class TestWatchBullet extends RobocodeTestBed {
@Test
public void run() {
super.run();
}
public String getRobotNames() {
return "tested.robots.WatchBullets,sample.SittingDuck";
}
public void onTurnEnded(TurnEndedEvent event) {
super.onTurnEnded(event);
final IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[0];
final String out = robot.getOutputStreamSnapshot();
final int time = event.getTurnSnapshot().getTurn();
test(out, time, 33, "33 483.3423438731687 132.35505419382304 347.8464407127698 true");
test(out, time, 45, "45 455.5520553019654 261.3965198594347 347.8464407127698 true");
test(out, time, 51, "51 441.6569110163638 325.91725269224054 347.8464407127698 true");
test(out, time, 52, "52 439.34105363543017 336.67070816437484 347.8464407127698 false");
}
private void test(String out, int timecurr, int timeWatch, String in) {
if (timecurr == timeWatch) {
Assert.assertTrue("got: " + out + ", expected: " + in, out.contains(in));
}
}
}