[mlpack-git] master, mlpack-1.0.x: Patch from Sumedh: tests for row_col_iterator (de45cf4)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:54:43 EST 2015
Repository : https://github.com/mlpack/mlpack
On branches: master,mlpack-1.0.x
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit de45cf4c79287ae745461bf203c3eaee945c2ed3
Author: Ryan Curtin <ryan at ratml.org>
Date: Fri Jul 25 21:24:32 2014 +0000
Patch from Sumedh: tests for row_col_iterator
>---------------------------------------------------------------
de45cf4c79287ae745461bf203c3eaee945c2ed3
src/mlpack/tests/arma_extend_test.cpp | 43 +++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/mlpack/tests/arma_extend_test.cpp b/src/mlpack/tests/arma_extend_test.cpp
index 1427c22..dd0b0b3 100644
--- a/src/mlpack/tests/arma_extend_test.cpp
+++ b/src/mlpack/tests/arma_extend_test.cpp
@@ -10,6 +10,7 @@
#include "old_boost_test_definitions.hpp"
using namespace mlpack;
+using namespace arma;
BOOST_AUTO_TEST_SUITE(ArmaExtendTest);
@@ -47,4 +48,46 @@ BOOST_AUTO_TEST_CASE(InplaceReshapeMatrixTest)
BOOST_REQUIRE_CLOSE(X[i], oldX[i], 1e-5); // Order should be preserved.
}
+/**
+ * Test const_row_col_iterator for basic functionality.
+ */
+BOOST_AUTO_TEST_CASE(ConstRowColIteratorTest)
+{
+ mat X;
+ X.ones(2, 2);
+ // make sure default costructor works okay
+ mat::const_row_col_iterator it;
+ // make sure ++ operator, operator* and comparison operators work fine
+ size_t count = 0;
+ for(it = X.begin_row_col();it != X.end_row_col();it++)
+ {
+ count++;
+ BOOST_REQUIRE_EQUAL(*it, 1);
+ }
+ BOOST_REQUIRE_EQUAL(count, 4);
+ // make sure it can be constructed from row_iterator
+ it = X.begin_row(0);
+}
+
+/**
+ * Test row_col_iterator for basic functionality.
+ */
+BOOST_AUTO_TEST_CASE(RowColIteratorTest)
+{
+ mat X;
+ X.ones(2, 2);
+ // make sure default costructor works okay
+ mat::row_col_iterator it;
+ // make sure ++ operator, operator* and comparison operators work fine
+ size_t count = 0;
+ for(it = X.begin_row_col();it != X.end_row_col();it++)
+ {
+ count++;
+ BOOST_REQUIRE_EQUAL(*it, 1);
+ }
+ BOOST_REQUIRE_EQUAL(count, 4);
+ // make sure it can be constructed from row_iterator
+ it = X.begin_row(0);
+}
+
BOOST_AUTO_TEST_SUITE_END();
More information about the mlpack-git
mailing list