Files
divkit/test_data/expression_test_data/string_regex.json
T
avmushtukov 96dd86835f add encodeRegex function on android
commit_hash:9a0e6fe81b5c6b73101110a976e3b9576db43179
2024-10-01 14:43:18 +03:00

290 lines
7.9 KiB
JSON

{
"cases": [
{
"name": "testRegex('a', 'a') => true",
"expression": "@{testRegex('a', 'a')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('b', 'a') => false",
"expression": "@{testRegex('b', 'a')}",
"expected": {
"type": "boolean",
"value": false
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('abc', 'b') => true",
"description": "testRegex does not require that the whole string should match regex, only a part of it can match",
"expression": "@{testRegex('abc', 'b')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('a', 'A') => false",
"description": "testRegex honors case",
"expression": "@{testRegex('a', 'A')}",
"expected": {
"type": "boolean",
"value": false
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('a', '[a-z]') => true",
"expression": "@{testRegex('a', '[a-z]')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('\\', '\\\\') => true",
"description": "Triple escape. Json, DivKit, and RegExp",
"expression": "@{testRegex('\\\\', '\\\\\\\\')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('abc', '(b)') => true",
"expression": "@{testRegex('abc', '(b)')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('5', '\\d') => true",
"expression": "@{testRegex('5', '\\\\d')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('ab', 'ac?b') => true",
"expression": "@{testRegex('ab', 'ac?b')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('ab', '^ab$') => true",
"expression": "@{testRegex('ab', '^ab$')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('abc', '^ab$') => false",
"expression": "@{testRegex('abc', '^ab$')}",
"expected": {
"type": "boolean",
"value": false
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('a', 'a{1,3}') => true",
"expression": "@{testRegex('a', 'a{1,3}')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('a', 'a{2,3}') => false",
"expression": "@{testRegex('a', 'a{2,3}')}",
"expected": {
"type": "boolean",
"value": false
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('a', '(?:a)') => true",
"expression": "@{testRegex('a', '(?:a)')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('[]', '\\[]') => true",
"expression": "@{testRegex('[]', '\\\\[]')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('-', '[-]') => true",
"expression": "@{testRegex('-', '[-]')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('a-b', '^[-ab]+$') => true",
"expression": "@{testRegex('a-b', '^[-ab]+$')}",
"expected": {
"type": "boolean",
"value": true
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('[', '[') => error",
"expression": "@{testRegex('[', '[')}",
"expected": {
"type": "error",
"value": "Failed to evaluate [testRegex('[', '[')]. Invalid regular expression."
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('(', '(') => error",
"expression": "@{testRegex('(', '(')}",
"expected": {
"type": "error",
"value": "Failed to evaluate [testRegex('(', '(')]. Invalid regular expression."
},
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "testRegex('a', '\\') => error",
"expression": "@{testRegex('a', '\\\\')}",
"expected": {
"type": "error",
"value": "Failed to evaluate [testRegex('a', '\\\\')]. Invalid regular expression."
},
"platforms": [
"android",
"web",
"ios"
]
},
{
"expression": "@{encodeRegex('')}",
"expected": {
"type": "string",
"value": ""
},
"platforms": [
"web",
"android"
]
},
{
"expression": "@{encodeRegex('.*+?^${}()|[]\\\\abcde12345')}",
"expected": {
"type": "string",
"value": "\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\\\abcde12345"
},
"platforms": [
"web",
"android"
]
}
]
}