[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    [Haskell-cafe] Testing serialization/deserialization.
From:       Pupeno <pupeno () pupeno ! com>
Date:       2005-12-31 11:20:13
Message-ID: 200512310820.19904.pupeno () pupeno ! com
[Download RAW message or body]


Hello,
I am working with NewBinary, I have made a lot of datatypes which are Binary 
instances. Now I want to write some testing for the 
serialization/de-serialization.
I've started with QuickCheck but it seems I can't do IO inside a property of 
QuickCheck, am I right ? If not, how is it done ?
Not being able to work with QuickCheck, I tried HUnit only to find another 
problem (which I would have found with QuickCheck anyway). How do I generate 
a BinHandle where I can write and read what I written ?
Tring to do that I wrote a test for Int:

intSerialization = TestCase (do bh <- openBinMem 1024 []
                                let i :: Int
                                    i = 3
                                put_ bh i
                                i2 <- (get bh) :: IO Int
                                assertEqual "i == i2" i i2)

it didn't work:

*Network.Server.DNS> runTestTT tests
### Error in:   1
user error (HUnit:i == i2
expected: 3
 but got: 209944584)

In general, what method/way do you recommend to test 
serialization/de-serialization (note: I'd like to use QuickCheck if 
possible)?

Thank you.
-- 
Pupeno <pupeno@pupeno.com> (http://pupeno.com)

[Attachment #3 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic