mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 15:23:11 +02:00
feat: more easy unit tests
This commit is contained in:
parent
87523aabe2
commit
a52cef8dbc
@ -1 +1 @@
|
||||
<!DOCTYPE html><html><html> <table><tr><td align='left'>test </td><td style='border-left: 1px solid black'align='center'> 2 </td><td style='border-left: 1px solid black'align='right'> test </td></tr><tr><td align='left'></td></tr><tr><td align='left'>4 </td><td style='border-left: 1px solid black'align='center'> 5 </td><td style='border-left: 1px solid black'align='right'> 6 </td></tr><tr><td align='left'></td></tr><tr><td align='left'></td></tr> </table> </html>
|
||||
<!DOCTYPE html><html>Error!</tr></table>
|
||||
@ -44,6 +44,9 @@ def document_class_only_checks(latex_string):
|
||||
"""
|
||||
Checks only errors connected to document class
|
||||
"""
|
||||
if len(latex_string) < len("\\documentclass{"):
|
||||
print(latex_string + "Error! latex string to short to be document class!")
|
||||
return "Error!"
|
||||
if latex_string[len("\\documentclass{") - 1] != "{":
|
||||
print(latex_string + "Error! curly bracket not opened!")
|
||||
return "Error!"
|
||||
@ -355,7 +358,7 @@ def handle_single_column(column, column_style,
|
||||
f"""Error! column_number index: {column_number}
|
||||
is out of length of column_style: {column_style}"""
|
||||
)
|
||||
return "Error!"
|
||||
return "Error!", column_number
|
||||
return_string, column_number = handle_line_strings(
|
||||
line_string, column_style, column_number, return_string)
|
||||
|
||||
|
||||
24
program/unit_tests/test_code/test_command_name_check.py
Normal file
24
program/unit_tests/test_code/test_command_name_check.py
Normal file
@ -0,0 +1,24 @@
|
||||
from code.main import command_name_check
|
||||
|
||||
|
||||
def given_valid_then_empty():
|
||||
assert command_name_check("{documentclass}", "documentclass") == ""
|
||||
|
||||
|
||||
def given_valid_begin_then_empty():
|
||||
assert command_name_check("{begin}", "begin") == ""
|
||||
|
||||
|
||||
def given_invalid_then_error():
|
||||
assert command_name_check("{documentclasS}", "documentclass") == "Error!"
|
||||
|
||||
|
||||
def given_invalid_begin_then_error():
|
||||
assert command_name_check("{begIn}", "begin") == "Error!"
|
||||
|
||||
|
||||
def test_command_name_check():
|
||||
given_valid_then_empty()
|
||||
given_valid_begin_then_empty()
|
||||
given_invalid_then_error()
|
||||
given_invalid_begin_then_error()
|
||||
@ -0,0 +1,19 @@
|
||||
from code.main import document_class_only_checks
|
||||
|
||||
|
||||
def test_missing_curly_bracket():
|
||||
assert document_class_only_checks("\\documentclass") == "Error!"
|
||||
|
||||
|
||||
def test_missing_command_name():
|
||||
assert document_class_only_checks("\\otherclass{}") == "Error!"
|
||||
|
||||
|
||||
def test_correct_input():
|
||||
assert document_class_only_checks("\\documentclass{}") == ""
|
||||
|
||||
|
||||
def test_document_class_only_checks():
|
||||
test_missing_curly_bracket()
|
||||
test_missing_command_name()
|
||||
test_correct_input()
|
||||
21
program/unit_tests/test_code/test_generic_checks.py
Normal file
21
program/unit_tests/test_code/test_generic_checks.py
Normal file
@ -0,0 +1,21 @@
|
||||
from code.main import generic_checks
|
||||
|
||||
|
||||
def test_empty_string():
|
||||
assert generic_checks("") == "Error!"
|
||||
|
||||
|
||||
def test_no_curly_bracket():
|
||||
assert generic_checks(
|
||||
"latex_string_without_curly_bracket") == "Error!"
|
||||
|
||||
|
||||
def test_with_curly_bracket_at_end():
|
||||
assert generic_checks(
|
||||
"latex_string_with_curly_bracket}") == ""
|
||||
|
||||
|
||||
def test_generic_checks():
|
||||
test_empty_string()
|
||||
test_no_curly_bracket()
|
||||
test_with_curly_bracket_at_end()
|
||||
27
program/unit_tests/test_code/test_generic_checks_command.py
Normal file
27
program/unit_tests/test_code/test_generic_checks_command.py
Normal file
@ -0,0 +1,27 @@
|
||||
from code.main import generic_checks_command
|
||||
|
||||
|
||||
def test_empty_string():
|
||||
assert (generic_checks_command("")) == "Error!"
|
||||
|
||||
|
||||
def test_no_curly_bracket():
|
||||
assert (generic_checks_command(
|
||||
"latex_string_without_curly_bracket")) == "Error!"
|
||||
|
||||
|
||||
def test_no_slash_at_beginning():
|
||||
assert (generic_checks_command(
|
||||
"latex_string_without_slash_at_beginning}")) == "Error!"
|
||||
|
||||
|
||||
def test_with_slash_and_curly_bracket():
|
||||
assert (generic_checks_command(
|
||||
"\\latex_string_with_slash_and_curly_bracket}")) == ""
|
||||
|
||||
|
||||
def test_generic_checks_command():
|
||||
test_empty_string()
|
||||
test_no_curly_bracket()
|
||||
test_no_slash_at_beginning()
|
||||
test_with_slash_and_curly_bracket()
|
||||
Loading…
Reference in New Issue
Block a user