Skip to content

Commit

Permalink
Merge pull request #43 from online-judge-tools/fix/add-tests-mod
Browse files Browse the repository at this point in the history
Add more tests about constants detection
  • Loading branch information
kmyk authored Aug 15, 2020
2 parents 727f904 + 13f8d83 commit de14134
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion tests/analyzer_constants.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
import unittest

import onlinejudge_template.analyzer.constants as analyzer
from onlinejudge_template.network import download_html
from onlinejudge_template.network import download_html, download_sample_cases
from onlinejudge_template.types import *


class TestConstantsDetectorAtCoder(unittest.TestCase):
"""TestConstantsDetectorAtCoder is a class for unit tests about the constants detection of AtCoder (with network access).
"""
def test_agc043_c(self) -> None:
"""In the statement, `,` are used as `998,244,353`.
"""
url = 'https://atcoder.jp/contests/agc043/tasks/agc043_c'
expected = {
"MOD": ConstantDecl(name="MOD", value="998244353", type=VarType.ValueInt),
}

html = download_html(url)
self.assertEqual(analyzer.list_constants_from_html(html), expected)


class TestConstantsDetectorCodeforces(unittest.TestCase):
"""TestConstantsDetectorCodeforces is a class for unit tests about the constants detection of Codeforces (with network access).
"""
def test_1395_a(self) -> None:
"""The answer is `Yes` or `No`.
"""

url = 'https://codeforces.com/contest/1395/problem/A'
expected = {
"YES": ConstantDecl(name="YES", value="Yes", type=VarType.String),
"NO": ConstantDecl(name="NO", value="No", type=VarType.String),
}

sample_cases = download_sample_cases(url)
self.assertEqual(analyzer.list_constants_from_sample_cases(sample_cases), expected)


class TestConstantsDetectorYukicoder(unittest.TestCase):
"""TestConstantsDetectorYukicoder is a class for unit tests about the constants detection of yukicoder (with network access).
"""
def test_no_1039(self) -> None:
"""In the statement, specified as 「$\bmod 10^9+7$で答えてください。」
"""

url = 'https://yukicoder.me/problems/no/1039'
expected = {
"MOD": ConstantDecl(name="MOD", value="1000000007", type=VarType.ValueInt),
Expand All @@ -25,3 +60,16 @@ def test_no_1073(self) -> None:

html = download_html(url)
self.assertEqual(analyzer.list_constants_from_html(html), expected)


class TestConstantsDetectorTopcoder(unittest.TestCase):
"""TestConstantsDetectorTopcoder is a class for unit tests about the constants detection of Topcoder (with network access).
"""
def test_apple_trees(self) -> None:
url = 'https://community.topcoder.com/stat?c=problem_statement&pm=11213'
expected = {
"MOD": ConstantDecl(name="MOD", value="1000000007", type=VarType.ValueInt),
}

html = download_html(url)
self.assertEqual(analyzer.list_constants_from_html(html), expected)

0 comments on commit de14134

Please sign in to comment.