File: HelperSpec.hs

package info (click to toggle)
haskell-utf8-light 0.4.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 108 kB
  • sloc: haskell: 445; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 746 bytes parent folder | download
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
34
35
36
37
module Codec.Binary.UTF8.Light.HelperSpec where

import Test.Hspec

import Codec.Binary.UTF8.Light.Helper

import GHC.Word (Word32)


main :: IO ()
main = hspec spec


spec :: Spec
spec = do

    describe "w2c" $ do
      it "converts a Word32 to a Char" $
        w2c 97 `shouldBe` 'a'

    describe "c2w" $ do
      it "converts a Char to a Word32" $
        c2w 'b' `shouldBe` 98

    describe "i2w" $ do
      it "converts an Int to a Word32" $
        i2w 98 `shouldBe` (98 :: Word32)
      -- TODO [bug] Bug in the old implementation
      --   λ> i2w 4294967296
      --   4294967296
      --   λ> 4294967296 :: Word32
      --   0

    describe "w2i" $ do
      it "converts a Word32 to an Int" $
        w2i 18 `shouldBe` (18 :: Int)