DecodeUnsignedInt16BETest
Bytes.Decode.unsignedInt16 BE reads back a value written by Bytes.Encode.unsignedInt16 BE. The value 0x1234 is encoded and decoded big-endian, and the logged result is 4660, its decimal form. A failed decode would log -1.
Results
elm-0.19.1
passran in 71 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. DecodeUnsignedInt16BETest: 4660
elm-0.19.2
passran in 76 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. DecodeUnsignedInt16BETest: 4660
elm-0.19.3
passran in 53 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. DecodeUnsignedInt16BETest: 4660
lamdera-1.5.0
passran in 39 msOutput
DecodeUnsignedInt16BETest: 4660
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/DecodeUnsignedInt16BETest] in its title.
Source
The -- CHECK: lines give the expected output.
module DecodeUnsignedInt16BETest exposing (main)
{-| Bytes.Decode.unsignedInt16 BE reads back a value written by
Bytes.Encode.unsignedInt16 BE.
The value 0x1234 is encoded and decoded big-endian, and the logged result is
4660, its decimal form. A failed decode would log -1.
-}
-- CHECK: DecodeUnsignedInt16BETest: 4660
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.unsignedInt16 BE 0x1234)
result =
D.decode (D.unsignedInt16 BE) bytes
|> Maybe.withDefault -1
_ =
Debug.log "DecodeUnsignedInt16BETest" result
in
text (String.fromInt result)