quality: Add test cases for instructions
This commit is contained in:
parent
b4c6f0822c
commit
a0ee397921
9 changed files with 120 additions and 43 deletions
35
test/ofp_instruction_test.exs
Normal file
35
test/ofp_instruction_test.exs
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue