fixed the tests and done some frontend shit

This commit is contained in:
2025-08-12 13:46:48 +02:00
parent 5fe140c4f9
commit 1ac0a13fc3
9 changed files with 777 additions and 142 deletions

View File

@@ -1,19 +1,26 @@
import unittest
#<!-- The Function the User needs to write -->
def revstring(x):
return x[::-1]
#<!-- This Test, test if the function works -->
class TestSolution(unittest.TestCase):
def test_simple(self):
x = "Hello World"
self.assertEqual(revstring(x), "dlroW olleH") # Test simple string reversal
self.assertEqual(revstring(""), "") # Test empty string
self.assertEqual(revstring("a"), "a") # Test single character
self.assertEqual(revstring("racecar"), "racecar") # Test palindrome
self.assertEqual(revstring("12345"), "54321") # Test numbers as string
self.assertEqual(revstring("!@# $%"), "%$ #@!") # Test special chars and spaces
test_cases = [
("Hello World", "dlroW olleH"),
("", ""),
("a", "a"),
("racecar", "racecar"),
("12345", "54321"),
("!@# $%", "%$ #@!")
]
print("\n=== Function Output Test Results ===")
for input_val, expected in test_cases:
try:
actual = revstring(input_val) # pyright: ignore[reportUndefinedVariable]
status = "✓ PASS" if actual == expected else "✗ FAIL"
print(f"{status} | Input: '{input_val}' -> Got: '{actual}' | Expected: '{expected}'")
self.assertEqual(actual, expected)
except Exception as e:
print(f"✗ ERROR | Input: '{input_val}' -> Exception: {e}")
raise
if __name__ == "__main__":
unittest.main()
unittest.main(verbosity=2)

View File

@@ -2,15 +2,16 @@ import unittest
# This is the function the user is expected to write.
# Its a really simple one, the user can choose not to type tho.
def sortlist(lst = [4,3,2,1]) -> list:
return sorted(lst)
#def sortlist(lst = [4,3,2,1]) -> list:
#return sorted(lst)
class TestSolution(unittest.TestCase):
def test_sort(self):
# define x as a empty array.
# this will be used for the functiun ; a empty var does not work.
self.x = []
self.assertEqual(sortlist(self.x), sorted(self.x)) ## sort
self.assertEqual(sortlist(self.x), sorted(self.x)) # pyright: ignore[reportUndefinedVariable]
if __name__ == "__main__":
unittest.main()