TEST (41.0%): Decoder.decode_ints

pull/1130/head
Rick Carlino 2020-01-31 15:03:07 -06:00
parent 986ac6884d
commit f67a4d2f4f
2 changed files with 7 additions and 3 deletions

View File

@ -194,9 +194,9 @@ defmodule FarmbotFirmware.GCODE.Decoder do
[{param, value}]
end
defp decode_ints(pvm, acc \\ [])
def decode_ints(pvm, acc \\ [])
defp decode_ints([<<arg::binary-1, val::binary>> | rest], acc) do
def decode_ints([<<arg::binary-1, val::binary>> | rest], acc) do
arg =
arg
|> String.downcase()
@ -208,7 +208,7 @@ defmodule FarmbotFirmware.GCODE.Decoder do
end
end
defp decode_ints([], acc), do: Enum.reverse(acc)
def decode_ints([], acc), do: Enum.reverse(acc)
@spec decode_echo(binary()) :: [binary()]
defp decode_echo(str) when is_binary(str) do

View File

@ -4,6 +4,10 @@ defmodule FarmbotFirmware.GCODE.DecoderTest do
setup :verify_on_exit!
alias FarmbotFirmware.GCODE.Decoder
test "Decoder.decode_ints(pvm, acc \\ [])" do
assert [a: 1, b: 2, c: 3] == Decoder.decode_ints(["A1", "B2", "C3"])
end
test "Decoder.decode_pv" do
assert [param_config_ok: 3.0] == Decoder.decode_pv(["P2", "V3"])
end