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

Tests double move #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion EGOI-2021/EGOI-2021-Moviento-Doble/examples/sample.in
2 changes: 1 addition & 1 deletion EGOI-2021/EGOI-2021-Moviento-Doble/examples/sample2.in
2 changes: 1 addition & 1 deletion EGOI-2021/EGOI-2021-Moviento-Doble/statements/es.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Asume que Alice y Bob van a jugar el resto del juego como se definió arriba. Ca

La primera línea de entrada contiene los números $n$ y $k$ — el número de piedras y el número de declaraciones que ya se han hecho.

Las siguientes $k$ líneas, describen las declaraciones en el orden en que se hicieron. Cada línea contiene 2 números eneros separados por espacio: los números de las piedras declaradas (ambos entre $1$ y $n$ inclusive y no necesariamente distintas).
Las siguientes $k$ líneas, describen las declaraciones en el orden en que se hicieron. Cada línea contiene 2 números enteros separados por espacio: los números de las piedras declaradas (ambos entre $1$ y $n$ inclusive y no necesariamente distintas).

Nota que cuando $k < n + 1$ el siguiente jugador en hacer una declaración depende de la paridad de $k$.

Expand Down
4 changes: 2 additions & 2 deletions EGOI-2021/EGOI-2021-Moviento-Doble/testplan
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sample 100
sample2 0
sample.sub1 100
sample2.sub4 0
65 changes: 65 additions & 0 deletions EGOI-2021/EGOI-2021-Moviento-Doble/tests/test-validator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# too-many-locals
# pylint: disable=R0914
# too-many-statements
# pylint: disable=R0915

import sys
import re
import unittest
from collections import deque
from omegaup.validator import validatortest


class Test(unittest.TestCase):

def test(self):
case_name = sys.argv[1]
if not any(f'sub{i}' in case_name for i in range(1, 6)):
self.fail(f"Invalid case name: {case_name}")

with open('data.in', 'r') as handle:
original_input = handle.read()

lines = original_input.split('\n')
self.assertEqual(lines[-1], '')
lines.pop()

regex = re.compile(r'^(\d+) (\d+)$')
self.assertTrue(regex.match(lines[0]))

# Verificar tamaño de archivo

lines[0] = lines[0].split(' ')
n = int(lines[0][0])
k = int(lines[0][1])

self.assertEqual(len(lines), k + 1)

# Definir limites

lim_n = 35
lim_k = lim_n + 1

if 'sub1' in case_name:
lim_n = 4
elif 'sub2' in case_name:
lim_n = 10
elif 'sub3' in case_name:
lim_n = 25
elif 'sub4' in case_name:
lim_k = 0

self.assertTrue(1 <= n <= lim_n)
self.assertTrue(0 <= k <= lim_k)

regex2 = re.compile(r'^(\d+) (\d+)$')
for line in lines[1:]:
self.assertTrue(regex2.match(line))
arr = line.split(' ')
self.assertTrue(1 <= int(arr[0]) <= n and 1 <= int(arr[1]) <= n)

if __name__ == '__main__':
validatortest.main()
3 changes: 3 additions & 0 deletions EGOI-2021/EGOI-2021-Moviento-Doble/tests/tests.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"inputs": {
"filename": "test-validator.py"
},
"max_score": 100
}
3 changes: 3 additions & 0 deletions problems.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
},
{
"path": "2022/selectivo-dia-2/OFMI-2022-Bruna"
},
{
"path": "EGOI-2021/EGOI-2021-Moviento-Doble"
}
]
}