Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Base tests for Core Operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan W. McAdams committed Dec 5, 2010
1 parent 395a13e commit 78cfc29
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 7 deletions.
7 changes: 0 additions & 7 deletions casbah-query/src/main/scala/CoreOperators.scala
Expand Up @@ -778,9 +778,6 @@ trait GeoNearOp extends QueryOperator {
* a) the order you specified your actual index in
* b) if you're using actual world maps or something else
*
* Due to a quirk in the way I implemented type detection this fails if you mix numeric types. E.g. floats work, but not mixing floats and ints.
*
* This can be easily circumvented if you want 'ints' with floats by making your ints floats with .0:
*
* @author Brendan W. McAdams <brendan@10gen.com>
* @since 2.0
Expand All @@ -801,10 +798,6 @@ trait GeoNearSphereOp extends QueryOperator {
* a) the order you specified your actual index in
* b) if you're using actual world maps or something else
*
* Due to a quirk in the way I implemented type detection this fails if you mix numeric types. E.g. floats work, but not mixing floats and ints.
*
* This can be easily circumvented if you want 'ints' with floats by making your ints floats with .0:
*
* @author Brendan W. McAdams <brendan@10gen.com>
* @since 2.0
* @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
Expand Down
79 changes: 79 additions & 0 deletions casbah-query/src/test/scala/DSLCoreOperatorsSpec.scala
Expand Up @@ -1251,6 +1251,85 @@ class DSLCoreOperatorsSpec extends Specification with PendingUntilFixed with Log
val geo = GeoCoords(5.23, -123)
geo must notBeNull
}
"Be convertible from a tuple" in {
val geo = tupleToGeoCoords((5.23, -123))
geo must notBeNull
geo must haveClass[GeoCoords[_,_]]
}
}

"Support $near" in {
"With an explicit GeoCoords instance" in {
val near = "foo" $near GeoCoords(74.2332, -75.23452)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$near", MongoDBList(74.2332, -75.23542)))*/
}
"With a tuple converted coordinate set" in {
val near = "foo" $near (74.2332, -75.23452)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$near", MongoDBList(74.2332, -75.23542)))*/
}
}

"Support $nearSphere" in {
"With an explicit GeoCoords instance" in {
val near = "foo" $nearSphere GeoCoords(74.2332, -75.23452)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$nearSphere", MongoDBList(74.2332, -75.23542)))*/
}
"With a tuple converted coordinate set" in {
val near = "foo" $nearSphere (74.2332, -75.23452)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$nearSphere", MongoDBList(74.2332, -75.23542)))*/
}
}
"Support.$within ..." in {
"... $box" in {
"With an explicit GeoCoords instance" in {
val near = "foo".$within $box (GeoCoords(74.2332, -75.23452), GeoCoords(123, 456))
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$box", MongoDBList(74.2332, -75.23542)))*/
}
"With a tuple converted coordinate set" in {
val near = "foo".$within $box ((74.2332, -75.23452), (123, 456))
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$box", MongoDBList(74.2332, -75.23542)))*/
}
}
"... $center" in {
"With an explicit GeoCoords instance" in {
val near = "foo".$within $center (GeoCoords(74.2332, -75.23452), 5)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$center", MongoDBList(74.2332, -75.23542)))*/
}
"With a tuple converted coordinate set" in {
val near = "foo".$within $center ((74.2332, -75.23452), 5)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$center", MongoDBList(74.2332, -75.23542)))*/
}
}
"... $centerSphere" in {
"With an explicit GeoCoords instance" in {
val near = "foo".$within $centerSphere (GeoCoords(74.2332, -75.23452), 5)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$centerSphere", MongoDBList(74.2332, -75.23542)))*/
}
"With a tuple converted coordinate set" in {
val near = "foo".$within $centerSphere ((74.2332, -75.23452), 5)
near must notBeNull
near must haveSuperClass[DBObject]
/*near must beEqualTo(nonDSL("foo", "$centerSphere", MongoDBList(74.2332, -75.23542)))*/
}
}
}

}
Expand Down

0 comments on commit 78cfc29

Please sign in to comment.