Skip to content

Commit edfd144

Browse files
updated tests
1 parent d5b7173 commit edfd144

File tree

15 files changed

+302
-1
lines changed

15 files changed

+302
-1
lines changed

tests/Base.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,22 @@ abstract class Base extends TestCase
118118
'{"method":"createdAfter","values":["2023-01-01"]}',
119119
'{"method":"updatedBefore","values":["2023-01-01"]}',
120120
'{"method":"updatedAfter","values":["2023-01-01"]}',
121+
'{"method":"distanceEqual","attribute":"location","values":[[[40.7128,-74.0060],1000,false]]}',
122+
'{"method":"distanceEqual","attribute":"location","values":[[[40.7128,-74.0060],1000,true]]}',
123+
'{"method":"distanceNotEqual","attribute":"location","values":[[[40.7128,-74.0060],1000,false]]}',
124+
'{"method":"distanceNotEqual","attribute":"location","values":[[[40.7128,-74.0060],1000,true]]}',
125+
'{"method":"distanceGreaterThan","attribute":"location","values":[[[40.7128,-74.0060],1000,false]]}',
126+
'{"method":"distanceGreaterThan","attribute":"location","values":[[[40.7128,-74.0060],1000,true]]}',
127+
'{"method":"distanceLessThan","attribute":"location","values":[[[40.7128,-74.0060],1000,false]]}',
128+
'{"method":"distanceLessThan","attribute":"location","values":[[[40.7128,-74.0060],1000,true]]}',
129+
'{"method":"intersects","attribute":"location","values":[[40.7128,-74.0060]]}',
130+
'{"method":"notIntersects","attribute":"location","values":[[40.7128,-74.0060]]}',
131+
'{"method":"crosses","attribute":"location","values":[[40.7128,-74.0060]]}',
132+
'{"method":"notCrosses","attribute":"location","values":[[40.7128,-74.0060]]}',
133+
'{"method":"overlaps","attribute":"location","values":[[40.7128,-74.0060]]}',
134+
'{"method":"notOverlaps","attribute":"location","values":[[40.7128,-74.0060]]}',
135+
'{"method":"touches","attribute":"location","values":[[40.7128,-74.0060]]}',
136+
'{"method":"notTouches","attribute":"location","values":[[40.7128,-74.0060]]}',
121137
'{"method":"or","values":[{"method":"equal","attribute":"released","values":[true]},{"method":"lessThan","attribute":"releasedYear","values":[1990]}]}',
122138
'{"method":"and","values":[{"method":"equal","attribute":"released","values":[false]},{"method":"greaterThan","attribute":"releasedYear","values":[2015]}]}'
123139
];

