jsonlogic-hs-0.1.0.0: test/community/string/substr.json
[
"Basic Substring",
{
"description": "Substr from start index",
"rule": { "substr": ["jsonlogic", 4] },
"data": null,
"result": "logic"
},
{
"description": "Substr with negative start index",
"rule": { "substr": ["jsonlogic", -5] },
"data": null,
"result": "logic"
},
"Start and Length",
{
"description": "Substr with start and positive length",
"rule": { "substr": ["jsonlogic", 0, 1] },
"data": null,
"result": "j"
},
{
"description": "Substr with negative start and positive length",
"rule": { "substr": ["jsonlogic", -1, 1] },
"data": null,
"result": "c"
},
{
"description": "Substr with start and length",
"rule": { "substr": ["jsonlogic", 4, 5] },
"data": null,
"result": "logic"
},
{
"description": "Substr with negative start and length",
"rule": { "substr": ["jsonlogic", -5, 5] },
"data": null,
"result": "logic"
},
"Negative Length",
{
"description": "Substr with negative length from end",
"rule": { "substr": ["jsonlogic", -5, -2] },
"data": null,
"result": "log"
},
{
"description": "Substr with positive start and negative length",
"rule": { "substr": ["jsonlogic", 1, -5] },
"data": null,
"result": "son"
},
"Edge Cases",
{
"description": "Substr with empty string",
"rule": { "substr": ["", 0, 1] },
"data": null,
"result": ""
},
{
"description": "Substr with start beyond string length",
"rule": { "substr": ["test", 10, 1] },
"data": null,
"result": ""
},
{
"description": "Substr with negative start beyond string length",
"rule": { "substr": ["test", -10, 1] },
"data": null,
"result": "t"
},
{
"description": "Substr with non-string input returns empty",
"rule": { "substr": [42, 0, 1] },
"data": null,
"result": "4"
}
]