fix some tests

This commit is contained in:
v-kaywon 2018-03-05 13:21:19 -08:00
parent 2925f6d444
commit 85871448bc
3 changed files with 35 additions and 25 deletions

View file

@ -50,36 +50,45 @@ try {
// with or without AE: 1 or 0 should be inserted when inserting into an integer column
// double is inserted when inserting into a real column
} else if ($pdoParamType == "PDO::PARAM_BOOL") {
$sql = "SELECT c_det, c_rand FROM $tbname";
$stmt = $conn->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($dataType == "real") {
if (abs($row['c_det'] - $inputValues[0]) < $epsilon && abs($row['c_rand'] - $inputValues[1]) < $epsilon) {
echo "****Conversion from $pdoParamType to $dataType is supported****\n";
} else {
echo "Conversion from $pdoParamType to $dataType causes data corruption\n";
}
if ($r === false) {
echo "Conversion from $pdoParamType to $dataType should be supported\n";
} else {
if ($row['c_det'] != ($inputValues[0] != 0) && $row['c_rand'] != ($inputValues[1] != 0)) {
echo "Conversion from $pdoParamType to $dataType insert a boolean\n";
$sql = "SELECT c_det, c_rand FROM $tbname";
$stmt = $conn->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($dataType == "real") {
if (abs($row['c_det'] - $inputValues[0]) < $epsilon && abs($row['c_rand'] - $inputValues[1]) < $epsilon) {
echo "****Conversion from $pdoParamType to $dataType is supported****\n";
} else {
echo "Conversion from $pdoParamType to $dataType causes data corruption\n";
}
} else {
if ($row['c_det'] != ($inputValues[0] != 0) && $row['c_rand'] != ($inputValues[1] != 0)) {
echo "Conversion from $pdoParamType to $dataType insert a boolean\n";
}
}
}
// check the case when inserting as PDO::PARAM_INT, PDO::PARAM_STR or PDO::PARAM_LOB
// with or without AE: should work
} else {
$sql = "SELECT c_det, c_rand FROM $tbname";
$stmt = $conn->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($dataType == "real") {
if (abs($row['c_det'] - $inputValues[0]) < $epsilon && abs($row['c_rand'] - $inputValues[1]) < $epsilon) {
echo "****Conversion from $pdoParamType to $dataType is supported****\n";
} else {
echo "Conversion from $pdoParamType to $dataType causes data corruption\n";
}
if ($r === false) {
echo "Conversion from $pdoParamType to $dataType should be supported\n";
} else {
if ($row['c_det'] == $inputValues[0] && $row['c_rand'] == $inputValues[1]) {
echo "****Conversion from $pdoParamType to $dataType is supported****\n";
$sql = "SELECT c_det, c_rand FROM $tbname";
$stmt = $conn->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($dataType == "real") {
if (abs($row['c_det'] - $inputValues[0]) < $epsilon && abs($row['c_rand'] - $inputValues[1]) < $epsilon) {
echo "****Conversion from $pdoParamType to $dataType is supported****\n";
} else {
echo "Conversion from $pdoParamType to $dataType causes data corruption\n";
}
} else {
echo "Conversion from $pdoParamType to $dataType causes data corruption\n";
if ($row['c_det'] == $inputValues[0] && $row['c_rand'] == $inputValues[1]) {
echo "****Conversion from $pdoParamType to $dataType is supported****\n";
} else {
echo "Conversion from $pdoParamType to $dataType causes data corruption\n";
}
}
}
}

View file

@ -122,6 +122,7 @@ foreach($dataTypes as $dataType) {
echo "****Conversion from $sqlType to $typeFull is supported****\n";
} else {
echo "Conversion from $sqlType to $typeFull causes data corruption\n";
var_dump($row);
}
}
}

View file

@ -97,7 +97,7 @@ Testing float(24):
Test successfully done
Testing float(36):
Conversion from SQLSRV_SQLTYPE_FLOAT to float(36) should be supported
****Conversion from SQLSRV_SQLTYPE_FLOAT to float(36) is supported****
Testing float(53):
Conversion from SQLSRV_SQLTYPE_FLOAT to float(53) should be supported
****Conversion from SQLSRV_SQLTYPE_FLOAT to float(53) is supported****