quality: Add test cases for openflow actions

This commit is contained in:
Eishun Kondoh 2019-04-22 15:55:06 +09:00
parent 462905a13d
commit 2c0a283932
4 changed files with 136 additions and 3 deletions

View file

@ -13,12 +13,28 @@ defmodule Openflow.Action.NxFlowSpecLoad do
alias __MODULE__
@type t :: %NxFlowSpecLoad{
src: atom(),
dst: atom(),
n_bits: non_neg_integer(),
src_offset: non_neg_integer(),
dst_offset: non_neg_integer()
}
@spec new(
src: atom(),
dst: atom(),
n_bits: non_neg_integer(),
src_offset: non_neg_integer(),
dst_offset: non_neg_integer()
) :: t()
def new(options) do
dst = options[:dst]
dst = options[:dst] || raise(":dst must be specified")
src = options[:src] || raise(":src must be specified")
n_bits = options[:n_bits] || Openflow.Match.Field.n_bits_of(dst)
%NxFlowSpecLoad{
src: options[:src],
src: src,
dst: dst,
n_bits: n_bits,
src_offset: options[:src_offset] || 0,