Skip to content

Commit

Permalink
Bugfix of issue #42. Test 007.phpt now working.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Köditz committed Jan 31, 2023
1 parent 7a0a740 commit 2a6bf54
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
21 changes: 19 additions & 2 deletions tests/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ InterBase: misc sql types (may take a while)
require("interbase.inc");
ibase_connect($test_base);

/* To prevent unwanted roundings set PHP precision to 18 */
ini_set('precision',"18");

/* Check if PHP precision is set correctly */
if(ini_get('precision') < 18) {
echo "PHP precision check fail\n";
echo "Precision set in php.ini: " . ini_get('precision') . "\n";
echo "Precision required: 18\n";
}

ibase_query(
"create table test3 (
iter integer not null,
Expand All @@ -18,6 +28,7 @@ InterBase: misc sql types (may take a while)
v_decimal7_2 decimal(7,2),
v_decimal7_0 decimal(7,0),
v_numeric15_15 numeric(15,15),
v_decimal18_3 decimal(18,3),
v_numeric15_0 numeric(15,0),
v_double double precision,
v_float float,
Expand All @@ -42,6 +53,7 @@ InterBase: misc sql types (may take a while)
$v_decimal7_2 = rand_number(7,2);
$v_decimal7_0 = rand_number(7,0);
$v_numeric15_15 = rand_number(15,15);
$v_decimal18_3 = $iter ? rand_number(18,3) : 0;
$v_numeric15_0 = $iter ? rand_number(15,0) : 0;
$v_double = rand_number(18);
$v_float = rand_number(7);
Expand All @@ -50,8 +62,8 @@ InterBase: misc sql types (may take a while)
$v_varchar = rand_str(10000);

ibase_query(
"insert into test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar)
values ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0,$v_numeric15_15, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')");
"insert into test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,v_numeric15_15, v_decimal18_3, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar)
values ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0,$v_numeric15_15, $v_decimal18_3, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')");
$sel = ibase_query("select * from test3 where iter = $iter");
$row = ibase_fetch_object($sel);
if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){
Expand Down Expand Up @@ -89,6 +101,11 @@ InterBase: misc sql types (may take a while)
echo " in: $v_numeric15_15\n";
echo " out: $row->V_NUMERIC15_15\n";
}
if($row->V_DECIMAL18_3 != $v_decimal18_3){
echo " DECIMAL18_3 fail\n";
echo " in: $v_decimal18_3\n";
echo " out: $row->V_DECIMAL18_3\n";
}
if($row->V_NUMERIC15_0 != (string)$v_numeric15_0){
echo " NUMERIC15_0 fail\n";
echo " in: $v_numeric15_0\n";
Expand Down
18 changes: 14 additions & 4 deletions tests/007.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
InterBase: array handling
--SKIPIF--
<?php die("skip: Broken test (Disabled until issue 42 is fixed)"); include("skipif.inc"); ?>
<?php include("skipif.inc"); ?>
--FILE--
<?php

Expand All @@ -27,7 +27,17 @@ InterBase: array handling

/* if timefmt not supported, hide error */
ini_set('ibase.timestampformat',"%m/%d/%Y %H:%M:%S");


/* To prevent unwanted roundings set PHP precision to 18 */
ini_set('precision',"18");

/* Check if PHP precision is set correctly */
if(ini_get('precision') < 18) {
echo "PHP precision check fail\n";
echo "Precision set in php.ini: " . ini_get('precision') . "\n";
echo "Precision required: 18\n";
}

echo "insert\n";

for ($i = 1; $i <= 10; ++$i) {
Expand Down Expand Up @@ -59,7 +69,7 @@ InterBase: array handling
$v_float[$i] = rand_number(7);
$v_integer[$i] = rand_number(9,0);
$v_numeric[$i] = rand_number(9,2);
$v_smallint[$i] = rand_number(5) % 32767;
$v_smallint[$i] = ((int)rand_number(5) % 32767);
$v_varchar[$i] = rand_str(1000);
}

Expand All @@ -72,7 +82,7 @@ InterBase: array handling
$sel = ibase_query("select * from test7 where iter = $iter");

$row = ibase_fetch_object($sel,IBASE_FETCH_ARRAYS);
for ($i = 1; $i <= 10; ++$i) {
for ($i = 1; $i <= 10; ++$i) {

if(strncmp($row->V_CHAR[$i],$v_char[$i],strlen($v_char[$i])) != 0) {
echo " CHAR[$i] fail:\n";
Expand Down

0 comments on commit 2a6bf54

Please sign in to comment.