From b42ac97c91c9df81aa6bce6ff88651f776d763e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 20 Jan 2006 22:52:21 +0000 Subject: [PATCH] * ctype tests --- tests/CtypeTest.php | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/CtypeTest.php diff --git a/tests/CtypeTest.php b/tests/CtypeTest.php new file mode 100644 index 0000000000..1b628e2317 --- /dev/null +++ b/tests/CtypeTest.php @@ -0,0 +1,64 @@ +PHPUnit_TestCase( $name ); + } + + function setUp() { + $cont = file_get_contents( '../includes/compatability/ctype.php' ); + + preg_match_all( '~function (ctype_[a-z]+)~', $cont, $m ); + $this->populateFunctions( $m[1] ); + + // Will get called before each test* function + if ( function_exists( '_ctype_alnum' ) ) + return; + else { + $cont = preg_replace( '~^<\?php~', '', $cont ); + $cont = preg_replace( '~\?>$~', '', $cont ); + + // Rename the custom functions so they don't conflict + $cont = preg_replace( '~(function )(ctype_)~', '\1_\2', $cont ); + + eval( $cont ); + } + } + + function populateFunctions( $functions ) { + $this->functions = array(); + foreach ( $functions as $function ) + $this->functions[$function] = "_$function"; + } + + function tearDown() {} + +// function testInteger256_to_big() {} + + function testInteger0_to_255() { + foreach ( $this->functions as $phpfunc => $mwfunc ) + foreach ( range( 0, 255 ) as $i ) + $this->assertEquals( + _ctype_alnum( $i ), + ctype_alnum( $i ), + "On $i ($phpfunc)" + ); + } + + function testChr0_to_255() { + foreach ( $this->functions as $phpfunc => $mwfunc ) + foreach ( range( 0, 255 ) as $i ) { + $i = chr( $i ); + $this->assertEquals( + _ctype_alnum( $i ), + ctype_alnum( $i ), + "On $i ($phpfunc)" + ); + } + } + +} +?> -- 2.20.1