From 930027a0d51c91f6184db1a803a545e0b0ceed4a Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Sat, 3 Jun 2023 10:32:23 +0300 Subject: [PATCH] Added/Updated tests\bugs\gh_7599_test.py: Checked on 5.0.0.1066 --- tests/bugs/gh_7599_test.py | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/bugs/gh_7599_test.py diff --git a/tests/bugs/gh_7599_test.py b/tests/bugs/gh_7599_test.py new file mode 100644 index 00000000..1f22da46 --- /dev/null +++ b/tests/bugs/gh_7599_test.py @@ -0,0 +1,69 @@ +#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 "" + + 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 "" + 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