Change code style.

This commit is contained in:
youtaol
2013-08-19 11:30:56 +08:00
parent 4cf647b02c
commit cbd6d8158a
11 changed files with 97 additions and 85 deletions
@@ -67,6 +67,7 @@ public class TripStatisticsTest extends TestCase {
statistics.setMinGrade(-25.0); // Resulting min grade
statistics2.setMaxGrade(35.0); // Resulting max grade
statistics2.setMinGrade(0.0);
statistics2.setCalorie(50.0);
// Resulting bounds: -10000, 35000, 30000, -40000
statistics.setBounds(-10000, 20000, 30000, -40000);
@@ -89,6 +90,7 @@ public class TripStatisticsTest extends TestCase {
assertEquals(3575.0, statistics.getMaxElevation());
assertEquals(-25.0, statistics.getMinGrade());
assertEquals(35.0, statistics.getMaxGrade());
assertEquals(50.0, statistics.getCalorie());
}
public void testGetAverageSpeed() {
@@ -29,14 +29,15 @@ public class CalorieUtilsTest extends TestCase {
Location start = new Location(LocationManager.GPS_PROVIDER);
Location stop = new Location(LocationManager.GPS_PROVIDER);
private double grade = 10;
private double grade = 10.0;
private int weight = 20;
private final long TIME_INTERVAL = 1000l;
@Override
protected void setUp() throws Exception {
super.setUp();
// Make the time interval is not 0.
stop.setTime(start.getTime() + 1000);
// Make the time interval is not 0
stop.setTime(start.getTime() + TIME_INTERVAL);
}
/**
@@ -53,9 +54,11 @@ public class CalorieUtilsTest extends TestCase {
* Checks whether using foot calculation equation while grade is negative.
*/
public void testGetCalories_footNegativeGrade() {
double actual = CalorieUtils.getCalories(start, stop, -5, weight,
double actualGrade = -5;
double expectGrade = 0;
double actual = CalorieUtils.getCalories(start, stop, actualGrade, weight,
CalorieUtils.ActivityType.FOOT);
double expected = CalorieUtils.calculateExpenditureFoot(start, stop, 0, weight);
double expected = CalorieUtils.calculateExpenditureFoot(start, stop, expectGrade, weight);
assertEquals(expected, actual);
}
@@ -83,9 +86,11 @@ public class CalorieUtilsTest extends TestCase {
* Checks using walking VO2 equation.
*/
public void testGetVO2_walking() {
double actual = CalorieUtils.getVO2(CalorieUtils.CRTICAL_SPEED_RUNNING / 2, grade);
double expected = CalorieUtils.calculateWalkingVO2(CalorieUtils.CRTICAL_SPEED_RUNNING / 2,
grade);
// Test at half the critical speed
double footSpeed = CalorieUtils.CRTICAL_SPEED_RUNNING / 2.0;
double actual = CalorieUtils.getVO2(footSpeed, grade);
double expected = CalorieUtils.calculateWalkingVO2(footSpeed, grade);
assertEquals(expected, actual);
}