mirror of
https://github.com/zap-proto/haskell.git
synced 2026-10-30 15:05:00 +00:00
The primary reason for this is that we'll need this to implement canonicalization (#36), in light of #57, since the default will no longer always allocate inside the first segment. This also reverts the change to the test suite made in #57; we do want to verify that the new segment has the index we think it does, and adding a larger default segment size has the effect of no-longer breaking that test.
30 lines
891 B
Haskell
30 lines
891 B
Haskell
{-# LANGUAGE ScopedTypeVariables #-}
|
|
module Module.Capnp.Basics (basicsTests) where
|
|
|
|
import Test.Hspec
|
|
import Test.QuickCheck
|
|
|
|
import Control.Monad.IO.Class (liftIO)
|
|
import Test.QuickCheck.Instances ()
|
|
import Test.QuickCheck.IO (propertyIO)
|
|
|
|
import qualified Data.ByteString as BS
|
|
import qualified Data.Text as T
|
|
|
|
import Capnp.Basics
|
|
|
|
import Capnp (cerialize, evalLimitT, newMessage)
|
|
|
|
import qualified Capnp.Untyped as U
|
|
|
|
basicsTests :: Spec
|
|
basicsTests =
|
|
describe "textBuffer and textBytes agree" $
|
|
it "Should return the same number of bytes" $
|
|
property $ \(text :: T.Text) -> propertyIO $ evalLimitT maxBound $ do
|
|
msg <- newMessage Nothing
|
|
cerial <- cerialize msg text
|
|
buf <- textBuffer cerial
|
|
bytes <- textBytes cerial
|
|
liftIO $ BS.length bytes `shouldBe` U.length buf
|