From 0719ca88f7becebd7e18813e629887d7aa8097fe Mon Sep 17 00:00:00 2001 From: Aakash Kaushik Date: Sat, 19 Sep 2020 01:41:51 +0530 Subject: [PATCH 1/2] arma_extend_test.cpp from boost to catch2 --- src/mlpack/tests/CMakeLists.txt | 2 +- src/mlpack/tests/arma_extend_test.cpp | 89 +++++++++++++-------------- 2 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt index 224a14c215..ce9ef730da 100644 --- a/src/mlpack/tests/CMakeLists.txt +++ b/src/mlpack/tests/CMakeLists.txt @@ -1,6 +1,5 @@ # mlpack test executable. add_executable(mlpack_test - arma_extend_test.cpp async_learning_test.cpp augmented_rnns_tasks_test.cpp callback_test.cpp @@ -121,6 +120,7 @@ add_executable(mlpack_catch_test ann_test_tools.hpp ann_visitor_test.cpp armadillo_svd_test.cpp + arma_extend_test.cpp bayesian_linear_regression_test.cpp bias_svd_test.cpp binarize_test.cpp diff --git a/src/mlpack/tests/arma_extend_test.cpp b/src/mlpack/tests/arma_extend_test.cpp index e6fe005c80..34adaa2b29 100644 --- a/src/mlpack/tests/arma_extend_test.cpp +++ b/src/mlpack/tests/arma_extend_test.cpp @@ -11,18 +11,17 @@ */ #include -#include -#include "test_tools.hpp" +#include "test_catch_tools.hpp" +#include "catch.hpp" using namespace mlpack; using namespace arma; -BOOST_AUTO_TEST_SUITE(ArmaExtendTest); /** * Test const_row_col_iterator for basic functionality. */ -BOOST_AUTO_TEST_CASE(ConstRowColIteratorTest) +TEST_CASE("ConstRowColIteratorTest", "[ArmaExtendTest]") { mat X; X.zeros(5, 5); @@ -39,15 +38,15 @@ BOOST_AUTO_TEST_CASE(ConstRowColIteratorTest) for (it = X.begin_row_col(); it != X.end_row_col(); ++it) { // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == ((count % 5) * 3 + (count / 5))); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); ++count; } - BOOST_REQUIRE_EQUAL(count, 25); + REQUIRE(count == 25); it = X.end_row_col(); do { @@ -55,20 +54,20 @@ BOOST_AUTO_TEST_CASE(ConstRowColIteratorTest) --count; // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == ((count % 5) * 3 + (count / 5))); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); } while (it != X.begin_row_col()); - BOOST_REQUIRE_EQUAL(count, 0); + REQUIRE(count == 0); } /** * Test row_col_iterator for basic functionality. */ -BOOST_AUTO_TEST_CASE(RowColIteratorTest) +TEST_CASE("RowColIteratorTest", "[ArmaExtendTest]") { mat X; X.zeros(5, 5); @@ -85,15 +84,15 @@ BOOST_AUTO_TEST_CASE(RowColIteratorTest) for (it = X.begin_row_col(); it != X.end_row_col(); ++it) { // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == ((count % 5) * 3 + (count / 5))); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); ++count; } - BOOST_REQUIRE_EQUAL(count, 25); + REQUIRE(count == 25); it = X.end_row_col(); do { @@ -101,20 +100,20 @@ BOOST_AUTO_TEST_CASE(RowColIteratorTest) --count; // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == ((count % 5) * 3 + (count / 5))); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); } while (it != X.begin_row_col()); - BOOST_REQUIRE_EQUAL(count, 0); + REQUIRE(count == 0); } /** * Operator-- test for mat::row_col_iterator and mat::const_row_col_iterator */ -BOOST_AUTO_TEST_CASE(MatRowColIteratorDecrementOperatorTest) +TEST_CASE("MatRowColIteratorDecrementOperatorTest", "[ArmaExtendTest]") { mat test = ones(5, 5); @@ -124,14 +123,14 @@ BOOST_AUTO_TEST_CASE(MatRowColIteratorDecrementOperatorTest) // Check that postfix-- does not decrement the position when position is // pointing to the beginning. auto junk = it2--; (void)(junk); - BOOST_REQUIRE_EQUAL(it1.row(), it2.row()); - BOOST_REQUIRE_EQUAL(it1.col(), it2.col()); + REQUIRE(it1.row() == it2.row()); + REQUIRE(it1.col() == it2.col()); // Check that prefix-- does not decrement the position when position is // pointing to the beginning. --it2; - BOOST_REQUIRE_EQUAL(it1.row(), it2.row()); - BOOST_REQUIRE_EQUAL(it1.col(), it2.col()); + REQUIRE(it1.row() == it2.row()); + REQUIRE(it1.col() == it2.col()); } // These tests don't work when the sparse iterators hold references and not @@ -140,7 +139,7 @@ BOOST_AUTO_TEST_CASE(MatRowColIteratorDecrementOperatorTest) /** * Test sparse const_row_col_iterator for basic functionality. */ -BOOST_AUTO_TEST_CASE(ConstSpRowColIteratorTest) +TEST_CASE("ConstSpRowColIteratorTest", "[ArmaExtendTest]") { sp_mat X(5, 5); for (size_t i = 0; i < 5; ++i) @@ -156,15 +155,15 @@ BOOST_AUTO_TEST_CASE(ConstSpRowColIteratorTest) for (it = X.begin_row_col(); it != X.end_row_col(); ++it) { // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == (count % 5) * 3 + (count / 5)); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); ++count; } - BOOST_REQUIRE_EQUAL(count, 25); + REQUIRE(count == 25); it = X.end_row_col(); do { @@ -172,20 +171,20 @@ BOOST_AUTO_TEST_CASE(ConstSpRowColIteratorTest) --count; // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == ((count % 5) * 3 + (count / 5))); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); } while (it != X.begin_row_col()); - BOOST_REQUIRE_EQUAL(count, 1); + REQUIRE(count == 1); } /** * Test sparse row_col_iterator for basic functionality. */ -BOOST_AUTO_TEST_CASE(SpRowColIteratorTest) +TEST_CASE("SpRowColIteratorTest", "[ArmaExtendTest]") { sp_mat X(5, 5); for (size_t i = 0; i < 5; ++i) @@ -201,15 +200,15 @@ BOOST_AUTO_TEST_CASE(SpRowColIteratorTest) for (it = X.begin_row_col(); it != X.end_row_col(); ++it) { // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == ((count % 5) * 3 + (count / 5))); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); ++count; } - BOOST_REQUIRE_EQUAL(count, 25); + REQUIRE(count == 25); it = X.end_row_col(); do { @@ -217,14 +216,12 @@ BOOST_AUTO_TEST_CASE(SpRowColIteratorTest) --count; // Check iterator value. - BOOST_REQUIRE_EQUAL(*it, (count % 5) * 3 + (count / 5)); + REQUIRE(*it == ((count % 5) * 3 + (count / 5))); // Check iterator position. - BOOST_REQUIRE_EQUAL(it.row(), count % 5); - BOOST_REQUIRE_EQUAL(it.col(), count / 5); + REQUIRE(it.row() == count % 5); + REQUIRE(it.col() == count / 5); } while (it != X.begin_row_col()); - BOOST_REQUIRE_EQUAL(count, 1); + REQUIRE(count == 1); } - -BOOST_AUTO_TEST_SUITE_END(); From f5ce6011d55c77075e58b5f22bc456887f513ac5 Mon Sep 17 00:00:00 2001 From: Aakash Kaushik Date: Sat, 19 Sep 2020 01:56:58 +0530 Subject: [PATCH 2/2] adding myself to the contributors list --- COPYRIGHT.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index 0613e4ed15..53e4f155c5 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -132,7 +132,8 @@ Copyright: Copyright 2020, Lakshya Ojha Copyright 2020, Bisakh Mondal Copyright 2020, Benson Muite - Copyright 2020, Sarthak Bhardwaj <7sarthakbhardwaj@gmail.com> + Copyright 2020, Sarthak Bhardwaj <7sarthakbhardwaj@gmail.com> + Copyright 2020, Aakash Kaushik License: BSD-3-clause All rights reserved.