Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made some tests more robusts across platforms #1092

Merged
merged 4 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions test/functional/pdo_sqlsrv/pdo_ae_insert_numeric.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ No PDO::PARAM_ tpe specified when binding parameters
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array("bit", "tinyint", "smallint", "int", "bigint", "decimal(18,5)", "numeric(10,5)", "float", "real");

// Note the size of a float is platform dependent, with a precision of roughly 14 digits
// http://php.net/manual/en/language.types.float.php
try {
$conn = connect();
foreach ($dataTypes as $dataType) {
Expand All @@ -26,7 +29,7 @@ try {
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, "default type");
} else {
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
echo "-----Encrypted default type is compatible with encrypted $dataType-----\n";
fetchAll($conn, $tbname);
}
dropTable($conn, $tbname);
Expand All @@ -37,49 +40,49 @@ try {
echo $e->getMessage();
}
?>
--EXPECT--
--EXPECTREGEX--

Testing bit:
****Encrypted default type is compatible with encrypted bit****
-----Encrypted default type is compatible with encrypted bit-----
c_det: 1
c_rand: 0

Testing tinyint:
****Encrypted default type is compatible with encrypted tinyint****
-----Encrypted default type is compatible with encrypted tinyint-----
c_det: 0
c_rand: 255

Testing smallint:
****Encrypted default type is compatible with encrypted smallint****
-----Encrypted default type is compatible with encrypted smallint-----
c_det: -32767
c_rand: 32767

Testing int:
****Encrypted default type is compatible with encrypted int****
-----Encrypted default type is compatible with encrypted int-----
c_det: -2147483647
c_rand: 2147483647

Testing bigint:
****Encrypted default type is compatible with encrypted bigint****
-----Encrypted default type is compatible with encrypted bigint-----
c_det: -922337203685479936
c_rand: 922337203685479936

Testing decimal(18,5):
****Encrypted default type is compatible with encrypted decimal(18,5)****
c_det: -9223372036854.80000
c_rand: 9223372036854.80000
Testing decimal\(18,5\):
-----Encrypted default type is compatible with encrypted decimal\(18,5\)-----
c_det: -9223372036854\.80000
c_rand: 9223372036854\.80000

Testing numeric(10,5):
****Encrypted default type is compatible with encrypted numeric(10,5)****
c_det: -21474.83647
c_rand: 21474.83647
Testing numeric\(10,5\):
-----Encrypted default type is compatible with encrypted numeric\(10,5\)-----
c_det: -21474\.83647
c_rand: 21474\.83647

Testing float:
****Encrypted default type is compatible with encrypted float****
c_det: -9223372036.8547993
c_rand: 9223372036.8547993
-----Encrypted default type is compatible with encrypted float-----
c_det: (-9223372036\.8547993|-9223372036\.8547992)
c_rand: (9223372036\.8547993|9223372036\.8547992)

Testing real:
****Encrypted default type is compatible with encrypted real****
c_det: -2147.4829
c_rand: 2147.4829
-----Encrypted default type is compatible with encrypted real-----
c_det: (-2147\.4829|-2147\.483)
c_rand: (2147\.4829|2147\.483)
Original file line number Diff line number Diff line change
Expand Up @@ -80,34 +80,34 @@ try {
}
?>

--EXPECT--
--EXPECTF--
Prepare without emulate prepare:
Array
(
[c1_decimal] => 422
[c2_money] => 132.2220
[c3_float] => 622.22000000000003
[c3_float] => 622.22%S
)
Prepare with emulate prepare and no bind param options:
Array
(
[c1_decimal] => 422
[c2_money] => 132.2220
[c3_float] => 622.22000000000003
[c3_float] => 622.22%S
)
Prepare with emulate prepare and SQLSRV_ENCODING_SYSTEM:
Array
(
[c1_decimal] => 422
[c2_money] => 132.2220
[c3_float] => 622.22000000000003
[c3_float] => 622.22%S
)
Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:
Array
(
[c1_decimal] => 422
[c2_money] => 132.2220
[c3_float] => 622.22000000000003
[c3_float] => 622.22%S
)
Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:
No results for this query
10 changes: 5 additions & 5 deletions test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_float.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,34 @@ try {
}
?>

--EXPECT--
--EXPECTF--
Prepare without emulate prepare:
Array
(
[c1_decimal] => 411
[c2_money] => 131.1100
[c3_float] => 611.11099999999999
[c3_float] => 611.1109999999999%d
)
Prepare with emulate prepare and no bind param options:
Array
(
[c1_decimal] => 411
[c2_money] => 131.1100
[c3_float] => 611.11099999999999
[c3_float] => 611.1109999999999%d
)
Prepare with emulate prepare and SQLSRV_ENCODING_SYSTEM:
Array
(
[c1_decimal] => 411
[c2_money] => 131.1100
[c3_float] => 611.11099999999999
[c3_float] => 611.1109999999999%d
)
Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:
Array
(
[c1_decimal] => 411
[c2_money] => 131.1100
[c3_float] => 611.11099999999999
[c3_float] => 611.1109999999999%d
)
Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:
No results for this query
10 changes: 5 additions & 5 deletions test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_money.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -80,34 +80,34 @@ try {
}
?>

--EXPECT--
--EXPECTF--
Prepare without emulate prepare:
Array
(
[c1_decimal] => 433
[c2_money] => 133.3333
[c3_float] => 633.33333000000005
[c3_float] => 633.3333300000000%d
)
Prepare with emulate prepare and no bind param options:
Array
(
[c1_decimal] => 433
[c2_money] => 133.3333
[c3_float] => 633.33333000000005
[c3_float] => 633.3333300000000%d
)
Prepare with emulate prepare and SQLSRV_ENCODING_SYSTEM:
Array
(
[c1_decimal] => 433
[c2_money] => 133.3333
[c3_float] => 633.33333000000005
[c3_float] => 633.3333300000000%d
)
Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:
Array
(
[c1_decimal] => 433
[c2_money] => 133.3333
[c3_float] => 633.33333000000005
[c3_float] => 633.3333300000000%d
)
Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:
No results for this query
34 changes: 19 additions & 15 deletions test/functional/pdo_sqlsrv/pdo_test_non_LOB_types.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ try {
verifyResult($result);

// test not streamable types
// The size of a float is platform dependent, with a precision of roughly 14 digits
// http://php.net/manual/en/language.types.float.php
// For example, the input value for column [real_type] in setup\test_types.sql is 1.18E-38
// but in some distros the fetched value is 1.1799999E-38
$tsql = "SELECT * FROM [test_types]";
$stmt = $conn->query($tsql);
$result = $stmt->fetch(PDO::FETCH_NUM);
Expand All @@ -60,19 +64,19 @@ unset($stmt);
unset($conn);

?>
--EXPECT--
--EXPECTREGEX--
Array
(
[0] => 9223372036854775807
[1] => 2147483647
[2] => 32767
[3] => 255
[4] => 1
[5] => 9999999999999999999999999999999999999
[6] => 922337203685477.5807
[7] => 214748.3647
[8] => 1.79E+308
[9] => 1.1799999E-38
[10] => 1968-12-12 16:20:00.000
[11] =>
)
\(
\[0\] => 9223372036854775807
\[1\] => 2147483647
\[2\] => 32767
\[3\] => 255
\[4\] => 1
\[5\] => 9999999999999999999999999999999999999
\[6\] => 922337203685477\.5807
\[7\] => 214748\.3647
\[8\] => 1\.79E\+308
\[9\] => (1\.18E-38|1\.1799999E-38)
\[10\] => 1968-12-12 16:20:00.000
\[11\] =>
\)
10 changes: 5 additions & 5 deletions test/functional/pdo_sqlsrv/pdostatement_fetchAll.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ array(2) {
[5]=>
string(10) "STRINGCOL2"
["FloatCol"]=>
string(18) "222.22200000000001"
string(%d) "222.222%S"
[6]=>
string(18) "222.22200000000001"
string(%d) "222.222%S"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, this change in string length is because the value returned may have a different number of digits on different platforms, is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

["XmlCol"]=>
string(431) "<xml> 2 This is a really large string used to test certain large data types like xml data type. The length of this string is greater than 256 to correctly test a large data type. This is currently used by atleast varchar type and by xml type. The fetch tests are the primary consumer of this string to validate that fetch on large types work fine. The length of this string as counted in terms of number of characters is 417.</xml>"
[7]=>
Expand Down Expand Up @@ -395,7 +395,7 @@ object(stdClass)#%x (%x) {
["NVarCharCol"]=>
string(10) "STRINGCOL2"
["FloatCol"]=>
string(18) "222.22200000000001"
string(%d) "222.222%S"
["XmlCol"]=>
string(431) "<xml> 2 This is a really large string used to test certain large data types like xml data type. The length of this string is greater than 256 to correctly test a large data type. This is currently used by atleast varchar type and by xml type. The fetch tests are the primary consumer of this string to validate that fetch on large types work fine. The length of this string as counted in terms of number of characters is 417.</xml>"
}
Expand All @@ -414,7 +414,7 @@ array(8) {
[5]=>
string(10) "STRINGCOL2"
[6]=>
string(18) "222.22200000000001"
string(%d) "222.222%S"
[7]=>
string(431) "<xml> 2 This is a really large string used to test certain large data types like xml data type. The length of this string is greater than 256 to correctly test a large data type. This is currently used by atleast varchar type and by xml type. The fetch tests are the primary consumer of this string to validate that fetch on large types work fine. The length of this string as counted in terms of number of characters is 417.</xml>"
}
Expand All @@ -425,7 +425,7 @@ string(10) "STRINGCOL2"
string(23) "2000-11-11 11:11:11.223"
string(10) "STRINGCOL2"
string(10) "STRINGCOL2"
string(18) "222.22200000000001"
string(%d) "222.222%S"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other floating point values in this test's output, are you sure the other values are the same across different platforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, yes

string(431) "<xml> 2 This is a really large string used to test certain large data types like xml data type. The length of this string is greater than 256 to correctly test a large data type. This is currently used by atleast varchar type and by xml type. The fetch tests are the primary consumer of this string to validate that fetch on large types work fine. The length of this string as counted in terms of number of characters is 417.</xml>"
Test_9 : FETCH_INVALID :

Expand Down
6 changes: 3 additions & 3 deletions test/functional/pdo_sqlsrv/pdostatement_nextRowset.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ try {
var_dump($e);
}
?>
--EXPECT--
--EXPECTF--
array(1) {
[0]=>
array(62) {
Expand Down Expand Up @@ -224,9 +224,9 @@ array(2) {
[5]=>
string(10) "STRINGCOL2"
["FloatCol"]=>
string(18) "222.22200000000001"
string(%d) "222.222%S"
[6]=>
string(18) "222.22200000000001"
string(%d) "222.222%S"
["XmlCol"]=>
string(431) "<xml> 2 This is a really large string used to test certain large data types like xml data type. The length of this string is greater than 256 to correctly test a large data type. This is currently used by atleast varchar type and by xml type. The fetch tests are the primary consumer of this string to validate that fetch on large types work fine. The length of this string as counted in terms of number of characters is 417.</xml>"
[7]=>
Expand Down
Loading