[mlpack-svn] r14062 - mlpack/trunk/src/mlpack/tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Jan 2 02:28:20 EST 2013
Author: rcurtin
Date: 2013-01-02 02:28:19 -0500 (Wed, 02 Jan 2013)
New Revision: 14062
Modified:
mlpack/trunk/src/mlpack/tests/tree_test.cpp
Log:
Add test for Parent() method in BinarySpaceTree.
Modified: mlpack/trunk/src/mlpack/tests/tree_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/tree_test.cpp 2013-01-02 07:28:03 UTC (rev 14061)
+++ mlpack/trunk/src/mlpack/tests/tree_test.cpp 2013-01-02 07:28:19 UTC (rev 14062)
@@ -1490,6 +1490,32 @@
BOOST_REQUIRE(rootNode.Right()->Right()->Count() == 1);
}
+BOOST_AUTO_TEST_CASE(CheckParents)
+{
+ arma::mat dataset = "2.0 5.0 9.0 4.0 8.0 7.0;"
+ "3.0 4.0 6.0 7.0 1.0 2.0 ";
+
+ // Leaf size of 1.
+ BinarySpaceTree<HRectBound<2> > rootNode(dataset, 1);
+
+ BOOST_REQUIRE_EQUAL(rootNode.Parent(),
+ (BinarySpaceTree<HRectBound<2> >*) NULL);
+ BOOST_REQUIRE_EQUAL(&rootNode, rootNode.Left()->Parent());
+ BOOST_REQUIRE_EQUAL(&rootNode, rootNode.Right()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Left(), rootNode.Left()->Left()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Left(), rootNode.Left()->Right()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Left()->Left(),
+ rootNode.Left()->Left()->Left()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Left()->Left(),
+ rootNode.Left()->Left()->Right()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Right(), rootNode.Right()->Left()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Right(), rootNode.Right()->Right()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Right()->Left(),
+ rootNode.Right()->Left()->Left()->Parent());
+ BOOST_REQUIRE_EQUAL(rootNode.Right()->Left(),
+ rootNode.Right()->Left()->Right()->Parent());
+}
+
// Ensure FurthestDescendantDistance() works.
BOOST_AUTO_TEST_CASE(FurthestDescendantDistanceTest)
{
More information about the mlpack-svn
mailing list