@@ -31,6 +31,7 @@ import qualified Streamly.Internal.Data.Serialize.TH as Serialize
32import Data.Functor.Identity (Identity (..))
32import Data.Functor.Identity (Identity (..))
34+import qualified Streamly.Internal.Data.Array as Array
34import qualified Streamly.Internal.Data.Serialize as Serialize
35import qualified Streamly.Internal.Data.Serialize as Serialize
36import Language.Haskell.TH
37import Language.Haskell.TH
@@ -120,17 +121,20 @@ roundtrip val = do
121 let sz = Serialize.size 0 val
122 let sz = Serialize.size 0 val
123− -- putStrLn "----------------------------------------------------------------"
124+ -- Use a proper slice to test instead of the array directly. This will catch
124− -- putStrLn $ show val
125+ -- any hardcoded 0 offsets
125− -- putStrLn $ "Size is: " ++ show sz
126+ let arrSize = sz + 100
126− -- putStrLn "----------------------------------------------------------------"
127+ serStartOff = 50
127− arr <- newBytes sz
129+ arr <- newBytes arrSize
129− off1 <- Serialize.serialize 0 arr val
131+ off1 <- Serialize.serialize serStartOff arr val
130− (off2, val2) <- Serialize.deserialize 0 arr sz
132+ (off2, val2) <- Serialize.deserialize serStartOff arr serEndOff
131 val2 `shouldBe` val
133 val2 `shouldBe` val
132 off2 `shouldBe` off1
134 off2 `shouldBe` off1
133− off2 `shouldBe` sz
135+ off2 `shouldBe` serEndOff
136+ val `shouldBe` Serialize.decode (Serialize.encode val)
137+ val `shouldBe` Serialize.decode (Array.Array arr serStartOff serEndOff)
135testSerializeList
139testSerializeList
136 :: forall a. (Eq a, Show a, Serialize.Serialize a)
140 :: forall a. (Eq a, Show a, Serialize.Serialize a)