Initial commit:
Added framework to generate DOT and png files of character map chart from data folder. Added all figures in the 1-2 chapters. Added font file SimSum for render chart
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
package relationship_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
r "xyj-figures/pkg/relationship"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRelationship_IsSame(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
r r.Relationship
|
||||
other r.Relationship
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "Bidirectional relationships with same source and destination",
|
||||
r: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: true,
|
||||
},
|
||||
other: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: true,
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Bidirectional relationships with swapped source and destination",
|
||||
r: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: true,
|
||||
},
|
||||
other: r.Relationship{
|
||||
Src: "B",
|
||||
Dst: "A",
|
||||
Description: "friend",
|
||||
Bidirection: true,
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Bidirectional relationships with different descriptions",
|
||||
r: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: true,
|
||||
},
|
||||
other: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "enemy",
|
||||
Bidirection: true,
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Unidirectional relationships with same source and destination",
|
||||
r: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: false,
|
||||
},
|
||||
other: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: false,
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Unidirectional relationships with swapped source and destination",
|
||||
r: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: false,
|
||||
},
|
||||
other: r.Relationship{
|
||||
Src: "B",
|
||||
Dst: "A",
|
||||
Description: "friend",
|
||||
Bidirection: false,
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Unidirectional relationships with different descriptions",
|
||||
r: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "friend",
|
||||
Bidirection: false,
|
||||
},
|
||||
other: r.Relationship{
|
||||
Src: "A",
|
||||
Dst: "B",
|
||||
Description: "enemy",
|
||||
Bidirection: false,
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
assert.Equal(t, tt.expected, tt.r.IsSame(tt.other))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user