rosavox/lib/alveolata/string/test.spec.json
2025-05-23 07:33:29 +00:00

380 lines
6.5 KiB
JSON

{
"active": true,
"sections": [
{
"name": "split",
"active": true,
"execution": {
"call": "\\alveolata\\string\\split({{subject}}, {{delimiter}})"
},
"cases": [
{
"name": "empty",
"active": true,
"input": {
"subject": "",
"delimiter": ","
},
"output": {
"kind": "regular",
"value": []
}
},
{
"name": "non-empty",
"active": true,
"input": {
"subject": "foo,bar,baz,qux",
"delimiter": ","
},
"output": {
"kind": "regular",
"value": ["foo","bar","baz","qux"]
}
}
]
},
{
"name": "join",
"active": true,
"execution": {
"call": "\\alveolata\\string\\join({{parts}}, {{delimiter}})"
},
"cases": [
{
"name": "empty",
"active": true,
"input": {
"parts": [],
"delimiter": ","
},
"output": {
"kind": "regular",
"value": ""
}
},
{
"name": "non-empty",
"active": true,
"input": {
"parts": ["foo","bar","baz","qux"],
"delimiter": ","
},
"output": {
"kind": "regular",
"value": "foo,bar,baz,qux"
}
}
]
},
{
"name": "starts_with",
"active": true,
"execution": {
"call": "\\alveolata\\string\\starts_with({{subject}}, {{part}})"
},
"cases": [
{
"name": "test1",
"active": true,
"input": {
"subject": "foobar",
"part": "foo"
},
"output": {
"kind": "regular",
"value": true
}
},
{
"name": "test2",
"active": true,
"input": {
"subject": "foobar",
"part": "fox"
},
"output": {
"kind": "regular",
"value": false
}
},
{
"name": "test3",
"active": true,
"input": {
"subject": "foobar",
"part": ""
},
"output": {
"kind": "regular",
"value": true
}
},
{
"name": "test4",
"active": true,
"input": {
"subject": "foobar",
"part": "foobar_"
},
"output": {
"kind": "regular",
"value": false
}
}
]
},
{
"name": "ends_with",
"active": true,
"execution": {
"call": "\\alveolata\\string\\ends_with({{subject}}, {{part}})"
},
"cases": [
{
"name": "test1",
"active": true,
"input": {
"subject": "foobar",
"part": "bar"
},
"output": {
"kind": "regular",
"value": true
}
},
{
"name": "test2",
"active": true,
"input": {
"subject": "foobar",
"part": "baz"
},
"output": {
"kind": "regular",
"value": false
}
},
{
"name": "test3",
"active": true,
"input": {
"subject": "foobar",
"part": ""
},
"output": {
"kind": "regular",
"value": true
}
},
{
"name": "test4",
"active": true,
"input": {
"subject": "foobar",
"part": "_foobar"
},
"output": {
"kind": "regular",
"value": false
}
},
{
"name": "test5",
"active": true,
"input": {
"subject": "foobar",
"part": "foo"
},
"output": {
"kind": "regular",
"value": false
}
}
]
},
{
"name": "contains",
"active": true,
"execution": {
"call": "\\alveolata\\string\\contains({{subject}}, {{part}})"
},
"cases": [
{
"name": "empty_subject",
"active": true,
"input": {
"subject": "",
"part": "x"
},
"output": {
"kind": "regular",
"value": false
}
},
{
"name": "empty_part",
"active": true,
"input": {
"subject": "whatever",
"part": ""
},
"output": {
"kind": "regular",
"value": true
}
},
{
"name": "regular_negative",
"active": true,
"input": {
"subject": "whatever",
"part": "ex"
},
"output": {
"kind": "regular",
"value": false
}
},
{
"name": "regular_positiv",
"active": true,
"input": {
"subject": "whatever",
"part": "ev"
},
"output": {
"kind": "regular",
"value": true
}
}
]
},
{
"name": "coin",
"active": true,
"execution": {
"call": "\\alveolata\\string\\coin({{template}}, {{arguments}})"
},
"cases": [
{
"name": "regular",
"active": true,
"input": {
"template": "{{blumen}} sind {{farbe}}",
"arguments": {
"blumen": "rosen",
"farbe": "rot"
}
},
"output": {
"kind": "regular",
"value": "rosen sind rot"
}
},
{
"name": "missing_argument",
"active": true,
"input": {
"template": "{{blumen}} sind {{farbe}}",
"arguments": {
"farbe": "rot"
}
},
"output": {
"kind": "regular",
"value": "{{blumen}} sind rot"
}
}
]
},
{
"name": "limit",
"active": true,
"execution": {
"call": "\\alveolata\\string\\limit({{string}}, {{length}}, {{ellipsis}})"
},
"cases": [
{
"name": "without unicode | short enough",
"active": true,
"input": {
"string": "foo",
"length": 5,
"ellipsis": "."
},
"output": {
"kind": "regular",
"value": "foo"
}
},
{
"name": "without unicode | exact length",
"active": true,
"input": {
"string": "foo b",
"length": 5,
"ellipsis": "."
},
"output": {
"kind": "regular",
"value": "foo b"
}
},
{
"name": "without unicode | too long",
"active": true,
"input": {
"string": "foo bar",
"length": 5,
"ellipsis": "."
},
"output": {
"kind": "regular",
"value": "foo ."
}
},
{
"name": "with unicode | short enough",
"active": true,
"input": {
"string": "foo",
"length": 5,
"ellipsis": " …"
},
"output": {
"kind": "regular",
"value": "foo"
}
},
{
"name": "with unicode | exact length",
"active": true,
"input": {
"string": "foo b",
"length": 5,
"ellipsis": " …"
},
"output": {
"kind": "regular",
"value": "foo b"
}
},
{
"name": "with unicode | too long",
"active": true,
"input": {
"string": "foo bar",
"length": 5,
"ellipsis": " …"
},
"output": {
"kind": "regular",
"value": "foo …"
}
}
]
}
]
}