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

@ -0,0 +1,35 @@
defmodule OfpInstructionTest do
use ExUnit.Case
doctest Openflow
alias Openflow.Instruction.{
ApplyActions,
WriteActions,
ClearActions,
GotoTable,
WriteMetadata,
Meter,
Experimenter
}
describe "Openflow.Instruction" do
test "with all instructions parse and generate" do
instructions = [
ApplyActions.new([Openflow.Action.Output.new(:controller)]),
WriteActions.new([Openflow.Action.Output.new(5)]),
ClearActions.new(),
GotoTable.new(10),
WriteMetadata.new(value: 100, mask: 0xFFFFFFFFFFFFFFFF),
Meter.new(100),
Experimenter.new(0xCAFEBABE, "hogehoge"),
Experimenter.new(0xCAFEBABE)
]
instructions
|> Openflow.Instruction.to_binary()
|> Openflow.Instruction.read()
|> Kernel.==(instructions)
|> assert()
end
end
end