forked from facebookincubator/hsthrift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinaryProtocolTest.hs
33 lines (25 loc) · 1.16 KB
/
BinaryProtocolTest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{-
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
-}
module BinaryProtocolTest where
import Data.ByteString (ByteString)
import Test.HUnit
import TestRunner
import qualified Data.Vector as Vector
import qualified Data.Vector.Storable as VectorStorable
import Foo.Types
import Thrift.Protocol.Binary
foo :: Foo
foo = Foo (Just 10) True (Bar 99 "xxx") 3 (Vector.fromList [1,2,3])
(VectorStorable.fromList [1,2,3])
cereal :: ByteString
cereal =
"\n\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\n\STX\NUL\STX\SOH\f\NUL\ETX\b\255\255\NUL\NUL\NULc\v\NUL\SOH\NUL\NUL\NUL\ETXxxx\NUL\n\NUL\EOT\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ETX\SI\NUL\ENQ\n\NUL\NUL\NUL\ETX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ETX\SI\NUL\ACK\n\NUL\NUL\NUL\ETX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ETX\NUL"
binaryTest :: Test
binaryTest = TestLabel "binaryTest" $ serializeBinary foo ~?= cereal
main :: IO ()
main = testRunner $ TestList
[ binaryTest ]