-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
Hightail/test/org/hightail/parsers/contest/AtCoderContestParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
Hightail/test/org/hightail/parsers/task/AtCoderTaskParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters