summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/bin2hex_basic.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/strings/bin2hex_basic.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/strings/bin2hex_basic.phpt')
-rw-r--r--ext/standard/tests/strings/bin2hex_basic.phpt50
1 files changed, 50 insertions, 0 deletions
diff --git a/ext/standard/tests/strings/bin2hex_basic.phpt b/ext/standard/tests/strings/bin2hex_basic.phpt
new file mode 100644
index 0000000..5d667a7
--- /dev/null
+++ b/ext/standard/tests/strings/bin2hex_basic.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test bin2hex() function : basic functionality
+--FILE--
+<?php
+
+/* Prototype : string bin2hex ( string $str )
+ * Description: Convert binary data into hexadecimal representation
+ * Source code: ext/standard/string.c
+*/
+
+echo "*** Testing bin2hex() : basic functionality ***\n";
+
+// array with different values for $string
+$strings = array (
+
+ //double quoted strings
+/*1*/ "Here is a simple string",
+ "\t This String contains \t\t some control characters\r\n",
+ "\x90\x91\x00\x93\x94\x90\x91\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
+
+ //single quoted strings
+/*4*/ 'Here is a simple string',
+ '\t This String contains \t\t some control characters\r\n',
+ '\x90\x91\x00\x93\x94\x90\x91\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f',
+);
+
+// loop through with each element of the $strings array to test bin2hex() function
+$count = 1;
+foreach($strings as $string) {
+ echo "-- Iteration $count --\n";
+ var_dump(bin2hex($string));
+ $count ++;
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing bin2hex() : basic functionality ***
+-- Iteration 1 --
+string(46) "4865726520697320612073696d706c6520737472696e67"
+-- Iteration 2 --
+string(102) "09205468697320537472696e6720636f6e7461696e7320090920736f6d6520636f6e74726f6c20636861726163746572730d0a"
+-- Iteration 3 --
+string(36) "9091009394909195969798999a9b9c9d9e9f"
+-- Iteration 4 --
+string(46) "4865726520697320612073696d706c6520737472696e67"
+-- Iteration 5 --
+string(112) "5c74205468697320537472696e6720636f6e7461696e73205c745c7420736f6d6520636f6e74726f6c20636861726163746572735c725c6e"
+-- Iteration 6 --
+string(144) "5c7839305c7839315c7830305c7839335c7839345c7839305c7839315c7839355c7839365c7839375c7839385c7839395c7839615c7839625c7839635c7839645c7839655c783966"
+===DONE===