Testing serialization/deserialization.

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Testing serialization/deserialization.

J. Pablo Fernández
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
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

Thank you.
Pupeno <[hidden email]> (http://pupeno.com)

Haskell-Cafe mailing list
[hidden email]

attachment0 (196 bytes) Download Attachment