DecodeUnsignedInt32BETest
Bytes.Decode.unsignedInt32 BE reads back a value written by Bytes.Encode.unsignedInt32 BE. The value 0x12345678 is encoded and decoded big-endian, and the logged result is 305419896, its decimal form. A failed decode would log -1.
Results
elm-0.19.1
passran in 47 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. DecodeUnsignedInt32BETest: 305419896
elm-0.19.2
passran in 72 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. DecodeUnsignedInt32BETest: 305419896
elm-0.19.3
passran in 48 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. DecodeUnsignedInt32BETest: 305419896
lamdera-1.5.0
passran in 81 msOutput
DecodeUnsignedInt32BETest: 305419896
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/DecodeUnsignedInt32BETest] in its title.
Source
The -- CHECK: lines give the expected output.
module DecodeUnsignedInt32BETest exposing (main)
{-| Bytes.Decode.unsignedInt32 BE reads back a value written by
Bytes.Encode.unsignedInt32 BE.
The value 0x12345678 is encoded and decoded big-endian, and the logged result is
305419896, its decimal form. A failed decode would log -1.
-}
-- CHECK: DecodeUnsignedInt32BETest: 305419896
import Bytes exposing (Bytes, Endianness(..))
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
main =
let
bytes =
E.encode (E.unsignedInt32 BE 0x12345678)
result =
D.decode (D.unsignedInt32 BE) bytes
|> Maybe.withDefault -1
_ =
Debug.log "DecodeUnsignedInt32BETest" result
in
text (String.fromInt result)