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