Skip to content
Snippets Groups Projects
Commit 6153804c authored by Lasse Pikkemaat's avatar Lasse Pikkemaat
Browse files

Merge branch 'Hatices' into 'develop'

Hatice Code + Tests

See merge request !8
parents a3ef4268 8b1190da
No related branches found
No related tags found
2 merge requests!9Develop,!8Hatice Code + Tests
#Bei Eingabe von Zahlen, die in der Liste definiert sind, sollen römische Zhalen zurückgegeben werden.
#Bei Eingabe von Zahlen, die nicht in der Liste definiert ist, soll ein "" ausgeben werden.
'''
import unittest
from abc import ABC, abstractmethod
class IRomanNumber(ABC):
@abstractmethod
def convert(self, n:int) -> str:
pass
class RomanNumber(IRomanNumber):
def convert(self, n: int) -> str:
roman_numerals = {
1: "I", 2: "II", 3: "III",
4: "IV", 5: "V", 9: "IX",
21: "XXI", 50: "L", 100: "C",
500: "D", 1000: "M"
}
return roman_numerals.get(n, "")
'''
import unittest
from src.romannumerals import RomanNumber
from src.interfaces import IRomanNumber
class TestRomanConverter(unittest.TestCase):
def setUp(self):
self.converter = RomanNumber()
def test_single_value(self):
self.assertEqual(self.converter.convert(1), "I")
self.assertEqual(self.converter.convert(2), "II")
self.assertEqual(self.converter.convert(3), "III")
self.assertEqual(self.converter.convert(4), "IV")
self.assertEqual(self.converter.convert(5), "V")
self.assertEqual(self.converter.convert(9), "IX")
self.assertEqual(self.converter.convert(21), "XXI")
self.assertEqual(self.converter.convert(50), "L")
self.assertEqual(self.converter.convert(100), "C")
self.assertEqual(self.converter.convert(500), "D")
self.assertEqual(self.converter.convert(1000), "M")
def test_inivalid_numbers(self):
self.assertEqual(self.converter.convert(6), "")
self.assertEqual(self.converter.convert(99), "")
self.assertEqual(self.converter.convert(-1), "")
if __name__ == "__main__":
unittest.main()
#python -m unittest others.Hatice.HaticeRomanConverter -v
\ No newline at end of file
| Name | Interface break | Failed Testcases | |
|--------|-----------------|--------------------------------------------------------------------------------|---------------------------------------|
| Hatice | no | test_convert_addition (tests.test_romannumerals.TestRomanNumber) ... FAIL | AssertionError: '' != 'II' + II |
| Hatice | no | test_convert_invalid (tests.test_romannumerals.TestRomanNumber) ... FAIL | AssertionError: ValueError not raised |
| Hatice | no | test_convert_large_numbers (tests.test_romannumerals.TestRomanNumber) ... FAIL | AssertionError: '' != 'MI' + MI |
| Hatice | no | test_convert_mixed (tests.test_romannumerals.TestRomanNumber) ... FAIL | AssertionError: '' != 'XIV' + XIV |
| Hatice | no | test_convert_subtraction (tests.test_romannumerals.TestRomanNumber) ... FAIL | AssertionError: '' != 'IV' + IV |
\ No newline at end of file
| Name | Interface break | Failed Testcases | |
|--------|-----------------|----------------------------------------------------------------------------------------|---------------------------------|
| Hatice | no | test_inivalid_numbers (others.Hatice.HaticeRomanConverter.TestRomanConverter) ... FAIL | AssertionError: 'VI' != '' - VI |
\ No newline at end of file
......@@ -56,9 +56,12 @@ from others.Dani.DaniRomanConverter import Converter, IConverter
import unittest
from others.Momo.MomoRomanConverter import convert
'''
import unittest
from others.Alma.AlmaRomanConverter import IRomanNumber, RomanNumber
'''
import unittest
from others.Hatice.HaticeRomanConverter import IRomanNumber, RomanNumber
class TestRomanNumber(unittest.TestCase):
def setUp(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment