# [EMAIL PROTECTED] / 2007-02-19 17:29:53 +0100:
> Roman Neuhauser wrote:
> >
> >class serializeASCII241 extends Tence_TestCase
> >{
> >    function testTruncates()
> >    {
> >        return $this->assertEquals(
> >            "120GB 2X512MB 15.4IN DVD",
> >            serialize("120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP  FR")
> >        );
> >    }
> >}
> >
> >?>
> 
> I'd just like to point out that your test will fail systematically 
> unless you use something like this :
> 
>      function testTruncates()
>      {
>       $string = "120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP  FR";
>         return $this->assertEquals(
>          "s:" . strlen($string) . ":\"120GB 2X512MB 15.4IN DVD",
>          serialize("120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP  FR")
>          );
>      }

You're right, of course, I wrote that in a hurry, after I checked the
output of serialize() contained the whole input.

This is a better test, and it does work with the beforementioned
configuration (5.2.1 on FreeBSD).

<?php

class serializeASCII241 extends Tence_TestCase
{
    function setUp()
    {
        $this->raw = "120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP  FR";
        $this->serialized = sprintf(
            's:%d:"%s";', strlen($this->raw), $this->raw
        );
    }
    function testWorksAsExpected()
    {
        return $this->assertEquals(
            $this->serialized,
            serialize($this->raw)
        );
    }
}

?>

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to