tests++
authorMichael Wallner <mike@php.net>
Wed, 5 Jan 2022 22:14:58 +0000 (23:14 +0100)
committerMichael Wallner <mike@php.net>
Wed, 5 Jan 2022 22:14:58 +0000 (23:14 +0100)
tests/LOB.phpt [new file with mode: 0644]
tests/Reader/Stream.phpt [new file with mode: 0644]
tests/Writer/Buffer.phpt [new file with mode: 0644]
tests/Writer/Stream.phpt [new file with mode: 0644]

diff --git a/tests/LOB.phpt b/tests/LOB.phpt
new file mode 100644 (file)
index 0000000..f9855d3
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+ion\LOB
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+$l = new ion\LOB("foobar");
+echo ion\serialize($l), "\n";
+$l = new ion\LOB("barfuz", ion\Type::CLob);
+echo ion\serialize($l), "\n";
+$l = new ion\LOB("gooza", ion\Type::BLob);
+echo ion\serialize($l), "\n";
+?>
+DONE
+--EXPECTF--
+TEST
+{{"foobar"}}
+{{"barfuz"}}
+{{Z29vemE=}}
+DONE
diff --git a/tests/Reader/Stream.phpt b/tests/Reader/Stream.phpt
new file mode 100644 (file)
index 0000000..c856437
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+ion\Reader\Stream
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+$s = fopen("php://memory", "r+");
+var_dump(fwrite($s, "123d0"));
+rewind($s);
+$r = new ion\Reader\Stream\Reader($s);
+$r->next();
+var_dump($r->readDecimal());
+?>
+DONE
+--EXPECTF--
+TEST
+int(5)
+object(ion\Decimal)#2 (2) {
+  ["number"]=>
+  int(123)
+  ["context"]=>
+  object(ion\Decimal\Context)#3 (5) {
+    ["digits"]=>
+    int(999999999)
+    ["eMax"]=>
+    int(999999999)
+    ["eMin"]=>
+    int(-999999999)
+    ["round"]=>
+    int(3)
+    ["clamp"]=>
+    bool(false)
+  }
+}
+DONE
diff --git a/tests/Writer/Buffer.phpt b/tests/Writer/Buffer.phpt
new file mode 100644 (file)
index 0000000..aaa5b01
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+ion\Writer\Buffer
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+
+$w = new ion\Writer\Buffer\Writer($buf);
+for ($i = 0; $i < 100; ++$i) $w->writeTypedNull(ion\Type::Int);
+var_dump($buf === $w->getBuffer());
+$w->finish();
+echo $buf;
+?>
+
+DONE
+--EXPECTF--
+TEST
+bool(true)
+null.int%r( null.int)*%r
+DONE
diff --git a/tests/Writer/Stream.phpt b/tests/Writer/Stream.phpt
new file mode 100644 (file)
index 0000000..5b41194
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+ion\Writer\Stream
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+
+$w = new ion\Writer\Stream\Writer(STDOUT);
+$w->writeTypedNull(ion\Type::Int);
+var_dump(STDOUT === $w->getStream());
+$w->finish();
+
+?>
+
+DONE
+--EXPECTF--
+TEST
+bool(true)
+null.int
+DONE