File: attr_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 (36 lines) | stat: -rw-r--r-- 822 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
package dot

import "testing"

func TestAttributesMap_Attrs(t *testing.T) {
	g := NewGraph()
	g.Attrs("l", "v", "l2", "v2")
	if got, want := g.attributes["l"], "v"; got != want {
		t.Errorf("got [%v:%T] want [%v:%T]", got, got, want, want)
	}
	if got, want := g.attributes["l2"], "v2"; got != want {
		t.Errorf("got [%v:%T] want [%v:%T]", got, got, want, want)
	}
}

func TestAttributesMap_AttrsMissingValue(t *testing.T) {
	caught := false
	defer func() {
		if r := recover(); r != nil {
			caught = true
		}
	}()
	NewGraph().Attrs("l", "v", "l2")
	if !caught {
		t.Fail()
	}
}

func TestAttributesMap_EmptyKey_NilValue(t *testing.T) {
	g := NewGraph()
	g.Attr("", "skip")
	novalue := interface{}(nil)
	if got, want := g.Value(""), novalue; got != want {
		t.Errorf("got [%v:%T] want [%v:%T]", got, got, want, want)
	}
}