mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 21:43:06 +01:00
70 lines
4.5 KiB
Python
70 lines
4.5 KiB
Python
|
#coding:utf-8
|
||
|
|
||
|
"""
|
||
|
ID: issue-7599
|
||
|
ISSUE: https://github.com/FirebirdSQL/firebird/issues/7599
|
||
|
TITLE: Conversion of text with '\0' to DECFLOAT without errors.
|
||
|
DESCRIPTION:
|
||
|
Checked on 5.0.0.1066.
|
||
|
"""
|
||
|
|
||
|
import pytest
|
||
|
from firebird.qa import *
|
||
|
|
||
|
db = db_factory()
|
||
|
|
||
|
act = python_act('db')
|
||
|
|
||
|
expected_stdout = """
|
||
|
Statement failed, SQLSTATE = 22018
|
||
|
conversion error from string "123#x00321"
|
||
|
|
||
|
CASE_02 -0E+6111
|
||
|
|
||
|
Statement failed, SQLSTATE = 22018
|
||
|
Decimal float invalid operation. An indeterminant error occurred during an operation.
|
||
|
-conversion error from string "<Too long string or can't be translated>"
|
||
|
|
||
|
CASE_04 0
|
||
|
|
||
|
Statement failed, SQLSTATE = 22001
|
||
|
arithmetic exception, numeric overflow, or string truncation
|
||
|
-string right truncation
|
||
|
-expected length 1024, actual 1025
|
||
|
"""
|
||
|
|
||
|
@pytest.mark.version('>=5.0')
|
||
|
def test_1(act: Action):
|
||
|
test_sql = """
|
||
|
set list on;
|
||
|
--set echo on;
|
||
|
|
||
|
-- must FAIL with:
|
||
|
-- Statement failed, SQLSTATE = 22018
|
||
|
-- conversion error from string "123#x00321"
|
||
|
select cast( '123' || x'00' || '321' as decfloat(34)) as case_01 from rdb$database;
|
||
|
|
||
|
-- must PASS with result = -0E+6111
|
||
|
select cast('-0000000000000000000000000000000000000000000000000000000000000000000000000000000.E+7000' as decfloat(34)) as case_02 from rdb$database;
|
||
|
|
||
|
-- must FAIL with:
|
||
|
-- Statement failed, SQLSTATE = 22018
|
||
|
-- Decimal float invalid operation. An indeterminant error occurred during an operation.
|
||
|
-- -conversion error from string "<Too long string or can't be translated>"
|
||
|
select cast( '0000000000000000000000000000000000000000000000000000000000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000.E+0' as decfloat(34)) as case_03 from rdb$database;
|
||
|
|
||
|
-- must PASS with result = 0
|
||
|
select cast( '0.E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' as decfloat(34)) as case_04 from rdb$database;
|
||
|
|
||
|
-- must FAIL with
|
||
|
-- Statement failed, SQLSTATE = 22001
|
||
|
-- arithmetic exception, numeric overflow, or string truncation
|
||
|
-- -string right truncation
|
||
|
-- -expected length 1024, actual 1025
|
||
|
select cast( '0.E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' as decfloat(34)) as case_05 from rdb$database;
|
||
|
|
||
|
"""
|
||
|
act.expected_stdout = expected_stdout
|
||
|
act.isql(switches=['-q'], input = test_sql, combine_output = True)
|
||
|
assert act.clean_stdout == act.clean_expected_stdout
|