[Haskell-cafe] Testing serialization/deserialization.
Pupeno
pupeno at pupeno.com
Sat Dec 31 06:20:13 EST 2005
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 at pupeno.com> (http://pupeno.com)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20051231/460e439e/attachment-0001.bin
More information about the Haskell-Cafe
mailing list