1
1
package com .fasterxml .jackson .core ;
2
2
3
3
import java .io .ByteArrayInputStream ;
4
+ import java .io .File ;
4
5
import java .io .InputStream ;
5
6
6
7
import com .fasterxml .jackson .core .io .ContentReference ;
7
8
8
- public class TestLocation extends BaseTest
9
+ public class JsonLocationTest extends BaseTest
9
10
{
10
11
static class Foobar { }
11
12
@@ -121,6 +122,21 @@ public void testDisableSourceInclusion() throws Exception
121
122
p .close ();
122
123
}
123
124
125
+ // for [jackson-core#739]: try to support equality
126
+ public void testLocationEquality () throws Exception
127
+ {
128
+ // important: create separate but equal instances
129
+ File src1 = new File ("/tmp/foo" );
130
+ File src2 = new File ("/tmp/foo" );
131
+ assertEquals (src1 , src2 );
132
+
133
+ JsonLocation loc1 = new JsonLocation (_sourceRef (src1 ),
134
+ 10L , 10L , 1 , 2 );
135
+ JsonLocation loc2 = new JsonLocation (_sourceRef (src2 ),
136
+ 10L , 10L , 1 , 2 );
137
+ assertEquals (loc1 , loc2 );
138
+ }
139
+
124
140
private ContentReference _sourceRef (String rawSrc ) {
125
141
return ContentReference .construct (true , rawSrc , 0 , rawSrc .length ());
126
142
}
@@ -137,6 +153,10 @@ private ContentReference _sourceRef(InputStream rawSrc) {
137
153
return ContentReference .construct (true , rawSrc , -1 , -1 );
138
154
}
139
155
156
+ private ContentReference _sourceRef (File rawSrc ) {
157
+ return ContentReference .construct (true , rawSrc , -1 , -1 );
158
+ }
159
+
140
160
private ContentReference _rawSourceRef (boolean textual , Object rawSrc ) {
141
161
return ContentReference .rawReference (textual , rawSrc );
142
162
}
0 commit comments