2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
|
|
|
ID: issue-5750
|
|
|
|
ISSUE: 5750
|
|
|
|
TITLE: SUBSTRING startposition smaller than 1 should be allowed
|
|
|
|
DESCRIPTION:
|
|
|
|
Test is based on ticket samples, plus similar checks for non-ascii strings.
|
|
|
|
JIRA: CORE-5480
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_5480
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set list on;
|
|
|
|
|
|
|
|
-- ASCII string tests:
|
|
|
|
select '|' || substring('abcdef' from 0) || '|' a01 from rdb$database; -- Expected result: 'abcdef'
|
|
|
|
select '|' || substring('abcdef' from 0 for 2) || '|' a02 from rdb$database; --Expected result: 'a' (and NOT 'ab')
|
2021-12-19 22:25:36 +01:00
|
|
|
select '|' || substring('abcdef' from -5 for 2) || '|' a03 from rdb$database; --Expected result: ''
|
|
|
|
select '|' || substring('abcdef' from -1 for 3) || '|' a04 from rdb$database; --Expected result: 'a'
|
|
|
|
select '|' || substring('abcdef' from -2 for 5) || '|' a05 from rdb$database; --Expected result: 'ab'
|
2021-04-26 20:07:00 +02:00
|
|
|
select '|' || substring('abcdef' from -2147483645 for 2147483647) || '|' a06 from rdb$database; -- added case with big values for arguments
|
|
|
|
|
|
|
|
-- multi-byte string tests:
|
2021-12-19 22:25:36 +01:00
|
|
|
-- Euro sign (requires three bytes for encoding) concatenated
|
2021-04-26 20:07:00 +02:00
|
|
|
-- with letters from Danish, German & Iceland alphabets:
|
|
|
|
select '|' || substring('€åßðéæø' from 0) || '|' n01 from rdb$database;
|
|
|
|
select '|' || substring('€åßðéæø' from 0 for 2) || '|' n02 from rdb$database;
|
|
|
|
select '|' || substring('€åßðéæø' from -5 for 2) || '|' n03 from rdb$database;
|
|
|
|
select '|' || substring('€åßðéæø' from -1 for 3) || '|' n04 from rdb$database;
|
|
|
|
select '|' || substring('€åßðéæø' from -2 for 5) || '|' n05 from rdb$database;
|
|
|
|
select '|' || substring('€åßðéæø' from -2147483645 for 2147483647) || '|' n06 from rdb$database;
|
|
|
|
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
A01 |abcdef|
|
|
|
|
A02 |a|
|
|
|
|
A03 ||
|
|
|
|
A04 |a|
|
|
|
|
A05 |ab|
|
|
|
|
A06 |a|
|
|
|
|
|
|
|
|
N01 |€åßðéæø|
|
|
|
|
N02 |€|
|
|
|
|
N03 ||
|
|
|
|
N04 |€|
|
|
|
|
N05 |ی|
|
2021-12-19 22:25:36 +01:00
|
|
|
N06 |€|
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2024-10-31 11:17:14 +01:00
|
|
|
@pytest.mark.intl
|
2021-04-26 20:07:00 +02:00
|
|
|
@pytest.mark.version('>=4.0')
|
2022-01-25 22:55:48 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute(charset='utf8')
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|