Fixed unit float and unit double generators.
authorMarkus Kauppila <markus.kauppila@gmail.com>
Wed, 17 Aug 2011 12:57:14 +0300
changeset 5839 98eed46feb99
parent 5838 8b9d6ec8150a
child 5840 802775b331b1
Fixed unit float and unit double generators.
test/test-automation/src/libSDLtest/fuzzer/fuzzer.c
test/test-automation/src/libSDLtest/fuzzer/fuzzer.h
test/test-automation/tests/testdummy/testdummy.c
--- a/test/test-automation/src/libSDLtest/fuzzer/fuzzer.c	Wed Aug 17 11:44:57 2011 +0300
+++ b/test/test-automation/src/libSDLtest/fuzzer/fuzzer.c	Wed Aug 17 12:57:14 2011 +0300
@@ -562,13 +562,13 @@
 float
 RandomUnitFloat()
 {
-	return (float) utl_randomInt(&rndContext) / UINT_MAX;
+	return (float) RandomUint32() / UINT_MAX;
 }
 
 double
 RandomUnitDouble()
 {
-	return (double) RandomUint64() / LLONG_MAX;
+	 return (RandomUint64() >> 11) * (1.0/9007199254740992.0);
 }
 
 float
@@ -599,7 +599,7 @@
 		return NULL;
 	}
 
-	int size = (abs(RandomSint32()) % (maxSize + 1)) + 1;
+	int size = (RandomUint32() % (maxSize + 1)) + 1;
 	char *string = SDL_malloc(size * sizeof(char));
 
 	int counter = 0;
--- a/test/test-automation/src/libSDLtest/fuzzer/fuzzer.h	Wed Aug 17 11:44:57 2011 +0300
+++ b/test/test-automation/src/libSDLtest/fuzzer/fuzzer.h	Wed Aug 17 12:57:14 2011 +0300
@@ -111,17 +111,21 @@
 float RandomUnitFloat();
 
 /*!
- * Returns random double in range [0.0 - 1.0] (inclusive)
+ * Returns random double in range [0.0 - 1.0[ (note: zero included, 1 is not!)
  */
 double RandomUnitDouble();
 
 /*!
- * Returns random float
+ * Returns random float.
+ *
+ * Note: NOT implemented.
  */
 float RandomFloat();
 
 /*!
  * Returns random double
+ *
+ * Note: NOT implemented.
  */
 double RandomDouble();
 
--- a/test/test-automation/tests/testdummy/testdummy.c	Wed Aug 17 11:44:57 2011 +0300
+++ b/test/test-automation/tests/testdummy/testdummy.c	Wed Aug 17 12:57:14 2011 +0300
@@ -103,6 +103,9 @@
 
 	//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
 
+	for(; 1 ; )
+			printf("%f\n", RandomUnitFloat());
+
 	for(; 0 ; )
 		printf("%d\n", RandomSint16());