Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only substring 5, if the string contains "No - ". #951

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/edu/csus/ecs/pc2/core/util/JSONTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ public ObjectNode convertToJSON(Judgement judgement) {
solved = true;
penalty = false;
} else {
name = name.substring(5, name.length());
if (name.startsWith("No - ")) {
name = name.substring(5, name.length());
}
Properties scoringProperties = model.getContestInformation().getScoringProperties();
if (judgement.getAcronym().equalsIgnoreCase("ce") || name.toLowerCase().contains("compilation error")
|| name.toLowerCase().contains("compile error")) {
Expand Down
32 changes: 32 additions & 0 deletions test/edu/csus/ecs/pc2/core/util/JSONToolTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.util;

import edu.csus.ecs.pc2.core.IInternalController;
import edu.csus.ecs.pc2.core.model.IInternalContest;
import edu.csus.ecs.pc2.core.model.Judgement;
import edu.csus.ecs.pc2.core.model.SampleContest;

/**
* Unit test.
*
* @author Douglas A. Lane, PC^2 Team, [email protected]
*/
public class JSONToolTest extends AbstractTestCase {

/**
* Test judgement not starting with "No - " github issue #950
*
* @throws Exception
*/
public void testIssue950failed() throws Exception {
SampleContest sampleContest = new SampleContest();
IInternalContest contest = sampleContest.createContest(2, 2, 12, 12, true);
String outputTestDirectory = getOutputDataDirectory();
IInternalController controller = sampleContest.createController(contest, outputTestDirectory, true, false); // creates StaticLog instance

Judgement judgementJE = new Judgement("JE", "JE");
contest.addJudgement(judgementJE);
JSONTool json_tool = new JSONTool(contest, controller);
json_tool.convertToJSON(judgementJE);
}
}
4 changes: 2 additions & 2 deletions test/edu/csus/ecs/pc2/services/core/JSONToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,11 @@ public void testConvertToJSONJudgement() throws Exception {
Judgement judgement = contest.getJudgements()[4];

String json = jsonTool.convertToJSON(judgement).toString();
// System.out.println("debug judgement "+json);
// System.out.println("debug judgement "+json);
// debug judgement {"id":"WA2","name":"ave no clue","penalty":true,"solved":false}

assertJSONStringValue(json, "id", "WA2");
assertJSONStringValue(json, "name", "ave no clue");
assertJSONStringValue(json, "name", "You have no clue"); // does not start with "No - "
assertJSONBooleanValue(json, "penalty", true);
assertJSONBooleanValue(json, "solved", false);

Expand Down
Loading