tests/languages/android/Tests.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,26 @@ class ServiceTest {
220220
writeToFile(Query.createdAfter("2023-01-01"))
221221
writeToFile(Query.updatedBefore("2023-01-01"))
222222
writeToFile(Query.updatedAfter("2023-01-01"))
223+
224+
// Spatial Distance query tests
225+
writeToFile(Query.distanceEqual("location", listOf(40.7128, -74.0060), 1000))
226+
writeToFile(Query.distanceEqual("location", listOf(40.7128, -74.0060), 1000, true))
227+
writeToFile(Query.distanceNotEqual("location", listOf(40.7128, -74.0060), 1000))
228+
writeToFile(Query.distanceNotEqual("location", listOf(40.7128, -74.0060), 1000, true))
229+
writeToFile(Query.distanceGreaterThan("location", listOf(40.7128, -74.0060), 1000))
230+
writeToFile(Query.distanceGreaterThan("location", listOf(40.7128, -74.0060), 1000, true))
231+
writeToFile(Query.distanceLessThan("location", listOf(40.7128, -74.0060), 1000))
232+
writeToFile(Query.distanceLessThan("location", listOf(40.7128, -74.0060), 1000, true))
233+
234+
// Spatial query tests
235+
writeToFile(Query.intersects("location", listOf(40.7128, -74.0060)))
236+
writeToFile(Query.notIntersects("location", listOf(40.7128, -74.0060)))
237+
writeToFile(Query.crosses("location", listOf(40.7128, -74.0060)))
238+
writeToFile(Query.notCrosses("location", listOf(40.7128, -74.0060)))
239+
writeToFile(Query.overlaps("location", listOf(40.7128, -74.0060)))
240+
writeToFile(Query.notOverlaps("location", listOf(40.7128, -74.0060)))
241+
writeToFile(Query.touches("location", listOf(40.7128, -74.0060)))
242+
writeToFile(Query.notTouches("location", listOf(40.7128, -74.0060)))
223243

224244
writeToFile(Query.or(listOf(Query.equal("released", listOf(true)), Query.lessThan("releasedYear", 1990))))
225245
writeToFile(Query.and(listOf(Query.equal("released", listOf(false)), Query.greaterThan("releasedYear", 2015))))

tests/languages/apple/Tests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ class Tests: XCTestCase {
195195
print(Query.updatedBefore("2023-01-01"))
196196
print(Query.updatedAfter("2023-01-01"))
197197

198+
// Spatial Distance query tests
199+
print(Query.distanceEqual("location", values: [40.7128, -74.0060], distance: 1000))
200+
print(Query.distanceEqual("location", values: [40.7128, -74.0060], distance: 1000, meters: true))
201+
print(Query.distanceNotEqual("location", values: [40.7128, -74.0060], distance: 1000))
202+
print(Query.distanceNotEqual("location", values: [40.7128, -74.0060], distance: 1000, meters: true))
203+
print(Query.distanceGreaterThan("location", values: [40.7128, -74.0060], distance: 1000))
204+
print(Query.distanceGreaterThan("location", values: [40.7128, -74.0060], distance: 1000, meters: true))
205+
print(Query.distanceLessThan("location", values: [40.7128, -74.0060], distance: 1000))
206+
print(Query.distanceLessThan("location", values: [40.7128, -74.0060], distance: 1000, meters: true))
207+
208+
// Spatial query tests
209+
print(Query.intersects("location", values: [40.7128, -74.0060]))
210+
print(Query.notIntersects("location", values: [40.7128, -74.0060]))
211+
print(Query.crosses("location", values: [40.7128, -74.0060]))
212+
print(Query.notCrosses("location", values: [40.7128, -74.0060]))
213+
print(Query.overlaps("location", values: [40.7128, -74.0060]))
214+
print(Query.notOverlaps("location", values: [40.7128, -74.0060]))
215+
print(Query.touches("location", values: [40.7128, -74.0060]))
216+
print(Query.notTouches("location", values: [40.7128, -74.0060]))
217+
198218
print(Query.or([
199219
Query.equal("released", value: true),
200220
Query.lessThan("releasedYear", value: 1990)

tests/languages/dart/tests.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,31 @@ void main() async {
170170
Query.greaterThan("releasedYear", 2015)
171171
]));
172172

173+
// Spatial Distance query tests
174+
print(Query.distanceEqual("location", [40.7128, -74.0060], 1000));
175+
print(Query.distanceEqual("location", [40.7128, -74.0060], 1000, true));
176+
print(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000));
177+
print(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000, true));
178+
print(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000));
179+
print(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000, true));
180+
print(Query.distanceLessThan("location", [40.7128, -74.0060], 1000));
181+
print(Query.distanceLessThan("location", [40.7128, -74.0060], 1000, true));
182+
183+
// Spatial query tests
184+
print(Query.intersects("location", [40.7128, -74.0060]));
185+
print(Query.notIntersects("location", [40.7128, -74.0060]));
186+
print(Query.crosses("location", [40.7128, -74.0060]));
187+
print(Query.notCrosses("location", [40.7128, -74.0060]));
188+
print(Query.overlaps("location", [40.7128, -74.0060]));
189+
print(Query.notOverlaps("location", [40.7128, -74.0060]));
190+
print(Query.touches("location", [40.7128, -74.0060]));
191+
print(Query.notTouches("location", [40.7128, -74.0060]));
192+
193+
print(Query.or([
194+
Query.equal("released", true),
195+
Query.lessThan("releasedYear", 1990)
196+
]));
197+
173198
// Permission & Role helper tests
174199
print(Permission.read(Role.any()));
175200
print(Permission.write(Role.user(ID.custom('userid'))));

