quality: Add test cases for instructions

This commit is contained in:
Eishun Kondoh 2019-04-28 23:57:22 +09:00
parent b4c6f0822c
commit a0ee397921
9 changed files with 120 additions and 43 deletions

View file

@ -3,15 +3,18 @@ defmodule Openflow.Instruction.GotoTable do
alias __MODULE__
def new(table_id) do
%GotoTable{table_id: table_id}
end
@type t :: %GotoTable{table_id: 0..0xFF}
@spec new(table_id :: 0..0xFF) :: t()
def new(table_id), do: %GotoTable{table_id: table_id}
@spec to_binary(t()) :: <<_::64>>
def to_binary(%GotoTable{table_id: table_id}) do
table_id_int = Openflow.Utils.get_enum(table_id, :table_id)
<<1::16, 8::16, table_id_int::8, 0::size(3)-unit(8)>>
end
@spec read(<<_::64>>) :: t()
def read(<<1::16, 8::16, table_id_int::8, _::size(3)-unit(8)>>) do
table_id = Openflow.Utils.get_enum(table_id_int, :table_id)
%GotoTable{table_id: table_id}