flowclass_test.go 864 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package flowclass
  2. import (
  3. "testing"
  4. )
  5. func TestBasicFunctionality(t *testing.T) {
  6. /*
  7. Pseudo-Haskell for how I expect this to parse:
  8. FlowClass
  9. (SourceClass (Prefix "192.0.2.0/24"))
  10. (Set DestinationClass [
  11. (DestinationClass
  12. (Set Prefix [
  13. (Prefix "198.51.100.4"),
  14. (Prefix "203.0.113.208")])
  15. (IPPInst ICMP Nil)
  16. )
  17. (DestinationClass
  18. (Prefix "198.51.100.1")
  19. (Set IPPInst [
  20. (IPPInst TCP
  21. (TCPParms
  22. Nil
  23. (Set Port [(Port 1234), (Port 12345)])
  24. )
  25. ),
  26. (IPPInst UDP (UDPParms Nil (Port 12345)))
  27. ])
  28. )
  29. ])
  30. */
  31. str := `
  32. 192.0.2.0/24 -> {
  33. {198.51.100.4, 203.0.113.208}:icmp,
  34. 198.51.100.1 : {
  35. tcp({1234, 12345}),
  36. udp(12345),
  37. },
  38. }`
  39. fc := new(FlowClass)
  40. if err := fc.Compile(str); err != nil {
  41. t.Errorf("failed to compile flowclass: %v", err)
  42. }
  43. }