Skip to content
Browse files

changed StrictTyper to use double instead of float; added new test to…

… confirm correctness
  • Loading branch information...
1 parent a8e7867 commit a525b3ad141e032cdbdf8553399a7b10b176b62f @marcesher committed Nov 12, 2011
Showing with 22 additions and 11 deletions.
  1. +2 −2 java/src/net/marcesher/CFStrictTyper.java
  2. BIN lib/cfmongodb.jar
  3. +11 −9 test/BaseTestCase.cfc
  4. +9 −0 test/MongoTest.cfc
View
4 java/src/net/marcesher/CFStrictTyper.java
@@ -59,9 +59,9 @@ public Object handleSimpleValue(Object value) {
}
try {
- return Float.parseFloat(stringValue);
+ return Double.parseDouble(stringValue);
} catch (Exception e) {
- //nothing; it's not a float
+ //nothing; it's not a double
}
}
return value;
View
BIN lib/cfmongodb.jar
Binary file not shown.
View
20 test/BaseTestCase.cfc
@@ -1,33 +1,35 @@
<cfcomponent output="false" extends="mxunit.framework.TestCase">
-
-
+
+
<cfset dbName = "cfmongodb_tests">
<cfset factoryType = "cfmongodb.core.JavaloaderFactory">
-
+
<!--- will be created by commonBeforeTests and closed by commonAfterTests --->
<cfset mongo = "">
-
+
<cffunction name="beforeTests">
<cfset mongoConfig = getMongoConfig()>
<cfset variables.mongo = createObject('component','cfmongodb.core.Mongo').init(mongoConfig)>
</cffunction>
-
+
<cffunction name="afterTests">
<cfset variables.mongo.close()>
</cffunction>
-
+
<cffunction name="setUp">
<cfscript>
variables.types = {
'number' = 100,
'negativefloat' = -987.097654,
'positivefloat' = 9654.5555555,
+ 'five_one' = 5.1,
+ 'point_nine' = .9,
'israd' = true,
'stringwithnum' = 'string ending with 1',
'numbers' = [1,2,3],
'booleans' = [true, false],
- 'floats' = [1.3,2.59870,-148.27654]
+ 'floats' = [1.3,2.5987,-148.27654]
};
variables.doc = {
@@ -45,7 +47,7 @@
</cfscript>
</cffunction>
-
+
<cffunction name="tearDown">
<cfset var delete = {"name"="unittest"}>
<!--- the different tests will define "dbCol" --->
@@ -66,7 +68,7 @@
<cfset debug( getMetadata(mongoConfig.getMongoFactory()).fullName )>--->
<cfset assertEquals( factoryType, getMetadata(mongoConfig.getMongoFactory()).fullName )>
</cffunction>
-
+
<cffunction name="createPeople" access="private" returntype="Array" output="false">
<cfargument name="count" type="numeric" required="false" default="5"/>
<cfargument name="save" type="boolean" required="false" default="true"/>
View
9 test/MongoTest.cfc
@@ -124,6 +124,7 @@ import cfmongodb.core.*;
var newNestedFloats = mongo.query( col ).$eq("types.floats",1.3).count();
var newString = mongo.query( col ).$eq("address.street", "123 big top lane").count();
+
assertEquals( origNums+1, newNums );
assertEquals( origNestedNums+1, newNestedNums );
assertEquals( origBool+1, newBool );
@@ -132,6 +133,14 @@ import cfmongodb.core.*;
assertEquals( origNestedFloats+1, newNestedFloats );
assertEquals( origString+1, newString );
+ debug(doc);
+ var fetched = dbCol.findById( doc._id );
+ debug(fetched);
+
+ /*assertEquals( doc["types"]["floats"], fetched["types"]["floats"] );
+ assertEquals( doc.negativeFloat, fetched.negativeFloat, "negativeFloat should be equal" );
+ assertEquals( doc.positiveFloat, fetched.positiveFloat, "positiveFloat should be equal" );*/
+ assertEquals( doc, fetched );
}
/**

0 comments on commit a525b3a

Please sign in to comment.
Something went wrong with that request. Please try again.