mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
46 lines
617 B
Go
46 lines
617 B
Go
|
package dag
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestGraph_empty(t *testing.T) {
|
||
|
var g Graph
|
||
|
g.Add(1)
|
||
|
g.Add(2)
|
||
|
g.Add(3)
|
||
|
|
||
|
actual := strings.TrimSpace(g.String())
|
||
|
expected := strings.TrimSpace(testGraphEmptyStr)
|
||
|
if actual != expected {
|
||
|
t.Fatalf("bad: %s", actual)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestGraph_basic(t *testing.T) {
|
||
|
var g Graph
|
||
|
g.Add(1)
|
||
|
g.Add(2)
|
||
|
g.Add(3)
|
||
|
g.Connect(BasicEdge(1, 3))
|
||
|
|
||
|
actual := strings.TrimSpace(g.String())
|
||
|
expected := strings.TrimSpace(testGraphBasicStr)
|
||
|
if actual != expected {
|
||
|
t.Fatalf("bad: %s", actual)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const testGraphBasicStr = `
|
||
|
1
|
||
|
3
|
||
|
2
|
||
|
3
|
||
|
`
|
||
|
const testGraphEmptyStr = `
|
||
|
1
|
||
|
2
|
||
|
3
|
||
|
`
|