diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/ctype | |
download | php2-c4dd7a1a684490673e25aaf4fabec5df138854c4.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/ctype')
79 files changed, 6709 insertions, 0 deletions
diff --git a/ext/ctype/CREDITS b/ext/ctype/CREDITS new file mode 100644 index 0000000..22de902 --- /dev/null +++ b/ext/ctype/CREDITS @@ -0,0 +1,2 @@ +ctype +Hartmut Holzgraefe diff --git a/ext/ctype/config.m4 b/ext/ctype/config.m4 new file mode 100644 index 0000000..7d575a3 --- /dev/null +++ b/ext/ctype/config.m4 @@ -0,0 +1,11 @@ +dnl +dnl $Id$ +dnl + +PHP_ARG_ENABLE(ctype, whether to enable ctype functions, +[ --disable-ctype Disable ctype functions], yes) + +if test "$PHP_CTYPE" != "no"; then + AC_DEFINE(HAVE_CTYPE, 1, [ ]) + PHP_NEW_EXTENSION(ctype, ctype.c, $ext_shared) +fi diff --git a/ext/ctype/config.w32 b/ext/ctype/config.w32 new file mode 100644 index 0000000..1ade89c --- /dev/null +++ b/ext/ctype/config.w32 @@ -0,0 +1,9 @@ +// $Id$ +// vim:ft=javascript + +ARG_ENABLE("ctype", "ctype", "yes"); + +if (PHP_CTYPE == "yes") { + EXTENSION("ctype", "ctype.c"); + AC_DEFINE('HAVE_CTYPE', 1, 'Have ctype'); +} diff --git a/ext/ctype/ctype.c b/ext/ctype/ctype.c new file mode 100644 index 0000000..e2698f5 --- /dev/null +++ b/ext/ctype/ctype.c @@ -0,0 +1,278 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Hartmut Holzgraefe <hholzgra@php.net> | + +----------------------------------------------------------------------+ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "php_ctype.h" +#include "SAPI.h" +#include "ext/standard/info.h" + +#include <ctype.h> + +#if HAVE_CTYPE + +static PHP_MINFO_FUNCTION(ctype); + +static PHP_FUNCTION(ctype_alnum); +static PHP_FUNCTION(ctype_alpha); +static PHP_FUNCTION(ctype_cntrl); +static PHP_FUNCTION(ctype_digit); +static PHP_FUNCTION(ctype_lower); +static PHP_FUNCTION(ctype_graph); +static PHP_FUNCTION(ctype_print); +static PHP_FUNCTION(ctype_punct); +static PHP_FUNCTION(ctype_space); +static PHP_FUNCTION(ctype_upper); +static PHP_FUNCTION(ctype_xdigit); + +/* {{{ arginfo */ +ZEND_BEGIN_ARG_INFO(arginfo_ctype_alnum, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_alpha, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_cntrl, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_digit, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_lower, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_graph, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_print, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_punct, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_space, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_upper, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_ctype_xdigit, 0) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +/* }}} */ + +/* {{{ ctype_functions[] + * Every user visible function must have an entry in ctype_functions[]. + */ +static const zend_function_entry ctype_functions[] = { + PHP_FE(ctype_alnum, arginfo_ctype_alnum) + PHP_FE(ctype_alpha, arginfo_ctype_alpha) + PHP_FE(ctype_cntrl, arginfo_ctype_cntrl) + PHP_FE(ctype_digit, arginfo_ctype_digit) + PHP_FE(ctype_lower, arginfo_ctype_lower) + PHP_FE(ctype_graph, arginfo_ctype_graph) + PHP_FE(ctype_print, arginfo_ctype_print) + PHP_FE(ctype_punct, arginfo_ctype_punct) + PHP_FE(ctype_space, arginfo_ctype_space) + PHP_FE(ctype_upper, arginfo_ctype_upper) + PHP_FE(ctype_xdigit, arginfo_ctype_xdigit) + PHP_FE_END +}; +/* }}} */ + +/* {{{ ctype_module_entry + */ +zend_module_entry ctype_module_entry = { + STANDARD_MODULE_HEADER, + "ctype", + ctype_functions, + NULL, + NULL, + NULL, + NULL, + PHP_MINFO(ctype), + NO_VERSION_YET, + STANDARD_MODULE_PROPERTIES +}; +/* }}} */ + +#ifdef COMPILE_DL_CTYPE +ZEND_GET_MODULE(ctype) +#endif + +/* {{{ PHP_MINFO_FUNCTION + */ +static PHP_MINFO_FUNCTION(ctype) +{ + php_info_print_table_start(); + php_info_print_table_row(2, "ctype functions", "enabled"); + php_info_print_table_end(); +} +/* }}} */ + +/* {{{ ctype + */ +#define CTYPE(iswhat) \ + zval *c, tmp; \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &c) == FAILURE) \ + return; \ + if (Z_TYPE_P(c) == IS_LONG) { \ + if (Z_LVAL_P(c) <= 255 && Z_LVAL_P(c) >= 0) { \ + RETURN_BOOL(iswhat(Z_LVAL_P(c))); \ + } else if (Z_LVAL_P(c) >= -128 && Z_LVAL_P(c) < 0) { \ + RETURN_BOOL(iswhat(Z_LVAL_P(c) + 256)); \ + } \ + tmp = *c; \ + zval_copy_ctor(&tmp); \ + convert_to_string(&tmp); \ + } else { \ + tmp = *c; \ + } \ + if (Z_TYPE(tmp) == IS_STRING) { \ + char *p = Z_STRVAL(tmp), *e = Z_STRVAL(tmp) + Z_STRLEN(tmp); \ + if (e == p) { \ + if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \ + RETURN_FALSE; \ + } \ + while (p < e) { \ + if(!iswhat((int)*(unsigned char *)(p++))) { \ + if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \ + RETURN_FALSE; \ + } \ + } \ + if (Z_TYPE_P(c) == IS_LONG) zval_dtor(&tmp); \ + RETURN_TRUE; \ + } else { \ + RETURN_FALSE; \ + } \ + +/* }}} */ + +/* {{{ proto bool ctype_alnum(mixed c) + Checks for alphanumeric character(s) */ +static PHP_FUNCTION(ctype_alnum) +{ + CTYPE(isalnum); +} +/* }}} */ + +/* {{{ proto bool ctype_alpha(mixed c) + Checks for alphabetic character(s) */ +static PHP_FUNCTION(ctype_alpha) +{ + CTYPE(isalpha); +} +/* }}} */ + +/* {{{ proto bool ctype_cntrl(mixed c) + Checks for control character(s) */ +static PHP_FUNCTION(ctype_cntrl) +{ + CTYPE(iscntrl); +} +/* }}} */ + +/* {{{ proto bool ctype_digit(mixed c) + Checks for numeric character(s) */ +static PHP_FUNCTION(ctype_digit) +{ + CTYPE(isdigit); +} +/* }}} */ + +/* {{{ proto bool ctype_lower(mixed c) + Checks for lowercase character(s) */ +static PHP_FUNCTION(ctype_lower) +{ + CTYPE(islower); +} +/* }}} */ + +/* {{{ proto bool ctype_graph(mixed c) + Checks for any printable character(s) except space */ +static PHP_FUNCTION(ctype_graph) +{ + CTYPE(isgraph); +} +/* }}} */ + +/* {{{ proto bool ctype_print(mixed c) + Checks for printable character(s) */ +static PHP_FUNCTION(ctype_print) +{ + CTYPE(isprint); +} +/* }}} */ + +/* {{{ proto bool ctype_punct(mixed c) + Checks for any printable character which is not whitespace or an alphanumeric character */ +static PHP_FUNCTION(ctype_punct) +{ + CTYPE(ispunct); +} +/* }}} */ + +/* {{{ proto bool ctype_space(mixed c) + Checks for whitespace character(s)*/ +static PHP_FUNCTION(ctype_space) +{ + CTYPE(isspace); +} +/* }}} */ + +/* {{{ proto bool ctype_upper(mixed c) + Checks for uppercase character(s) */ +static PHP_FUNCTION(ctype_upper) +{ + CTYPE(isupper); +} +/* }}} */ + +/* {{{ proto bool ctype_xdigit(mixed c) + Checks for character(s) representing a hexadecimal digit */ +static PHP_FUNCTION(ctype_xdigit) +{ + CTYPE(isxdigit); +} +/* }}} */ + +#endif /* HAVE_CTYPE */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 + */ diff --git a/ext/ctype/ctype.dsp b/ext/ctype/ctype.dsp new file mode 100644 index 0000000..1305c72 --- /dev/null +++ b/ext/ctype/ctype.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="ctype" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=ctype - Win32 Debug_TS
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ctype.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ctype.mak" CFG="ctype - Win32 Debug_TS"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ctype - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ctype - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ctype - Win32 Release_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release_TS"
+# PROP BASE Intermediate_Dir "Release_TS"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_TS"
+# PROP Intermediate_Dir "Release_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D "WIN32" /D "PHP_EXPORTS" /D "COMPILE_DL_CTYPE" /D ZTS=1 /D HAVE_CTYPE=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 php5ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_ctype.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
+
+!ELSEIF "$(CFG)" == "ctype - Win32 Debug_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug_TS"
+# PROP BASE Intermediate_Dir "Debug_TS"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_TS"
+# PROP Intermediate_Dir "Debug_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_CTYPE" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_CTYPE=1 /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 php5ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_ctype.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"
+
+!ENDIF
+
+# Begin Target
+
+# Name "ctype - Win32 Release_TS"
+# Name "ctype - Win32 Debug_TS"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\ctype.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\php_ctype.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/ext/ctype/ctype.xml b/ext/ctype/ctype.xml new file mode 100644 index 0000000..5837b9b --- /dev/null +++ b/ext/ctype/ctype.xml @@ -0,0 +1,245 @@ + <reference id="ref.ctype"> + <title>Character type functions</title> + <titleabbrev>ctype</titleabbrev> + + <partintro> + <para> + These functions check whether a character or string + falls into a certain character class according to the i + current locale. + </para> + <para> + When called with an integer argument theese functions + behave exactly like their C counterparts. + </para> + <para> + When called with a string argument they will check + every character in the string and will only return + true if every character in the string matches the + requested criteria. + </para> + <para> + Passing anything else but a string or integer will + return false immediately. + </para> + </partintro> + + + <refentry id="function.isalnum"> + <refnamediv> + <refname>isalnum</refname> + <refpurpose>Check for alphanumeric character(s)</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isalnum</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + See also <function>setlocale</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.isalpha"> + <refnamediv> + <refname>isalpha</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isalpha</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.iscntrl"> + <refnamediv> + <refname>iscntrl</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>iscntrl</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.isdigit"> + <refnamediv> + <refname>isdigit</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isdigit</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.islower"> + <refnamediv> + <refname>islower</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>islower</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.isgraph"> + <refnamediv> + <refname>isgraph</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isgraph</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.isprint"> + <refnamediv> + <refname>isprint</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isprint</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.ispunct"> + <refnamediv> + <refname>ispunct</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>ispunct</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.isspace"> + <refnamediv> + <refname>isspace</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isspace</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.isupper"> + <refnamediv> + <refname>isupper</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isupper</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + <refentry id="function.isxdigit"> + <refnamediv> + <refname>isxdigit</refname> + <refpurpose></refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool <function>isxdigit</function></funcdef> + <paramdef>string <parameter>c</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + </para> + </refsect1> + </refentry> + + </reference> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +sgml-parent-document:nil +sgml-default-dtd-file:"../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +--> + diff --git a/ext/ctype/package.xml b/ext/ctype/package.xml new file mode 100644 index 0000000..71c9cd9 --- /dev/null +++ b/ext/ctype/package.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE package SYSTEM "../pear/package.dtd"> +<package> + <name>ctype</name> + <summary>Character type detection</summary> + <maintainers> + <maintainer> + <user>hholzgra</user> + <name>Hartmut Holzgraefe</name> + <email>hartmut@php.net</email> + <role>lead</role> + </maintainer> + </maintainers> + <description> +The functions provided by this extension check whether a +character or string falls into a certain character class +according to the current locale. + </description> + <license>PHP</license> + <release> + <state>beta</state> + <version>5.0.0rc1</version> + <date>2004-03-19</date> + <notes> +package.xml added to support installation using pear installer + </notes> + <filelist> + <file role="doc" name="CREDITS"/> + <file role="doc" name="README"/> + <file role="src" name="config.m4"/> + <file role="src" name="config.w32"/> + <file role="src" name="ctype.dsp"/> + <file role="src" name="ctype.c"/> + <file role="src" name="php_ctype.h"/> + <file role="test" name="tests/001.phpt"/> + <file role="test" name="tests/002.phpt"/> + <file role="test" name="tests/bug25745.phpt"/> + </filelist> + <deps> + <dep type="php" rel="ge" version="5" /> + </deps> + </release> +</package> +<!-- +vim:et:ts=1:sw=1 +--> diff --git a/ext/ctype/php_ctype.h b/ext/ctype/php_ctype.h new file mode 100644 index 0000000..e1036b9 --- /dev/null +++ b/ext/ctype/php_ctype.h @@ -0,0 +1,41 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Hartmut Holzgraefe <hholzgra@php.net> | + +----------------------------------------------------------------------+ + */ + +#ifndef PHP_CTYPE_H +#define PHP_CTYPE_H + +#if HAVE_CTYPE + +extern zend_module_entry ctype_module_entry; +#define phpext_ctype_ptr &ctype_module_entry + +#else + +#define phpext_ctype_ptr NULL + +#endif + +#endif /* PHP_CTYPE_H */ + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ diff --git a/ext/ctype/tests/001.phpt b/ext/ctype/tests/001.phpt new file mode 100644 index 0000000..0c80aec --- /dev/null +++ b/ext/ctype/tests/001.phpt @@ -0,0 +1,39 @@ +--TEST-- +ctype on integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + setlocale(LC_ALL,"C"); + + function ctype_test_001($function) { + $n=0; + for($a=0;$a<256;$a++) { + if($function($a)) $n++; + } + echo "$function $n\n"; + } +ctype_test_001("ctype_lower"); +ctype_test_001("ctype_upper"); +ctype_test_001("ctype_alpha"); +ctype_test_001("ctype_digit"); +ctype_test_001("ctype_alnum"); +ctype_test_001("ctype_cntrl"); +ctype_test_001("ctype_graph"); +ctype_test_001("ctype_print"); +ctype_test_001("ctype_punct"); +ctype_test_001("ctype_space"); +ctype_test_001("ctype_xdigit"); +?> +--EXPECT-- +ctype_lower 26 +ctype_upper 26 +ctype_alpha 52 +ctype_digit 10 +ctype_alnum 62 +ctype_cntrl 33 +ctype_graph 94 +ctype_print 95 +ctype_punct 32 +ctype_space 6 +ctype_xdigit 22 diff --git a/ext/ctype/tests/002.phpt b/ext/ctype/tests/002.phpt new file mode 100644 index 0000000..c20612c --- /dev/null +++ b/ext/ctype/tests/002.phpt @@ -0,0 +1,48 @@ +--TEST-- +ctype on strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +setlocale(LC_ALL,"C"); +print "LOCALE is '" . setlocale(LC_ALL,0) . "'\n"; + +function ctype_test_002($function) { + $n1 = $n2 = $n3 = 0; + // test portable POSIX characters 0..127 + for ($a=0;$a<128;$a++) { + $c = chr($a); + if($function($a)) $n1++; + if($function("$c$c$c")) $n2++; + if($function("1-$c$c$c-x")) $n3++; + } + print "$function $n1 $n2 $n3\n"; +} + +ctype_test_002("ctype_lower"); +ctype_test_002("ctype_upper"); +ctype_test_002("ctype_alpha"); +ctype_test_002("ctype_digit"); +ctype_test_002("ctype_alnum"); +ctype_test_002("ctype_cntrl"); +ctype_test_002("ctype_graph"); +ctype_test_002("ctype_print"); +ctype_test_002("ctype_punct"); +ctype_test_002("ctype_space"); +ctype_test_002("ctype_xdigit"); + +?> +--EXPECTF-- +LOCALE is '%s' +ctype_lower 26 26 0 +ctype_upper 26 26 0 +ctype_alpha 52 52 0 +ctype_digit 10 10 0 +ctype_alnum 62 62 0 +ctype_cntrl 33 33 0 +ctype_graph 94 94 94 +ctype_print 95 95 95 +ctype_punct 32 32 0 +ctype_space 6 6 0 +ctype_xdigit 22 22 0 diff --git a/ext/ctype/tests/bug25745.phpt b/ext/ctype/tests/bug25745.phpt new file mode 100644 index 0000000..ecacebb --- /dev/null +++ b/ext/ctype/tests/bug25745.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #25745 (ctype functions fail with non-ascii characters) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$funcs = array( + "ctype_alnum", "ctype_alpha", "ctype_cntrl", "ctype_digit", + "ctype_graph", "ctype_lower", "ctype_print", "ctype_punct", + "ctype_space", "ctype_upper", "ctype_xdigit" +); + +foreach ($funcs as $ctype_func) { + for ($i = 0; $i < 256; $i++) { + $a = $ctype_func($i); + $b = $ctype_func(chr($i)); + if ($a != $b) { + echo "broken... $ctype_func($i) = $a, $ctype_func(chr($i)) = $b\n"; + exit; + } + } +} +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/ext/ctype/tests/bug34645.phpt b/ext/ctype/tests/bug34645.phpt new file mode 100644 index 0000000..7aa3862 --- /dev/null +++ b/ext/ctype/tests/bug34645.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #34645 (ctype corrupts memory when validating large numbers) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$id = 394829384; +var_dump(ctype_digit($id)); +var_dump($id); +?> +--EXPECT-- +bool(true) +int(394829384) diff --git a/ext/ctype/tests/ctype_alnum_basic.phpt b/ext/ctype/tests/ctype_alnum_basic.phpt new file mode 100644 index 0000000..2a18b82 --- /dev/null +++ b/ext/ctype/tests/ctype_alnum_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_alnum() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alnum(mixed $c) + * Description: Checks for alphanumeric character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_alnum() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = 'abcXYZ'; +$c2 = ' \t*@'; + +var_dump(ctype_alnum($c1)); +var_dump(ctype_alnum($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alnum() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_alnum_error.phpt b/ext/ctype/tests/ctype_alnum_error.phpt new file mode 100644 index 0000000..0b4a636 --- /dev/null +++ b/ext/ctype/tests/ctype_alnum_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test ctype_alnum() function : error conditions - Incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alnum(mixed $c) + * Description: Checks for alphanumeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass incorrect number of arguments to ctype_alnum() to test behaviour + */ + +echo "*** Testing ctype_alnum() : error conditions ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +// Zero arguments +echo "\n-- Testing ctype_alnum() function with Zero arguments --\n"; +var_dump( ctype_alnum() ); + +//Test ctype_alnum with one more than the expected number of arguments +echo "\n-- Testing ctype_alnum() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_alnum($c, $extra_arg) ); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alnum() : error conditions *** + +-- Testing ctype_alnum() function with Zero arguments -- + +Warning: ctype_alnum() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_alnum() function with more than expected no. of arguments -- + +Warning: ctype_alnum() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_alnum_variation1.phpt b/ext/ctype/tests/ctype_alnum_variation1.phpt new file mode 100644 index 0000000..2505428 --- /dev/null +++ b/ext/ctype/tests/ctype_alnum_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_alnum() function : usage variations - Different data types as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alnum(mixed $c) + * Description: Checks for alphanumeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_alnum() to test behaviour + */ + +echo "*** Testing ctype_alnum() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "xyz"; + } +} + +// heredoc string +$heredoc = <<<EOT +123 +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "pqr", + 'LMN', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_alnum() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_alnum($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alnum() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(true) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_alnum_variation2.phpt b/ext/ctype/tests/ctype_alnum_variation2.phpt new file mode 100644 index 0000000..94ae22d --- /dev/null +++ b/ext/ctype/tests/ctype_alnum_variation2.phpt @@ -0,0 +1,94 @@ +--TEST-- +Test ctype_alnum() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alnum(mixed $c) + * Description: Checks for alphanumeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_alnum() to test which character codes are considered + * valid alphanumeric characters + */ + +echo "*** Testing ctype_alnum() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_alnum($i)) { + echo "character code $i is alpha numeric\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alnum() : usage variations *** +character code 48 is alpha numeric +character code 49 is alpha numeric +character code 50 is alpha numeric +character code 51 is alpha numeric +character code 52 is alpha numeric +character code 53 is alpha numeric +character code 54 is alpha numeric +character code 55 is alpha numeric +character code 56 is alpha numeric +character code 57 is alpha numeric +character code 65 is alpha numeric +character code 66 is alpha numeric +character code 67 is alpha numeric +character code 68 is alpha numeric +character code 69 is alpha numeric +character code 70 is alpha numeric +character code 71 is alpha numeric +character code 72 is alpha numeric +character code 73 is alpha numeric +character code 74 is alpha numeric +character code 75 is alpha numeric +character code 76 is alpha numeric +character code 77 is alpha numeric +character code 78 is alpha numeric +character code 79 is alpha numeric +character code 80 is alpha numeric +character code 81 is alpha numeric +character code 82 is alpha numeric +character code 83 is alpha numeric +character code 84 is alpha numeric +character code 85 is alpha numeric +character code 86 is alpha numeric +character code 87 is alpha numeric +character code 88 is alpha numeric +character code 89 is alpha numeric +character code 90 is alpha numeric +character code 97 is alpha numeric +character code 98 is alpha numeric +character code 99 is alpha numeric +character code 100 is alpha numeric +character code 101 is alpha numeric +character code 102 is alpha numeric +character code 103 is alpha numeric +character code 104 is alpha numeric +character code 105 is alpha numeric +character code 106 is alpha numeric +character code 107 is alpha numeric +character code 108 is alpha numeric +character code 109 is alpha numeric +character code 110 is alpha numeric +character code 111 is alpha numeric +character code 112 is alpha numeric +character code 113 is alpha numeric +character code 114 is alpha numeric +character code 115 is alpha numeric +character code 116 is alpha numeric +character code 117 is alpha numeric +character code 118 is alpha numeric +character code 119 is alpha numeric +character code 120 is alpha numeric +character code 121 is alpha numeric +character code 122 is alpha numeric +===DONE=== diff --git a/ext/ctype/tests/ctype_alnum_variation3.phpt b/ext/ctype/tests/ctype_alnum_variation3.phpt new file mode 100644 index 0000000..a9da6c9 --- /dev/null +++ b/ext/ctype/tests/ctype_alnum_variation3.phpt @@ -0,0 +1,129 @@ +--TEST-- +Test ctype_alnum() function : usage variations - different string values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alnum(mixed $c) + * Description: Checks for alphanumeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different strings to ctype_alnum to test behaviour + */ + +echo "*** Testing ctype_alnum() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + 'abc123\n', +/*20*/ 'abc 123', + '', + ' ', +/*23*/ base64_decode("w4DDoMOHw6fDiMOo") // non-ascii characters +); + + +// loop through each element of $values to test behaviour of ctype_alnum() +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_alnum($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alnum() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +bool(true) + +-- Iteration 8 -- +bool(true) + +-- Iteration 9 -- +bool(true) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(true) + +-- Iteration 12 -- +bool(true) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(true) + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_alnum_variation4.phpt b/ext/ctype/tests/ctype_alnum_variation4.phpt new file mode 100644 index 0000000..49167eb --- /dev/null +++ b/ext/ctype/tests/ctype_alnum_variation4.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test ctype_alnum() function : usage variations - octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alnum(mixed $c) + * Description: Checks for alphanumeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values to ctype_alnum() to test behaviour + */ + +echo "*** Testing ctype_alnum() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array (060, 061, 062, 063); +$hex_values = array(0x30, 0x31, 0x32, 0x33); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alnum($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alnum($c)); + $iterator++; +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alnum() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_alpha_basic.phpt b/ext/ctype/tests/ctype_alpha_basic.phpt new file mode 100644 index 0000000..f0d8af8 --- /dev/null +++ b/ext/ctype/tests/ctype_alpha_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_alpha() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alpha(mixed $c) + * Description: Checks for alphabetic character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_alpha() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = 'abcXYZ'; +$c2 = "Hello, World!"; + +var_dump(ctype_alpha($c1)); +var_dump(ctype_alpha($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alpha() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_alpha_error.phpt b/ext/ctype/tests/ctype_alpha_error.phpt new file mode 100644 index 0000000..4cf8234 --- /dev/null +++ b/ext/ctype/tests/ctype_alpha_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_alpha() function : error conditions - Incorrect number of arguments +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alpha(mixed $c) + * Description: Checks for alphabetic character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass an incorrect number of arguments to ctype_alpha() to test behaviour + */ + +echo "*** Testing ctype_alpha() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_alpha() function with Zero arguments --\n"; +var_dump( ctype_alpha() ); + +//Test ctype_alpha with one more than the expected number of arguments +echo "\n-- Testing ctype_alpha() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_alpha($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alpha() : error conditions *** + +-- Testing ctype_alpha() function with Zero arguments -- + +Warning: ctype_alpha() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_alpha() function with more than expected no. of arguments -- + +Warning: ctype_alpha() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_alpha_variation1.phpt b/ext/ctype/tests/ctype_alpha_variation1.phpt new file mode 100644 index 0000000..baa75c8 --- /dev/null +++ b/ext/ctype/tests/ctype_alpha_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_alpha() function : usage variations - different data types as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alpha(mixed $c) + * Description: Checks for alphabetic character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_alpha() to test behaviour + */ + +echo "*** Testing ctype_alpha() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "abcdef"; + } +} + +// heredoc string +$heredoc = <<<EOT +XYZ +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "string", + 'string', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_alpha() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_alpha($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alpha() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_alpha_variation2.phpt b/ext/ctype/tests/ctype_alpha_variation2.phpt new file mode 100644 index 0000000..866f372 --- /dev/null +++ b/ext/ctype/tests/ctype_alpha_variation2.phpt @@ -0,0 +1,84 @@ +--TEST-- +Test ctype_alpha() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alpha(mixed $c) + * Description: Checks for alphabetic character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_alpha() to test which character codes are considered + * valid alphabetic characters + */ + +echo "*** Testing ctype_alpha() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_alpha($i)) { + echo "character code $i is alphabetic\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alpha() : usage variations *** +character code 65 is alphabetic +character code 66 is alphabetic +character code 67 is alphabetic +character code 68 is alphabetic +character code 69 is alphabetic +character code 70 is alphabetic +character code 71 is alphabetic +character code 72 is alphabetic +character code 73 is alphabetic +character code 74 is alphabetic +character code 75 is alphabetic +character code 76 is alphabetic +character code 77 is alphabetic +character code 78 is alphabetic +character code 79 is alphabetic +character code 80 is alphabetic +character code 81 is alphabetic +character code 82 is alphabetic +character code 83 is alphabetic +character code 84 is alphabetic +character code 85 is alphabetic +character code 86 is alphabetic +character code 87 is alphabetic +character code 88 is alphabetic +character code 89 is alphabetic +character code 90 is alphabetic +character code 97 is alphabetic +character code 98 is alphabetic +character code 99 is alphabetic +character code 100 is alphabetic +character code 101 is alphabetic +character code 102 is alphabetic +character code 103 is alphabetic +character code 104 is alphabetic +character code 105 is alphabetic +character code 106 is alphabetic +character code 107 is alphabetic +character code 108 is alphabetic +character code 109 is alphabetic +character code 110 is alphabetic +character code 111 is alphabetic +character code 112 is alphabetic +character code 113 is alphabetic +character code 114 is alphabetic +character code 115 is alphabetic +character code 116 is alphabetic +character code 117 is alphabetic +character code 118 is alphabetic +character code 119 is alphabetic +character code 120 is alphabetic +character code 121 is alphabetic +character code 122 is alphabetic +===DONE=== diff --git a/ext/ctype/tests/ctype_alpha_variation3.phpt b/ext/ctype/tests/ctype_alpha_variation3.phpt new file mode 100644 index 0000000..5ab4bd6 --- /dev/null +++ b/ext/ctype/tests/ctype_alpha_variation3.phpt @@ -0,0 +1,130 @@ +--TEST-- +Test ctype_alpha() function : usage variations - different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alpha(mixed $c) + * Description: Checks for alphabetic character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_alpha() to test + * which are considered valid alphabetic character only strings + */ + +echo "*** Testing ctype_alpha() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + 'abc123\n', +/*20*/ 'abc 123', + '', + ' ', +/*23*/ base64_decode("w4DDoMOHw6fDiMOo") // non-ascii characters +); + + +// loop through each element of $values to test behaviour of ctype_alnum() +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_alpha($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alpha() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +bool(true) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_alpha_variation4.phpt b/ext/ctype/tests/ctype_alpha_variation4.phpt new file mode 100644 index 0000000..c41d972 --- /dev/null +++ b/ext/ctype/tests/ctype_alpha_variation4.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test ctype_alpha() function : usage variations - Octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_alpha(mixed $c) + * Description: Checks for alphabetic character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values to ctype_alpha() to test behaviour + */ + +echo "*** Testing ctype_alpha() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array (0101, 0102, 0103, 0104); +$hex_values = array (0x41, 0x42, 0x43, 0x44); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alpha($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alpha($c)); + $iterator++; +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_alpha() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_cntrl_basic.phpt b/ext/ctype/tests/ctype_cntrl_basic.phpt new file mode 100644 index 0000000..b9241ad --- /dev/null +++ b/ext/ctype/tests/ctype_cntrl_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_cntrl() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_cntrl(mixed $c) + * Description: Checks for control character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_cntrl() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = "\r\n\t"; +$c2 = "Hello, World!\n"; + +var_dump(ctype_cntrl($c1)); +var_dump(ctype_cntrl($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_cntrl() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_cntrl_error.phpt b/ext/ctype/tests/ctype_cntrl_error.phpt new file mode 100644 index 0000000..7319ef6 --- /dev/null +++ b/ext/ctype/tests/ctype_cntrl_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_cntrl() function : error conditions - Incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_cntrl(mixed $c) + * Description: Checks for control character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass an incorrect number of arguments to ctype_cntrl() to test behaviour + */ + +echo "*** Testing ctype_cntrl() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_cntrl() function with Zero arguments --\n"; +var_dump( ctype_cntrl() ); + +//Test ctype_cntrl with one more than the expected number of arguments +echo "\n-- Testing ctype_cntrl() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_cntrl($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_cntrl() : error conditions *** + +-- Testing ctype_cntrl() function with Zero arguments -- + +Warning: ctype_cntrl() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_cntrl() function with more than expected no. of arguments -- + +Warning: ctype_cntrl() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_cntrl_variation1.phpt b/ext/ctype/tests/ctype_cntrl_variation1.phpt new file mode 100644 index 0000000..f74c13f --- /dev/null +++ b/ext/ctype/tests/ctype_cntrl_variation1.phpt @@ -0,0 +1,180 @@ +--TEST-- +Test ctype_cntrl() function : usage variations - Different data types as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_cntrl(mixed $c) + * Description: Checks for control character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_cntrl() to test behaviour + */ + +echo "*** Testing ctype_cntrl() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "\n\r\t"; + } +} + +// heredoc string +$heredoc = <<<EOT +\t\r\n +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "\t\r\n", + ' +', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_cntrl() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_cntrl($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_cntrl() : usage variations *** + +-- Iteration 1 -- +bool(true) + +-- Iteration 2 -- +bool(true) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_cntrl_variation2.phpt b/ext/ctype/tests/ctype_cntrl_variation2.phpt new file mode 100644 index 0000000..b48ab94 --- /dev/null +++ b/ext/ctype/tests/ctype_cntrl_variation2.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test ctype_cntrl() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_cntrl(mixed $c) + * Description: Checks for control character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_cntrl() to test which character codes are considered + * valid control characters + */ + +echo "*** Testing ctype_cntrl() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_cntrl($i)) { + echo "character code $i is control character\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_cntrl() : usage variations *** +character code 0 is control character +character code 1 is control character +character code 2 is control character +character code 3 is control character +character code 4 is control character +character code 5 is control character +character code 6 is control character +character code 7 is control character +character code 8 is control character +character code 9 is control character +character code 10 is control character +character code 11 is control character +character code 12 is control character +character code 13 is control character +character code 14 is control character +character code 15 is control character +character code 16 is control character +character code 17 is control character +character code 18 is control character +character code 19 is control character +character code 20 is control character +character code 21 is control character +character code 22 is control character +character code 23 is control character +character code 24 is control character +character code 25 is control character +character code 26 is control character +character code 27 is control character +character code 28 is control character +character code 29 is control character +character code 30 is control character +character code 31 is control character +character code 127 is control character +===DONE=== diff --git a/ext/ctype/tests/ctype_cntrl_variation3.phpt b/ext/ctype/tests/ctype_cntrl_variation3.phpt new file mode 100644 index 0000000..4ae5bc3 --- /dev/null +++ b/ext/ctype/tests/ctype_cntrl_variation3.phpt @@ -0,0 +1,158 @@ +--TEST-- +Test ctype_cntrl() function : usage variations - Different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_cntrl(mixed $c) + * Description: Checks for control character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_cntrl() to test + * which are considered valid control character only strings + */ + +echo "*** Testing ctype_cntrl() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + 'abc123\n', +/*20*/ 'abc 123', + '', + ' ', + base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters + "\n", +/*25*/ "\r", + "\t", + "0xD", + "0xA", + "0xE", +/*30*/ "\t\r\n", +); + + +// loop through each element of $values to test behaviour of ctype_cntrl() +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_cntrl($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_cntrl() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(true) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(true) + +-- Iteration 25 -- +bool(true) + +-- Iteration 26 -- +bool(true) + +-- Iteration 27 -- +bool(false) + +-- Iteration 28 -- +bool(false) + +-- Iteration 29 -- +bool(false) + +-- Iteration 30 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_cntrl_variation4.phpt b/ext/ctype/tests/ctype_cntrl_variation4.phpt new file mode 100644 index 0000000..0e1c503 --- /dev/null +++ b/ext/ctype/tests/ctype_cntrl_variation4.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test ctype_cntrl() function : usage variations - Octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_cntrl(mixed $c) + * Description: Checks for control character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass hexadecimal and octal values to ctype_cntrl() to test behaviour + */ + +echo "*** Testing ctype_cntrl() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array(01, 02, 03, 04); +$hex_values = array(0x1, 0x2, 0x3, 0x4); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_cntrl($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_cntrl($c)); + $iterator++; +} +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_cntrl() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_digit_basic.phpt b/ext/ctype/tests/ctype_digit_basic.phpt new file mode 100644 index 0000000..049580d --- /dev/null +++ b/ext/ctype/tests/ctype_digit_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_digit() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_digit(mixed $c) + * Description: Checks for numeric character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_digit() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = '1234'; +$c2 = 'abc123'; + +var_dump(ctype_digit($c1)); +var_dump(ctype_digit($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_digit() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_digit_error.phpt b/ext/ctype/tests/ctype_digit_error.phpt new file mode 100644 index 0000000..5e80882 --- /dev/null +++ b/ext/ctype/tests/ctype_digit_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_digit() function : error conditions - incorrect number of arguments +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_digit(mixed $c) + * Description: Checks for numeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass an incorrect number of arguments to ctype_digit() to test behaviour + */ + +echo "*** Testing ctype_digit() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_digit() function with Zero arguments --\n"; +var_dump( ctype_digit() ); + +//Test ctype_digit with one more than the expected number of arguments +echo "\n-- Testing ctype_digit() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_digit($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_digit() : error conditions *** + +-- Testing ctype_digit() function with Zero arguments -- + +Warning: ctype_digit() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_digit() function with more than expected no. of arguments -- + +Warning: ctype_digit() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_digit_variation1.phpt b/ext/ctype/tests/ctype_digit_variation1.phpt new file mode 100644 index 0000000..3069491 --- /dev/null +++ b/ext/ctype/tests/ctype_digit_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_digit() function : usage variations - different data types as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_digit(mixed $c) + * Description: Checks for numeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_digit() to test behaviour + */ + +echo "*** Testing ctype_digit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "123456"; + } +} + +// heredoc string +$heredoc = <<<EOT +1 +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "2", + '309', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_digit() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_digit($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_digit() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(true) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_digit_variation2.phpt b/ext/ctype/tests/ctype_digit_variation2.phpt new file mode 100644 index 0000000..318737f --- /dev/null +++ b/ext/ctype/tests/ctype_digit_variation2.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test ctype_digit() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_digit(mixed $c) + * Description: Checks for numeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_digit() to test which character codes are considered + * valid decimal digits + */ + +echo "*** Testing ctype_digit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_digit($i)) { + echo "character code $i is a numeric digit\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_digit() : usage variations *** +character code 48 is a numeric digit +character code 49 is a numeric digit +character code 50 is a numeric digit +character code 51 is a numeric digit +character code 52 is a numeric digit +character code 53 is a numeric digit +character code 54 is a numeric digit +character code 55 is a numeric digit +character code 56 is a numeric digit +character code 57 is a numeric digit +===DONE=== diff --git a/ext/ctype/tests/ctype_digit_variation3.phpt b/ext/ctype/tests/ctype_digit_variation3.phpt new file mode 100644 index 0000000..66ef6f3 --- /dev/null +++ b/ext/ctype/tests/ctype_digit_variation3.phpt @@ -0,0 +1,160 @@ +--TEST-- +Test ctype_digit() function : usage variations - different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_digit(mixed $c) + * Description: Checks for numeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_digit() to test + * which are considered valid decimal digit only strings + */ + +echo "*** Testing ctype_digit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + ")speci@! ch@r$(", + '@!$*', + "0", +/*15*/ "3", + "9", + "1234", + "7890", + "0677", +/*20*/ '0', + '3', + '9', + '1234', + '7890', +/*25*/ "123abc", + "abc123", + "123\r\t", + "123 ", + " 123", +/*30*/ "123E4", +/*31*/ "0x3F", +); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_digit($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_digit() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(true) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(true) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(true) + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(true) + +-- Iteration 23 -- +bool(true) + +-- Iteration 24 -- +bool(true) + +-- Iteration 25 -- +bool(false) + +-- Iteration 26 -- +bool(false) + +-- Iteration 27 -- +bool(false) + +-- Iteration 28 -- +bool(false) + +-- Iteration 29 -- +bool(false) + +-- Iteration 30 -- +bool(false) + +-- Iteration 31 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_digit_variation4.phpt b/ext/ctype/tests/ctype_digit_variation4.phpt new file mode 100644 index 0000000..c94be3e --- /dev/null +++ b/ext/ctype/tests/ctype_digit_variation4.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test ctype_digit() function : usage variations - octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_digit(mixed $c) + * Description: Checks for numeric character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values as $c argument to ctype_digit() to test behaviour + */ + +echo "*** Testing ctype_digit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array(061, 062, 063, 064); +$hex_values = array (0x31, 0x32, 0x33, 0x34); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_digit($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_digit($c)); + $iterator++; +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_digit() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_graph_basic.phpt b/ext/ctype/tests/ctype_graph_basic.phpt new file mode 100644 index 0000000..b45aac6 --- /dev/null +++ b/ext/ctype/tests/ctype_graph_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_graph() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_graph(mixed $c) + * Description: Checks for any printable character(s) except space + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_graph() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = 'helloWorld!'; +$c2 = "Hello, world!\n"; + +var_dump(ctype_graph($c1)); +var_dump(ctype_graph($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_graph() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_graph_error.phpt b/ext/ctype/tests/ctype_graph_error.phpt new file mode 100644 index 0000000..953b553 --- /dev/null +++ b/ext/ctype/tests/ctype_graph_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_graph() function : error conditions - incorrect number of arguments +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_graph(mixed $c) + * Description: Checks for any printable character(s) except space + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass an incorrect number of arguments to ctype_graph() to test behaviour + */ + +echo "*** Testing ctype_graph() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_graph() function with Zero arguments --\n"; +var_dump( ctype_graph() ); + +//Test ctype_graph with one more than the expected number of arguments +echo "\n-- Testing ctype_graph() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_graph($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_graph() : error conditions *** + +-- Testing ctype_graph() function with Zero arguments -- + +Warning: ctype_graph() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_graph() function with more than expected no. of arguments -- + +Warning: ctype_graph() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_graph_variation1.phpt b/ext/ctype/tests/ctype_graph_variation1.phpt new file mode 100644 index 0000000..03471f1 --- /dev/null +++ b/ext/ctype/tests/ctype_graph_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_graph() function : usage variations - different data types as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_graph(mixed $c) + * Description: Checks for any printable character(s) except space + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_graph() to test behaviour + */ + +echo "*** Testing ctype_graph() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "myClass"; + } +} + +// heredoc string +$heredoc = <<<EOT +hiWorld! +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "string", + 'string', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_graph() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_graph($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_graph() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(true) + +-- Iteration 4 -- +bool(true) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_graph_variation2.phpt b/ext/ctype/tests/ctype_graph_variation2.phpt new file mode 100644 index 0000000..8f8b3fe --- /dev/null +++ b/ext/ctype/tests/ctype_graph_variation2.phpt @@ -0,0 +1,126 @@ +--TEST-- +Test ctype_graph() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_graph(mixed $c) + * Description: Checks for any printable character(s) except space + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_graph() to test which character codes are considered + * valid visibly printable characters + */ + +echo "*** Testing ctype_graph() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_graph($i)) { + echo "character code $i is a printable character\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_graph() : usage variations *** +character code 33 is a printable character +character code 34 is a printable character +character code 35 is a printable character +character code 36 is a printable character +character code 37 is a printable character +character code 38 is a printable character +character code 39 is a printable character +character code 40 is a printable character +character code 41 is a printable character +character code 42 is a printable character +character code 43 is a printable character +character code 44 is a printable character +character code 45 is a printable character +character code 46 is a printable character +character code 47 is a printable character +character code 48 is a printable character +character code 49 is a printable character +character code 50 is a printable character +character code 51 is a printable character +character code 52 is a printable character +character code 53 is a printable character +character code 54 is a printable character +character code 55 is a printable character +character code 56 is a printable character +character code 57 is a printable character +character code 58 is a printable character +character code 59 is a printable character +character code 60 is a printable character +character code 61 is a printable character +character code 62 is a printable character +character code 63 is a printable character +character code 64 is a printable character +character code 65 is a printable character +character code 66 is a printable character +character code 67 is a printable character +character code 68 is a printable character +character code 69 is a printable character +character code 70 is a printable character +character code 71 is a printable character +character code 72 is a printable character +character code 73 is a printable character +character code 74 is a printable character +character code 75 is a printable character +character code 76 is a printable character +character code 77 is a printable character +character code 78 is a printable character +character code 79 is a printable character +character code 80 is a printable character +character code 81 is a printable character +character code 82 is a printable character +character code 83 is a printable character +character code 84 is a printable character +character code 85 is a printable character +character code 86 is a printable character +character code 87 is a printable character +character code 88 is a printable character +character code 89 is a printable character +character code 90 is a printable character +character code 91 is a printable character +character code 92 is a printable character +character code 93 is a printable character +character code 94 is a printable character +character code 95 is a printable character +character code 96 is a printable character +character code 97 is a printable character +character code 98 is a printable character +character code 99 is a printable character +character code 100 is a printable character +character code 101 is a printable character +character code 102 is a printable character +character code 103 is a printable character +character code 104 is a printable character +character code 105 is a printable character +character code 106 is a printable character +character code 107 is a printable character +character code 108 is a printable character +character code 109 is a printable character +character code 110 is a printable character +character code 111 is a printable character +character code 112 is a printable character +character code 113 is a printable character +character code 114 is a printable character +character code 115 is a printable character +character code 116 is a printable character +character code 117 is a printable character +character code 118 is a printable character +character code 119 is a printable character +character code 120 is a printable character +character code 121 is a printable character +character code 122 is a printable character +character code 123 is a printable character +character code 124 is a printable character +character code 125 is a printable character +character code 126 is a printable character +===DONE=== diff --git a/ext/ctype/tests/ctype_graph_variation3.phpt b/ext/ctype/tests/ctype_graph_variation3.phpt new file mode 100644 index 0000000..327a497 --- /dev/null +++ b/ext/ctype/tests/ctype_graph_variation3.phpt @@ -0,0 +1,148 @@ +--TEST-- +Test ctype_graph() function : usage variations - different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_graph(mixed $c) + * Description: Checks for any printable character(s) except space + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_graph() to test + * which are considered valid printable character only strings + */ + +echo "*** Testing ctype_graph() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + "abc123\n", +/*20*/ 'abc 123', + '', + ' ', + base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters + "!$%^&*()_+-={}[]:;@~'#<,>.?/", +/*25*/ "\"ABC\"", + "String\twith\ttabs", + "Sample string with newline\n", +/*28*/ "123 ABC XYZ", +); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_graph($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_graph() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +bool(true) + +-- Iteration 8 -- +bool(true) + +-- Iteration 9 -- +bool(true) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(true) + +-- Iteration 12 -- +bool(true) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(true) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(true) + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(true) + +-- Iteration 25 -- +bool(true) + +-- Iteration 26 -- +bool(false) + +-- Iteration 27 -- +bool(false) + +-- Iteration 28 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_graph_variation4.phpt b/ext/ctype/tests/ctype_graph_variation4.phpt new file mode 100644 index 0000000..d425b4c --- /dev/null +++ b/ext/ctype/tests/ctype_graph_variation4.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test ctype_graph() function : usage variations - octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_graph(mixed $c) + * Description: Checks for any printable character(s) except space + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values to ctype_graph() to test behaviour + */ + +echo "*** Testing ctype_graph() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array(061, 062, 063, 064); +$hex_values = array (0x31, 0x32, 0x33, 0x34); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_graph($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_graph($c)); + $iterator++; +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_graph() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_lower_basic.phpt b/ext/ctype/tests/ctype_lower_basic.phpt new file mode 100644 index 0000000..be6c0af --- /dev/null +++ b/ext/ctype/tests/ctype_lower_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_lower() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_lower(mixed $c) + * Description: Checks for lowercase character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_lower() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = 'helloworld'; +$c2 = "Hello, world!\n"; + +var_dump(ctype_lower($c1)); +var_dump(ctype_lower($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_lower() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_lower_error.phpt b/ext/ctype/tests/ctype_lower_error.phpt new file mode 100644 index 0000000..ef49c4c --- /dev/null +++ b/ext/ctype/tests/ctype_lower_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_lower() function : error conditions - incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_lower(mixed $c) + * Description: Checks for lowercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass incorrect number of arguments to ctype_lower() to test behaviour + */ + +echo "*** Testing ctype_lower() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_lower() function with Zero arguments --\n"; +var_dump( ctype_lower() ); + +//Test ctype_lower with one more than the expected number of arguments +echo "\n-- Testing ctype_lower() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_lower($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_lower() : error conditions *** + +-- Testing ctype_lower() function with Zero arguments -- + +Warning: ctype_lower() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_lower() function with more than expected no. of arguments -- + +Warning: ctype_lower() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_lower_variation1.phpt b/ext/ctype/tests/ctype_lower_variation1.phpt new file mode 100644 index 0000000..91c8ef5 --- /dev/null +++ b/ext/ctype/tests/ctype_lower_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_lower() function : usage variations - different data types as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_lower(mixed $c) + * Description: Checks for lowercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_lower() to test behaviour + */ + +echo "*** Testing ctype_lower() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "class"; + } +} + +// heredoc string +$heredoc = <<<EOT +heredoc +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "string", + 'string', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_lower() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_lower($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_lower() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_lower_variation2.phpt b/ext/ctype/tests/ctype_lower_variation2.phpt new file mode 100644 index 0000000..39eff9a --- /dev/null +++ b/ext/ctype/tests/ctype_lower_variation2.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test ctype_lower() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_lower(mixed $c) + * Description: Checks for lowercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_lower() to test which character codes are considered + * valid lowercase characters + */ + +echo "*** Testing ctype_lower() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_lower($i)) { + echo "character code $i is a lower case character\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_lower() : usage variations *** +character code 97 is a lower case character +character code 98 is a lower case character +character code 99 is a lower case character +character code 100 is a lower case character +character code 101 is a lower case character +character code 102 is a lower case character +character code 103 is a lower case character +character code 104 is a lower case character +character code 105 is a lower case character +character code 106 is a lower case character +character code 107 is a lower case character +character code 108 is a lower case character +character code 109 is a lower case character +character code 110 is a lower case character +character code 111 is a lower case character +character code 112 is a lower case character +character code 113 is a lower case character +character code 114 is a lower case character +character code 115 is a lower case character +character code 116 is a lower case character +character code 117 is a lower case character +character code 118 is a lower case character +character code 119 is a lower case character +character code 120 is a lower case character +character code 121 is a lower case character +character code 122 is a lower case character +===DONE=== diff --git a/ext/ctype/tests/ctype_lower_variation3.phpt b/ext/ctype/tests/ctype_lower_variation3.phpt new file mode 100644 index 0000000..061cc1c --- /dev/null +++ b/ext/ctype/tests/ctype_lower_variation3.phpt @@ -0,0 +1,140 @@ +--TEST-- +Test ctype_lower() function : usage variations - different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_lower(mixed $c) + * Description: Checks for lowercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_lower() to test + * which are considered valid lowercase character only strings + */ + +echo "*** Testing ctype_lower() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + 'abc123\n', +/*20*/ 'abc 123', + '', + ' ', + base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters + "abcXYZ", +/*25*/ "abc xyz", +/*26*/ "abc+efg*xyz", +); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_lower($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_lower() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(true) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) + +-- Iteration 26 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_lower_variation4.phpt b/ext/ctype/tests/ctype_lower_variation4.phpt new file mode 100644 index 0000000..25e3d17 --- /dev/null +++ b/ext/ctype/tests/ctype_lower_variation4.phpt @@ -0,0 +1,64 @@ +--TEST-- +Test ctype_lower() function : usage variations - octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_lower(mixed $c) + * Description: Checks for lowercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values to ctype_lower() to test behaviour + */ + +echo "*** Testing ctype_lower() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array(0141, 0142, 0143, 0144); +$hex_values = array (0x61, 0x62, 0x63, 0x64); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_lower($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_lower($c)); + $iterator++; +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_lower() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_print_basic.phpt b/ext/ctype/tests/ctype_print_basic.phpt new file mode 100644 index 0000000..49cb26f --- /dev/null +++ b/ext/ctype/tests/ctype_print_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_print() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_print(mixed $c) + * Description: Checks for printable character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_print() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = "Hello, World!"; +$c2 = null; + +var_dump(ctype_print($c1)); +var_dump(ctype_print($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_print() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_print_error.phpt b/ext/ctype/tests/ctype_print_error.phpt new file mode 100644 index 0000000..09ed8c9 --- /dev/null +++ b/ext/ctype/tests/ctype_print_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_print() function : error conditions - incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_print(mixed $c) + * Description: Checks for printable character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass incorrect number of arguments to ctype_print() to test behaviour + */ + +echo "*** Testing ctype_print() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_print() function with Zero arguments --\n"; +var_dump( ctype_print() ); + +//Test ctype_print with one more than the expected number of arguments +echo "\n-- Testing ctype_print() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_print($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_print() : error conditions *** + +-- Testing ctype_print() function with Zero arguments -- + +Warning: ctype_print() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_print() function with more than expected no. of arguments -- + +Warning: ctype_print() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_print_variation1.phpt b/ext/ctype/tests/ctype_print_variation1.phpt new file mode 100644 index 0000000..a882c96 --- /dev/null +++ b/ext/ctype/tests/ctype_print_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_print() function : usage variations - different data types as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_print(mixed $c) + * Description: Checks for printable character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_print() to test behaviour + */ + +echo "*** Testing ctype_print() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "string", + 'string', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_print() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_print($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_print() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(true) + +-- Iteration 4 -- +bool(true) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_print_variation2.phpt b/ext/ctype/tests/ctype_print_variation2.phpt new file mode 100644 index 0000000..c216e4d --- /dev/null +++ b/ext/ctype/tests/ctype_print_variation2.phpt @@ -0,0 +1,127 @@ +--TEST-- +Test ctype_print() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_print(mixed $c) + * Description: Checks for printable character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_print() to test which character codes are considered + * valid printable characters + */ + +echo "*** Testing ctype_print() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_print($i)) { + echo "character code $i is a printable character\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_print() : usage variations *** +character code 32 is a printable character +character code 33 is a printable character +character code 34 is a printable character +character code 35 is a printable character +character code 36 is a printable character +character code 37 is a printable character +character code 38 is a printable character +character code 39 is a printable character +character code 40 is a printable character +character code 41 is a printable character +character code 42 is a printable character +character code 43 is a printable character +character code 44 is a printable character +character code 45 is a printable character +character code 46 is a printable character +character code 47 is a printable character +character code 48 is a printable character +character code 49 is a printable character +character code 50 is a printable character +character code 51 is a printable character +character code 52 is a printable character +character code 53 is a printable character +character code 54 is a printable character +character code 55 is a printable character +character code 56 is a printable character +character code 57 is a printable character +character code 58 is a printable character +character code 59 is a printable character +character code 60 is a printable character +character code 61 is a printable character +character code 62 is a printable character +character code 63 is a printable character +character code 64 is a printable character +character code 65 is a printable character +character code 66 is a printable character +character code 67 is a printable character +character code 68 is a printable character +character code 69 is a printable character +character code 70 is a printable character +character code 71 is a printable character +character code 72 is a printable character +character code 73 is a printable character +character code 74 is a printable character +character code 75 is a printable character +character code 76 is a printable character +character code 77 is a printable character +character code 78 is a printable character +character code 79 is a printable character +character code 80 is a printable character +character code 81 is a printable character +character code 82 is a printable character +character code 83 is a printable character +character code 84 is a printable character +character code 85 is a printable character +character code 86 is a printable character +character code 87 is a printable character +character code 88 is a printable character +character code 89 is a printable character +character code 90 is a printable character +character code 91 is a printable character +character code 92 is a printable character +character code 93 is a printable character +character code 94 is a printable character +character code 95 is a printable character +character code 96 is a printable character +character code 97 is a printable character +character code 98 is a printable character +character code 99 is a printable character +character code 100 is a printable character +character code 101 is a printable character +character code 102 is a printable character +character code 103 is a printable character +character code 104 is a printable character +character code 105 is a printable character +character code 106 is a printable character +character code 107 is a printable character +character code 108 is a printable character +character code 109 is a printable character +character code 110 is a printable character +character code 111 is a printable character +character code 112 is a printable character +character code 113 is a printable character +character code 114 is a printable character +character code 115 is a printable character +character code 116 is a printable character +character code 117 is a printable character +character code 118 is a printable character +character code 119 is a printable character +character code 120 is a printable character +character code 121 is a printable character +character code 122 is a printable character +character code 123 is a printable character +character code 124 is a printable character +character code 125 is a printable character +character code 126 is a printable character +===DONE=== diff --git a/ext/ctype/tests/ctype_print_variation3.phpt b/ext/ctype/tests/ctype_print_variation3.phpt new file mode 100644 index 0000000..7b90e4f --- /dev/null +++ b/ext/ctype/tests/ctype_print_variation3.phpt @@ -0,0 +1,128 @@ +--TEST-- +Test ctype_print() function : usage variations - different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_print(mixed $c) + * Description: Checks for printable character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_print() to test + * which are considered valid printable character only strings + */ + +echo "*** Testing ctype_print() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + "abc123\n", +/*20*/ 'abc 123', + '', + ' ', +/*23*/ base64_decode("w4DDoMOHw6fDiMOo") // non-ascii characters +); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_print($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_print() : usage variations *** + +-- Iteration 1 -- +bool(true) + +-- Iteration 2 -- +bool(true) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(true) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +bool(true) + +-- Iteration 8 -- +bool(true) + +-- Iteration 9 -- +bool(true) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(true) + +-- Iteration 12 -- +bool(true) + +-- Iteration 13 -- +bool(true) + +-- Iteration 14 -- +bool(true) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(true) + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(true) + +-- Iteration 23 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_print_variation4.phpt b/ext/ctype/tests/ctype_print_variation4.phpt new file mode 100644 index 0000000..d6dc84a --- /dev/null +++ b/ext/ctype/tests/ctype_print_variation4.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test ctype_print() function : usage variations - octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_print(mixed $c) + * Description: Checks for printable character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values to ctype_print() to test behaviour + */ + +echo "*** Testing ctype_print() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array(040, 041, 042, 043); +$hex_values = array (0x20, 0x21, 0x23, 0x24); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_print($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_print($c)); + $iterator++; +} +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_print() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_punct_basic.phpt b/ext/ctype/tests/ctype_punct_basic.phpt new file mode 100644 index 0000000..647f851 --- /dev/null +++ b/ext/ctype/tests/ctype_punct_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test ctype_punct() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_punct(mixed $c) + * Description: Checks for any printable character which is not whitespace + * or an alphanumeric character + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_punct() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = '@!$*'; +$c2 = 'hello, world!'; + +var_dump(ctype_punct($c1)); +var_dump(ctype_punct($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_punct() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_punct_error.phpt b/ext/ctype/tests/ctype_punct_error.phpt new file mode 100644 index 0000000..afb9ff0 --- /dev/null +++ b/ext/ctype/tests/ctype_punct_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test ctype_punct() function : error conditions - incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_punct(mixed $c) + * Description: Checks for any printable character which is not whitespace + * or an alphanumeric character + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass incorrect number of arguments to ctype_punct() to test behaviour + */ + +echo "*** Testing ctype_punct() : error conditions ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +// Zero arguments +echo "\n-- Testing ctype_punct() function with Zero arguments --\n"; +var_dump( ctype_punct() ); + +//Test ctype_punct with one more than the expected number of arguments +echo "\n-- Testing ctype_punct() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_punct($c, $extra_arg) ); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_punct() : error conditions *** + +-- Testing ctype_punct() function with Zero arguments -- + +Warning: ctype_punct() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_punct() function with more than expected no. of arguments -- + +Warning: ctype_punct() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_punct_variation1.phpt b/ext/ctype/tests/ctype_punct_variation1.phpt new file mode 100644 index 0000000..0f57c45 --- /dev/null +++ b/ext/ctype/tests/ctype_punct_variation1.phpt @@ -0,0 +1,180 @@ +--TEST-- +Test ctype_punct() function : usage variations - different data types as $c argument +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_punct(mixed $c) + * Description: Checks for any printable character which is not whitespace + * or an alphanumeric character + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_punt() to test behaviour + */ + +echo "*** Testing ctype_punct() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return ",<.>"; + } +} + +// heredoc string +$heredoc = <<<EOT +[{}] +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ ";:'@", + '#~/?', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_punct +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_punct($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_punct() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_punct_variation2.phpt b/ext/ctype/tests/ctype_punct_variation2.phpt new file mode 100644 index 0000000..3a4a66a --- /dev/null +++ b/ext/ctype/tests/ctype_punct_variation2.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test ctype_punct() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_punct(mixed $c) + * Description: Checks for any printable character which is not whitespace + * or an alphanumeric character + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_punct() to test which character codes are considered + * valid punctuation characters + */ + +echo "*** Testing ctype_punct() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($c = 1; $c < 256; $c++) { + if (ctype_punct($c)) { + echo "character code $c is punctuation\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_punct() : usage variations *** +character code 33 is punctuation +character code 34 is punctuation +character code 35 is punctuation +character code 36 is punctuation +character code 37 is punctuation +character code 38 is punctuation +character code 39 is punctuation +character code 40 is punctuation +character code 41 is punctuation +character code 42 is punctuation +character code 43 is punctuation +character code 44 is punctuation +character code 45 is punctuation +character code 46 is punctuation +character code 47 is punctuation +character code 58 is punctuation +character code 59 is punctuation +character code 60 is punctuation +character code 61 is punctuation +character code 62 is punctuation +character code 63 is punctuation +character code 64 is punctuation +character code 91 is punctuation +character code 92 is punctuation +character code 93 is punctuation +character code 94 is punctuation +character code 95 is punctuation +character code 96 is punctuation +character code 123 is punctuation +character code 124 is punctuation +character code 125 is punctuation +character code 126 is punctuation +===DONE=== diff --git a/ext/ctype/tests/ctype_punct_variation3.phpt b/ext/ctype/tests/ctype_punct_variation3.phpt new file mode 100644 index 0000000..73e377e --- /dev/null +++ b/ext/ctype/tests/ctype_punct_variation3.phpt @@ -0,0 +1,140 @@ +--TEST-- +Test ctype_punct() function : usage variations - different punctuation +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_punct(mixed $c) + * Description: Checks for any printable character which is not whitespace + * or an alphanumeric character + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_punct() to test + * which are considered valid punctuation character only strings + */ + +echo "*** Testing ctype_punct() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + "abc123\n", +/*20*/ 'abc 123', + '', + ' ', + base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters + "!$%@\n", +/*25*/ "\"?!\"", +/*26*/ "|\ @~", +); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_punct($value) ); + $iterator++; +}; +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_punct() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(true) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(true) + +-- Iteration 26 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_punct_variation4.phpt b/ext/ctype/tests/ctype_punct_variation4.phpt new file mode 100644 index 0000000..7b7201b --- /dev/null +++ b/ext/ctype/tests/ctype_punct_variation4.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test ctype_punct() function : usage variations - Octal and Hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_punct(mixed $c) + * Description: Checks for any printable character which is not whitespace + * or an alphanumeric character + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different octal and hexadecimal values to ctype_punct() to test behaviour + */ + +echo "*** Testing ctype_punct() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array(041, 042, 043, 044); +$hex_values = array(0x21, 0x22, 0x23, 0x24); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_punct($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_punct($c)); + $iterator++; +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_punct() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_space_basic.phpt b/ext/ctype/tests/ctype_space_basic.phpt new file mode 100644 index 0000000..55d9a81 --- /dev/null +++ b/ext/ctype/tests/ctype_space_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_space() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_space(mixed $c) + * Description: Checks for whitespace character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_space() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = " \t\r\n"; +var_dump(ctype_space($c1)); + +$c2 = "Hello, world!\n"; +var_dump(ctype_space($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_space() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_space_error.phpt b/ext/ctype/tests/ctype_space_error.phpt new file mode 100644 index 0000000..d8f17d4 --- /dev/null +++ b/ext/ctype/tests/ctype_space_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test ctype_space() function : error conditions - Incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_space(mixed $c) + * Description: Checks for whitespace character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass an incorrect number of arguments to ctype_space() to test behaviour + */ + +echo "*** Testing ctype_space() : error conditions ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +// Zero arguments +echo "\n-- Testing ctype_space() function with Zero arguments --\n"; +var_dump( ctype_space() ); + +//Test ctype_space with one more than the expected number of arguments +echo "\n-- Testing ctype_space() function with more than expected no. of arguments --\n"; +$c = " "; +$extra_arg = 10; +var_dump( ctype_space($c, $extra_arg) ); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_space() : error conditions *** + +-- Testing ctype_space() function with Zero arguments -- + +Warning: ctype_space() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_space() function with more than expected no. of arguments -- + +Warning: ctype_space() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_space_variation1.phpt b/ext/ctype/tests/ctype_space_variation1.phpt new file mode 100644 index 0000000..4a469ae --- /dev/null +++ b/ext/ctype/tests/ctype_space_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_space() function : usage variations - different data types as $c argument +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_space(mixed $c) + * Description: Checks for whitespace character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_space() to test behaviour + */ + +echo "*** Testing ctype_space() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "\n\t\r"; + } +} + +// heredoc string +$heredoc = <<<EOT + +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "\n\t\r", + ' ', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_space() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_space($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_space() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_space_variation2.phpt b/ext/ctype/tests/ctype_space_variation2.phpt new file mode 100644 index 0000000..6ffdb9c --- /dev/null +++ b/ext/ctype/tests/ctype_space_variation2.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test ctype_space() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_space(mixed $c) + * Description: Checks for whitespace character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_space() to test which character codes are considered + * valid whitespace characters + */ + +echo "*** Testing ctype_space() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for ($c = 1; $c < 256; $c++) { + if (ctype_space($c)) { + echo "character code $c is a space character\n"; + } +} +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_space() : usage variations *** +character code 9 is a space character +character code 10 is a space character +character code 11 is a space character +character code 12 is a space character +character code 13 is a space character +character code 32 is a space character +===DONE=== diff --git a/ext/ctype/tests/ctype_space_variation3.phpt b/ext/ctype/tests/ctype_space_variation3.phpt new file mode 100644 index 0000000..bb8423b --- /dev/null +++ b/ext/ctype/tests/ctype_space_variation3.phpt @@ -0,0 +1,140 @@ +--TEST-- +Test ctype_space() function : usage variations - different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_space(mixed $c) + * Description: Checks for whitespace character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_space() to test + * which are considered valid whitespace character only strings + */ + +echo "*** Testing ctype_space() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + "abc123\n", +/*20*/ 'abc 123', + '', + ' ', + base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters + "\"\n", +/*25*/ " \t\r\n", +/*26*/ "\v\f", +); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_space($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_space() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(true) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(true) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(true) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(true) + +-- Iteration 26 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_space_variation4.phpt b/ext/ctype/tests/ctype_space_variation4.phpt new file mode 100644 index 0000000..305c123 --- /dev/null +++ b/ext/ctype/tests/ctype_space_variation4.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test ctype_space() function : usage variations - octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_space(mixed $c) + * Description: Checks for whitespace character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values as $c to ctype_space() to test behaviour + */ + +echo "*** Testing ctype_space() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array (011, 012, 013, 014, 015, 040); +$hex_values = array (0x9, 0xA, 0xB, 0xC, 0xD, 0x20); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_space($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_space($c)); + $iterator++; +} +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_space() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(true) +-- Iteration 6 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_upper_basic.phpt b/ext/ctype/tests/ctype_upper_basic.phpt new file mode 100644 index 0000000..635e481 --- /dev/null +++ b/ext/ctype/tests/ctype_upper_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test ctype_upper() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_upper(mixed $c) + * Description: Checks for uppercase character(s) + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_upper() : basic functionality ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = 'HELLOWORLD'; +$c2 = "Hello, World!\n"; + +var_dump(ctype_upper($c1)); +var_dump(ctype_upper($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_upper() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_upper_error.phpt b/ext/ctype/tests/ctype_upper_error.phpt new file mode 100644 index 0000000..e9183f4 --- /dev/null +++ b/ext/ctype/tests/ctype_upper_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_upper() function : error conditions - incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_upper(mixed $c) + * Description: Checks for uppercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass incorrect number of arguments to ctype_upper() to test behaviour + */ + +echo "*** Testing ctype_upper() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_upper() function with Zero arguments --\n"; +var_dump( ctype_upper() ); + +//Test ctype_upper with one more than the expected number of arguments +echo "\n-- Testing ctype_upper() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_upper($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_upper() : error conditions *** + +-- Testing ctype_upper() function with Zero arguments -- + +Warning: ctype_upper() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_upper() function with more than expected no. of arguments -- + +Warning: ctype_upper() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_upper_variation1.phpt b/ext/ctype/tests/ctype_upper_variation1.phpt new file mode 100644 index 0000000..a257cd3 --- /dev/null +++ b/ext/ctype/tests/ctype_upper_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_upper() function : usage variations - different data types +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_upper(mixed $c) + * Description: Checks for uppercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_upper() to test behaviour + */ + +echo "*** Testing ctype_upper() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "HELLO"; + } +} + +// heredoc string +$heredoc = <<<EOT +HI +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "STRING", + 'STRING', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_upper() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_upper($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_upper() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_upper_variation2.phpt b/ext/ctype/tests/ctype_upper_variation2.phpt new file mode 100644 index 0000000..9357feb --- /dev/null +++ b/ext/ctype/tests/ctype_upper_variation2.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test ctype_upper() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_upper(mixed $c) + * Description: Checks for uppercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_upper() to test which character codes are considered + * valid uppercase characters + */ + +echo "*** Testing ctype_upper() : usage variations ***\n"; +$orig = setlocale(LC_CTYPE, "C"); + +for ($i = 0; $i < 256; $i++) { + if (ctype_upper($i)) { + echo "character code $i is a uppercase character\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_upper() : usage variations *** +character code 65 is a uppercase character +character code 66 is a uppercase character +character code 67 is a uppercase character +character code 68 is a uppercase character +character code 69 is a uppercase character +character code 70 is a uppercase character +character code 71 is a uppercase character +character code 72 is a uppercase character +character code 73 is a uppercase character +character code 74 is a uppercase character +character code 75 is a uppercase character +character code 76 is a uppercase character +character code 77 is a uppercase character +character code 78 is a uppercase character +character code 79 is a uppercase character +character code 80 is a uppercase character +character code 81 is a uppercase character +character code 82 is a uppercase character +character code 83 is a uppercase character +character code 84 is a uppercase character +character code 85 is a uppercase character +character code 86 is a uppercase character +character code 87 is a uppercase character +character code 88 is a uppercase character +character code 89 is a uppercase character +character code 90 is a uppercase character +===DONE=== diff --git a/ext/ctype/tests/ctype_upper_variation3.phpt b/ext/ctype/tests/ctype_upper_variation3.phpt new file mode 100644 index 0000000..3e4509e --- /dev/null +++ b/ext/ctype/tests/ctype_upper_variation3.phpt @@ -0,0 +1,139 @@ +--TEST-- +Test ctype_upper() function : usage variations - different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_upper(mixed $c) + * Description: Checks for uppercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_upper() to test + * which are considered valid uppercase character only strings + */ + +echo "*** Testing ctype_upper() : usage variations ***\n"; +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + 'abc123\n', +/*20*/ 'abc 123', + '', + ' ', + base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters + "abcXYZ", +/*25*/ "ABC XYZ", +/*26*/ "ABC+EFG*XYZ", +); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_upper($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_upper() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) + +-- Iteration 26 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_upper_variation4.phpt b/ext/ctype/tests/ctype_upper_variation4.phpt new file mode 100644 index 0000000..0c27992 --- /dev/null +++ b/ext/ctype/tests/ctype_upper_variation4.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test ctype_upper() function : usage variations - octal and hexadecimal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_upper(mixed $c) + * Description: Checks for uppercase character(s) + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass octal and hexadecimal values to ctype_upper() to test behaviour + */ + +echo "*** Testing ctype_upper() : usage variations ***\n"; +$orig = setlocale(LC_CTYPE, "C"); + +$octal_values = array(0101, 0102, 0103, 0104); +$hex_values = array(0x41, 0x42, 0x43, 0x44); + +echo "\n-- Octal Values --\n"; +$iterator = 1; +foreach($octal_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_upper($c)); + $iterator++; +} + +echo "\n-- Hexadecimal Values --\n"; +$iterator = 1; +foreach($hex_values as $c) { + echo "-- Iteration $iterator --\n"; + var_dump(ctype_upper($c)); + $iterator++; +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_upper() : usage variations *** + +-- Octal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) + +-- Hexadecimal Values -- +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +===DONE=== diff --git a/ext/ctype/tests/ctype_xdigit_basic.phpt b/ext/ctype/tests/ctype_xdigit_basic.phpt new file mode 100644 index 0000000..179115d --- /dev/null +++ b/ext/ctype/tests/ctype_xdigit_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test ctype_xdigit() function : basic functionality +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_xdigit(mixed $c) + * Description: Checks for character(s) representing a hexadecimal digit + * Source code: ext/ctype/ctype.c + */ + +echo "*** Testing ctype_xdigit() : basic functionality ***\n"; +$orig = setlocale(LC_CTYPE, "C"); + +$c1 = 'abcdefABCDEF0123456789'; +$c2 = 'face 034'; + +var_dump(ctype_xdigit($c1)); +var_dump(ctype_xdigit($c2)); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_xdigit() : basic functionality *** +bool(true) +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_xdigit_error.phpt b/ext/ctype/tests/ctype_xdigit_error.phpt new file mode 100644 index 0000000..60ea69c --- /dev/null +++ b/ext/ctype/tests/ctype_xdigit_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test ctype_xdigit() function : error conditions - Incorrect number of args +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_xdigit(mixed $c) + * Description: Checks for character(s) representing a hexadecimal digit + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass incorrect number of arguments to ctype_xdigit() to test behaviour + */ + +echo "*** Testing ctype_xdigit() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing ctype_xdigit() function with Zero arguments --\n"; +var_dump( ctype_xdigit() ); + +//Test ctype_xdigit with one more than the expected number of arguments +echo "\n-- Testing ctype_xdigit() function with more than expected no. of arguments --\n"; +$c = 1; +$extra_arg = 10; +var_dump( ctype_xdigit($c, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_xdigit() : error conditions *** + +-- Testing ctype_xdigit() function with Zero arguments -- + +Warning: ctype_xdigit() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ctype_xdigit() function with more than expected no. of arguments -- + +Warning: ctype_xdigit() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/ctype/tests/ctype_xdigit_variation1.phpt b/ext/ctype/tests/ctype_xdigit_variation1.phpt new file mode 100644 index 0000000..963755b --- /dev/null +++ b/ext/ctype/tests/ctype_xdigit_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test ctype_xdigit() function : usage variations - different data typse as $c arg +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_xdigit(mixed $c) + * Description: Checks for character(s) representing a hexadecimal digit + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different data types as $c argument to ctype_xdigit() to test behaviour + */ + +echo "*** Testing ctype_xdigit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "ABcd"; + } +} + +// heredoc string +$heredoc = <<<EOT +234 +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $c argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "456", + 'def', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of ctype_xdigit() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_xdigit($input) ); + $iterator++; +}; + +fclose($fp); + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_xdigit() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(true) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_xdigit_variation2.phpt b/ext/ctype/tests/ctype_xdigit_variation2.phpt new file mode 100644 index 0000000..1e7b7bd --- /dev/null +++ b/ext/ctype/tests/ctype_xdigit_variation2.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test ctype_xdigit() function : usage variations - different integers +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_xdigit(mixed $c) + * Description: Checks for character(s) representing a hexadecimal digit + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different integers to ctype_xdigit() to test which character codes are considered + * valid hexadecimal 'digits' + */ + +echo "*** Testing ctype_xdigit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +for($c = 1; $c < 256; $c++) { + if (ctype_xdigit($c)) { + echo "character code $c is a hexadecimal 'digit'\n"; + } +} + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_xdigit() : usage variations *** +character code 48 is a hexadecimal 'digit' +character code 49 is a hexadecimal 'digit' +character code 50 is a hexadecimal 'digit' +character code 51 is a hexadecimal 'digit' +character code 52 is a hexadecimal 'digit' +character code 53 is a hexadecimal 'digit' +character code 54 is a hexadecimal 'digit' +character code 55 is a hexadecimal 'digit' +character code 56 is a hexadecimal 'digit' +character code 57 is a hexadecimal 'digit' +character code 65 is a hexadecimal 'digit' +character code 66 is a hexadecimal 'digit' +character code 67 is a hexadecimal 'digit' +character code 68 is a hexadecimal 'digit' +character code 69 is a hexadecimal 'digit' +character code 70 is a hexadecimal 'digit' +character code 97 is a hexadecimal 'digit' +character code 98 is a hexadecimal 'digit' +character code 99 is a hexadecimal 'digit' +character code 100 is a hexadecimal 'digit' +character code 101 is a hexadecimal 'digit' +character code 102 is a hexadecimal 'digit' +===DONE=== diff --git a/ext/ctype/tests/ctype_xdigit_variation3.phpt b/ext/ctype/tests/ctype_xdigit_variation3.phpt new file mode 100644 index 0000000..2c9960c --- /dev/null +++ b/ext/ctype/tests/ctype_xdigit_variation3.phpt @@ -0,0 +1,140 @@ +--TEST-- +Test ctype_xdigit() function : usage variations - Different strings +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_xdigit(mixed $c) + * Description: Checks for character(s) representing a hexadecimal digit + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass strings containing different character types to ctype_xdigit() to test + * which are considered valid hexadecimal 'digit' only strings + */ + +echo "*** Testing ctype_xdigit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +$values = array( +/*1*/ "This string contains just letters and spaces", // Simple string + "but this one contains some numbers too 123+456 = 678", // Mixed string + "", + " ", +/*5*/ "a", + "ABCXYZ", + "abcxyz", + "ABCXYZ123DEF456", + "abczyz123DEF456", +/*10*/ "\r\n", + "123", + "03F", // hexadecimal 'digits' + ")speci@! ch@r$(", + '@!$*', +/*15*/ 'ABC', + 'abc', + 'ABC123', + 'abc123', + 'abc123\n', +/*20*/ 'abc 123', + '', + ' ', + base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters + 'ABCdef07', + "56ea\tFB", + "0x2A" + ); + +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_xdigit($value) ); + $iterator++; +}; + +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_xdigit() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(true) + +-- Iteration 12 -- +bool(true) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(true) + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(true) + +-- Iteration 25 -- +bool(false) + +-- Iteration 26 -- +bool(false) +===DONE=== diff --git a/ext/ctype/tests/ctype_xdigit_variation4.phpt b/ext/ctype/tests/ctype_xdigit_variation4.phpt new file mode 100644 index 0000000..4707bce --- /dev/null +++ b/ext/ctype/tests/ctype_xdigit_variation4.phpt @@ -0,0 +1,83 @@ +--TEST-- +Test ctype_xdigit() function : usage variations - heaxadecimal and octal values +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +/* Prototype : bool ctype_xdigit(mixed $c) + * Description: Checks for character(s) representing a hexadecimal digit + * Source code: ext/ctype/ctype.c + */ + +/* + * Pass different hexadecimal and octal values that: + * 1. contain hexadecimal digits + * 2. correspond to character codes recognised as hexadecimal digits (see variation2) + * referred to as 'correct' integers below + */ + +echo "*** Testing ctype_xdigit() : usage variations ***\n"; + +$orig = setlocale(LC_CTYPE, "C"); + +// contain hexadecimal digits but do not correspond to 'correct' ints +$octal_values1 = array(012, 013, 014, 015); + +// correspond to 'correct' integers +$octal_values2 = array(061, 062, 063, 064); + +// contain hexadecimal digits but do not correspond to 'correct' ints +$hex_values1 = array(0x1A, 0x1B, 0x1C, 0x1D); + +//correspond to 'correct' integers +$hex_values2 = array(0x61, 0x62, 0x63, 0x64); + +echo "\n-- Octal values --\n"; +echo "'Incorrect' Integers: \n"; +foreach($octal_values1 as $c) { + var_dump(ctype_xdigit($c)); +} +echo "'Correct' Integers: \n"; +foreach($octal_values2 as $c) { + var_dump(ctype_xdigit($c)); +} + +echo "\n-- Hexadecimal values --\n"; +echo "'Incorrect' Integers: \n"; +foreach($hex_values1 as $c) { + var_dump(ctype_xdigit($c)); +} +echo "'Correct' Integers: \n"; +foreach($hex_values2 as $c) { + var_dump(ctype_xdigit($c)); +} +setlocale(LC_CTYPE, $orig); +?> +===DONE=== +--EXPECTF-- +*** Testing ctype_xdigit() : usage variations *** + +-- Octal values -- +'Incorrect' Integers: +bool(false) +bool(false) +bool(false) +bool(false) +'Correct' Integers: +bool(true) +bool(true) +bool(true) +bool(true) + +-- Hexadecimal values -- +'Incorrect' Integers: +bool(false) +bool(false) +bool(false) +bool(false) +'Correct' Integers: +bool(true) +bool(true) +bool(true) +bool(true) +===DONE=== diff --git a/ext/ctype/tests/skipif.inc b/ext/ctype/tests/skipif.inc new file mode 100644 index 0000000..55f6c11 --- /dev/null +++ b/ext/ctype/tests/skipif.inc @@ -0,0 +1 @@ +<?php if (!extension_loaded('ctype')) die('skip ctype extension not available');?> |