103 lines
1.9 KiB
Python
103 lines
1.9 KiB
Python
definitions = [
|
|
{
|
|
"name": "lib.string_coin",
|
|
"procedure": lambda input_: string_coin(input_["template"], input_["arguments"]),
|
|
"cases": [
|
|
{
|
|
"input": {
|
|
"template": "{{sachen}} sind {{farbe}}",
|
|
"arguments": {
|
|
"farbe": "rot",
|
|
},
|
|
},
|
|
"output": "{{sachen}} sind rot"
|
|
},
|
|
{
|
|
"input": {
|
|
"template": "{{sachen}} sind {{farbe}}",
|
|
"arguments": {
|
|
},
|
|
},
|
|
"output": "{{sachen}} sind {{farbe}}"
|
|
},
|
|
{
|
|
"input": {
|
|
"template": "{{sachen}} sind {{farbe}}",
|
|
"arguments": {
|
|
"sachen": "rosen",
|
|
"farbe": "rot",
|
|
},
|
|
},
|
|
"output": "rosen sind rot"
|
|
},
|
|
{
|
|
"input": {
|
|
"template": "{{sachen}} sind {{farbe}}",
|
|
"arguments": {
|
|
"sachen": "rosen",
|
|
"farbe": "rot",
|
|
"ort": "frankreich",
|
|
},
|
|
},
|
|
"output": "rosen sind rot"
|
|
},
|
|
],
|
|
},
|
|
{
|
|
"name": "lib.format_bytes",
|
|
"procedure": lambda input_: format_bytes(input_),
|
|
"cases": [
|
|
{
|
|
"input": 999,
|
|
"output": "999 B",
|
|
},
|
|
{
|
|
"input": 1000,
|
|
"output": "1.0 KB",
|
|
},
|
|
{
|
|
"input": 1000000,
|
|
"output": "1.0 MB",
|
|
},
|
|
{
|
|
"input": 1000000000,
|
|
"output": "1.0 GB",
|
|
},
|
|
{
|
|
"input": 1000000000000,
|
|
"output": "1.0 TB",
|
|
},
|
|
{
|
|
"input": 1000000000000000,
|
|
"output": "1.0 PB",
|
|
},
|
|
{
|
|
"input": 1000000000000000000,
|
|
"output": "1000.0 PB",
|
|
},
|
|
],
|
|
},
|
|
]
|
|
|
|
|
|
for definition in definitions:
|
|
for index in range(len(definition["cases"])):
|
|
case = definition["cases"][index]
|
|
output_actual = definition["procedure"](case["input"])
|
|
output_expected = case["output"]
|
|
passed = (output_actual == output_expected)
|
|
info = {
|
|
"input": case["input"],
|
|
"output_expected": output_expected,
|
|
"output_actual": output_actual,
|
|
}
|
|
_sys.stderr.write(
|
|
"[%s] %s.%u%s\n"
|
|
% (
|
|
("+" if passed else "x"),
|
|
definition["name"],
|
|
index,
|
|
("" if passed else (": " + _json.dumps(info))),
|
|
)
|
|
)
|