Skip to content

Commit

Permalink
add tests, update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dj3500 committed Feb 26, 2017
1 parent 0217374 commit 37d22b4
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.hightail.parsers.contest;

import java.util.ArrayList;
import org.hightail.AuthenticationInfo;
import org.hightail.Config;
import org.hightail.Problem;
import org.hightail.SupportedSites;
import org.htmlparser.util.ParserException;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

public class AtCoderContestParserTest {
private final String ATCODERUSERNAME = "hightail", ATCODERPASSWORD = "simplepassword123";

@BeforeClass
public static void setUpClass() {
Config.fillInUnsetValuesWithDefaults();
}

@Test
public void testPracticeWithCredentials() {
try {
final String url = "http://practice.contest.atcoder.jp"; // no slash at the end
AuthenticationInfo.setUsername(ATCODERUSERNAME);
AuthenticationInfo.setPassword(ATCODERPASSWORD);

ContestParser parser = SupportedSites.getContestParser(url);
ArrayList<Problem> problems = parser.getProblemListFromContestURL(url);
assertTrue(problems.size() >= 1);
} catch (ParserException | InterruptedException ex) {
fail("Exception was thrown.");
}
}


@Test
public void testAGCWithCredentials() {
try {
final String url = "https://agc010.contest.atcoder.jp/"; // has slash at the end and HTTPS
AuthenticationInfo.setUsername(ATCODERUSERNAME);
AuthenticationInfo.setPassword(ATCODERPASSWORD);

ContestParser parser = SupportedSites.getContestParser(url);
ArrayList<Problem> problems = parser.getProblemListFromContestURL(url);
assertTrue(problems.size() == 6);
} catch (ParserException | InterruptedException ex) {
fail("Exception was thrown.");
}
}

@Test
public void testAGCWithoutCredentials() {
try {
final String url = "http://agc010.contest.atcoder.jp/"; // has slash at the end
AuthenticationInfo.setUsername("");
AuthenticationInfo.setPassword("");

ContestParser parser = SupportedSites.getContestParser(url);
ArrayList<Problem> problems = parser.getProblemListFromContestURL(url);
assertTrue(problems.size() == 6);
} catch (ParserException | InterruptedException ex) {
fail("Exception was thrown.");
}
}

@Test
public void testMujinWithoutCredentials() {
try {
final String url = "http://mujin-pc-2017.contest.atcoder.jp/assignments"; // has "assignments" at the end
AuthenticationInfo.setUsername("");
AuthenticationInfo.setPassword("");

ContestParser parser = SupportedSites.getContestParser(url);
ArrayList<Problem> problems = parser.getProblemListFromContestURL(url);
assertTrue(problems.size() == 4);
} catch (ParserException | InterruptedException ex) {
fail("Exception was thrown.");
}
}
}

37 changes: 37 additions & 0 deletions Hightail/test/org/hightail/parsers/task/AtCoderTaskParserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.hightail.parsers.task;

import org.hightail.Config;
import org.hightail.Problem;
import org.hightail.SupportedSites;
import org.hightail.Testcase;
import org.htmlparser.util.ParserException;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

public class AtCoderTaskParserTest {

private final String URL = "http://arc069.contest.atcoder.jp/tasks/arc069_b",
SHORT_PROBLEM_NAME = "D",
EXPECTED_THIRD_INPUT = "10\noxooxoxoox",
EXPECTED_THIRD_OUTPUT = "SSWWSSSWWS";

@BeforeClass
public static void setUpClass() {
Config.fillInUnsetValuesWithDefaults();
}

@Test
public void testParseProblem() {
try {
TaskParser parser = SupportedSites.getTaskParser(URL);
Problem problem = parser.parse(URL);
assertEquals(SHORT_PROBLEM_NAME, problem.getName());
Testcase thirdTestcase = problem.getTestcase(2);
assertEquals(thirdTestcase.getInput(), EXPECTED_THIRD_INPUT);
assertEquals(thirdTestcase.getExpectedOutput(), EXPECTED_THIRD_OUTPUT);
} catch (ParserException | InterruptedException ex) {
fail("Exception was thrown.");
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A list of Hightail's features:
It supports the following online judges:
* CodeForces (incl. Gym)
* CodeChef (experimental)
* AtCoder (only past contests)
* AtCoder (now also live-running contests!)
* Jutge.org
* Open Kattis
* what other judges should we support? do you want to help?
Expand Down

0 comments on commit 37d22b4

Please sign in to comment.