summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2023-01-19 18:51:12 +0100
committerNathan Gass2023-01-19 18:52:31 +0100
commit399bc5c45f0b74feee825e75a39003d1bf286112 (patch)
tree94fd2b65c4ffca90967ac63548a1964f53396f11
parentfadbe60cb25afb17777d5180e41ad7593fa25b97 (diff)
downloaditools-399bc5c45f0b74feee825e75a39003d1bf286112.tar.gz
itools-399bc5c45f0b74feee825e75a39003d1bf286112.tar.bz2
itools-399bc5c45f0b74feee825e75a39003d1bf286112.zip
some tests to make sure we don't have any wrong conversions from int to float
-rwxr-xr-xtest/it_dbi.t24
1 files changed, 18 insertions, 6 deletions
diff --git a/test/it_dbi.t b/test/it_dbi.t
index 2b5b0c5..ac6d526 100755
--- a/test/it_dbi.t
+++ b/test/it_dbi.t
@@ -27,6 +27,7 @@ $dbi->query("create temporary table it_dbi_test (
$autoid,
x int,
y float,
+ z bigint,
foo varchar(42),
flag boolean,
$dyncols,
@@ -44,9 +45,9 @@ try {
is(it::match('syntax', $e->getMessage()), 'syntax', "Syntax error triggers error");
}
-$record->insert(['x' => 42, 'y' => 0.0001, 'foo' => null, 'flag' => 1]);
-$record->insert(['foo' => "bar", 'y' => 1e-10, 'flag' => 0]);
-$record->insert(['x' => 64738, 'y' => 1, 'foo' => "q'uux"]);
+$record->insert(['x' => 42, 'y' => 0.0001, 'z' => 0, 'foo' => null, 'flag' => 1]);
+$record->insert(['foo' => "bar", 'y' => 1e-10, 'z' => 0, 'flag' => 0]);
+$record->insert(['x' => 64738, 'y' => 1, 'z' => 0, 'foo' => "q'uux"]);
is(
$record->ID,
@@ -192,6 +193,17 @@ is(
"update with function"
);
+$value = pow(2, 24) + 1;
+$record->update(['x' => $value]);
+is($record->x, $value, "update 32bit integer without float representation");
+is($record->select(['x' => $value]), 1, "select 32bit integer without float representation");
+
+$value = pow(2, 53) + 1;
+$record->update(['z' => $value]);
+is($record->z, $value, "update 64bit integer without double representation");
+is($record->select(['z' => $value]), 1, "select 64bit integer without double representation");
+
+
$record->update(['foo' => "00"]);
$rand = $record->x;
is (
@@ -489,14 +501,14 @@ $record->delete(['WHERE TRUE' ]);
$record->upsert(['ID' => 1, 'x' => 42, 'y' => 2.5, 'foo' => ['value' => "a"], 'flag' => 0]);
$record->read(1);
is($record->x, 42, 'value of x after reading with _read_postprocess');
-is($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'foo' => '{"value":"a"}', 'flag' => 0], 'data after reading with _read_postprocess');
+is($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"a"}', 'flag' => 0], 'data after reading with _read_postprocess');
is($record->foo, ['value' => "a"], 'field after reading with _read_postprocess');
$record2 = new it_dbi_test;
$record2->read(1);
is($record2->x, 43, 'raw value of x after writing with _write_preprocess');
-is($record2->_data, ["ID" => 1, "x" => 43, 'y' => 2.5, 'foo' => '{"value":"a"}', 'flag' => 0], 'raw data after writing with _write_preprocess');
+is($record2->_data, ["ID" => 1, "x" => 43, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"a"}', 'flag' => 0], 'raw data after writing with _write_preprocess');
$record->update(['foo' => ['value' => "b"]]);
-is($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'foo' => '{"value":"b"}', 'flag' => 0], 'raw data after updating with _write_preprocess');
+is($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"b"}', 'flag' => 0], 'raw data after updating with _write_preprocess');
is($record->foo, ['value' => "b"], 'field data after updating with _write_preprocess');