| 1 | package parser |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/czerwonk/testutils/assert" |
| 7 | ) |
| 8 | |
| 9 | func TestOSPFArea(t *testing.T) { |
| 10 | data := "ospf1:\n" + |
| 11 | "RFC1583 compatibility: disabled\n" + |
| 12 | "Stub router: No\n" + |
| 13 | "RT scheduler tick: 1\n" + |
| 14 | "Number of areas: 2\n" + |
| 15 | "Number of LSAs in DB: 33\n" + |
| 16 | " Area: 0.0.0.0 (0) [BACKBONE]\n" + |
| 17 | " Stub: No\n" + |
| 18 | " NSSA: No\n" + |
| 19 | " Transit: No\n" + |
| 20 | " Number of interfaces: 3\n" + |
| 21 | " Number of neighbors: 2\n" + |
| 22 | " Number of adjacent neighbors: 1\n" + |
| 23 | " Area: 0.0.0.1 (1)\n" + |
| 24 | " Stub: No\n" + |
| 25 | " NSSA: No\n" + |
| 26 | " Transit: No\n" + |
| 27 | " Number of interfaces: 4\n" + |
| 28 | " Number of neighbors: 6\n" + |
| 29 | " Number of adjacent neighbors: 5\n" |
| 30 | a := ParseOSPF([]byte(data)) |
| 31 | assert.IntEqual("areas", 2, len(a), t) |
| 32 | |
| 33 | a1 := a[0] |
| 34 | assert.StringEqual("Area1 Name", "0", a1.Name, t) |
| 35 | assert.Int64Equal("Area1 InterfaceCount", 3, a1.InterfaceCount, t) |
| 36 | assert.Int64Equal("Area1 NeighborCount", 2, a1.NeighborCount, t) |
| 37 | assert.Int64Equal("Area1 NeighborAdjacentCount", 1, a1.NeighborAdjacentCount, t) |
| 38 | |
| 39 | a2 := a[1] |
| 40 | assert.StringEqual("Area2 Name", "1", a2.Name, t) |
| 41 | assert.Int64Equal("Area2 InterfaceCount", 4, a2.InterfaceCount, t) |
| 42 | assert.Int64Equal("Area2 NeighborCount", 6, a2.NeighborCount, t) |
| 43 | assert.Int64Equal("Area2 NeighborAdjacentCount", 5, a2.NeighborAdjacentCount, t) |
| 44 | } |