[TYPO3-core] RFC #15020: Enhancement of t3lib_div::testInt

Christian Futterlieb christian.futterlieb at agenturamwasser.ch
Thu Jul 8 13:01:00 CEST 2010


On 08.07.2010 12:34, Dmitry Dulepov wrote:
> 
> This uses two returns while CGL explicitly states that only a single return
> is allowed...
> 
> This is not a -1 but a note.

It could surely be written like this:

function testInt ($var) {
    return is_numeric($var) ? (int) $var == $var : FALSE;
}

But this is slightly slower. The more interesting point is the behaviour
of testInt('01234'), I think.

> could you add the following data set to you testcase:
> 
> empty string ('').
> Largest int (2147483647 or 9223372036854775807)
> Largest int +1 (2147483648 or 9223372036854775808)
Done
I also added a negative int and a negative int in a string.

> 
> Testing for integers is a system specific thing e.i.:
> On 32 bit system the "largest" integer would be 2147483647 while it would be
> 9223372036854775807 on 64 bit systems.
This could be covered with the usage of constant PHP_INT_MAX, I guess.

> 
> One thing: I thing it's common practice to put the dataproviders above the
> actuall test.
Done

Regards, Christian
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 15020_unitTest_v2.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100708/74f1fe6a/attachment.txt>


More information about the TYPO3-team-core mailing list