-
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
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
package activitypub
import "testing"
func TestIRI_GetLink(t *testing.T) {
val := "http://example.com"
u := IRI(val)
if u.GetLink() != IRI(val) {
t.Errorf("IRI %q should equal %q", u, val)
}
}
func TestIRI_String(t *testing.T) {
val := "http://example.com"
u := IRI(val)
if u.String() != val {
t.Errorf("IRI %q should equal %q", u, val)
}
}
func TestIRI_GetID(t *testing.T) {
i := IRI("http://example.com")
if id := i.GetID(); !id.IsValid() || id != ObjectID(i) {
t.Errorf("ObjectID %q (%T) should equal %q (%T)", id, id, i, ObjectID(i))
}
}
func TestIRI_GetType(t *testing.T) {
i := IRI("http://example.com")
if i.GetType() != LinkType {
t.Errorf("Invalid type for %T object %s, expected %s", i, i.GetType(), LinkType)
}
}
func TestIRI_IsLink(t *testing.T) {
i := IRI("http://example.com")
if i.IsLink() != true {
t.Errorf("%T.IsLink() returned %t, expected %t", i, i.IsLink(), true)
}
}
func TestIRI_IsObject(t *testing.T) {
i := IRI("http://example.com")
if i.IsObject() != false {
t.Errorf("%T.IsObject() returned %t, expected %t", i, i.IsObject(), false)
}
}
func TestIRI_UnmarshalJSON(t *testing.T) {
val := "http://example.com"
i := IRI("")
err := i.UnmarshalJSON([]byte(val))
if err != nil {
t.Error(err)
}
if val != i.String() {
t.Errorf("%T invalid value after Unmarshal %q, expected %q", i, i, val)
}
}
func TestFlattenToIRI(t *testing.T) {
t.Skipf("TODO")
}
func TestIRI_URL(t *testing.T) {
t.Skipf("TODO")
}
func TestIRIs_Contains(t *testing.T) {
t.Skipf("TODO")
}
func TestIRI_Equals(t *testing.T) {
{
i1 := IRI("http://example.com")
i2 := IRI("http://example.com")
// same host same scheme
if !i1.Equals(i2, true) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com/ana/are/mere")
i2 := IRI("http://example.com/ana/are/mere")
// same host, same scheme and same path
if !i1.Equals(i2, true) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("https://example.com")
i2 := IRI("http://example.com")
// same host different scheme
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com/ana/are/mere")
i2 := IRI("https://example.com/ana/are/mere")
// same host, different scheme and same path
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("https://example.com?ana=mere")
i2 := IRI("http://example.com?ana=mere")
// same host different scheme, same query
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("https://example.com?ana=mere&foo=bar")
i2 := IRI("http://example.com?foo=bar&ana=mere")
// same host different scheme, same query - different order
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com/ana/are/mere?foo=bar&ana=mere")
i2 := IRI("https://example.com/ana/are/mere?ana=mere&foo=bar")
// same host, different scheme and same path, same query different order
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("https://example.com?ana=mere")
i2 := IRI("http://example.com?ana=mere")
// same host different scheme, same query
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("https://example.com?ana=mere&foo=bar")
i2 := IRI("http://example.com?foo=bar&ana=mere")
// same host different scheme, same query - different order
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com/ana/are/mere?foo=bar&ana=mere")
i2 := IRI("https://example.com/ana/are/mere?ana=mere&foo=bar")
// same host, different scheme and same path, same query different order
if !i1.Equals(i2, false) {
t.Errorf("%s should equal %s", i1, i2)
}
}
///
{
i1 := IRI("http://example.com")
i2 := IRI("https://example.com")
// same host different scheme
if i1.Equals(i2, true) {
t.Errorf("%s should not equal %s", i1, i2)
}
}
{
i1 := IRI("http://example1.com")
i2 := IRI("http://example.com")
// different host same scheme
if i1.Equals(i2, true) {
t.Errorf("%s should not equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com/ana/1are/mere")
i2 := IRI("http://example.com/ana/are/mere")
// same host, same scheme and different path
if i1.Equals(i2, true) {
t.Errorf("%s should not equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com?ana1=mere")
i2 := IRI("http://example.com?ana=mere")
// same host same scheme, different query key
if i1.Equals(i2, false) {
t.Errorf("%s should not equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com?ana=mere")
i2 := IRI("http://example.com?ana=mere1")
// same host same scheme, different query value
if i1.Equals(i2, false) {
t.Errorf("%s should not equal %s", i1, i2)
}
}
{
i1 := IRI("https://example.com?ana=mere&foo=bar")
i2 := IRI("http://example.com?foo=bar1&ana=mere")
// same host different scheme, different query value - different order
if i1.Equals(i2, false) {
t.Errorf("%s should not equal %s", i1, i2)
}
}
{
i1 := IRI("http://example.com/ana/are/mere?foo=bar&ana=mere")
i2 := IRI("https://example.com/ana/are/mere?ana=mere&foo1=bar")
// same host, different scheme and same path, differnt query key different order
if i1.Equals(i2, false) {
t.Errorf("%s should not equal %s", i1, i2)
}
}
}