Skip to content

Commit

Permalink
bug forgetting to set score to 0 if test passed
Browse files Browse the repository at this point in the history
  • Loading branch information
tkutcher committed Jan 31, 2019
1 parent 77d43c2 commit bb6a405
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public void grade(List<GradedTestResult> l) {
for (GradedTestResult r : l) {
if (!r.passed()) {
this.deductedPoints += this.deduct(r);
} else {
r.setScore(0);
}
r.setPoints(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ private static GradedTestResult failedGradedTestResult(double points) {
return r;
}

private static GradedTestResult successfulGradedTestResult(double points) {
GradedTestResult r = new GradedTestResult("", "", points, HIDDEN);
r.setPassed(true);
r.setScore(points);
return r;
}

@Test
public void noDeductions() {
List<GradedTestResult> l = new ArrayList<>();
l.add(new GradedTestResult("", "", 2.0, HIDDEN));
l.add(new GradedTestResult("", "", 2.0, HIDDEN));
l.add(new GradedTestResult("", "", 2.0, HIDDEN));
l.add(new GradedTestResult("", "", 2.0, HIDDEN));
l.add(successfulGradedTestResult(2.0));
l.add(successfulGradedTestResult(2.0));
l.add(successfulGradedTestResult(2.0));
l.add(successfulGradedTestResult(2.0));

this.unit.grade(l);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class GradescopeJsonObserverTest {

private GradescopeJsonObserver unit;
Expand Down

0 comments on commit bb6a405

Please sign in to comment.