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