1
0
standardize_test_format/test/test_standardize.py
Jon Michael Aanes 097d11875d
Some checks failed
Run Python tests (through Pytest) / Test (push) Successful in 23s
Verify Python project can be installed, loaded and have version checked / Test (push) Failing after 22s
Improve javadoc parsing
2025-02-27 17:00:52 +01:00

74 lines
1.8 KiB
Python

from standardize_test_format import standardize_java_text, PATTERN_JAVADOC
import re
INPUT_1 = """
@Test
@DisplayName("Invocations fail with callers without required permissions")
public void selectInvocationWithoutPermission() { }
"""
OUTPUT_1 = """
@Test
@DisplayName("Invocations fail with callers without required permissions")
public void invocationsFailWithCallersWithoutRequiredPermissions() { }
"""
INPUT_2 = """
/** Invocations fail with callers without required permissions. */
@Test
public void selectInvocationWithoutPermission() { }
"""
OUTPUT_2 = """
@Test
@DisplayName("Invocations fail with callers without required permissions")
public void invocationsFailWithCallersWithoutRequiredPermissions() { }
"""
INPUT_3 = """
@Test
public void helloWorldTest(
"""
OUTPUT_3 = """
@Test
@DisplayName("Hello World Test")
public void helloWorldTest(
"""
INPUT_4 = """
/**
* Concat two produces a new array with the two input arrays joined together, with no separators.
*/
@Test
public void concatTwo()
"""
OUTPUT_4 = """
@Test
@DisplayName("Concat two produces a new array with the two input arrays joined together, with no separators")
public void concatTwoProducesANewArrayWithTheTwoInputArraysJoinedTogetherWithNoSeparators()
"""
def test_javadoc_parsing():
assert re.match(PATTERN_JAVADOC, '/** Hello World */') is not None
assert re.match(PATTERN_JAVADOC, '/** Hello\n * World */') is not None
assert re.match(PATTERN_JAVADOC, '/**\n * Hello World\n */') is not None
def test_1():
assert standardize_java_text(INPUT_1.strip(),False,True) == OUTPUT_1.strip()
def test_2():
assert standardize_java_text(INPUT_2.strip(),False,True) == OUTPUT_2.strip()
def test_3():
assert standardize_java_text(INPUT_3.strip(),False,True) == OUTPUT_3.strip()
def test_4():
assert standardize_java_text(INPUT_4.strip(),False,True) == OUTPUT_4.strip()