tests/languages/deno/tests.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ async function start() {
187187
console.log(Query.updatedBefore("2023-01-01"));
188188
console.log(Query.updatedAfter("2023-01-01"));
189189

190+
// Spatial Distance query tests
191+
console.log(Query.distanceEqual("location", [40.7128, -74.0060], 1000));
192+
console.log(Query.distanceEqual("location", [40.7128, -74.0060], 1000, true));
193+
console.log(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000));
194+
console.log(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000, true));
195+
console.log(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000));
196+
console.log(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000, true));
197+
console.log(Query.distanceLessThan("location", [40.7128, -74.0060], 1000));
198+
console.log(Query.distanceLessThan("location", [40.7128, -74.0060], 1000, true));
199+
200+
// Spatial query tests
201+
console.log(Query.intersects("location", [40.7128, -74.0060]));
202+
console.log(Query.notIntersects("location", [40.7128, -74.0060]));
203+
console.log(Query.crosses("location", [40.7128, -74.0060]));
204+
console.log(Query.notCrosses("location", [40.7128, -74.0060]));
205+
console.log(Query.overlaps("location", [40.7128, -74.0060]));
206+
console.log(Query.notOverlaps("location", [40.7128, -74.0060]));
207+
console.log(Query.touches("location", [40.7128, -74.0060]));
208+
console.log(Query.notTouches("location", [40.7128, -74.0060]));
209+
190210
console.log(Query.or([
191211
Query.equal("released", true),
192212
Query.lessThan("releasedYear", 1990)

tests/languages/dotnet/Tests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,26 @@ public async Task Test1()
169169
TestContext.WriteLine(Query.UpdatedBefore("2023-01-01"));
170170
TestContext.WriteLine(Query.UpdatedAfter("2023-01-01"));
171171

172+
// Spatial Distance query tests
173+
TestContext.WriteLine(Query.DistanceEqual("location", new List<object> { 40.7128, -74.0060 }, 1000));
174+
TestContext.WriteLine(Query.DistanceEqual("location", new List<object> { 40.7128, -74.0060 }, 1000, true));
175+
TestContext.WriteLine(Query.DistanceNotEqual("location", new List<object> { 40.7128, -74.0060 }, 1000));
176+
TestContext.WriteLine(Query.DistanceNotEqual("location", new List<object> { 40.7128, -74.0060 }, 1000, true));
177+
TestContext.WriteLine(Query.DistanceGreaterThan("location", new List<object> { 40.7128, -74.0060 }, 1000));
178+
TestContext.WriteLine(Query.DistanceGreaterThan("location", new List<object> { 40.7128, -74.0060 }, 1000, true));
179+
TestContext.WriteLine(Query.DistanceLessThan("location", new List<object> { 40.7128, -74.0060 }, 1000));
180+
TestContext.WriteLine(Query.DistanceLessThan("location", new List<object> { 40.7128, -74.0060 }, 1000, true));
181+
182+
// Spatial query tests
183+
TestContext.WriteLine(Query.Intersects("location", new List<object> { 40.7128, -74.0060 }));
184+
TestContext.WriteLine(Query.NotIntersects("location", new List<object> { 40.7128, -74.0060 }));
185+
TestContext.WriteLine(Query.Crosses("location", new List<object> { 40.7128, -74.0060 }));
186+
TestContext.WriteLine(Query.NotCrosses("location", new List<object> { 40.7128, -74.0060 }));
187+
TestContext.WriteLine(Query.Overlaps("location", new List<object> { 40.7128, -74.0060 }));
188+
TestContext.WriteLine(Query.NotOverlaps("location", new List<object> { 40.7128, -74.0060 }));
189+
TestContext.WriteLine(Query.Touches("location", new List<object> { 40.7128, -74.0060 }));
190+
TestContext.WriteLine(Query.NotTouches("location", new List<object> { 40.7128, -74.0060 }));
191+
172192
TestContext.WriteLine(Query.Or(
173193
new List<string> {
174194
Query.Equal("released", true),

tests/languages/flutter/tests.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ void main() async {
195195
print(Query.updatedBefore("2023-01-01"));
196196
print(Query.updatedAfter("2023-01-01"));
197197

198+
// Spatial Distance query tests
199+
print(Query.distanceEqual("location", [40.7128, -74.0060], 1000));
200+
print(Query.distanceEqual("location", [40.7128, -74.0060], 1000, true));
201+
print(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000));
202+
print(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000, true));
203+
print(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000));
204+
print(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000, true));
205+
print(Query.distanceLessThan("location", [40.7128, -74.0060], 1000));
206+
print(Query.distanceLessThan("location", [40.7128, -74.0060], 1000, true));
207+
208+
// Spatial query tests
209+
print(Query.intersects("location", [40.7128, -74.0060]));
210+
print(Query.notIntersects("location", [40.7128, -74.0060]));
211+
print(Query.crosses("location", [40.7128, -74.0060]));
212+
print(Query.notCrosses("location", [40.7128, -74.0060]));
213+
print(Query.overlaps("location", [40.7128, -74.0060]));
214+
print(Query.notOverlaps("location", [40.7128, -74.0060]));
215+
print(Query.touches("location", [40.7128, -74.0060]));
216+
print(Query.notTouches("location", [40.7128, -74.0060]));
217+
198218
print(Query.or([
199219
Query.equal("released", true),
200220
Query.lessThan("releasedYear", 1990)

tests/languages/go/tests.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,26 @@ func testQueries() {
219219
fmt.Println(query.CreatedAfter("2023-01-01"))
220220
fmt.Println(query.UpdatedBefore("2023-01-01"))
221221
fmt.Println(query.UpdatedAfter("2023-01-01"))
222+
223+
// Spatial Distance query tests
224+
fmt.Println(query.DistanceEqual("location", []interface{}{40.7128, -74.0060}, 1000, false))
225+
fmt.Println(query.DistanceEqual("location", []interface{}{40.7128, -74.0060}, 1000, true))
226+
fmt.Println(query.DistanceNotEqual("location", []interface{}{40.7128, -74.0060}, 1000, false))
227+
fmt.Println(query.DistanceNotEqual("location", []interface{}{40.7128, -74.0060}, 1000, true))
228+
fmt.Println(query.DistanceGreaterThan("location", []interface{}{40.7128, -74.0060}, 1000, false))
229+
fmt.Println(query.DistanceGreaterThan("location", []interface{}{40.7128, -74.0060}, 1000, true))
230+
fmt.Println(query.DistanceLessThan("location", []interface{}{40.7128, -74.0060}, 1000, false))
231+
fmt.Println(query.DistanceLessThan("location", []interface{}{40.7128, -74.0060}, 1000, true))
232+
233+
// Spatial query tests
234+
fmt.Println(query.Intersects("location", []interface{}{40.7128, -74.0060}))
235+
fmt.Println(query.NotIntersects("location", []interface{}{40.7128, -74.0060}))
236+
fmt.Println(query.Crosses("location", []interface{}{40.7128, -74.0060}))
237+
fmt.Println(query.NotCrosses("location", []interface{}{40.7128, -74.0060}))
238+
fmt.Println(query.Overlaps("location", []interface{}{40.7128, -74.0060}))
239+
fmt.Println(query.NotOverlaps("location", []interface{}{40.7128, -74.0060}))
240+
fmt.Println(query.Touches("location", []interface{}{40.7128, -74.0060}))
241+
fmt.Println(query.NotTouches("location", []interface{}{40.7128, -74.0060}))
222242

223243
fmt.Println(query.Or([]string{
224244
query.Equal("released", true),

tests/languages/kotlin/Tests.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,26 @@ class ServiceTest {
188188
writeToFile(Query.updatedBefore("2023-01-01"))
189189
writeToFile(Query.updatedAfter("2023-01-01"))
190190

191+
// Spatial Distance query tests
192+
writeToFile(Query.distanceEqual("location", listOf(40.7128, -74.0060), 1000))
193+
writeToFile(Query.distanceEqual("location", listOf(40.7128, -74.0060), 1000, true))
194+
writeToFile(Query.distanceNotEqual("location", listOf(40.7128, -74.0060), 1000))
195+
writeToFile(Query.distanceNotEqual("location", listOf(40.7128, -74.0060), 1000, true))
196+
writeToFile(Query.distanceGreaterThan("location", listOf(40.7128, -74.0060), 1000))
197+
writeToFile(Query.distanceGreaterThan("location", listOf(40.7128, -74.0060), 1000, true))
198+
writeToFile(Query.distanceLessThan("location", listOf(40.7128, -74.0060), 1000))
199+
writeToFile(Query.distanceLessThan("location", listOf(40.7128, -74.0060), 1000, true))
200+
201+
// Spatial query tests
202+
writeToFile(Query.intersects("location", listOf(40.7128, -74.0060)))
203+
writeToFile(Query.notIntersects("location", listOf(40.7128, -74.0060)))
204+
writeToFile(Query.crosses("location", listOf(40.7128, -74.0060)))
205+
writeToFile(Query.notCrosses("location", listOf(40.7128, -74.0060)))
206+
writeToFile(Query.overlaps("location", listOf(40.7128, -74.0060)))
207+
writeToFile(Query.notOverlaps("location", listOf(40.7128, -74.0060)))
208+
writeToFile(Query.touches("location", listOf(40.7128, -74.0060)))
209+
writeToFile(Query.notTouches("location", listOf(40.7128, -74.0060)))
210+
191211
writeToFile(Query.or(listOf(Query.equal("released", listOf(true)), Query.lessThan("releasedYear", 1990))))
192212
writeToFile(Query.and(listOf(Query.equal("released", listOf(false)), Query.greaterThan("releasedYear", 2015))))
193213

tests/languages/node/test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,26 @@ async function start() {
271271
console.log(Query.createdAfter("2023-01-01"));
272272
console.log(Query.updatedBefore("2023-01-01"));
273273
console.log(Query.updatedAfter("2023-01-01"));
274+
275+
// Spatial Distance query tests
276+
console.log(Query.distanceEqual("location", [40.7128, -74.0060], 1000));
277+
console.log(Query.distanceEqual("location", [40.7128, -74.0060], 1000, true));
278+
console.log(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000));
279+
console.log(Query.distanceNotEqual("location", [40.7128, -74.0060], 1000, true));
280+
console.log(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000));
281+
console.log(Query.distanceGreaterThan("location", [40.7128, -74.0060], 1000, true));
282+
console.log(Query.distanceLessThan("location", [40.7128, -74.0060], 1000));
283+
console.log(Query.distanceLessThan("location", [40.7128, -74.0060], 1000, true));
284+
285+
// Spatial query tests
286+
console.log(Query.intersects("location", [40.7128, -74.0060]));
287+
console.log(Query.notIntersects("location", [40.7128, -74.0060]));
288+
console.log(Query.crosses("location", [40.7128, -74.0060]));
289+
console.log(Query.notCrosses("location", [40.7128, -74.0060]));
290+
console.log(Query.overlaps("location", [40.7128, -74.0060]));
291+
console.log(Query.notOverlaps("location", [40.7128, -74.0060]));
292+
console.log(Query.touches("location", [40.7128, -74.0060]));
293+
console.log(Query.notTouches("location", [40.7128, -74.0060]));
274294

275295
console.log(Query.or([
276296
Query.equal("released", true),

0 commit comments

Comments
 (0)