on master help sign in
Add tests to do round-trips with toWords and fromWords.
commit807db7faf4e9723b436ecc2906abb2d6388884bc authorAntoine Latter <aslatter@gmail.com> dateWed 24 Dec 2014, 13:42 (12 years ago) parenta9603c4
1 file changed+13
tests/TestUUID.hs+13
tests/TestUUID.hs+13
@@ -168,6 +168,17 @@ toASCIIBytes_fromASCIIBytes :: U.UUID -> Bool
168168toASCIIBytes_fromASCIIBytes uuid =
169169 Just uuid == U.fromASCIIBytes (U.toASCIIBytes uuid)
170170
171+toWords_fromWords :: U.UUID -> Bool
172+toWords_fromWords uuid =
173+ uuid == myUncurry4 U.fromWords (U.toWords uuid)
174+
175+fromWords_toWords :: (Word32, Word32, Word32, Word32) -> Bool
176+fromWords_toWords wds =
177+ wds == U.toWords (myUncurry4 U.fromWords wds)
178+
179+myUncurry4 :: (x1 -> x2 -> x3 -> x4 -> y) -> (x1, x2, x3, x4) -> y
180+myUncurry4 f (a,b,c,d) = f a b c d
181+
171182prop_storableRoundTrip :: Test
172183prop_storableRoundTrip =
173184 testProperty "Storeable round-trip" $ unsafePerformIO . prop
@@ -211,5 +222,7 @@ main = do
211222 , testProperty "fromASCIIBytes_toString" toASCIIBytes_toString
212223 , testProperty "fromASCIIBytes_toASCIIBytes" fromASCIIBytes_toASCIIBytes
213224 , testProperty "toASCIIBytes_fromASCIIBytes" toASCIIBytes_fromASCIIBytes
225+ , testProperty "toWords_fromWords" toWords_fromWords
226+ , testProperty "fromWords_toWords" fromWords_toWords
214227 ]
215228 ]