python-codewars-solutions/brainfuck-to-c-translator/tests.py

33 lines
646 B
Python
Raw Permalink Normal View History

2024-01-23 13:51:55 +00:00
import codewars_test as test
from solution import brainfuck_to_c
def testing(code, expected):
result = brainfuck_to_c(code)
test.assert_equals(result, expected)
test.describe("general tests")
test.it("thib")
testing("-+-+", "")
testing("<>", "")
#testing(">>><<<<", "<")
test.it("basic")
testing("+-", "")
testing("++++", "*p += 4;\n")
testing("----", "*p -= 4;\n")
testing(">>>>", "p += 4;\n");
testing("<<<<", "p -= 4;\n");
testing(".", "putchar(*p);\n");
testing(",", "*p = getchar();\n");
testing("[[[]]", "Error!");
testing("[][]", "");
testing("[.]", "if (*p) do {\n putchar(*p);\n} while (*p);\n");