File: node_test.go

package info (click to toggle)
golang-github-emicklei-dot 1.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 300 kB
  • sloc: makefile: 9
file content (51 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package dot

import (
	"testing"
)

func TestNode_Box(t *testing.T) {
	g := NewGraph(Directed)
	n := g.Node("A")
	n.Box()
	if n.Value("shape") != "box" {
		t.Fail()
	}
}

func TestNode_Label(t *testing.T) {
	g := NewGraph(Directed)
	n := g.Node("A")
	n.Label("42")
	if n.Value("label") != "42" {
		t.Fail()
	}
}

func TestNodesWithBidirectionalEdge(t *testing.T) {
	g := NewGraph(Directed)
	a := g.Node("A")
	b := g.Node("B")
	e := a.BidirectionalEdge(b)
	if got, want := len(e), 2; got != want {
		t.Errorf("got [%v]:%T want [%v]:%T", got, got, want, want)
	}
	if got, want := e[0].from, a; got.id != want.id {
		t.Errorf("got [%v]:%T want [%v]:%T", got, got, want, want)
	}
	if got, want := e[0].to, b; got.id != want.id {
		t.Errorf("got [%v]:%T want [%v]:%T", got, got, want, want)
	}
	if got, want := e[1].from, b; got.id != want.id {
		t.Errorf("got [%v]:%T want [%v]:%T", got, got, want, want)
	}
	if got, want := e[1].to, a; got.id != want.id {
		t.Errorf("got [%v]:%T want [%v]:%T", got, got, want, want)
	}
	if got, want := e[0].attributes["style"], "invis"; got != want {
		t.Errorf("got [%v]:%T want [%v]:%T", got, got, want, want)
	}
	if got, want := e[1].attributes["dir"], "both"; got != want {
		t.Errorf("got [%v]:%T want [%v]:%T", got, got, want, want)
	}
}