-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathturtle_test.go
87 lines (83 loc) · 1.67 KB
/
turtle_test.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package turtle
import (
"io/ioutil"
"testing"
"github.com/d4l3k/messagediff"
)
func TestParse(t *testing.T) {
testData := []struct {
file string
want []Triple
diff bool
}{
{
"testdata/example.turtle",
[]Triple{
{
"http://example.org/#green-goblin",
"http://www.perceive.net/schemas/relationship/enemyOf",
"http://example.org/#spiderman",
"", "",
},
{
"http://example.org/#green-goblin",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"http://xmlns.com/foaf/0.1/Person",
"", "",
},
{
"http://example.org/#green-goblin",
"http://xmlns.com/foaf/0.1/name",
"Green Goblin",
"", "",
},
{
"http://example.org/#spiderman",
"http://www.perceive.net/schemas/relationship/enemyOf",
"http://example.org/#green-goblin",
"", "",
},
{
"http://example.org/#spiderman",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"http://xmlns.com/foaf/0.1/Person",
"", "",
},
{
"http://example.org/#spiderman",
"http://xmlns.com/foaf/0.1/name",
"Spiderman \"Wow\"",
"", "",
},
{
"http://example.org/#spiderman",
"http://xmlns.com/foaf/0.1/name",
"Человек-паук",
"", "ru",
},
},
true,
},
/*{
"testdata/02mjmr.turtle",
nil,
false,
},*/
}
for i, td := range testData {
rdf, err := ioutil.ReadFile(td.file)
if err != nil {
t.Fatal(err)
}
out, err := Parse(rdf)
if err != nil {
t.Fatal(err)
}
if !td.diff {
continue
}
if diff, equal := messagediff.PrettyDiff(td.want, out); !equal {
t.Errorf("%d. Parse(%s) = %#v; diff %s", i, td.file, out, diff)
}
}
}