Skip to content

Commit

Permalink
#201: add a utility to add test cases using --json
Browse files Browse the repository at this point in the history
  • Loading branch information
kmyk committed Dec 17, 2018
1 parent 9373eec commit d92ca11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@
import sys
import tempfile

def snippet_call_download(self, url, files, is_system=False):
def get_files_from_json(samples):
files = {}
for i, sample in enumerate(samples):
for ext in ('in', 'out'):
if 'name' in sample:
name = sample['name'] + '.' + ext
else:
name = 'sample-{}.{}'.format(i + 1, ext)
files[name] = sample[ext + 'put']
return files

def snippet_call_download(self, url, files, is_system=False, type='files'):
assert type in 'files' or 'json'
if type == 'json':
files = get_files_from_json(files)

cwd = os.getcwd()
ojtools = os.path.join( cwd, 'oj' )
try:
Expand Down
6 changes: 6 additions & 0 deletions tests/download_atcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ def test_call_download_atcoder_agc029_a(self):
'sample-2.in': '5bdcc020d84b69530288143e38b643b9',
'sample-2.out': '9ae0ea9e3c9c6e1b9b6252c8395efdc1',
})
def test_call_download_atcoder_abc114_c(self):
self.snippet_call_download('https://atcoder.jp/contests/abc114/tasks/abc114_c', [
{"input": "575\n", "output": "4\n"},
{"input": "3600\n", "output": "13\n"},
{"input": "999999999\n", "output": "26484\n"},
], type='json')

0 comments on commit d92ca11

Please sign in to comment.