Skip to content

Commit 2a6bf54

Browse files
author
Martin Köditz
committed
Bugfix of issue #42. Test 007.phpt now working.
1 parent 7a0a740 commit 2a6bf54

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

tests/003.phpt

+19-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ InterBase: misc sql types (may take a while)
88
require("interbase.inc");
99
ibase_connect($test_base);
1010

11+
/* To prevent unwanted roundings set PHP precision to 18 */
12+
ini_set('precision',"18");
13+
14+
/* Check if PHP precision is set correctly */
15+
if(ini_get('precision') < 18) {
16+
echo "PHP precision check fail\n";
17+
echo "Precision set in php.ini: " . ini_get('precision') . "\n";
18+
echo "Precision required: 18\n";
19+
}
20+
1121
ibase_query(
1222
"create table test3 (
1323
iter integer not null,
@@ -18,6 +28,7 @@ InterBase: misc sql types (may take a while)
1828
v_decimal7_2 decimal(7,2),
1929
v_decimal7_0 decimal(7,0),
2030
v_numeric15_15 numeric(15,15),
31+
v_decimal18_3 decimal(18,3),
2132
v_numeric15_0 numeric(15,0),
2233
v_double double precision,
2334
v_float float,
@@ -42,6 +53,7 @@ InterBase: misc sql types (may take a while)
4253
$v_decimal7_2 = rand_number(7,2);
4354
$v_decimal7_0 = rand_number(7,0);
4455
$v_numeric15_15 = rand_number(15,15);
56+
$v_decimal18_3 = $iter ? rand_number(18,3) : 0;
4557
$v_numeric15_0 = $iter ? rand_number(15,0) : 0;
4658
$v_double = rand_number(18);
4759
$v_float = rand_number(7);
@@ -50,8 +62,8 @@ InterBase: misc sql types (may take a while)
5062
$v_varchar = rand_str(10000);
5163

5264
ibase_query(
53-
"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)
54-
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')");
65+
"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)
66+
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')");
5567
$sel = ibase_query("select * from test3 where iter = $iter");
5668
$row = ibase_fetch_object($sel);
5769
if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){
@@ -89,6 +101,11 @@ InterBase: misc sql types (may take a while)
89101
echo " in: $v_numeric15_15\n";
90102
echo " out: $row->V_NUMERIC15_15\n";
91103
}
104+
if($row->V_DECIMAL18_3 != $v_decimal18_3){
105+
echo " DECIMAL18_3 fail\n";
106+
echo " in: $v_decimal18_3\n";
107+
echo " out: $row->V_DECIMAL18_3\n";
108+
}
92109
if($row->V_NUMERIC15_0 != (string)$v_numeric15_0){
93110
echo " NUMERIC15_0 fail\n";
94111
echo " in: $v_numeric15_0\n";

tests/007.phpt

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
InterBase: array handling
33
--SKIPIF--
4-
<?php die("skip: Broken test (Disabled until issue 42 is fixed)"); include("skipif.inc"); ?>
4+
<?php include("skipif.inc"); ?>
55
--FILE--
66
<?php
77

@@ -27,7 +27,17 @@ InterBase: array handling
2727

2828
/* if timefmt not supported, hide error */
2929
ini_set('ibase.timestampformat',"%m/%d/%Y %H:%M:%S");
30-
30+
31+
/* To prevent unwanted roundings set PHP precision to 18 */
32+
ini_set('precision',"18");
33+
34+
/* Check if PHP precision is set correctly */
35+
if(ini_get('precision') < 18) {
36+
echo "PHP precision check fail\n";
37+
echo "Precision set in php.ini: " . ini_get('precision') . "\n";
38+
echo "Precision required: 18\n";
39+
}
40+
3141
echo "insert\n";
3242

3343
for ($i = 1; $i <= 10; ++$i) {
@@ -59,7 +69,7 @@ InterBase: array handling
5969
$v_float[$i] = rand_number(7);
6070
$v_integer[$i] = rand_number(9,0);
6171
$v_numeric[$i] = rand_number(9,2);
62-
$v_smallint[$i] = rand_number(5) % 32767;
72+
$v_smallint[$i] = ((int)rand_number(5) % 32767);
6373
$v_varchar[$i] = rand_str(1000);
6474
}
6575

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

7484
$row = ibase_fetch_object($sel,IBASE_FETCH_ARRAYS);
75-
for ($i = 1; $i <= 10; ++$i) {
85+
for ($i = 1; $i <= 10; ++$i) {
7686

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

0 commit comments

Comments
 (0)