[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29011] branches/soc-2010-leifandersen/ tests/gtest: Woops, I forgot to add the actual files to the workiing copy.

Leif Andersen leif.a.andersen at gmail.com
Wed May 26 21:35:40 CEST 2010


Revision: 29011
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29011
Author:   leifandersen
Date:     2010-05-26 21:35:40 +0200 (Wed, 26 May 2010)

Log Message:
-----------
Woops, I forgot to add the actual files to the workiing copy.  They should be there now.

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/gtest/blenlib/
    branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp
    branches/soc-2010-leifandersen/tests/gtest/blenlib/CMakeLists.txt

Added: branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp	2010-05-26 19:35:40 UTC (rev 29011)
@@ -0,0 +1,69 @@
+#include <gtest/gtest.h>
+
+extern "C" {
+	#include "BLI_math_base.h"
+	#include "BLI_rand.h"
+}
+
+class fnumpair {
+public:
+	float high;
+	float low;
+	
+	fnumpair(float high, float low) {
+		high = this->high;
+		low = this->low;
+	}
+	
+	fnumpair() {
+		high = BLI_frand();
+		low = BLI_frand();
+		if(high<low) {
+			float temp = high;
+			high = low;
+			low = temp;
+		}
+	}
+};
+
+// Tests that the BLI_math_base.h maxf() method finds the max.
+TEST(BLIMathBaseTest, TestMaxf) {
+	// Test Integers, Positive, Negative, Zero
+	EXPECT_EQ(5, maxf(5, 1));
+	EXPECT_EQ(5, maxf(1, 5));
+	EXPECT_EQ(-5, maxf(-5, -10));
+	EXPECT_EQ(6, maxf(-5,6));
+	EXPECT_EQ(0, maxf(0,-7));
+	
+	// Test floating point arrithmatic
+//	EXPECT_EQ(5.3, maxf(0.1, 5.3));
+	
+	// Preform a Random test
+	fnumpair nums;
+	EXPECT_EQ(nums.high, maxf(nums.high, nums.low));
+	EXPECT_EQ(nums.high, maxf(nums.low, nums.high));	
+}
+
+// Tests that the BLI_math_base.h minf() method finds the min.
+TEST(BLIMathBaseTest, TestMinf) {
+	//Test Integers, Positive, Negative, Zero	
+	EXPECT_EQ(1, minf(5, 1));
+	EXPECT_EQ(1, minf(1,5));
+	EXPECT_EQ(-10, minf(-5, -10));
+	EXPECT_EQ(-5, minf(-5,6));
+	EXPECT_EQ(0, minf(0,7));
+	
+	//Test floating point arrithmatic
+	
+	// Preform a Random test
+	fnumpair nums;
+	EXPECT_EQ(nums.low, minf(nums.high, nums.low));
+	EXPECT_EQ(nums.low, minf(nums.low, nums.high));		
+}
+
+// Tests that the BLI_math_base.h sqrt3d() method does the cubic root.
+TEST(BLIMathBaseTest, TestSqrt3d) {
+	EXPECT_EQ(2, sqrt3d(8));
+}
+
+

Added: branches/soc-2010-leifandersen/tests/gtest/blenlib/CMakeLists.txt
===================================================================





More information about the Bf-blender-cvs mailing list