-
Notifications
You must be signed in to change notification settings - Fork 35
/
term_test.go
62 lines (50 loc) · 1.95 KB
/
term_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
package gold
import (
"github.com/stretchr/testify/assert"
"strings"
"testing"
)
func TestLiteralEqual(t *testing.T) {
var t1 Literal
t1.Value = "test1"
t1.Language = "en"
assert.True(t, t1.Equal(NewLiteralWithLanguage("test1", "en")))
assert.False(t, t1.Equal(NewLiteralWithLanguage("test2", "en")))
assert.True(t, t1.Equal(NewLiteralWithLanguage("test1", "en")))
assert.False(t, t1.Equal(NewLiteralWithLanguage("test1", "fr")))
t1.Language = ""
t1.Datatype = NewResource("http://www.w3.org/2001/XMLSchema#string")
assert.False(t, t1.Equal(NewLiteral("test1")))
assert.True(t, t1.Equal(NewLiteralWithDatatype("test1", NewResource("http://www.w3.org/2001/XMLSchema#string"))))
assert.False(t, t1.Equal(NewLiteralWithDatatype("test1", NewResource("http://www.w3.org/2001/XMLSchema#int"))))
}
func TestNewLiteralWithLanguage(t *testing.T) {
s := NewLiteralWithLanguage("test", "en")
assert.Equal(t, "\"test\"@en", s.String())
}
func TestNewLiteralWithDatatype(t *testing.T) {
s := NewLiteralWithDatatype("test", NewResource("http://www.w3.org/2001/XMLSchema#string"))
assert.Equal(t, "\"test\"^^<http://www.w3.org/2001/XMLSchema#string>", s.String())
}
func TestNewLiteralWithLanguageAndDatatype(t *testing.T) {
s := NewLiteralWithLanguageAndDatatype("test", "en", NewResource("http://www.w3.org/2001/XMLSchema#string"))
assert.Equal(t, "\"test\"@en", s.String())
s = NewLiteralWithLanguageAndDatatype("test", "", NewResource("http://www.w3.org/2001/XMLSchema#string"))
assert.Equal(t, "\"test\"^^<http://www.w3.org/2001/XMLSchema#string>", s.String())
}
func TestNewBlankNode(t *testing.T) {
id := NewBlankNode("n1")
assert.Equal(t, "_:n1", id.String())
}
func TestNewAnonNode(t *testing.T) {
id := NewAnonNode()
assert.True(t, strings.Contains(id.String(), "_:anon"))
}
func TestBNodeEqual(t *testing.T) {
var id1 BlankNode
id1.ID = "n1"
id2 := NewBlankNode("n1")
assert.True(t, id1.Equal(id2))
id3 := NewBlankNode("n2")
assert.False(t, id1.Equal(id3))
}